lupkg package

Submodules

lupkg.exceptions module

exception lupkg.exceptions.LupkgMetadataException(message, key=None, valid_values=None)[source]

Bases: exceptions.Exception

Custom exception for LuPKG.

Thrown when there is a problem with the provided or missing metadata, either from user input, or the lupkg repo structure/format.

Parameters:
  • message (str) – the message to display
  • key (str) – the key of the metadata value that caused the issue
  • valid_values (list) – valid values for the key in question
exception lupkg.exceptions.LupkgProcessingException(message)[source]

Bases: exceptions.Exception

Custom exception for lupkg processing related errors.

exception lupkg.exceptions.LupkgSchemaException(message, item=None, validation_errors=None)[source]

Bases: exceptions.Exception

lupkg.lupkg module

Main module.

class lupkg.lupkg.LuPKG(metadata, base_url=None)[source]

Bases: object

Model class for a package.

Enables access to metadata like download url, author, type of file, etc.

details()[source]

Returns all metadata as a dictionary, in a raw form.

Returns:all metadata
Return type:dict
fill_string_template(text, version, properties=None, ignore_template_errors=False, use_first_value_as_default=False, use_global_properties=True, use_version_properties=True)[source]

Replace template variables in strings with values from the property attribute.

If ‘use_first_value_as_default’ is a list, the requirement key will be checked against this list,
and only if it is included will the first value used as default. Otherwise this value needs to be a bool.
Parameters:
  • text (str) – the source string
  • version (str) – the version
  • properties (dict) – the properties to use when templating the url details (defaults to merged version/general properties of this pkg)
  • ignore_template_errors (bool) – whether to error out when missing template keys are encountered (False) or not (True)
  • use_first_value_as_default (bool, list) – whether to use the first value of the version properties as default when no user input for that key
  • use_global_properties (bool) – whether to use the ‘global’ properties of this pkg for templating
  • use_version_properties (bool) – whether to use the properties of the specified version of this pkg for templating
Returns:

the templated string

Return type:

str

classmethod from_dict(lupkg_dict, pkg_name=None, base_url=None)[source]

Creates a :class:~LuPKG object.

Parameters:
  • lupkg_dict (dict) – the metadata
  • pkg_name (str) – if provided, overwrites a potential ‘meta/name’ value in the lupkg_dict
Returns:

the package object

Return type:

LuPKG

classmethod from_name_and_url(pkg_name, url, base_url=None)[source]

Creates a minimal package description from a name and url.

To use this, the package name and the (only) file need to be the same.

Parameters:
  • pkg_name (str) – the name of the package and (only) file
  • url (str) – the url to the file
Returns:

the package object

Return type:

LuPKG

get_property(prop_key)[source]

Returns the value(s) associated with a property key for this package.

Returns:a list of potential values for this property
Return type:list
get_property_names()[source]

Returns a list of additional property names available for this package.

Returns:a list of property names
Return type:list
get_url_details(version=None, properties=None, ignore_template_errors=False, use_first_value_as_default=False)[source]

Get url details for version number.

Parameters:
  • version (str) – the version in question, defaults to ‘LATEST’
  • properties (dict) – the properties to use when templating the url details
  • ignore_template_errors (bool) – whether to error out when missing template keys are encountered (False) or not (True)
  • use_first_value_as_default (bool) – whether to use the first value of the version properties as default when no user input for that key
Returns:

the url details

Return type:

dict

get_version(version_name)[source]

Returns the version details for the specified version name.

Parameters:version_name (str) – the version name
Returns:the version details dict (keys: ‘version’, ‘properties’, ‘urls’)
Return type:dict
get_version_details(version=None, properties=None, ignore_template_errors=False, use_first_value_as_default=False)[source]

Get version details for version number.

Parameters:
  • version (str) – the version in question, defaults to ‘LATEST’
  • properties (dict) – the properties to use when templating the url details (defaults to merged version/general properties of this pkg)
  • ignore_template_errors (bool) – whether to error out when missing template keys are encountered (False) or not (True)
  • use_first_value_as_default (bool) – whether to use the first value of the version properties as default when no user input for that key
