Skip to content

Commit 89e2141

Browse files
committed
A bit more cleanup.
1 parent d4f58da commit 89e2141

File tree

8 files changed

+97
-119
lines changed

8 files changed

+97
-119
lines changed

build/components/component.py

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
from .example import Example
1212

1313
def parseUri(uri: str) -> Tuple[ParseResult, str, str]:
14-
logging.debug("ENTERING: component.py:parseUri:17")
14+
logging.debug("ENTERING: ")
1515
_uri = urlparse(uri)
1616
dirname = os.path.dirname(uri)
1717
_, name = os.path.split(_uri.path)
1818
_, ext = os.path.splitext(name)
19-
logging.debug("EXITING: component.py:parseUri:22")
19+
logging.debug("EXITING: ")
2020
return _uri, dirname, name, ext
2121

2222

2323
class Component(dict):
2424
def __init__(self, filepath: str = None, root: dict = None, args: dict = None):
25-
logging.debug("ENTERING: component.py:Component.__init__:27")
25+
logging.debug("ENTERING: ")
2626
super().__init__()
2727
self._root = root
2828
self._args = args
@@ -36,10 +36,10 @@ def __init__(self, filepath: str = None, root: dict = None, args: dict = None):
3636
self._desc = self.get('description', '')
3737
self._stack_path = self.get('stack_path', '')
3838
self._repository = self.get('repository', None)
39-
logging.debug("EXITING: component.py:Component.__init__:41")
39+
logging.debug("EXITING: ")
4040

4141
def _git_clone(self, repo) -> str:
42-
logging.debug("ENTERING: component.py:Component._git_clone:104")
42+
logging.debug("ENTERING: ")
4343
git_uri = repo.get('git_uri')
4444
private = repo.get('private', False)
4545
uri, _, name, ext = parseUri(git_uri)
@@ -60,50 +60,50 @@ def _git_clone(self, repo) -> str:
6060
run(f'git fetch --all --tags', cwd=to)
6161
else:
6262
logging.debug(f'Skipping clone {git_uri}')
63-
logging.debug("EXITING: component.py:Component._git_clone:122")
63+
logging.debug("EXITING: ")
6464
return to
6565
elif self._repo_uri() == git_uri:
66-
logging.debug("EXITING: component.py:Component._git_clone:125")
66+
logging.debug("EXITING: ")
6767
return self._repo_env_dir()
6868
elif (uri.scheme == 'file' or uri.scheme == '') and ext == '':
69-
logging.debug("EXITING: component.py:Component._git_clone:128")
69+
logging.debug("EXITING: ")
7070
return uri.path
7171
else:
7272
die('Cannot determine git repo - aborting.')
7373

7474
def _repo_env_dir(self) -> str:
75-
logging.debug("ENTERING: component.py:Component._repo_env_dir:233")
75+
logging.debug("ENTERING: ")
7676
if os.getenv(f'REPO_DIR'):
77-
logging.debug("EXITING: component.py:Component._repo_env_dir:235")
77+
logging.debug("EXITING: ")
7878
return os.getenv(f'REPO_DIR')
79-
logging.debug("EXITING: component.py:Component._repo_env_dir:237")
79+
logging.debug("EXITING: ")
8080
return ''
8181

8282
def _repo_uri(self) -> str:
83-
logging.debug("ENTERING: component.py:Component._repo_uri:240")
83+
logging.debug("ENTERING: ")
8484
if(os.getenv('REPOSITORY_URL')):
85-
logging.debug("EXITING: component.py:Component._repo_uri:242")
85+
logging.debug("EXITING: ")
8686
return os.getenv('REPOSITORY_URL')
87-
logging.debug("EXITING: component.py:Component._repo_uri:244")
87+
logging.debug("EXITING: ")
8888
return ''
8989

9090
def _skip_checkout(self, obj) -> bool:
91-
logging.debug("ENTERING: component.py:Component._skip_checkout:254")
91+
logging.debug("ENTERING: ")
9292
if obj.get('git_uri') == self._repo_uri() and self._preview_mode():
93-
logging.debug("EXITING: component.py:Component._skip_checkout:256")
93+
logging.debug("EXITING: ")
9494
return True
95-
logging.debug("EXITING: component.py:Component._skip_checkout:258")
95+
logging.debug("EXITING: ")
9696
return False
9797

9898
def _checkout(self, ref, dest, obj):
99-
logging.debug("ENTERING: component.py:Component._checkout:261")
99+
logging.debug("ENTERING: ")
100100
if not self._skip_checkout(obj):
101101
run(f'git checkout {ref}', cwd=dest)
102-
logging.debug("EXITING: component.py:Component._checkout:264")
102+
logging.debug("EXITING: ")
103103

