Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit e46910b

Browse files
committed
Allow configuring html_dir via the command line and fix run_example.
Support a directory argument of "." to allow outputting in the current directory with an automatic suffix: ./_autoarchaologist
1 parent fa04605 commit e46910b

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ docs/_build/
88

99
# Temporary files
1010
_.*
11+
_autoarchaologist/

autoarchaeologist/ddhf/bitstore.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import mmap
99
import urllib.request
1010

11-
import ddhf_bitstore_metadata
12-
1311
from ..base import artifact
1412
from ..base import excavation
1513
from ..container import simh_tap_file
@@ -165,10 +163,6 @@ def fetch_single(self, arg):
165163
print("Could not fetch", arg)
166164
return
167165

168-
meta = ddhf_bitstore_metadata.internals.metadata.MetadataBase(metatxt)
169-
if meta is None:
170-
return
171-
172166
if self.media_types and not self.check_media_type(meta):
173167
return
174168

autoarchaeologist/ddhf/decorated_context.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
'''
88

9+
import argparse
910
import os
1011

1112
from ..base import excavation
@@ -84,13 +85,29 @@ def from_bitstore(self, *args, **kwargs):
8485
"AUTOARCHAEOLOGIST_BITSTORE_CACHE": "ddhf_bitstore_cache",
8586
}
8687

87-
def main(job, html_subdir="tmp", **kwargs):
88+
def parse_arguments(argv=None):
89+
parser = argparse.ArgumentParser()
90+
parser.add_argument('-o', '--out', default='/tmp/_autoarchaologist')
91+
92+
args = parser.parse_args(args=argv)
93+
if args.out == '.':
94+
args.out = os.path.join(os.getcwd(), "_autoarchaologist")
95+
return args
96+
97+
def main(job, html_subdir, **kwargs):
98+
args = parse_arguments()
99+
kwargs["html_dir"] = args.out
100+
88101
''' A standard main routine to reduce boiler-plate '''
89102
for key in os.environ:
90103
i = OK_ENVS.get(key)
91104
if i:
92105
kwargs[i] = os.environ[key]
93106

107+
if 'html_dir' not in kwargs:
108+
raise AttributeError("missing: html_dir")
109+
110+
94111
kwargs['html_dir'] = os.path.join(kwargs['html_dir'], html_subdir)
95112
kwargs.setdefault('download_links', True)
96113
kwargs.setdefault('download_limit', 1 << 20)

run_example.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2+
import argparse
23
import os
4+
import sys
35

46
import autoarchaeologist
57

@@ -8,10 +10,24 @@
810
from autoarchaeologist.data_general.absbin import AbsBin
911
from autoarchaeologist.data_general.papertapechecksum import DGC_PaperTapeCheckSum
1012

13+
def parse_arguments(argv=None):
14+
parser = argparse.ArgumentParser()
15+
parser.add_argument("-d", "--dir", default="/tmp/_autoarchaologist")
16+
17+
args = parser.parse_args(args=argv)
18+
if args.dir == ".":
19+
args.dir = os.path.join(os.getcwd(), "_autoarchaologist")
20+
return args
1121

1222
if __name__ == "__main__":
23+
args = parse_arguments()
24+
25+
try:
26+
os.mkdir(args.dir)
27+
except FileExistsError:
28+
pass
1329

14-
ctx = autoarchaeologist.Excavation()
30+
ctx = autoarchaeologist.Excavation(html_dir=args.dir)
1531

1632
ctx.add_examiner(BigDigits)
1733
ctx.add_examiner(AbsBin)
@@ -22,11 +38,6 @@
2238

2339
ctx.start_examination()
2440

25-
try:
26-
os.mkdir("/tmp/_autoarchaologist")
27-
except FileExistsError:
28-
pass
29-
30-
ctx.produce_html(html_dir="/tmp/_autoarchaologist")
41+
ctx.produce_html()
3142

3243
print("Now point your browser at", ctx.filename_for(ctx).link)

0 commit comments

Comments
 (0)