Returns:

the version details

Return type:

dict

get_version_properties(version=None)[source]

Get a dictionary of version-specific properties.

The result is a merged dictionary of the general properties and the versions specific ones.

Parameters:version (str) – the version
Returns:the version properties
Return type:dict
has_file(file_name, version=None)[source]

Checks whether this package contains a file with the specified filename.

Parameters:
  • file_name (str) – the filename in question
  • version (str) – the version to check, if none, all versions will be checked
Returns:

whether the file is available in this package (True) or not (False)

Return type:

bool

process_metadata(metadata)[source]
version_numbers()[source]

Returns a list of version numbers.

Returns:a list of version number strings
Return type:list
versions()[source]

The available versions for this package.

The result will be a list containing dicts. For more details look up the metadata format.

Returns:a list of versions for this package
Return type:list
class lupkg.lupkg.LupkgRepoFolderReader(use_folders_as_tags=True, **kwargs)[source]

Bases: luci.readers.MetadataFolderReader

Parses a folder for lupkg metadata files/structure.

Parameters:
  • use_folders_as_tags (bool) – whether to automatically add hierarchical folder names as tags for a package
  • **kwargs (dict) – arguments forwarded to parent class
is_usable_file(path)[source]

Utility method determine whether a file contains metadata relevant for lupkg or not.

By default, this returns true if the filename in question ends with either “.yaml” or “.yml”, and does not start with a ‘.’.

Can be overwrittern by a child class.

process_content(content, current_metadata, luci_metadata, luci_metadata_key_name=None)[source]

Processes a set of lines in a certain format.

Returns:the values of the processed dictlet
Return type:dict
class lupkg.lupkg.RepoLucifier(**kwargs)[source]

Bases: luci.lucify.Lucifier

get_default_dictlet_finder()[source]
get_default_dictlet_reader()[source]

Returns the default dictlet reader for this lucifier.

process_dictlet(metadata, dictlet_details=None)[source]

The main method implemented by a lucifier, it executes the task it is written for, using the metadata accrued as configuration.

Depending on the lucifier, this may return a string, an object, or nothing (and just prints out text to stdout).

Parameters:
  • metadata – the metadata to process
  • dictlet_details – metadata about the dictlet itself
Returns:

the new (processed) metadata

Return type:

object

lupkg.lupkg_cli module

Console script for lupkg.

lupkg.lupkg_cli.click_stdout(message)[source]

lupkg.lupkg_config module

Main module.

class lupkg.lupkg_config.LupkgIndexes[source]

Bases: object

DEFAULT_INDEX_CONFIG_PATH = '/home/docs/.local/share/lupkg/indexes'
DEFAULT_INDEX_READER_PARAMS = {'use_files': False, 'use_metadata_files': True}
download_index(index_name, ignore_if_already_installed=True)[source]
get_index(index_alias_or_url, update=False)[source]
get_indexes_index(update=False)[source]
get_local(update=False)[source]
list_available_index_names()[source]
update_index(index_alias_or_url)[source]
lupkg.lupkg_config.create_index(index_desc_dict)[source]
lupkg.lupkg_config.create_index_desc(url_orig)[source]

lupkg.lupkg_index module

Main module.

class lupkg.lupkg_index.LupkgFileIndex(url=None, alias=None, pkg_base_url=None, **kwargs)[source]

Bases: lupkg.lupkg_index.LupkgIndex

LuPKGS implementation that reads one or multiple yaml files to get package metadata.

get_available_packages()[source]

Returns all available package names in no particular order.

Returns:a list of package names
Return type:list
get_index(update=False)[source]
get_pkg_metadata(name)[source]

Returns the metadata of a package (in LuPKG format).

Parameters:name (str) – the package name
Returns:the metadata
Return type:dict
update_index()[source]

Updates the index.

class lupkg.lupkg_index.LupkgFolderIndex(url=None, alias=None, pkg_base_url=None, reader_params=None, **kwargs)[source]

