-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/ted 51 #22
Feature/ted 51 #22
Conversation
Codecov Report
@@ Coverage Diff @@
## main #22 +/- ##
==========================================
- Coverage 96.37% 96.32% -0.05%
==========================================
Files 26 33 +7
Lines 744 979 +235
==========================================
+ Hits 717 943 +226
- Misses 27 36 +9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done.
See minor fixes requests in the comments.
|
||
from jinja2 import Environment, PackageLoader | ||
|
||
TEMPLATES = Environment(loader=PackageLoader("ted_sws.notice_packager.resources", "templates")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be moved into the module
LIST_TYPE = List[PATH_TYPE] | ||
|
||
|
||
class ArchiverABC(abc.ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not use the Fakes for testing, this abstraction is not needed.
But not harmful either.
|
||
class TemplateGenerator: | ||
@classmethod | ||
def __generate_template(cls, template, data: Dict = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use single and not double underscore marking for "private" functions.
|
||
@classmethod | ||
def mets2action_mets_xml_generator(cls, data: Dict = None): | ||
action = data["notice"]["action"]["type"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcoded dictionary keys are rarely a good idea
return cls.__generate_template(template, data) | ||
|
||
@classmethod | ||
def mets2action_mets_xml_generator(cls, data: Dict = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shall not use arbitrary dictionaries but domain classes to pass parameters and return values
raise ValueError('No such action: %s' % v) | ||
|
||
|
||
class MetaMetadata(Metadata): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class can be merged into its parent
NORM_SEP = '_' | ||
|
||
|
||
class MetadataTransformer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic could have been implemented as a domain service. Alternatively it could have been integrated into the Package metadata.
return notice_metadata | ||
|
||
|
||
def create_notice_package(in_data: IN_DATA_TYPE, rdf_content: Union[str, bytes] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function is too long.
It could be broken down into a couple of smaller functions to ease the reading.
No description provided.