Skip to content
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

fixed pathlib issues for python < 3.6 compatibility #2

Merged
merged 5 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ optimize-ast=no
confidence=

# Disable the message, report, category or checker with the given id(s)
disable=missing-docstring,locally-disabled,logging-format-interpolation
disable=missing-docstring,locally-disabled,logging-format-interpolation,wrong-import-order


[REPORTS]
Expand Down
2 changes: 1 addition & 1 deletion fact_extractor/plugins/unpacking/xerox/code/dlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _create_meta_dict(xeroxdlm):


class XeroxDLM:
def __init__(self, firmware_file):
def __init__(self, firmware_file: str):
self.firmware_file = firmware_file
self.header_end_offset = None
self.dlm_signature = None
Expand Down
4 changes: 2 additions & 2 deletions fact_extractor/plugins/unpacking/xerox/test/test_dlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestXeroxDLM(TestUnpackerBase):
def setUp(self):
super().setUp()

self.test_path = Path(TEST_DATA_DIR, 'DLM-First_1MB.DLM')
self.test_path = str(Path(TEST_DATA_DIR, 'DLM-First_1MB.DLM'))
self.firmware_container = XeroxDLM(self.test_path)

def test_unpacker_selection(self):
Expand All @@ -39,7 +39,7 @@ def test_header_and_binary(self):
files, meta_data = self.unpacker.extract_files_from_file(self.test_path, self.tmp_dir.name)
files = set(files)
self.assertEqual(len(files), 1, 'file number incorrect')
data_bin = get_binary_from_file(Path(self.tmp_dir.name, 'dlm_data.bin'))
data_bin = get_binary_from_file(str(Path(self.tmp_dir.name, 'dlm_data.bin')))
self.assertEqual(get_sha256(data_bin), '701962b0d11f50d9129d5a1655ee054865e90cd1b547d40d590ea96f7dfb64eb')
self.assertEqual(meta_data['dlm_version'], 'NO_DLM_VERSION_CHECK', 'meta: dlm_version not correct')
self.assertEqual(meta_data['dlm_signature'], '90ec11f7b52468378362987a4ed9e56855070915887e6afe567e1c47875b29f9', 'meta: dlm_signature not correct')
Expand Down
4 changes: 2 additions & 2 deletions fact_extractor/test/unit/helperFunctions/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_unpack_status_unpacked_file(config_fixture):


def test_detect_unpack_loss_data_lost(config_fixture, common_tmpdir):
included_file = Path(common_tmpdir, 'inner')
included_file = Path(str(common_tmpdir), 'inner')
included_file.write_bytes(256 * b'ABCDEFGH')
result = {'summary': []}

Expand All @@ -57,7 +57,7 @@ def test_detect_unpack_loss_data_lost(config_fixture, common_tmpdir):


def test_detect_unpack_loss_no_data_lost(config_fixture, common_tmpdir):
included_file = Path(common_tmpdir, 'inner')
included_file = Path(str(common_tmpdir), 'inner')
included_file.write_bytes(512 * b'ABCDEFGH')
result = {'summary': []}

Expand Down
2 changes: 1 addition & 1 deletion fact_extractor/unpacker/unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ def move_extracted_files(self, file_paths: List[str], extraction_dir: Path) -> L
relative_path = absolute_path.relative_to(extraction_dir)
target_path = Path(self._file_folder, relative_path)
os.makedirs(str(target_path.parent), exist_ok=True)
shutil.move(absolute_path, target_path)
shutil.move(str(absolute_path), str(target_path))
extracted_files.append(target_path)
return extracted_files