-
Notifications
You must be signed in to change notification settings - Fork 1
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
comicrack: fix generated xml #7
Conversation
Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
mytree.write(comic_info_fp, encoding='UTF-8', xml_declaration=True) | ||
|
||
data = json.dumps(self.comic_info) | ||
tmp_xml = xmlschema.from_json(data, preserve_root=True, schema=schema) |
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.
schema is not defined, I think you meant to have something such as
with open(COMICINFO_TEMPLATE, 'r') as xsd_template:
schema = xsd_template.read()
tmp_xml = xmlschema.from_json(data, preserve_root=True, schema=schema)
ET.ElementTree(tmp_xml).write(comic_info_fp, encoding='UTF-8', xml_declaration=True)
However, even with this, this code change is not working unfortunately. Currently, all the values stored in self.comic_info (coming from the json file) are set as strings and converted into str or integer in the deleted code above, note that L34 should have been int(self.comic_info[metadata_key])
instead of str(self.comic_info[metadata_key])
.
So now with this code change, the data coming from the json file is expected to be of the right type but it now breaks against the xsd schema validation, see for example with the number of pages "120":
xmlschema.validators.exceptions.XMLSchemaEncodeError: failed validating '120' with XsdAtomicBuiltin(name='xs:int'):
Reason: '120' is not an instance of <class 'int'>
So maybe some refactoring could be done in https://github.com/lbesnard/bdnex/blob/main/bdnex/conf/bdgest_mapping.json to add the type of each key
such as:
{
"Couleurs": {"value": "Colorist",
"type": "str"},
"Couverture": {"value": "CoverArtist",
"type": "str"},
"Planches": {"value": "PageCount",
"type": "int"}
}
and modify the code accordingly in https://github.com/lbesnard/bdnex/blob/main/bdnex/lib/bdgest.py#L428
thoughts?
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.
Just pushed a fix regarding the schema i've forgot... thx for catching it!!
Doesn't the pagecount integer problem haven't been fixed here:
#5 ?
Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
Codecov ReportBase: 60.95% // Head: 61.53% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
==========================================
+ Coverage 60.95% 61.53% +0.58%
==========================================
Files 5 5
Lines 461 468 +7
==========================================
+ Hits 281 288 +7
Misses 180 180
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The current generated xml file is in fact, an xml schema.
xmlschema is used to generate the ComicInfo.xml against the xsd schema.
I needed to update the schema from
xs:sequence
toxs:all
(anansi-project/comicinfo#29) in order to make it work.In the mean time, fix Letterer.
Signed-off-by: Jean-Philippe Menil jpmenil@gmail.com