104104
class All(Component):
105105
def __init__(self, filepath: str, root: dict = None, args: dict = None):
106-
logging.debug("ENTERING: component.py:All.__init__:271")
106+
logging.debug("ENTERING: ")
107107
super().__init__(filepath, root, args)
108108
self._groups = {}
109109
self._commands = {}
@@ -116,17 +116,17 @@ def __init__(self, filepath: str, root: dict = None, args: dict = None):
116116
self._content = f'{self._website.get("path")}/{self._website.get("content")}'
117117
self._examples = {}
118118
mkdir_p(self._content)
119-
logging.debug("EXITING: component.py:All.__init__:284")
119+
logging.debug("EXITING: ")
120120

121121
def _persist_examples(self) -> None:
122-
logging.debug("ENTERING: component.py:All._persist_examples:302")
122+
logging.debug("ENTERING: ")
123123
filepath = f'{self._website.get("path")}/{self._website.get("examples")}'
124124
logging.info(f'Persisting {self._id} examples: {filepath}')
125125
dump_dict(filepath, self._examples)
126-
logging.debug("EXITING: component.py:All._persist_examples:306")
126+
logging.debug("EXITING: ")
127127

128128
def apply(self) -> None:
129-
logging.debug("ENTERING: component.py:All.apply:373")
129+
logging.debug("ENTERING: ")
130130
for kind in ['clients','core', 'docs', 'modules', 'assets']:
131131
for component in self.get(kind):
132132
if type(component) == str:
@@ -151,50 +151,30 @@ def apply(self) -> None:
151151
die(f'Unknown component definition for {component}')
152152
c.apply()
153153
self._persist_examples()
154-
logging.debug("EXITING: component.py:All.apply:402")
155-
156-
157-
class Core(Component):
158-
def __init__(self, filepath: str, root: dict = None):
159-
logging.debug("ENTERING: component.py:Core.__init__:408")
160-
super().__init__(filepath, root)
161-
self._content = f'{self._root._content}/{self._stack_path}'
162-
logging.debug("EXITING: component.py:Core.__init__:411")
163-
164-
def apply(self) -> None:
165-
logging.debug("ENTERING: component.py:Core.apply:477")
166-
logging.info(f'Applying core {self._id}')
167-
files = self._get_docs()
168-
files += self._get_commands()
169-
self._get_misc()
170-
self._get_groups()
171-
self._get_data()
172-
self._get_conf_file()
173-
logging.debug("EXITING: component.py:Core.apply:485")
174-
return files
154+
logging.debug("EXITING: ")
175155

176156

177157
class Client(Component):
178158
def __init__(self, filepath: str, root: dict = None):
179-
logging.debug("ENTERING: component.py:Client.__init__:558")
159+
logging.debug("ENTERING: ")
180160
print(str("file_path = {}".format(filepath)))
181161
super().__init__(filepath, root)
182-
logging.debug("EXITING: component.py:Client.__init__:561")
162+
logging.debug("EXITING: ")
183163

184164
def _get_example_id_from_file(self, path):
185-
logging.debug("ENTERING: component.py:Client._get_example_id_from_file:564")
165+
logging.debug("ENTERING: ")
186166
with open(path) as cf:
187167
fline = cf.readline()
188168

189169
if 'EXAMPLE:' in fline:
190-
logging.debug("EXITING: component.py:Client._get_example_id_from_file:569")
170+
logging.debug("EXITING: ")
191171
return fline.split(':')[1].strip()
192172

193-
logging.debug("EXITING: component.py:Client._get_example_id_from_file:572")
173+
logging.debug("EXITING: ")
194174
return None
195175

196176
def _copy_examples(self):
197-
logging.debug("ENTERING: component.py:Client._copy_examples:577")
177+
logging.debug("ENTERING: ")
198178
if ex := self.get('examples'):
199179
repo = self._git_clone(ex)
200180
dev_branch = ex.get('dev_branch')
@@ -238,10 +218,10 @@ def _copy_examples(self):
238218

239219
logging.info(f'Example {example_id} processed successfully.')
240220
examples[example_id][self.get('label')] = example_metadata
241-
logging.debug("EXITING: component.py:Client._copy_examples:615")
221+
logging.debug("EXITING: ")
242222

