Repository navigation
Modularised and extend critique.py - #22
Conversation
…initions used in the example files.
|
@benajamin suggested by email:
Seems possible but re-writing the README file could make it less intuitive how to edit the static content there. Maybe there is another way to have the content appear in the README even though it comes from another file. Some kind of include directive, if it exists. |
|
Also need to avoid the obvious race condition posed by a new commit from the Github Action. |
|
@prjemian, is it correct now? |
| fullname = os.path.join(path, fname) | ||
| if not os.path.exists(fullname): | ||
| return | ||
| ## can the file be found? |
There was a problem hiding this comment.
remove these commented-out lines
| ad_list.add(str(entry['definition'][0], encoding='utf-8')) | ||
| else: | ||
| for sub in subentry_list: | ||
| ad_list.add(str(sub['definition'][0], encoding='utf-8')) |
There was a problem hiding this comment.
add comment saying this counts application definitions as NXsubentry
|
|
||
| def __init__(self): | ||
| self.db = {} | ||
| self.test_bank = [func for func in dir(Critic) if callable(getattr(Critic, func)) and func.startswith("test_")] |
There was a problem hiding this comment.
While efficient for execution, list comprehensions such as this can be tricky to review and edit. Also, the line length becomes a bit long. I often break a list comprehension such as this into several lines to improve readability without compromising efficiency:
self.test_bank = [
func
for func in dir(Critic)
if callable(getattr(Critic, func)) and func.startswith("test_")
]
| :param str fname: (absolute or relative path and) name of file | ||
| ''' | ||
|
|
||
| def __init__(self, path, fname): |
There was a problem hiding this comment.
consider changing to path=None, fname=None with consequence to the caller as shown below
| def __init__(self): | ||
| self.db = {} | ||
| self.test_bank = [func for func in dir(Critic) if callable(getattr(Critic, func)) and func.startswith("test_")] | ||
| self.table_labels = ["path", "file"] + Critic( None, None).test_results |
There was a problem hiding this comment.
per previous suggestion, then Critic().test_results
| table.labels = ["file", "critique"] | ||
| for fname, critique in sorted(flist.items()): | ||
| table.addRow(("``"+fname+"``", critique)) | ||
| table.addRow(["`"+path+"`","`"+fname+"`"]+ critique.test_results) |
| return | ||
| for nm in files: | ||
| registrar.add(path, Critic(path, nm)) | ||
| if os.path.splitext(nm)[1] not in ['.txt','.py','.rst','.md','.in'] and nm[0] != '.': # skip other types of file |
There was a problem hiding this comment.
if os.path.splitext(nm)[1] not in extensions and nm[0] != '.': # skip other types of file
|
For code style matters, pylint, flake8, and black are the usual tools. Of these, black actually modifies the file per the style (the others point out items inconsistent with the style). While brutal, I usually use ALWAYS, I run black after committing the |
|
Good job! |
|
Black looks interesting and I'll check it out. I am pretty progressive in my personal opinions about code style though:
But style arguments are like wars, the only way to win is to not get involved. |
Why I have succumbed to black. The Borg have won. |
Fixes #20
Performing tests on the example files is now modular and each test reports with its own column. Tests are implemented to:
Implementing the tests for XML should be straightforward, but I don't think the HDF4 dependencies are worth working with.