mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
jw/pkg/cmds/distro/CmdPkg: Add distro pkg ls
Add the distro subcommand class CmdPkg, together with a first subcommand ls, which prints a list of files contained in a package. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
aebd9bb5e6
commit
881a915098
6 changed files with 98 additions and 0 deletions
19
src/python/jw/pkg/cmds/distro/CmdPkg.py
Normal file
19
src/python/jw/pkg/cmds/distro/CmdPkg.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from argparse import Namespace, ArgumentParser
|
||||||
|
|
||||||
|
from .Cmd import Cmd
|
||||||
|
from ..CmdDistro import CmdDistro
|
||||||
|
|
||||||
|
class CmdPkg(Cmd): # export
|
||||||
|
|
||||||
|
def __init__(self, parent: CmdDistro) -> None:
|
||||||
|
super().__init__(parent, 'pkg', help="Show package information")
|
||||||
|
self._add_subcommands()
|
||||||
|
|
||||||
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
|
super().add_arguments(parser)
|
||||||
|
parser.add_argument('--name', help='Package name')
|
||||||
|
|
||||||
|
async def _run(self, args: Namespace) -> None:
|
||||||
|
return await self._backend.run(args)
|
||||||
24
src/python/jw/pkg/cmds/distro/backend/BePkg.py
Normal file
24
src/python/jw/pkg/cmds/distro/backend/BePkg.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import abc
|
||||||
|
from typing import Iterable
|
||||||
|
|
||||||
|
from .Backend import Backend as Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..CmdPkg import CmdPkg as Parent
|
||||||
|
|
||||||
|
class BePkg(Base):
|
||||||
|
|
||||||
|
def __init__(self, parent: Parent):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
async def list_files(self, name: str) -> Iterable[str]:
|
||||||
|
return await self._list_files(name)
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
async def _list_files(self, name: str) -> Iterable[str]:
|
||||||
|
pass
|
||||||
17
src/python/jw/pkg/cmds/distro/backend/suse/Pkg.py
Normal file
17
src/python/jw/pkg/cmds/distro/backend/suse/Pkg.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from typing import Iterable
|
||||||
|
from argparse import Namespace
|
||||||
|
|
||||||
|
from ...lib.Package import Package
|
||||||
|
from ...lib.rpm import list_files
|
||||||
|
from ...Cmd import Cmd
|
||||||
|
from ..BePkg import BePkg as Base
|
||||||
|
|
||||||
|
class Pkg(Base):
|
||||||
|
|
||||||
|
def __init__(self, parent: Cmd):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
async def _list_files(self, name: str) -> Iterable[Package]:
|
||||||
|
return await list_files(name)
|
||||||
15
src/python/jw/pkg/cmds/distro/pkg/Cmd.py
Normal file
15
src/python/jw/pkg/cmds/distro/pkg/Cmd.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from ..Cmd import Cmd as Base
|
||||||
|
from ..CmdPkg import CmdPkg as Parent
|
||||||
|
|
||||||
|
class Cmd(Base): # export
|
||||||
|
|
||||||
|
from ..backend.Backend import Backend
|
||||||
|
|
||||||
|
def __init__(self, parent: Parent, name: str, help: str) -> None:
|
||||||
|
super().__init__(parent, name, help)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _backend(self) -> Backend:
|
||||||
|
return self.parent._backend
|
||||||
18
src/python/jw/pkg/cmds/distro/pkg/CmdLs.py
Normal file
18
src/python/jw/pkg/cmds/distro/pkg/CmdLs.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from argparse import Namespace, ArgumentParser
|
||||||
|
|
||||||
|
from .Cmd import Cmd
|
||||||
|
from ..CmdPkg import CmdPkg
|
||||||
|
|
||||||
|
class CmdLs(Cmd): # export
|
||||||
|
|
||||||
|
def __init__(self, parent: CmdPkg) -> None:
|
||||||
|
super().__init__(parent, 'ls', help="List package contents")
|
||||||
|
|
||||||
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
|
super().add_arguments(parser)
|
||||||
|
|
||||||
|
async def _run(self, args: Namespace) -> None:
|
||||||
|
files = await self._backend.list_files(args.name)
|
||||||
|
print('\n'.join(files))
|
||||||
5
src/python/jw/pkg/cmds/distro/pkg/Makefile
Normal file
5
src/python/jw/pkg/cmds/distro/pkg/Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
TOPDIR = ../../../../../../..
|
||||||
|
#PY_UPDATE_INIT_PY = false
|
||||||
|
|
||||||
|
include $(TOPDIR)/make/proj.mk
|
||||||
|
include $(JWBDIR)/make/py-mod.mk
|
||||||
Loading…
Add table
Add a link
Reference in a new issue