-
Notifications
You must be signed in to change notification settings - Fork 40
/
reader.py
22 lines (18 loc) · 829 Bytes
/
reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
class Reader(object):
def __init__(self, xml_dir):
self.xml_dir = xml_dir
def get_xml_files(self):
xml_filenames = []
for root, subdirectories, files in os.walk(self.xml_dir):
for filename in files:
if filename.endswith(".xml"):
file_path = os.path.join(root, filename)
file_path = os.path.relpath(file_path, start=self.xml_dir)
xml_filenames.append(file_path)
return xml_filenames
@staticmethod
def get_classes(filename):
with open(os.path.join(os.path.dirname(os.path.realpath('__file__')), filename), "r", encoding="utf8") as f:
lines = f.readlines()
return {value: key for (key, value) in enumerate(list(map(lambda x: x.strip(), lines)))}