Source code for meta_package_manager.managers.snap
# Copyright Kevin Deldycke <kevin@deldycke.com> and contributors.## This program is Free Software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.from__future__importannotationsimportrefromtypingimportIteratorfromextra_platformsimportUNIX_WITHOUT_MACOSfrommeta_package_manager.baseimportPackage,PackageManagerfrommeta_package_manager.capabilitiesimport(search_capabilities,version_not_implemented,)
[docs]@search_capabilities(extended_support=False,exact_support=False)defsearch(self,query:str,extended:bool,exact:bool)->Iterator[Package]:"""Fetch matching packages. .. caution:: Search is extended by default. So we returns the best subset of results and let :py:meth:`meta_package_manager.base.PackageManager.refiltered_search` refine them. .. code-block:: shell-session ► snap find doc --color=never Name Version Herausgeber Hinweise Zusammenfassung journey 2.14.3 2appstudio - Your private diary. nextcloud 17.0.5snap1 nextcloud✓ - Nextcloud Server skype 8.58.0.93 skype✓ classic One Skype for all. """output=self.run_cli("find",query)headerless_table=Noneifoutput:table=output.split("\n",1)iflen(table)>1:headerless_table=table[1]ifheaderless_table:regexp=re.compile(r"^(?P<package_id>\S+)\s+(?P<version>\S+)\s+\S+\s+\S+\s+(?P<description>.+)$",re.MULTILINE,)forpackage_id,version,descriptioninregexp.findall(headerless_table):yieldself.package(id=package_id,description=description,latest_version=version,)
[docs]defupgrade_all_cli(self)->tuple[str,...]:"""Generates the CLI to upgrade all packages (default) or only the one provided as parameter. .. code-block:: shell-session ► snap refresh --color=never """returnself.build_cli("refresh")
@version_not_implementeddefupgrade_one_cli(self,package_id:str,version:str|None=None,)->tuple[str,...]:"""Generates the CLI to upgrade all packages (default) or only the one provided as parameter. .. code-block:: shell-session ► snap refresh standard-notes --color=never """returnself.build_cli("refresh",package_id)