Bases: lupkg.lupkg_index.LupkgIndex

LuPKGS implementation that stores metadata about packages in a folder structure.

Internally this uses the luci python library to read the metadata from the folder. This happens in the LupkgMetadataFolderLucifier class to hold the relevant metadata derived from the folder.

get_available_packages()[source]

Returns all available package names in no particular order.

Returns:a list of package names
Return type:list
get_pkg_metadata(name)[source]

Returns the metadata of a package (in LuPKG format).

Parameters:name (str) – the package name
Returns:the metadata
Return type:dict
update_index()[source]

Updates the index.

class lupkg.lupkg_index.LupkgFolderLucifier(reader_params=None, **kwargs)[source]

Bases: luci.lucify.Lucifier

get_default_dictlet_finder()[source]
get_default_dictlet_reader()[source]

Returns the default dictlet reader for this lucifier.

process_dictlet(metadata, dictlet_details=None)[source]

The main method implemented by a lucifier, it executes the task it is written for, using the metadata accrued as configuration.

Depending on the lucifier, this may return a string, an object, or nothing (and just prints out text to stdout).

Parameters:
  • metadata – the metadata to process
  • dictlet_details – metadata about the dictlet itself
Returns:

the new (processed) metadata

Return type:

object

class lupkg.lupkg_index.LupkgIndex(url=None, alias=None, pkg_base_url=None)[source]

Bases: object

Base class to hold information about a package repository.

This can be extended by classes that wish to implement a specific way of storing and querying that data (e.g. using a database etc.).

get_all_metadata()[source]
get_all_urls(properties=None)[source]

Returns a map of all package names with their corresponding url for the latest version.

Parameters:properties (dict) – optional properties to be used in the package selection
Returns:a dict with the package name as key, and the url as value
Return type:OrderedDict
get_available_packages()[source]

Returns all available package names in no particular order.

Returns:a list of package names
Return type:list
get_name()[source]
get_package_types()[source]

Returns a list of package types in this repository.

Returns:the list of package types
Return type:list
get_pkg(name)[source]

Returns the LuPKG object for the specified package name.

Returns:the package details, or none if package doesn’t exist
Return type:LuPKG
get_pkg_metadata(name)[source]

Returns the metadata of a package (in LuPKG format).

Parameters:name (str) – the package name
Returns:the metadata
Return type:dict
get_pkg_names()[source]

Returns a sorted list of available package names.

Returns:a list of package names
Return type:list
get_pkgs_with_file(file)[source]

Returns a list of package names that contain a file with the specified name.

save_index_file(path)[source]
update()[source]
update_index()[source]

Updates the index.

class lupkg.lupkg_index.LupkgMultiIndex(url=None, alias=None, pkg_base_url=None, indexes=None, **kwargs)[source]

Bases: lupkg.lupkg_index.LupkgIndex

LuPKGS implementation to hold multiple, different LuPKGS objects

Parameters:
  • name (str) – the name of this index
  • lupkgs (list) – a list of LupkgIndex objects
  • **kwargs (dict) – additional init values
get_available_packages()[source]

Returns all available package names in no particular order.

Returns:a list of package names
Return type:list
get_pkg_metadata(name)[source]

Returns the metadata of a package (in LuPKG format).

Parameters:name (str) – the package name
Returns:the metadata
Return type:dict
update_index()[source]

Updates the index.

lupkg.lupkg_list module

class lupkg.lupkg_list.LupList(pkgs, context=None, meta=None, vars=None)[source]

Bases: frkl.frklist.Frklist

expand_and_augment_tasklist(pkgs)[source]
find_existing_package_in_list(pkg_name)[source]
find_list_index_of_package(pkg_name)[source]
get_package_names()[source]
process_meta_properties(meta_dict, tasklist)[source]
remote_package(pkg_name)[source]
render_tasklist()[source]
update_pkg_item(new_pkg)[source]
class lupkg.lupkg_list.LupkgPath(path, metadata_file=None)[source]

Bases: object