243223
def apply(self) -> None:
244-
logging.debug("ENTERING: component.py:Client.apply:618")
224+
logging.debug("ENTERING: ")
245225
logging.info(f'Applying client {self._id}')
246226
self._copy_examples()
247-
logging.debug("EXITING: component.py:Client.apply:621")
227+
logging.debug("EXITING: ")

build/components/example.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class Example(object):
3939
named_steps = None
4040

4141
def __init__(self, language: str, path: str) -> None:
42-
logging.debug("ENTERING: example.py:Example.__init__:41")
42+
logging.debug("ENTERING: ")
4343
if not PREFIXES.get(language.lower()):
4444
logging.error(f'Unknown language "{language}" for example {path}')
45-
logging.debug("EXITING: example.py:Example.__init__:44")
45+
logging.debug("EXITING: ")
4646
return
4747
self.language = language.lower()
4848
self.path = path
@@ -53,18 +53,18 @@ def __init__(self, language: str, path: str) -> None:
5353
self.named_steps = {}
5454
self.make_ranges()
5555
self.persist(self.path)
56-
logging.debug("EXITING: example.py:Example.__init__:53")
56+
logging.debug("EXITING: ")
5757

5858
def persist(self, path: str = None) -> None:
59-
logging.debug("ENTERING: example.py:Example.persist:58")
59+
logging.debug("ENTERING: ")
6060
if not path:
6161
path = self.path
6262
with open(path,'w') as f:
6363
f.writelines(self.content)
64-
logging.debug("EXITING: example.py:Example.persist:63")
64+
logging.debug("EXITING: ")
6565

6666
def make_ranges(self) -> None:
67-
logging.debug("ENTERING: example.py:Example.make_ranges:66")
67+
logging.debug("ENTERING: ")
6868
curr = 0
6969
highlight = 1
7070
hidden = None
@@ -160,10 +160,10 @@ def make_ranges(self) -> None:
160160

161161
if hidden is not None:
162162
logging.error(f'Unclosed hidden anchor in {self.path}:L{hidden+1} - aborting.')
163-
logging.debug("EXITING: example.py:Example.make_ranges:158")
163+
logging.debug("EXITING: ")
164164
return
165165
if highlight < len(content):
166166
self.highlight.append(f'{highlight}-{len(content)}')
167167

168168
self.content = content
169-
logging.debug("EXITING: example.py:Example.make_ranges:164")
169+
logging.debug("EXITING: ")

build/components/markdown.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ class Markdown:
2121
}
2222

2323
def __init__(self, filepath: str, warnings: bool = False):
24-
logging.debug("ENTERING: markdown.py:Markdown.__init__:25")
24+
logging.debug("ENTERING: ")
2525
self.filepath = filepath
2626
self.warnings = warnings
2727
self.fm_data = dict()
2828
self.fm_type = self.FM_TYPES.get('---\n')
2929
self.fm_ext = self.fm_type.get('ext')
3030
self.payload = ''
3131
if not self.filepath or not os.path.exists(self.filepath):
32-
logging.debug("EXITING: markdown.py:Markdown.__init__:33")
32+
logging.debug("EXITING: ")
3333
return
3434
with open(self.filepath, 'r') as f:
3535
payload = f.readlines()
3636
if len(payload) == 0:
3737
self.fm_type = self.FM_TYPES.get('---\n')
3838
self.fm_ext = self.fm_type.get('ext')
39-
logging.debug("EXITING: markdown.py:Markdown.__init__:39")
39+
logging.debug("EXITING: ")
4040
return
4141
i = 0
4242
while i < len(payload):
@@ -52,7 +52,7 @@ def __init__(self, filepath: str, warnings: bool = False):
5252
self.payload = ''.join(payload)
5353
self.fm_type = self.FM_TYPES.get('---\n')
5454
self.fm_ext = self.fm_type.get('ext')
55-
logging.debug("EXITING: markdown.py:Markdown.__init__:53")
55+
logging.debug("EXITING: ")
5656
return
5757
eof, self.fm_ext = self.fm_type.get('eof'), self.fm_type.get('ext')
5858
found = False
@@ -70,10 +70,10 @@ def __init__(self, filepath: str, warnings: bool = False):
7070
self.fm_data.update(StructuredData.loads(
7171
self.fm_ext, ''.join(payload[i+1:j])))
7272
self.payload = ''.join(payload[j+1:])
73-
logging.debug("EXITING: markdown.py:Markdown.__init__:70")
73+
logging.debug("EXITING: ")
7474

7575
def persist(self) -> None:
76-
logging.debug("ENTERING: markdown.py:Markdown.persist:101")
76+
logging.debug("ENTERING: ")
7777
payload = self.payload
7878
if self.fm_type:
7979
fm = StructuredData.dumps(self.fm_ext, self.fm_data)
@@ -89,4 +89,4 @@ def persist(self) -> None:
8989

