Skip to content

Commit

Permalink
Changes for artifact and path filters (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Mar 9, 2024
1 parent 1b29dfa commit 8c22542
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dfimagetools (20240301-1) unstable; urgency=low
dfimagetools (20240309-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline maintainers <[email protected]> Fri, 01 Mar 2024 10:18:45 +0100
-- Log2Timeline maintainers <[email protected]> Sat, 09 Mar 2024 17:23:57 +0100
2 changes: 1 addition & 1 deletion dfimagetools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"""Collection of tools to process storage media images."""


__version__ = '20240301'
__version__ = '20240309'
26 changes: 19 additions & 7 deletions dfimagetools/scripts/extract_data_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import os
import sys

import artifacts

from artifacts import reader as artifacts_reader
from artifacts import registry as artifacts_registry

Expand Down Expand Up @@ -83,7 +85,16 @@ def Main():
return 1

if options.artifact_filters:
if (not options.artifact_definitions and
artifact_definitions = options.artifact_definitions
if not artifact_definitions:
artifact_definitions = os.path.join(
os.path.dirname(artifacts.__file__), 'data')
if not os.path.exists(artifact_definitions):
artifact_definitions = os.path.join('/', 'usr', 'share', 'artifacts')
if not os.path.exists(artifact_definitions):
artifact_definitions = None

if (not artifact_definitions and
not options.custom_artifact_definitions):
print('[ERROR] artifact filters were specified but no paths to '
'artifact definitions were provided.')
Expand Down Expand Up @@ -118,11 +129,11 @@ def Main():
registry = artifacts_registry.ArtifactDefinitionsRegistry()
reader = artifacts_reader.YamlArtifactsReader()

if options.artifact_definitions:
if os.path.isdir(options.artifact_definitions):
registry.ReadFromDirectory(reader, options.artifact_definitions)
elif os.path.isfile(options.artifact_definitions):
registry.ReadFromFile(reader, options.artifact_definitions)
if artifact_definitions:
if os.path.isdir(artifact_definitions):
registry.ReadFromDirectory(reader, artifact_definitions)
elif os.path.isfile(artifact_definitions):
registry.ReadFromFile(reader, artifact_definitions)

if options.custom_artifact_definitions:
if os.path.isdir(options.custom_artifact_definitions):
Expand All @@ -142,7 +153,8 @@ def Main():
'--partitions command line argument.'))
print('')

volume_scanner_options.partitions = [filter_generator.partition]
if filter_generator.partition:
volume_scanner_options.partitions = [filter_generator.partition]

entry_lister = file_entry_lister.FileEntryLister(
mediator=mediator, use_aliases=options.use_aliases)
Expand Down
23 changes: 17 additions & 6 deletions dfimagetools/scripts/list_file_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import os
import sys

import artifacts

from artifacts import reader as artifacts_reader
from artifacts import registry as artifacts_registry

Expand Down Expand Up @@ -84,7 +86,16 @@ def Main():
return 1

if options.artifact_filters:
if (not options.artifact_definitions and
artifact_definitions = options.artifact_definitions
if not artifact_definitions:
artifact_definitions = os.path.join(
os.path.dirname(artifacts.__file__), 'data')
if not os.path.exists(artifact_definitions):
artifact_definitions = os.path.join('/', 'usr', 'share', 'artifacts')
if not os.path.exists(artifact_definitions):
artifact_definitions = None

if (not artifact_definitions and
not options.custom_artifact_definitions):
print('[ERROR] artifact filters were specified but no paths to '
'artifact definitions were provided.')
Expand All @@ -101,11 +112,11 @@ def Main():
registry = artifacts_registry.ArtifactDefinitionsRegistry()
reader = artifacts_reader.YamlArtifactsReader()

if options.artifact_definitions:
if os.path.isdir(options.artifact_definitions):
registry.ReadFromDirectory(reader, options.artifact_definitions)
elif os.path.isfile(options.artifact_definitions):
registry.ReadFromFile(reader, options.artifact_definitions)
if artifact_definitions:
if os.path.isdir(artifact_definitions):
registry.ReadFromDirectory(reader, artifact_definitions)
elif os.path.isfile(artifact_definitions):
registry.ReadFromFile(reader, artifact_definitions)

if options.custom_artifact_definitions:
if os.path.isdir(options.custom_artifact_definitions):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = dfimagetools
version = 20240301
version = 20240309
description = Storage media image tools
long_description = Collection of tools to process storage media images.
long_description_content_type = text/plain
Expand Down

0 comments on commit 8c22542

Please sign in to comment.