Skip to content

Commit e2ff0d7

Browse files
authored
Keep the 0.9.39 cdxt command lines working (deprecated) (#80)
1 parent c9c68ba commit e2ff0d7

11 files changed

Lines changed: 867 additions & 216 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
- unreleased
22
+ new command line interface: `cdxt index` and `cdxt repackage` (see README)
3-
+ `cdxt iter` is a deprecated alias of `cdxt index` (same arguments, prints a deprecation warning)
4-
+ removed `cdxt size` and `cdxt warc`; they print the equivalent new command
3+
+ the command lines of 0.9.39 (`cdxt --cc iter URL`, `size`, `warc`) are deprecated (to be removed in a future version): they run
4+
with the new code and print a suggested new command line; `iter` output, `--get` and `size --details` are kept;
5+
`warc` writes `TEST-001.warc.gz` (was `TEST-000000.extracted.warc.gz`) with the records copied byte-for-byte
6+
(no `WARC-Source-URI`/`WARC-Source-Range` headers), no file without captures, and exits with status 1 if
7+
captures could not be fetched; `iter --all-fields --csv` is a usage error (was a traceback)
58
+ `cdxt index`: `--hostname`, `--domain`, repeatable `--url`, `-o/--output` (local or remote),
69
JSONL/CDXJ/CSV/TSV output, all fields by default, `--count` replaces `size`
710
+ `cdxt repackage`: reads captures from a file or stdin, human-readable `--size`, `--is-part-of`, `--description`

‎README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,12 @@ upload (an S3 lifecycle rule for incomplete uploads removes it).
317317

318318
### Migrating from the old commands
319319

320-
`cdxt iter` is a deprecated alias of `cdxt index` with the same (new)
321-
arguments; it prints a deprecation warning. The `size` and `warc` commands
322-
have been removed; running them prints the equivalent new command. See the [migration guide](docs/cli-migration-guide.md)
323-
for all changes and more examples.
320+
The command lines of cdx_toolkit 0.9.39 (`cdxt --cc iter ...`, `size`,
321+
`warc`) still work, but are deprecated and will be removed in a future
322+
version; they print a suggested new command line. The old `warc` now writes
323+
`TEST-001.warc.gz` and exits with status 1 if captures could not be fetched.
324+
See the [migration guide](docs/cli-migration-guide.md) for all changes and
325+
more examples.
324326

325327
| Old | New |
326328
|---|---|

‎cdx_toolkit/cli/__init__.py‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
from . import index, repackage
1010
from .common import IncompleteError, add_verbose_arg, set_loglevel
11-
from .deprecated import DEPRECATED_COMMANDS, REMOVED_COMMANDS, exit_removed_command, get_command
12-
from .deprecated import rewrite_deprecated_command
11+
from .legacy import build_legacy_parser, deprecation_message, is_legacy_command_line
1312

1413

1514
def build_parser() -> ArgumentParser:
@@ -28,15 +27,13 @@ def main(args=None):
2827
if args is None: # pragma: no cover
2928
args = sys.argv[1:]
3029

31-
command = get_command(args)
32-
if command in REMOVED_COMMANDS:
33-
exit_removed_command(command, args)
34-
if command in DEPRECATED_COMMANDS:
35-
args = rewrite_deprecated_command(args)
36-
37-
parser = build_parser()
30+
# the command lines of cdx_toolkit 0.9.39 (deprecated): `cdxt --cc iter URL`, `size`, `warc`
31+
legacy = is_legacy_command_line(args)
32+
parser = build_legacy_parser() if legacy else build_parser()
3833
cmd = parser.parse_args(args=args)
3934
set_loglevel(cmd.verbose)
35+
if legacy:
36+
sys.stderr.write(deprecation_message(cmd))
4037
configure_fsspec_s3() # Common Crawl's S3 defaults for s3:// paths, unless configured by the user
4138
cmdline = ' '.join(['cdxt'] + list(args))
4239
if uses_hf(args):

‎cdx_toolkit/cli/deprecated.py‎

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

0 commit comments

Comments
 (0)