-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from pomfort/dev/windowsPathHandling
Make sure to properly read and write posix style relative paths to the xml files on windows
- Loading branch information
Showing
25 changed files
with
491 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# make sure the scenario output files are not converted to a different line ending when checked out by git on windows | ||
# otherwise the scenario tests will fail and the files can't be verified with the ascmhl tool | ||
/examples/scenarios/Output/** binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ docs/build | |
docs/docenv | ||
.coverage | ||
htmlcov | ||
/.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,7 @@ | |
__email__ = "[email protected]" | ||
""" | ||
|
||
from . import logger | ||
from .__version__ import ascmhl_reference_hash_format | ||
from .chain import MHLChain, MHLChainGeneration | ||
from .hashlist import MHLHashList | ||
import os | ||
import textwrap | ||
|
||
from lxml import etree | ||
|
@@ -20,6 +16,7 @@ | |
from .hashlist import * | ||
from .__version__ import ascmhl_supported_hashformats | ||
from .hashlist import MHLHashList | ||
from .utils import convert_local_path_to_posix, convert_posix_to_local_path | ||
|
||
|
||
def parse(file_path): | ||
|
@@ -51,14 +48,15 @@ def parse(file_path): | |
|
||
if type(current_object) is MHLChainGeneration: | ||
if tag == "path": | ||
current_object.ascmhl_filename = element.text | ||
current_object.ascmhl_filename = convert_posix_to_local_path(element.text) | ||
elif tag in ascmhl_supported_hashformats: | ||
current_object.hash_format = tag | ||
current_object.hash_string = element.text | ||
elif tag == "hashlist": | ||
current_object.generation_number = element.attrib.get("sequencenr") | ||
chain.append_generation(current_object) | ||
current_object = None | ||
file.close() | ||
|
||
return chain | ||
|
||
|
@@ -86,6 +84,7 @@ def write_chain(chain: MHLChain, new_hash_list: MHLHashList): | |
current_indent = current_indent[:-2] | ||
_write_xml_string_to_file(file, "</ascmhldirectory>\n", current_indent) | ||
file.flush() | ||
file.close() | ||
|
||
|
||
def _write_xml_element_to_file(file, xml_element, indent: str): | ||
|
@@ -102,7 +101,7 @@ def _hashlist_xml_element_from_hashlist(hash_list: MHLHashList): | |
"""builds and returns one <hashlist> element for a given HashList object""" | ||
|
||
hash_list_element = E.hashlist( | ||
E.path(os.path.basename(hash_list.file_path)), | ||
E.path(convert_local_path_to_posix(os.path.basename(hash_list.file_path))), | ||
E.c4(hash_list.generate_reference_hash()), | ||
) | ||
hash_list_element.attrib["sequencenr"] = str(hash_list.generation_number) | ||
|
@@ -115,7 +114,7 @@ def _hashlist_xml_element_from_chaingeneration(generation: MHLChainGeneration): | |
|
||
if generation.hash_format == "c4": | ||
hash_list_element = E.hashlist( | ||
E.path(generation.ascmhl_filename), | ||
E.path(convert_local_path_to_posix(generation.ascmhl_filename)), | ||
E.c4(generation.hash_string), | ||
) | ||
hash_list_element.attrib["sequencenr"] = str(generation.generation_number) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.