get_pkg(pkg_name)[source]
get_pkg_names()[source]
get_pkgs()[source]
install_pkg(pkg_name, version='__latest__', properties=None, index=None, install_properties=None, ignore_if_already_installed=False)[source]
uninstall_pkg(pkg_name)[source]
write_package_list()[source]
class lupkg.lupkg_list.LupkgPkgItem(pkg_name, base_path, version='__latest__', properties=None, index=None, path_map=None)[source]

Bases: object

exists(file_name)[source]
get_file_names()[source]
get_overlay_properties(properties)[source]
get_path_for_file(file_name)[source]
get_url_details(version=None, properties=None, ignore_template_errors=True)[source]
install(version='__latest__', pkg_properties=None, install_properties=None)[source]
is_installed()[source]
is_up_to_date(check_files_exist=True)[source]
uninstall()[source]

lupkg.lupkg_processors module

Main module.

class lupkg.lupkg_processors.DownloadExecutableProcessor(**kwargs)[source]

Bases: lupkg.lupkg_processors.DownloadProcessor

process_pkg_item(pkg_item, file_name, base_path, version='__latest__', properties=None, process_properties=None)[source]
class lupkg.lupkg_processors.DownloadProcessor(**kwargs)[source]

Bases: lupkg.lupkg_processors.LupkgProcessor

download_into_temp(pkg_item, file_name, temp_dir, version='__latest__', properties=None, process_properties=None)[source]
pre_process_target(file_name, base_path, force, reinstall)[source]
process_pkg_item(pkg_item, file_name, base_path, version='__latest__', properties=None, process_properties=None)[source]
class lupkg.lupkg_processors.LupkgProcessor(output_callback=None, default_log_level=20)[source]

Bases: object

output(message, log_level=None)[source]
process_pkg(file_name, base_path, pkg)[source]
update_pkg_folder_metadata(path, file_name, file_details)[source]
class lupkg.lupkg_processors.SimpleCallback[source]

Bases: object

is_silent()[source]
output(output, log_level=None)[source]
set_silent(silent)[source]
lupkg.lupkg_processors.create_processor(processor_alias, output_callback=None)[source]
lupkg.lupkg_processors.default_output_callback()[source]
lupkg.lupkg_processors.get_processor(pkg_file_type)[source]

lupkg.lupli_cli module

Console script for lupli.

lupkg.lupli_cli.click_stdout(message)[source]

lupkg.utils module

Main module.

class lupkg.utils.TqdmUpTo(iterable=None, desc=None, total=None, leave=True, file=None, ncols=None, mininterval=0.1, maxinterval=10.0, miniters=None, ascii=None, disable=False, unit='it', unit_scale=False, dynamic_ncols=False, smoothing=0.3, bar_format=None, initial=0, position=None, postfix=None, unit_divisor=1000, gui=False, **kwargs)[source]

Bases: tqdm._tqdm.tqdm

Alternative Class-based version of the above.

Provides update_to(n) which uses tqdm.update(delta_n).

Inspired by [twine#242](https://github.com/pypa/twine/pull/242), [here](https://github.com/pypa/twine/commit/42e55e06).

update_to(b=1, bsize=1, tsize=None)[source]
b : int, optional
Number of blocks transferred so far [default: 1].
bsize : int, optional
Size of each block (in tqdm units) [default: 1].
tsize : int, optional
Total size (in tqdm units). If [default: None] remains unchanged.
lupkg.utils.download_file(url, file_name, target_dir, output_callback=None)[source]
lupkg.utils.ensure_base_path(path, create_folder=False)[source]

Utility method to manage the target path.

lupkg.utils.ensure_metadata_file(path, create_file=False)[source]

Utility method to manage the task list metadata file.

lupkg.utils.find_pkg_file_in_archive_dir(file_name, archive_dir, archive_file)[source]
lupkg.utils.handle_metadata_exception(exc)[source]
lupkg.utils.unpack_file(url, file_name, archive, archive_format=None)[source]

Module contents

Top-level package for lupkg.