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

Commit df73880

Browse files
committed
Repair run_example and allow configuring html_dir via the command line.
Support a directory argument of "." to allow outputting to an output folder in the cwd with an automatic suffix: ./_autoarchaologist While here add top level run_example wrapper shell script in advance of a future change to provide a unified run CLI.
1 parent 3374d44 commit df73880

File tree

5 files changed

+45
-10
lines changed

5 files changed

+45
-10
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ __pycache__/
66
# Sphinx documentation
77
docs/_build/
88

9+
# Build files
10+
venv/
11+
912
# Temporary files
1013
_.*
14+
/output/

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
default: example
2+
3+
example:
4+
./venv/bin/python3 run_example.py -d .

ddhf/ddhf/decorated_context.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,29 @@ def from_argv(self):
110110
"AUTOARCHAEOLOGIST_BITSTORE_CACHE": "ddhf_bitstore_cache",
111111
}
112112

113-
def main(job, html_subdir="tmp", **kwargs):
113+
def parse_arguments(argv=None):
114+
parser = argparse.ArgumentParser()
115+
parser.add_argument('-o', '--out', default='/tmp/_autoarchaologist')
116+
117+
args = parser.parse_args(args=argv)
118+
if args.out == '.':
119+
args.out = os.path.join(os.getcwd(), "_autoarchaologist")
120+
return args
121+
122+
def main(job, html_subdir, **kwargs):
123+
args = parse_arguments()
124+
kwargs["html_dir"] = args.out
125+
114126
''' A standard main routine to reduce boiler-plate '''
115127
for key in os.environ:
116128
i = OK_ENVS.get(key)
117129
if i:
118130
kwargs[i] = os.environ[key]
119131

132+
if 'html_dir' not in kwargs:
133+
raise AttributeError("missing: html_dir")
134+
135+
120136
kwargs['html_dir'] = os.path.join(kwargs['html_dir'], html_subdir)
121137
kwargs.setdefault('download_links', True)
122138
kwargs.setdefault('download_limit', 1 << 20)

output/.gitkeep

Whitespace-only changes.

run_example.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11

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

46
import autoarchaeologist
57

6-
from autoarchaeologist.generic.bigdigits import BigDigits
8+
from autoarchaeologist.generic.bigtext import BigText
79
from autoarchaeologist.generic.samesame import SameSame
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(), "output", "_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

16-
ctx.add_examiner(BigDigits)
32+
ctx.add_examiner(BigText)
1733
ctx.add_examiner(AbsBin)
1834
ctx.add_examiner(DGC_PaperTapeCheckSum)
1935
ctx.add_examiner(SameSame)
@@ -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)