sourceledger 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: sourceledger
3
+ Version: 0.4.0
4
+ Summary: Fetch, verify and validate the public sources a dataset is built from, with a provenance record for every download
5
+ Keywords: provenance,data pipeline,reproducibility,open data,research software,FAIR
6
+ Author: Simon van Lierde
7
+ Author-email: Simon van Lierde <code@duinlab.nl>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: POSIX
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: openpyxl>=3.1 ; extra == 'xlsx'
21
+ Requires-Python: >=3.12
22
+ Project-URL: Homepage, https://github.com/simonvanlierde/sourceledger
23
+ Project-URL: Issues, https://github.com/simonvanlierde/sourceledger/issues
24
+ Provides-Extra: xlsx
25
+ Description-Content-Type: text/markdown
26
+
27
+ # sourceledger
28
+
29
+ [![python](https://github.com/simonvanlierde/sourceledger/actions/workflows/python.yml/badge.svg)](https://github.com/simonvanlierde/sourceledger/actions/workflows/python.yml)
30
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
31
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.23460694.svg)](https://doi.org/10.5281/zenodo.23460694)
32
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/simonvanlierde/sourceledger/badge)](https://scorecard.dev/viewer/?uri=github.com/simonvanlierde/sourceledger)
33
+ [![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://app.codspeed.io/simonvanlierde/sourceledger?utm_source=badge)
34
+
35
+ Build a dataset from published sources and keep a record of the downloads behind it.
36
+
37
+ sourceledger is a Python library and command for researchers who combine other people's
38
+ CSV, JSON, Excel or binary files. List the sources and reuse terms in `sources.toml`, then:
39
+
40
+ - `fetch` downloads the files and records their URLs, dates and SHA-256 checksums.
41
+ - `build` writes tables with provenance columns, or copies file sources unchanged.
42
+ - `validate` checks the outputs against the downloads and the manifest.
43
+
44
+ Each table row identifies its download. A `datapackage.json` describes the outputs.
45
+ The [documentation website](https://simonvanlierde.com/sourceledger/) follows a source through a publisher's revision.
46
+
47
+ ## Install
48
+
49
+ ```sh
50
+ uv tool install sourceledger
51
+ ```
52
+
53
+ For a Python project that imports the library, use `uv add sourceledger` instead.
54
+ Use `sourceledger[xlsx]` in either command to read Excel files.
55
+ Python 3.12 or later is required; Linux and macOS are supported (POSIX).
56
+ This README follows `main`, including [unreleased features](CHANGELOG.md#unreleased).
57
+
58
+ ## Quick start
59
+
60
+ Write a `sources.toml` in the project root (`sourceledger init` writes a starter):
61
+
62
+ ```toml
63
+ [[source]]
64
+ id = "co2"
65
+ status = "implemented"
66
+ url = "https://raw.githubusercontent.com/datasets/co2-ppm/main/data/co2-annmean-mlo.csv"
67
+ vintage = "main branch, unversioned"
68
+ terms = "ODC-PDDL-1.0 (datasets/co2-ppm package; original data from NOAA GML)"
69
+ terms_url = "https://opendatacommons.org/licenses/pddl/"
70
+ license = "PDDL-1.0"
71
+ redistribute = true
72
+ ```
73
+
74
+ Then run the stages from that directory:
75
+
76
+ ```sh
77
+ sourceledger fetch
78
+ sourceledger build
79
+ sourceledger validate
80
+ ```
81
+
82
+ `sourceledger` reads CSV (gzipped or not), JSON and Excel, by each source's `format` or its
83
+ URL's extension. Set `format = "file"` to keep a raster, archive or other file unchanged.
84
+ For another table format, see [custom readers](docs/readers.md).
85
+
86
+ ### What to commit
87
+
88
+ Commit `sources.toml` and `data/fetches.jsonl`. The log holds checksums and URLs, not
89
+ data: it's the history of every version you have fetched.
90
+
91
+ Build output is a local working dataset. A file source is copied unchanged, including
92
+ when `redistribute = false`. Check [reuse terms before publication](docs/secure-use.md#check-redistribute-before-you-publish-raw-files).
93
+
94
+ Keep `data/raw/` and `data/processed/` out of git, so the repository never redistributes
95
+ a publisher's data. The `.fetch.json` records live in `data/raw/` too, so a fresh clone
96
+ runs `fetch` before `build` and `validate`.
97
+
98
+ ## Documentation
99
+
100
+ - **Get started:** follow the [worked example](docs/getting-started.md) to notice a revised
101
+ source and rebuild the dataset.
102
+ - **Configure and run:** use the [manifest and command reference](docs/reference.md),
103
+ [download limits and retries](docs/fetching.md), and [custom readers](docs/readers.md).
104
+ - **Inspect and share:** consume [JSON reports](docs/reports.md) in CI, or create a
105
+ [standalone HTML provenance report](docs/provenance-report.md) for dataset recipients
106
+ with `sourceledger report > provenance.html`.
107
+ - **Understand the checks:** read [how it works](docs/architecture.md),
108
+ [safe use](docs/secure-use.md), and [what the checks establish](docs/assurance-case.md).
109
+ - **Choose and verify:** compare [related tools](docs/comparison.md), or check a
110
+ sourceledger release's [signed provenance and reproducible build](docs/releases.md).
111
+
112
+ ## Project status
113
+
114
+ ### Stability
115
+
116
+ Until 1.0, the public API is `sourceledger`'s `__all__`, the keys of `sources.toml`, and
117
+ the format of fetch records and the log. A breaking change to any of them comes only in a
118
+ minor version, listed in [CHANGELOG.md](CHANGELOG.md), with a warning first where that's
119
+ cheap. Older fetch logs stay readable.
120
+
121
+ ### Roadmap
122
+
123
+ - A `release` stage that writes the metadata for a dataset release (RO-Crate, Croissant,
124
+ CodeMeta, Zenodo and a `SHA256SUMS` file), checks each with its official validator, and
125
+ keeps the data of `redistribute = false` sources out of the release.
126
+ - An error class per kind of failure, under `ValueError` and `OSError`, once the release
127
+ stage needs to tell them apart. This will not break code that catches the base classes.
128
+ - A review by [pyOpenSci](https://www.pyopensci.org) once the project has users besides
129
+ its own template.
130
+
131
+ Ideas and requests are welcome as [issues](https://github.com/simonvanlierde/sourceledger/issues).
132
+
133
+ ## Development
134
+
135
+ ```sh
136
+ uv sync
137
+ just check
138
+ ```
139
+
140
+ [Contributing](.github/CONTRIBUTING.md) covers hooks, coding standards and tests.
141
+ [Governance](GOVERNANCE.md) explains project decisions. Report vulnerabilities through
142
+ [Security](.github/SECURITY.md).
143
+
144
+ ## License
145
+
146
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,120 @@
1
+ # sourceledger
2
+
3
+ [![python](https://github.com/simonvanlierde/sourceledger/actions/workflows/python.yml/badge.svg)](https://github.com/simonvanlierde/sourceledger/actions/workflows/python.yml)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.23460694.svg)](https://doi.org/10.5281/zenodo.23460694)
6
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/simonvanlierde/sourceledger/badge)](https://scorecard.dev/viewer/?uri=github.com/simonvanlierde/sourceledger)
7
+ [![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://app.codspeed.io/simonvanlierde/sourceledger?utm_source=badge)
8
+
9
+ Build a dataset from published sources and keep a record of the downloads behind it.
10
+
11
+ sourceledger is a Python library and command for researchers who combine other people's
12
+ CSV, JSON, Excel or binary files. List the sources and reuse terms in `sources.toml`, then:
13
+
14
+ - `fetch` downloads the files and records their URLs, dates and SHA-256 checksums.
15
+ - `build` writes tables with provenance columns, or copies file sources unchanged.
16
+ - `validate` checks the outputs against the downloads and the manifest.
17
+
18
+ Each table row identifies its download. A `datapackage.json` describes the outputs.
19
+ The [documentation website](https://simonvanlierde.com/sourceledger/) follows a source through a publisher's revision.
20
+
21
+ ## Install
22
+
23
+ ```sh
24
+ uv tool install sourceledger
25
+ ```
26
+
27
+ For a Python project that imports the library, use `uv add sourceledger` instead.
28
+ Use `sourceledger[xlsx]` in either command to read Excel files.
29
+ Python 3.12 or later is required; Linux and macOS are supported (POSIX).
30
+ This README follows `main`, including [unreleased features](CHANGELOG.md#unreleased).
31
+
32
+ ## Quick start
33
+
34
+ Write a `sources.toml` in the project root (`sourceledger init` writes a starter):
35
+
36
+ ```toml
37
+ [[source]]
38
+ id = "co2"
39
+ status = "implemented"
40
+ url = "https://raw.githubusercontent.com/datasets/co2-ppm/main/data/co2-annmean-mlo.csv"
41
+ vintage = "main branch, unversioned"
42
+ terms = "ODC-PDDL-1.0 (datasets/co2-ppm package; original data from NOAA GML)"
43
+ terms_url = "https://opendatacommons.org/licenses/pddl/"
44
+ license = "PDDL-1.0"
45
+ redistribute = true
46
+ ```
47
+
48
+ Then run the stages from that directory:
49
+
50
+ ```sh
51
+ sourceledger fetch
52
+ sourceledger build
53
+ sourceledger validate
54
+ ```
55
+
56
+ `sourceledger` reads CSV (gzipped or not), JSON and Excel, by each source's `format` or its
57
+ URL's extension. Set `format = "file"` to keep a raster, archive or other file unchanged.
58
+ For another table format, see [custom readers](docs/readers.md).
59
+
60
+ ### What to commit
61
+
62
+ Commit `sources.toml` and `data/fetches.jsonl`. The log holds checksums and URLs, not
63
+ data: it's the history of every version you have fetched.
64
+
65
+ Build output is a local working dataset. A file source is copied unchanged, including
66
+ when `redistribute = false`. Check [reuse terms before publication](docs/secure-use.md#check-redistribute-before-you-publish-raw-files).
67
+
68
+ Keep `data/raw/` and `data/processed/` out of git, so the repository never redistributes
69
+ a publisher's data. The `.fetch.json` records live in `data/raw/` too, so a fresh clone
70
+ runs `fetch` before `build` and `validate`.
71
+
72
+ ## Documentation
73
+
74
+ - **Get started:** follow the [worked example](docs/getting-started.md) to notice a revised
75
+ source and rebuild the dataset.
76
+ - **Configure and run:** use the [manifest and command reference](docs/reference.md),
77
+ [download limits and retries](docs/fetching.md), and [custom readers](docs/readers.md).
78
+ - **Inspect and share:** consume [JSON reports](docs/reports.md) in CI, or create a
79
+ [standalone HTML provenance report](docs/provenance-report.md) for dataset recipients
80
+ with `sourceledger report > provenance.html`.
81
+ - **Understand the checks:** read [how it works](docs/architecture.md),
82
+ [safe use](docs/secure-use.md), and [what the checks establish](docs/assurance-case.md).
83
+ - **Choose and verify:** compare [related tools](docs/comparison.md), or check a
84
+ sourceledger release's [signed provenance and reproducible build](docs/releases.md).
85
+
86
+ ## Project status
87
+
88
+ ### Stability
89
+
90
+ Until 1.0, the public API is `sourceledger`'s `__all__`, the keys of `sources.toml`, and
91
+ the format of fetch records and the log. A breaking change to any of them comes only in a
92
+ minor version, listed in [CHANGELOG.md](CHANGELOG.md), with a warning first where that's
93
+ cheap. Older fetch logs stay readable.
94
+
95
+ ### Roadmap
96
+
97
+ - A `release` stage that writes the metadata for a dataset release (RO-Crate, Croissant,
98
+ CodeMeta, Zenodo and a `SHA256SUMS` file), checks each with its official validator, and
99
+ keeps the data of `redistribute = false` sources out of the release.
100
+ - An error class per kind of failure, under `ValueError` and `OSError`, once the release
101
+ stage needs to tell them apart. This will not break code that catches the base classes.
102
+ - A review by [pyOpenSci](https://www.pyopensci.org) once the project has users besides
103
+ its own template.
104
+
105
+ Ideas and requests are welcome as [issues](https://github.com/simonvanlierde/sourceledger/issues).
106
+
107
+ ## Development
108
+
109
+ ```sh
110
+ uv sync
111
+ just check
112
+ ```
113
+
114
+ [Contributing](.github/CONTRIBUTING.md) covers hooks, coding standards and tests.
115
+ [Governance](GOVERNANCE.md) explains project decisions. Report vulnerabilities through
116
+ [Security](.github/SECURITY.md).
117
+
118
+ ## License
119
+
120
+ MIT. See [LICENSE](LICENSE).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sourceledger"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Fetch, verify and validate the public sources a dataset is built from, with a provenance record for every download"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -51,8 +51,8 @@ dev = [
51
51
  "pytest>=9.1.1",
52
52
  "pytest-codspeed>=5.0.3",
53
53
  "pytest-cov>=7.1.0",
54
- "ruff>=0.16.10",
55
- "ty>=0.0.84",
54
+ "ruff>=0.17.1",
55
+ "ty>=0.0.89",
56
56
  ]
57
57
  mutation = ["mutmut>=3.8.0"]
58
58
 
@@ -101,6 +101,9 @@ convention = "google"
101
101
  allow-magic-value-types = ["int"]
102
102
  max-args = 10
103
103
 
104
+ [tool.ty.terminal]
105
+ error-on-warning = false
106
+
104
107
  [tool.pytest.ini_options]
105
108
  addopts = [
106
109
  "-ra",
@@ -130,5 +133,6 @@ source_paths = ["src"]
130
133
  also_copy = [
131
134
  "README.md",
132
135
  "docs",
136
+ ".github/scripts",
133
137
  ]
134
138
  do_not_mutate_patterns = ['^\s*_logger\.\w+\(']
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sourceledger"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Fetch, verify and validate the public sources a dataset is built from, with a provenance record for every download"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -22,7 +22,7 @@ classifiers = [
22
22
  ]
23
23
  dependencies = []
24
24
 
25
- # `sourceledger fetch|build|validate|revisions`, reading every source as CSV. A project
25
+ # `sourceledger fetch|build|validate|revisions`, using each source's format. A project
26
26
  # with its own readers calls `sourceledger.main` from its own entry point instead.
27
27
  [project.scripts]
28
28
  sourceledger = "sourceledger.cli:main"
@@ -45,8 +45,8 @@ dev = [
45
45
  "pytest>=9.1.1",
46
46
  "pytest-codspeed>=5.0.3",
47
47
  "pytest-cov>=7.1.0",
48
- "ruff>=0.16.10",
49
- "ty>=0.0.84",
48
+ "ruff>=0.17.1",
49
+ "ty>=0.0.89",
50
50
  ]
51
51
  mutation = [
52
52
  "mutmut>=3.8.0",
@@ -101,6 +101,10 @@ convention = "google"
101
101
  allow-magic-value-types = ["int"]
102
102
  max-args = 10
103
103
 
104
+ # A rule set to "warn" reports without failing: ty otherwise exits 1 on warnings too.
105
+ [tool.ty.terminal]
106
+ error-on-warning = false
107
+
104
108
  [tool.pytest.ini_options]
105
109
  # `live` tests reach real services; `pytest -m live` runs only them (the last -m wins).
106
110
  addopts = ["-ra", "--strict-config", "--strict-markers", "--import-mode=importlib", "-m", "not live"]
@@ -123,6 +127,6 @@ exclude_also = ["if TYPE_CHECKING:", "raise NotImplementedError"]
123
127
  # `just py-mutation` runs it. The docs tests read the README and docs/ from the copy.
124
128
  [tool.mutmut]
125
129
  source_paths = ["src"]
126
- also_copy = ["README.md", "docs"]
130
+ also_copy = ["README.md", "docs", ".github/scripts"]
127
131
  # Log calls only change diagnostics; their mutants would all survive.
128
132
  do_not_mutate_patterns = ['^\s*_logger\.\w+\(']
@@ -29,6 +29,7 @@ from sourceledger.ledger import (
29
29
  verified,
30
30
  verify,
31
31
  )
32
+ from sourceledger.report import report
32
33
 
33
34
  __all__ = [
34
35
  "USER_AGENT",
@@ -46,6 +47,7 @@ __all__ = [
46
47
  "parse_source",
47
48
  "parse_xlsx",
48
49
  "read_output",
50
+ "report",
49
51
  "revisions",
50
52
  "status",
51
53
  "validate",
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import argparse
6
6
  import csv
7
+ import json
7
8
  import logging
8
9
  import sys
9
10
  from pathlib import Path
@@ -11,12 +12,15 @@ from pathlib import Path
11
12
  from sourceledger.ledger import (
12
13
  DATAPACKAGE,
13
14
  FETCH_LOG,
15
+ FILE_FORMAT,
14
16
  MANIFEST,
15
17
  PROCESSED,
16
18
  USER_AGENT,
17
19
  FetchError,
18
20
  FetchRecord,
19
21
  Parser,
22
+ _revision_records,
23
+ _status_records,
20
24
  attribution,
21
25
  build,
22
26
  fetch,
@@ -25,15 +29,18 @@ from sourceledger.ledger import (
25
29
  logged_versions,
26
30
  one_line,
27
31
  parse_source,
32
+ raw_name,
28
33
  revisions,
29
34
  status,
30
35
  validate,
31
36
  verify,
32
37
  )
38
+ from sourceledger.report import report
33
39
 
34
- _STAGES = ("init", "fetch", "build", "validate", "status", "attribution", "revisions", "verify")
40
+ _STAGES = ("init", "fetch", "build", "validate", "status", "attribution", "revisions", "verify", "report")
35
41
  # Stages that take --only.
36
42
  _SELECTABLE = ("fetch", "build", "validate")
43
+ _JSON_STAGES = ("status", "validate", "revisions")
37
44
  # Stages that take a path, and what it is.
38
45
  _NEEDS_PATH = {"revisions": "an earlier copy of the fetch log", "verify": "the folder of a published dataset"}
39
46
 
@@ -54,8 +61,10 @@ def main(
54
61
  user_agent: str = USER_AGENT,
55
62
  manifest: Path = MANIFEST,
56
63
  ) -> int:
57
- """Run one stage: init, fetch, build, validate, status, attribution, revisions or verify.
64
+ """Run one stage: init, fetch, build, validate, status, attribution, revisions, verify or report.
58
65
 
66
+ `report` writes standalone HTML to stdout for the current dataset.
67
+ `--json` prints structured status, validate and revisions reports, including runtime errors.
59
68
  `revisions` takes an earlier copy of the fetch log, and `verify` the folder of a published
60
69
  dataset. `--only ID`, repeatable, restricts fetch, build and validate to those sources.
61
70
 
@@ -78,13 +87,18 @@ def main(
78
87
  parser.add_argument(
79
88
  "--manifest", type=Path, default=manifest, metavar="PATH", help="the manifest to read (default: %(default)s)"
80
89
  )
81
- args = parser.parse_args(argv)
90
+ parser.add_argument("--json", action="store_true", help="status, validate and revisions: print JSON")
91
+ args = parser.parse_intermixed_args(argv)
92
+ if args.json and args.stage not in _JSON_STAGES:
93
+ parser.error(f"--json works with {', '.join(_JSON_STAGES)}, not {args.stage}")
82
94
  if args.only is not None and args.stage not in _SELECTABLE:
83
95
  parser.error(f"--only works with {', '.join(_SELECTABLE)}, not {args.stage}")
84
96
  if args.stage in _NEEDS_PATH and args.path is None:
85
97
  parser.error(f"{args.stage} needs {_NEEDS_PATH[args.stage]}")
86
98
  # Retries and recovered fetch logs are reported as warnings, on stderr.
87
99
  logging.basicConfig(format=f"{prog}: %(message)s", level=logging.WARNING)
100
+ if args.json:
101
+ return _json_run(args.stage, args.path, args.only, args.manifest)
88
102
  # Filled by fetch, for the lines of a run that fails.
89
103
  before: dict[str, str] = {}
90
104
  try:
@@ -105,6 +119,27 @@ def main(
105
119
  return 1 if problems else 0
106
120
 
107
121
 
122
+ def _json_run(stage: str, path: Path | None, only: list[str] | None, manifest: Path) -> int:
123
+ """Write one JSON report, including expected runtime failures, and return the stage's exit code."""
124
+ report: dict[str, object] = {"stage": stage, "errors": []}
125
+ failed = False
126
+ try:
127
+ match stage, path:
128
+ case "status", _:
129
+ report["sources"] = _status_records(load_manifest(manifest))
130
+ case "revisions", Path():
131
+ report["revisions"] = _revision_records(path)
132
+ case _:
133
+ problems = validate(load_manifest(manifest), only=only)
134
+ report["problems"] = problems
135
+ failed = bool(problems)
136
+ except (OSError, ValueError) as error:
137
+ report["errors"] = [one_line(error)]
138
+ failed = True
139
+ print(json.dumps(report))
140
+ return int(failed)
141
+
142
+
108
143
  def _run( # noqa: C901, PLR0912 # one case per stage
109
144
  stage: str,
110
145
  path: Path | None,
@@ -117,8 +152,8 @@ def _run( # noqa: C901, PLR0912 # one case per stage
117
152
  """Run `stage`, print its report, and return its problems: only validate and verify have any.
118
153
 
119
154
  fetch first fills `logged` with what the log held before this run, so each fetch line can
120
- say new or unchanged. Only fetch, status and revisions read the log, so a damaged one
121
- breaks only those.
155
+ say new or unchanged. Fetch, status, revisions and report read the log; a damaged log
156
+ breaks those stages.
122
157
  """
123
158
  match stage, path:
124
159
  case "init", _:
@@ -128,6 +163,8 @@ def _run( # noqa: C901, PLR0912 # one case per stage
128
163
  # Not a failure: a revised source is news, and the tripwire test decides whether it breaks anything.
129
164
  for line in revisions(path):
130
165
  print(line)
166
+ case "report", _:
167
+ print(report(load_manifest(manifest)), end="")
131
168
  case "verify", Path():
132
169
  problems = verify(path)
133
170
  print(f"{len(problems)} problems")
@@ -137,10 +174,19 @@ def _run( # noqa: C901, PLR0912 # one case per stage
137
174
  for record in fetch(load_manifest(manifest), user_agent=user_agent, only=only):
138
175
  print(_fetch_line(record, logged))
139
176
  case "build", _:
140
- for out in build(load_manifest(manifest), parse=parse, only=only):
141
- with out.open(newline="", encoding="utf-8") as fh:
142
- rows = sum(1 for _ in csv.DictReader(fh))
143
- print(f"{rows} rows -> {out}")
177
+ sources = load_manifest(manifest)
178
+ files = {
179
+ PROCESSED / raw_name(source)
180
+ for source in sources
181
+ if source.get("format") == FILE_FORMAT and source.get("url")
182
+ }
183
+ for out in build(sources, parse=parse, only=only):
184
+ if out in files:
185
+ print(f"{out.stat().st_size} bytes -> {out}")
186
+ else:
187
+ with out.open(newline="", encoding="utf-8") as fh:
188
+ rows = sum(1 for _ in csv.DictReader(fh))
189
+ print(f"{rows} rows -> {out}")
144
190
  print(f"package -> {PROCESSED / DATAPACKAGE}")
145
191
  case "status", _:
146
192
  for line in status(load_manifest(manifest)):