9090
with open(self.filepath, 'w') as f:
9191
f.write(payload)
92-
logging.debug("EXITING: markdown.py:Markdown.persist:117")
92+
logging.debug("EXITING: ")

build/components/structured_data.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,68 +30,68 @@ class StructuredData:
3030
}
3131

3232
def __init__(self):
33-
logging.debug("ENTERING: structured_data.py:StructuredData.__init__:31")
33+
logging.debug("ENTERING: ")
3434
pass
35-
logging.debug("EXITING: structured_data.py:StructuredData.__init__:33")
35+
logging.debug("EXITING: ")
3636

3737
@staticmethod
3838
def dump(ext: str, d: dict, f: Any) -> None:
39-
logging.debug("ENTERING: structured_data.py:StructuredData.dump:37")
39+
logging.debug("ENTERING: ")
4040
if ext in StructuredData.PARSERS:
4141
result = StructuredData.PARSERS.get(ext).get('dump')(d, f)
42-
logging.debug("EXITING: structured_data.py:StructuredData.dump:40")
42+
logging.debug("EXITING: ")
4343
return result
4444
else:
45-
logging.debug("EXITING: structured_data.py:StructuredData.dump:43")
45+
logging.debug("EXITING: ")
4646
raise RuntimeError(f'unknown extension {ext}')
4747

4848
@staticmethod
4949
def dumps(ext: str, d: dict) -> None:
50-
logging.debug("ENTERING: structured_data.py:StructuredData.dumps:47")
50+
logging.debug("ENTERING: ")
5151
if ext in StructuredData.PARSERS:
5252
result = StructuredData.PARSERS.get(ext).get('dumps')(d)
53-
logging.debug("EXITING: structured_data.py:StructuredData.dumps:50")
53+
logging.debug("EXITING: ")
5454
return result
5555
else:
56-
logging.debug("EXITING: structured_data.py:StructuredData.dumps:53")
56+
logging.debug("EXITING: ")
5757
raise RuntimeError(f'unknown extension {ext}')
5858

5959
@staticmethod
6060
def load(ext: str, f: Any) -> dict:
61-
logging.debug("ENTERING: structured_data.py:StructuredData.load:57")
61+
logging.debug("ENTERING: ")
6262
if ext in StructuredData.PARSERS:
6363
result = StructuredData.PARSERS.get(ext).get('load')(f)
64-
logging.debug("EXITING: structured_data.py:StructuredData.load:60")
64+
logging.debug("EXITING: ")
6565
return result
6666
else:
67-
logging.debug("EXITING: structured_data.py:StructuredData.load:63")
67+
logging.debug("EXITING: ")
6868
raise RuntimeError(f'unknown extension {ext}')
6969

7070
@staticmethod
7171
def loads(ext: str, s: str) -> dict:
72-
logging.debug("ENTERING: structured_data.py:StructuredData.loads:67")
72+
logging.debug("ENTERING: ")
7373
if ext in StructuredData.PARSERS:
7474
result = StructuredData.PARSERS.get(ext).get('loads')(s)
75-
logging.debug("EXITING: structured_data.py:StructuredData.loads:70")
75+
logging.debug("EXITING: ")
7676
return result
7777
else:
78-
logging.debug("EXITING: structured_data.py:StructuredData.loads:73")
78+
logging.debug("EXITING: ")
7979
raise RuntimeError(f'unknown extension {ext}')
8080

8181

8282
def load_dict(filepath: str) -> dict:
83-
logging.debug("ENTERING: structured_data.py:load_dict:82")
83+
logging.debug("ENTERING: ")
8484
# _, name = os.path.split(filepath)
8585
_, ext = os.path.splitext(filepath)
8686
with open(filepath, 'r') as f:
8787
o = StructuredData.load(ext, f)
88-
logging.debug("EXITING: structured_data.py:load_dict:87")
88+
logging.debug("EXITING: ")
8989
return o
9090

9191

9292
def dump_dict(filepath: str, d: dict) -> None:
93-
logging.debug("ENTERING: structured_data.py:dump_dict:91")
93+
logging.debug("ENTERING: ")
9494
_, ext = os.path.splitext(filepath)
9595
with open(filepath, 'w') as f:
9696
StructuredData.dump(ext, d, f)
97-
logging.debug("EXITING: structured_data.py:dump_dict:95")
97+
logging.debug("EXITING: ")

0 commit comments

Comments
 (0)