Skip to content

Commit e29f945

Browse files
committed
build datasheet with pydantic classes
1 parent 06af50b commit e29f945

File tree

9 files changed

+636
-1215
lines changed

9 files changed

+636
-1215
lines changed
Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
#!/usr/bin/env python3
21
import argparse
32
import sys
43
import os
54
import traceback
6-
from rocrate.datasheet_generator import DatasheetGenerator
5+
from pathlib import Path
6+
7+
from fairscape_cli.datasheet_builder.rocrate.datasheet_generator import DatasheetGenerator
8+
79

810
def main():
911
parser = argparse.ArgumentParser(
@@ -14,28 +16,51 @@ def main():
1416
required=True,
1517
help='Path to top-level ro-crate-metadata.json file'
1618
)
19+
parser.add_argument(
20+
'--templates',
21+
default='./templates',
22+
help='Path to templates directory (default: ./templates)'
23+
)
24+
parser.add_argument(
25+
'--output',
26+
help='Path for output datasheet HTML (default: same dir as input)'
27+
)
28+
parser.add_argument(
29+
'--published',
30+
action='store_true',
31+
help='Generate published version with fairscape.net links'
32+
)
33+
1734
args = parser.parse_args()
1835

1936
try:
20-
input_dir = os.path.dirname(args.input)
21-
template_dir = "./templates"
22-
output_path = os.path.join(input_dir, "ro-crate-datasheet.html")
37+
input_path = Path(args.input)
38+
input_dir = input_path.parent
39+
template_dir = Path(args.templates)
40+
41+
if args.output:
42+
output_path = Path(args.output)
43+
else:
44+
output_path = input_dir / "ro-crate-datasheet.html"
2345

2446
generator = DatasheetGenerator(
25-
json_path=args.input,
26-
template_dir=template_dir
47+
json_path=input_path,
48+
template_dir=template_dir,
49+
published=args.published
2750
)
2851

2952
generator.process_subcrates()
3053

3154
final_output_path = generator.save_datasheet(output_path)
3255
print(f"Datasheet generated successfully: {final_output_path}")
56+
3357
except Exception as e:
3458
print(f"Error: {str(e)}")
3559
traceback.print_exc()
3660
return 1
3761

3862
return 0
3963

64+
4065
if __name__ == "__main__":
4166
sys.exit(main())

src/fairscape_cli/datasheet_builder/rocrate/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from .base import ROCrateProcessor
2-
from .template_engine import TemplateEngine
31
from .section_generators import (
42
OverviewSectionGenerator,
53
UseCasesSectionGenerator,
@@ -9,8 +7,6 @@
97
from .datasheet_generator import DatasheetGenerator
108

119
__all__ = [
12-
'ROCrateProcessor',
13-
'TemplateEngine',
1410
'OverviewSectionGenerator',
1511
'UseCasesSectionGenerator',
1612
'DistributionSectionGenerator',

src/fairscape_cli/datasheet_builder/rocrate/base.py

Lines changed: 0 additions & 253 deletions
This file was deleted.

0 commit comments

Comments
 (0)