Command-Line Usage: “suggest” Subcommand

The suggest subcommand is used to query an inventory for objects fuzzy-matching a given search string. Fuzzy-matching is carried out via the fuzzywuzzy library, against the Restructured Text-like representation of each object exposed by SuperDataObj.as_rst:

The fuzzywuzzy match score and the index of the object within the inventory can be printed by passing the --score and --index options, respectively:

If too few or too many matches are returned, the reporting threshold can be changed via --thresh:

Remote objects.inv files can be retrieved for inspection by passing the --url flag:

The URL provided MUST have the leading protocol specified (here, https://).

It is usually not necessary to locate the objects.inv file before running sphobjinv; for most Sphinx documentation sets, if you provide a URL to any page in the docs, it will automatically find and use the correct objects.inv:

sphobjinv only supports download of zlib-compressed objects.inv files by URL. Plaintext download by URL is unreliable, presumably due to encoding problems. If download of JSON files by URL is desirable, please submit an issue.

New in version 2.1: The sphobjinv CLI can now read JSON and plaintext inventories from stdin by passing the special - argument for infile:

$ sphobjinv suggest -s - valid < objects_attrs.txt
/bin/sh: sphobjinv: inaccessible or not found

Usage

Positional Arguments

infile

Path (or URL, if --url is specified) to file to be searched.

If passed as -, sphobjinv will attempt import of a plaintext or JSON inventory from stdin. This is incompatible with --url, and automatically enables --all.

Search term for fuzzywuzzy matching.

Flags

-h, --help

Display suggest help message and exit.

-a, --all

Display all search results without prompting, regardless of the number of hits. Otherwise, prompt if number of results exceeds SUGGEST_CONFIRM_LENGTH.

-i, --index

Display the index position within the Inventory.objects list for each search result returned.

-s, --score

Display the fuzzywuzzy match score for each search result returned.

-t, --thresh <#>

Change the fuzzywuzzy match quality threshold (0-100; higher values yield fewer results). Default is specified in DEF_THRESH.

-u, --url

Treat infile as a URL for download. Cannot be used when infile is passed as -.