Package: py-libget
py_libget 0.0.6Module for handling libget packages.AboutDependenciesInstallationUsageCommand Line UsageModule UsageObjectsrepositorypackage_managerparserwebhandlerCredits / ThanksChangelog0.0.60.0.50.0.40.0.30.0.20.0.10.0.0About^This module was created to simplify testing and development with libget based repository systems.py_libget maintains a cache of previously downloaded icons, screenshots and repo jsons and uses an etagging system to minimize redownloads and save bandwidth.
The install / uninstall process should be thread-safe as long as you don't install duplicates of the same package at the same time and don't install and uninstall the same package at the same time.
The install method takes a callback that allows it to update frontends (GUISs, Flask apps, etc) from the backend thread.It also includes a command line mode for use in scripting, the command line mode has a--bundleoption that allows you to batch install a list of packages or generate a zip that can be extracted to an SD card.
There are also a number of other features, seepython -m py_libget -helpfor more details on command line usage.Dependencies^NoneInstallation^Available on pip -pip install py_libgetUsage^Command Line Usage^usage: python -m py_libget [-h] [-b BUNDLE] [-i INSTALL [INSTALL ...]]
                   [-u UNINSTALL [UNINSTALL ...]]
                   [-sc SCREENSHOT [SCREENSHOT ...]] [-ic ICON [ICON ...]]
                   repository [install_path]

py_libget CLI - Interact with libget repositories and manage package
installs. Runs Bundle -> Install -> Uninstall processes if multiple are
specified.

positional arguments:
  repository            URL of the libget repository.
  install_path          Path to SD Card root or target dir. Defaults to
                        current working dir if not specified.

