rpmget.utils module
Utility functions.
- rpmget.utils.check_for_rpm(pgm='rpm')[source]
Make sure we can find the
rpmbinary in the user environment and return a path string.- Returns:
program path string
- Parameters:
pgm (str)
- Return type:
str
- rpmget.utils.compare_file_data(old, new)[source]
Compare two dictionaries and return the difference result.
- Parameters:
old (Dict) – old dict
new (Dict) – new dict
- Returns:
any differences found
- Return type:
Dict
- rpmget.utils.compare_manifest_data(old, new)[source]
Compare full manifest data.
- Parameters:
old (Dict) – manifest data
new (Dict) – manifest data
- Return type:
List
- rpmget.utils.copy_rpms(src_dir, dst_dir)[source]
Copy .rpm globs while preserving arch dirs. This now replicates what glob.glob(root_dir=src_dir) does. Stem directories are each rpm tree with rpm files, ie SRPMS and RPMS.
- Parameters:
src_dir (str) – source dir is top_dir with stem
dst_dir (str) – destination dir is repo_dir with stem
- rpmget.utils.create_manifest_data(files, cfile)[source]
Create new manifest data from a list of downloaded files and return a nested dictionary.
- Parameters:
files (List[str]) – list of downloaded filenames
cfile (str) – matching config filename
- Returns:
manifest data
- Return type:
Dict
- rpmget.utils.download_progress_bin(url, dst, layout, timeout, mdata)[source]
Download a single binary with progress meter and default timeout. Create arch dir or top_dir depending on layout setting
- Parameters:
url (str) – URL to download
dst (str) – top-level destination directory
layout (str) – config layout
timeout (float) – httpx client timeout
mdata (Dict) – manifest data if available
- Returns:
name of downloaded file
- Return type:
str
- rpmget.utils.get_file_data(path)[source]
Get manifest data for a single rpm file from input path and return a dictionary full of metadata. Current keys are given below. This implements file metadata portion of REQ012.
- Parameters:
path (Path) – file target
- Returns:
file metadata
- Return type:
Tuple[str, Dict]
- rpmget.utils.get_file_hash(path)[source]
- Parameters:
path (Path) – file target
- Returns:
file digest using sha256
- Return type:
str
- rpmget.utils.get_file_mtime(path)[source]
- Parameters:
path (Path) – file target
- Returns:
formatted time string
- Return type:
str
- rpmget.utils.get_filelist(dirname, resolve=True, fileglob='*.rpm')[source]
Get path objects matching
fileglobstarting atdirnameand return a list of resolved path strings of any files found. Set theresolveparameter to False to return relative paths when input path is relative.- Parameters:
dirname (str) – directory name to start search in
fileglob (str) – extension of the form
*.<ext>resolve (bool)
- Returns:
file path strings
- Return type:
List[str]
- rpmget.utils.get_user_cachedir()[source]
Return user cache directory per platform.
- Returns:
user_cache_dir path as string
- rpmget.utils.load_manifest(cfile, temp_path='')[source]
If available, load a manifest file before config loop run.
- Parameters:
cfile (str) – matching config filename
temp_path (str) – use temp_path if provided
- Return type:
Dict
- rpmget.utils.manage_repo(config, debug=False, temp_path=None)[source]
Create or update rpm repository using createrepo tool. Requires an existing rpm tree with one or more packages. Satisfies REQ009.
- Parameters:
config (CfgParser) – loaded CfgParser instance
debug (bool) – enables verbose on
repo_tooltemp_path (Path | None) – prepended to config paths (mainly for testing)
- rpmget.utils.process_file_manifest(files, cfile, temp_path='')[source]
Process manifest file after successful config loop run (where success means at least one rpm file was downloaded). This is the main calling function for meeting REQ011.
- Parameters:
files (List[str]) – list of downloaded filenames
cfile (str) – matching config filename
temp_path (str) – use temp_path if provided
- Returns:
list of differences
- Return type:
List[Dict]
- rpmget.utils.read_manifest(mfile, temp_path='')[source]
Read a manifest file and return the data. Implements reading portion of REQ013 JSON requirement
- Parameters:
mfile (Path) – manifest file
temp_path (str) – use temp_path if provided
- Returns:
manifest data
- Return type:
Dict