pychoco¶
Minimal choco
command for use on non-Windows platforms.
Commands¶
choco¶
Minimal choco command.
choco [OPTIONS] COMMAND [ARGS]...
apikey¶
Manage API keys.
choco apikey [OPTIONS] COMMAND [ARGS]...
add¶
Add an API key for a source.
choco apikey add [OPTIONS]
Options
- -k, --key <API_KEY>¶
Required API key.
- -s, --source <SOURCE_URL>¶
Required Source URI.
- -p, --path <PATH>¶
Storage file.
list¶
Lists sources associated with API keys. Does not display the API key values.
choco apikey list [OPTIONS]
Options
- -p, --path <PATH>¶
Storage file.
config¶
Manage configuration.
choco config [OPTIONS] COMMAND [ARGS]...
set¶
Set a configuration value.
choco config set [OPTIONS]
Options
- -n, --name <KEY>¶
Required Key to set.
- Options:
defaultPushSource
- -v, --value <VALUE>¶
Required Value to set.
- -p, --path <PATH>¶
Storage file.
new¶
Create a new package.
choco new [OPTIONS] NAME
Arguments
- NAME¶
Required argument
pack¶
Create a package file for distribution.
choco pack [OPTIONS] [WORK_DIR]
Options
- -d, --debug¶
Enable debug logging.
Arguments
- WORK_DIR¶
Optional argument
push¶
Push a package to a source.
choco push [OPTIONS] PACKAGE
Options
- -s, --source <URL>¶
Source to upload to.
- --config-path <PATH>¶
Configuration storage file.
- --api-keys-path <PATH>¶
API keys storage file.
Arguments
- PACKAGE¶
Required argument
search¶
Search a source.
choco search [OPTIONS] TERMS
Options
- --by-id-only¶
Only return packages where the id contains the search filter.
- --by-tag-only, --by-tags-only¶
Only return packages where the search filter matches on the tags.
- --id-starts-with¶
Only return packages where the id starts with the search filter.
- --idonly, --id-only¶
Only return Package IDs in the list results.
- --order-by-popularity¶
Sort by package results by popularity.
- --page <page>¶
The “page” of results to return.
- --page-size <page_size>¶
Amount of packages to return in each page of results.
- --pre, --prerelease¶
Include prereleases.
- -a, --all, --allversions, --all-versions¶
Include results from all versions.
- -d, --debug¶
Enable debug logging.
- -e, --exact¶
Only return packages with this exact name.
- -p, --password <password>¶
Password.
- -s, --source <URL>¶
Source to search.
- -u, --user <user>¶
User name.
Arguments
- TERMS¶
Required argument
Library¶
Client.
- choco.client.Auth = tuple[str, str] | requests.auth.HTTPBasicAuth¶
Authentication details.
- class choco.client.ChocolateyClient(config: Config = {'pychoco': {'defaultPushSource': 'https://push.chocolatey.org'}}, api_keys: dict[str, str] | None = None)¶
Chocolatey client. Anything that involves interactions with the server will be in this class.
- add_key(key: str, source: str) None ¶
Add an API key for a source.
- config_set(name: Literal['defaultPushSource'], value: str) None ¶
Set a configuration value.
- get_default_push_source() str ¶
Gets the default push source URL.
- get_keys_available() Iterator[str] ¶
Return an iterator of the sources that have keys.
- push(package: str, source: str | None = None, auth: tuple[str, str] | HTTPBasicAuth | None = None) None ¶
Push a package to a source.
- search(terms: str, *, auth: tuple[str, str] | HTTPBasicAuth | None = None, all_versions: bool = False, by_id_only: bool = False, by_tag_only: bool = False, debug: bool = False, exact: bool = False, id_starts_with: bool = False, include_prerelease: bool = False, order_by_popularity: bool = False, page: int | None = None, page_size: bool = False, source: str | None = None) Iterator[SearchResult] ¶
Search packages. Returns a deduplicated iterator of results.
- update_api_key_header(source: str | None = None) None ¶
Updates the shared session API key header. If one does not exist, the existing header is removed if it is present.
Persistent configuration.
- choco.config.read_api_keys(path: Path | str | None = None) dict[str, str] ¶
Read API keys stored in given path or the default path.
- choco.config.read_config(path: Path | str | None = None) Config ¶
Read configuration from the given path or the default path.
- choco.config.write_api_keys(api_keys: dict[str, str], path: Path | str | None = None) None ¶
Write API keys dictionary to the given path or the default path.
- choco.config.write_config(config: Config, path: Path | str | None = None) None ¶
Write configuration to the given path or the default path.
Packaging-related functions.
- choco.packaging.is_valid_package_name(value: str) bool ¶
Check if a package name is valid.
- choco.packaging.new_package(name: str) Path ¶
Scaffolding to create a new package.
Utility functions.
- choco.utils.append_dir_to_zip_recursive(root: Path, z: ZipFile) None ¶
Appends a directory recursively to a zip file.
- choco.utils.entry_to_search_result(entry: Element, ns: dict[str, str] = {'': 'http://www.w3.org/2005/Atom', 'd': 'http://schemas.microsoft.com/ado/2007/08/dataservices', 'm': 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata'}) SearchResult ¶
Convert an
<entry>
to aSearchResult
dict.
- choco.utils.generate_unique_id() str ¶
Generates a unique ID for elements in
_rels/.rels
.
- choco.utils.setup_logging(debug: bool | None = False) None ¶
Shared function to enable logging.
- choco.utils.tag_text_or(tag: Element | None, default: str | None = None) str | None ¶
Return text from a tag or the default value specified.
Constants¶
Constants.
- choco.constants.CHOCOLATEY_UNINSTALL_PS1: Final[str]¶
Uninstall PowerShell template.
- choco.constants.CONTENT_TYPES_XML: Final[str]¶
Used in creating the
[Content_Types].xml
file.
- choco.constants.FEED_AUTHOR_TAG: Final[str]¶
Feed
author
tag.
- choco.constants.FEED_ENTRY_TAG: Final[str]¶
Feed
entry
tag.
- choco.constants.FEED_ID_TAG: Final[str]¶
Feed
id
tag.
- choco.constants.FEED_NAMESPACES: Final[dict[str, str]]¶
Namespaces used in parsing package feeds.
- choco.constants.FEED_SUMMARY_TAG: Final[str]¶
Feed
summary
tag.
- choco.constants.FEED_TITLE_TAG: Final[str]¶
Feed
title
tag.
- choco.constants.FEED_UPDATED_TAG: Final[str]¶
Feed
updated
tag.
- choco.constants.METADATA_DESCRIPTION_TAG: Final[str]¶
Feed
d:Description
tag.
- choco.constants.METADATA_DOCS_URL_TAG: Final[str]¶
Feed
d:DocsUrl
tag.
- choco.constants.METADATA_DOWNLOAD_COUNT_TAG: Final[str]¶
Feed
d:DownloadCount
tag.
- choco.constants.METADATA_GALLERY_DETAILS_URL_TAG: Final[str]¶
Feed
d:GalleryDetailsUrl
tag.
- choco.constants.METADATA_IS_APPROVED_TAG: Final[str]¶
Feed
d:IsApproved
tag.
- choco.constants.METADATA_IS_DOWNLOAD_CACHE_AVAILABLE_TAG: Final[str]¶
Feed
d:IsDownloadCacheAvailable
tag.
- choco.constants.METADATA_LICENSE_URL_TAG: Final[str]¶
Feed
d:LicenseUrl
tag.
- choco.constants.METADATA_PACKAGE_APPROVED_DATE_TAG: Final[str]¶
Feed
d:PackageApprovedDate
tag.
- choco.constants.METADATA_PACKAGE_SOURCE_URL_TAG: Final[str]¶
Feed
d:PackageSourceUrl
tag.
- choco.constants.METADATA_PACKAGE_STATUS_TAG: Final[str]¶
Feed
d:PackageStatus
tag.
- choco.constants.METADATA_PACKAGE_TEST_RESULT_STATUS_DATE_TAG¶
Feed
d:PackageTestResultStatusDate
tag.
- choco.constants.METADATA_PACKAGE_TEST_RESULT_STATUS_TAG: Final[str]¶
Feed
d:PackageTestResultStatus
tag.
- choco.constants.METADATA_PROJECT_URL_TAG: Final[str]¶
Feed
d:ProjectUrl
tag.
- choco.constants.METADATA_PUBLISHED_TAG: Final[str]¶
Feed
d:Published
tag.
- choco.constants.METADATA_RELEASE_NOTES_TAG: Final[str]¶
Feed
d:ReleaseNotes
tag.
- choco.constants.METADATA_SUMMARY_TAG: Final[str]¶
Feed
d:Summary
tag.
- choco.constants.METADATA_TAGS_TAG: Final[str]¶
Feed
d:Tags
tag.
- choco.constants.METADATA_VERSION_DOWNLOAD_COUNT_TAG: Final[str]¶
Feed
d:VersionDownloadCount
tag.
- choco.constants.METADATA_VERSION_TAG: Final[str]¶
Feed
d:Version
tag.
- choco.constants.NUSPEC_FIELD_AUTHORS: Final[str]¶
Nuspec authors tag.
- choco.constants.NUSPEC_FIELD_DESCRIPTION: Final[str]¶
Nuspec description tag.
- choco.constants.NUSPEC_FIELD_ID: Final[str]¶
Nuspec id tag.
- choco.constants.NUSPEC_FIELD_TAGS: Final[str]¶
Nuspec tags tag.
- choco.constants.NUSPEC_FIELD_VERSION: Final[str]¶
Nuspec version tag.
- choco.constants.PYCHOCO_API_KEYS_TOML_PATH: Final[Path]¶
Where pychoco’s API key list is stored.
- choco.constants.PYCHOCO_TOML_PATH: Final[Path]¶
Where pychoco’s main configuration file is by default.
- choco.constants.VALID_NAME_RE: Final[str]¶
Valid name for a package regular expression.
Templates¶
Template instances.
- choco.templates.CHOCOLATEY_INSTALL_PS1_TEMPLATE¶
Chocolatey PowerShell install template.
- choco.templates.NUSPEC_TEMPLATE¶
Used in construction of the Nuspec file.
- choco.templates.PSMDCP_XML_TEMPLATE¶
Used in construction of
packages/services/metadata/core-properties/{id}.psmdcp
.
- choco.templates.RELS_XML_TEMPLATE¶
Used in construction of
_rels/.rels
file.
- choco.templates.SEARCH_RESULT_TEMPLATE¶
Search result template.
Typing¶
Typing helpers.
- class choco.typing.Config¶
Configuration dictionary after de-serialisation.
- choco.typing.ConfigKey¶
Available keys for
ChocolateyClient.config_set
.alias of
Literal
[‘defaultPushSource’]
- class choco.typing.SearchResult¶
Represents a package search result.
- approval_date: datetime | None¶
Approval date.
- description: str | None¶
Description.
- documentation_uri: str | None¶
Documentation URL.
- is_approved: bool¶
If the package is approved.
- is_cached: bool¶
If the package has been cached.
- license: str | None¶
License URL.
- num_downloads: int¶
Total number of downloads.
- num_version_downloads: int¶
Number of downloads for this version of the package.
- package_src_uri: str | None¶
Nuspec source.
- package_url: str | None¶
Package download URL.
- publish_date: datetime | None¶
Publication date.
- release_notes_uri: str | None¶
Release notes URL.
- site: str | None¶
Package website.
- summary: str | None¶
Summary.
- tags: list[str]¶
Associated tags.
- testing_date: datetime | None¶
Last testing date.
- testing_status: Literal['Passing', 'Failing']¶
Testing status.
- title: str | None¶
Unique title of the package.
- version: str | None¶
Version.
- choco.typing.TestingStatus¶
Testing state of a package.
alias of
Literal
[‘Passing’, ‘Failing’]