options:
  -h, --help            show this help message and exit
  -b BUNDLE, --bundle BUNDLE
                        Path to bundle file. Bundles files are plaintext
                        with one package name per line, comments are
                        allowed by starting a line with a #. Will install
                        / update all packages in the bundle
  -i INSTALL [INSTALL ...], --install INSTALL [INSTALL ...]
                        List of package names to install / update,
                        separated by spaces.
  -u UNINSTALL [UNINSTALL ...], --uninstall UNINSTALL [UNINSTALL ...]
                        List of package names to uninstall, separated by
                        spaces.
  -sc SCREENSHOT [SCREENSHOT ...], --screenshot SCREENSHOT [SCREENSHOT ...]
                        Provide one or more package names separated by
                        spaces (minimum 1), screenshots will be downloaded
                        to cache. A map of the downloaded files will be
                        printed on download completion.
  -ic ICON [ICON ...], --icon ICON [ICON ...]
                        Provide one or more package names separated by
                        spaces (minimum 1), icons will be downloaded to
                        cache. A map of the downloaded files will be
                        printed on download completion.For example:To install the "appstore" and "vgedit" package from the 4TU Switch repository to an SD card located at D:/:python -m src https://www.switchbru.com/appstore/ -i appstore vgedit D:/Module Usage^frompy_libgetimportrepositoryrepo_name="Switch"repo_url="https://switchbru.com/appstore/"package_name="appstore"# Create repo object, by default repo loading is deferredrepo=repository(repo_name,repo_url,defer_load=False)# Get package iconpackage_icon_path=repo.get_icon(package_name)print(package_icon_path)# Get package screenshotpackage_screenshot_path=repo.get_screenshot(package_name)print(package_screenshot_path)# Get the package dict from the lookuppackage=repo.package_lookup.get(package_name)ifnotpackage:raiseLookupError(f'Failed to find{package_name}in package')# Make dir to test with and set repo to install packages thererepo.set_install_path(YOURTARGETINSTALLDIR,MUSTALREADYEXIST)# Initialize get folderifnotrepo.check_if_get_init():repo.init_get()# Install packagerepo.install_package(package)# repo.uninstall_package(package)Objects^repository^An object for interacting with all parts of a libget repository.classrepository(package_manager,parser,webhandler):def__init__(self,name:str,domain:str,defer_load:bool=True,force_cached:bool=False):...defcheck_if_get_init(self)->bool:"""Check if the libget packages folder has been inited at target location. `Returns True if libget dir exists.`"""defclean_version(self,ver:str,name:str)->str:"""Clean a version. `Returns a String`"""defclear(self)->dict:"""Alias for parser.init(). `Returns a Dict mapping package names as Strings to package entries as Dicts`"""defdownload(self,url:str,file:str)->str:"""Downloads a file at a given url to a given location. `Returns the file name as a String`"""defedit_info(self,name:str,key:str,value)->None:"""Edit a value in an installed package's info values. `Returns None`"""defget_cached_json(self,name:str)->str:"""Get a cached json file with a given name. `Returns the file name as a String`"""defget_icon(self,name:str,force:bool=False)->str:"""Downloads icon for a given package if needed. The force keyword argument forces a redownload of the file. `Returns the icon file's path as a String`"""defget_json(self,name:str,url:str)->str:"""Get a json file using etagging to limit unneeded bandwidth use. `Returns the file name as a String`"""defget_package(self,name:str)->str:"""Downloads the current zip for a given package. `Returns the downloaded file's path as a String`"""defget_package_dict(self,name:str)->dict:"""Get entry for a given package name. `Returns a Dict, empty on failure.`"""defget_package_entry(self,name:str)->dict:"""Get the contents of an installed package's info.json file. `Returns a Dict, empty on failure.`"""defget_package_manifest(self,name:str)->list:"""Returns a package's manifest. `Returns a List of the real file paths as Strings`"""defget_package_value(self,name:str,key:str)->str|None:"""Get a value from an installed package's info.json file. `Returns the value (usually a String) or None on failure."""defget_package_version(self,name:str)->str:"""Get the currently installed version of a package. `Returns a String`"""defget_packages(self)->list:"""Get a list of currently installed packages. `Returns a List`"""defget_screenshot(self,name:str,force:bool=False)->str:"""Downloads screenshot for a given package if needed. The force keyword argument forces a redownload of the file. `Returns the screenshot file's path as a String`"""definit(self)->None:"""Reinitialize parser. `Returns a Dict mapping package names as Strings to package entries as Dicts`"""definit_get(self)->None:"""Initializes the libget dir at the current install path. `Returns None.`"""definstall_package(self,package:dict,handler:Callable=None)->None:"""Installs a libget package, supply a callable handler to take a tuple containing a status and a message. A negative status is an error. Status is in the form of an integer from 0 to 100 during normal install progression. `Returns None`"""defload_cached_repo(self)->list:"""Loads / reloads repo from cached file. `Returns the loaded repo as a List.`"""defload_repo(self)->str:"""Loads / reloads repo from file. `Returns the loaded repo as a List.`"""defload_repo_file(self,repo_file:str)->list:"""Loads appstore json. `Returns a List of Dicts`"""defreload(self)->list:"""Reloads the list of installed packages. `Returns a List of packages installed.`"""defremove_store_entry(self,name:str)->None:"""THIS DOES NOT REMOVE THE PACKAGE FILES Removes a package entry by deleting the package folder containing the manifest and info.json `Returns None`"""defset_install_path(self,path:str)->list:"""Set this to a root of an sd card. `Returns a List of packages installed at the given path.`"""defuninstall_package(self,package:dict,handler:Callable=None)->None:"""Uninstalls a libget package, supply a callable handler to take a tuple containing a status and a message. A negative status is an error. Status is in the form of an integer from 0 to 100 during normal install progression. `Returns None`"""package_manager^Object for managing libget package installationclasspackage_manager(object):def__init__(self,webhandler,libget_dir:str='.libget'):...defcheck_if_get_init(self)->bool:"""Check if the libget packages folder has been inited at target location. `Returns True if libget dir exists.`"""defedit_info(self,name:str,key:str,value)->None:"""Edit a value in an installed package's info values. `Returns None`"""defget_package_entry(self,name:str)->dict:"""Get the contents of an installed package's info.json file. `Returns a Dict, empty on failure.`"""defget_package_manifest(self,name:str)->list:"""Returns a package's manifest. `Returns a List of the real file paths as Strings`"""defget_package_value(self,name:str,key:str)->str|None:"""Get a value from an installed package's info.json file. `Returns the value (usually a String) or None on failure."""defget_package_version(self,name:str)->str:"""Get the currently installed version of a package. `Returns a String`"""defget_packages(self)->list:"""Get a list of currently installed packages. `Returns a List`"""definit_get(self)->None:"""Initializes the libget dir at the current install path. `Returns None.`"""definstall_package(self,package:dict,handler:Callable=None)->None:"""Installs a libget package, supply a callable handler to take a tuple containing a status and a message. A negative status is an error. Status is in the form of an integer from 0 to 100 during normal install progression. `Returns None`"""defreload(self)->list:"""Reloads the list of installed packages. `Returns a List of packages installed.`"""defremove_store_entry(self,name:str)->None:"""THIS DOES NOT REMOVE THE PACKAGE FILES Removes a package entry by deleting the package folder containing the manifest and info.json `Returns None`"""defset_install_path(self,path:str)->list:"""Set this to a root of an sd card. `Returns a List of packages installed at the given path.`"""defuninstall_package(self,package:dict,handler:Callable=None)->None:"""Uninstalls a libget package, supply a callable handler to take a tuple containing a status and a message. A negative status is an error. Status is in the form of an integer from 0 to 100 during normal install progression. `Returns None`"""parser^Object to hold and parse libget reposclassparser(object):def__init__(self,):...defclean_version(self,ver:str,name:str)->str:"""Clean a version. `Returns a String`"""defclear(self)->dict:"""Alias for parser.init(). `Returns a Dict mapping package names as Strings to package entries as Dicts`"""defget_package_dict(self,name:str)->dict:"""Get entry for a given package name. `Returns a Dict, empty on failure.`"""definit(self)->None:"""Reinitialize parser. `Returns a Dict mapping package names as Strings to package entries as Dicts`"""defload_repo_file(self,repo_file:str)->list:"""Loads appstore json. `Returns a List of Dicts`"""webhandler^Object to handle libget icon, screenshot, and package zip downloads.classwebhandler(object):def__init__(self,domain:str):...defdownload(self,url:str,file:str)->str:"""Downloads a file at a given url to a given location. `Returns the file name as a String`"""defget_cached_json(self,name:str)->str:"""Get a cached json file with a given name. `Returns the file name as a String`"""defget_icon(self,name:str,force:bool=False)->str:"""Downloads icon for a given package if needed. The force keyword argument forces a redownload of the file. `Returns the icon file's path as a String`"""defget_json(self,name:str,url:str)->str:"""Get a json file using etagging to limit unneeded bandwidth use. `Returns the file name as a String`"""defget_package(self,name:str)->str:"""Downloads the current zip for a given package. `Returns the downloaded file's path as a String`"""defget_screenshot(self,name:str,force:bool=False)->str:"""Downloads screenshot for a given package if needed. The force keyword argument forces a redownload of the file. `Returns the screenshot file's path as a String`"""Credits / Thanks^Special thanks to vgmoose and the 4TU team for the libget standard.https://gitlab.com/4TU/libgetChangelog^0.0.6^Added instructions for command line usage0.0.5^Fix PyPi URLs0.0.4^Fix readme, bump version on pypi to display updated readme.0.0.3^Improve readme / add credits0.0.2^Fix readme.0.0.1^Cleanup, fix readme.0.0.0^Create ProjectGenerated withpy_simple_readme