summaryrefslogtreecommitdiff
path: root/contrib/python/pypodman/lib/actions/images_action.py
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2018-07-16 17:29:50 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-23 18:53:44 +0000
commit9a18681ba62d1a297809c243607a7b3763131c36 (patch)
tree8333f8727fd7d32f81cb1f54754ccd138a7e1063 /contrib/python/pypodman/lib/actions/images_action.py
parent8569ed03056ce39e0dc163747089ed4b60b1b9b1 (diff)
downloadpodman-9a18681ba62d1a297809c243607a7b3763131c36.tar.gz
podman-9a18681ba62d1a297809c243607a7b3763131c36.tar.bz2
podman-9a18681ba62d1a297809c243607a7b3763131c36.zip
[WIP] Refactor and simplify python builds
* pypodman namespaced in site-packages * version numbers pulled from requirements.txt * add python-podman spec file to install eggs Signed-off-by: Jhon Honce <jhonce@redhat.com> Closes: #1106 Approved by: rhatdan
Diffstat (limited to 'contrib/python/pypodman/lib/actions/images_action.py')
-rw-r--r--contrib/python/pypodman/lib/actions/images_action.py88
1 files changed, 0 insertions, 88 deletions
diff --git a/contrib/python/pypodman/lib/actions/images_action.py b/contrib/python/pypodman/lib/actions/images_action.py
deleted file mode 100644
index f6a7497e5..000000000
--- a/contrib/python/pypodman/lib/actions/images_action.py
+++ /dev/null
@@ -1,88 +0,0 @@
-"""Remote client commands dealing with images."""
-import operator
-from collections import OrderedDict
-
-import humanize
-import podman
-
-from .. import AbstractActionBase, Report, ReportColumn
-
-
-class Images(AbstractActionBase):
- """Class for Image manipulation."""
-
- @classmethod
- def subparser(cls, parent):
- """Add Images commands to parent parser."""
- parser = parent.add_parser('images', help='list images')
- super().subparser(parser)
- parser.add_argument(
- '--sort',
- choices=['created', 'id', 'repository', 'size', 'tag'],
- default='created',
- type=str.lower,
- help=('Change sort ordered of displayed images.'
- ' (default: %(default)s)'))
-
- group = parser.add_mutually_exclusive_group()
- group.add_argument(
- '--digests',
- action='store_true',
- help='Include digests with images. (default: %(default)s)')
- parser.set_defaults(class_=cls, method='list')
-
- def __init__(self, args):
- """Construct Images class."""
- super().__init__(args)
-
- self.columns = OrderedDict({
- 'name':
- ReportColumn('name', 'REPOSITORY', 40),
- 'tag':
- ReportColumn('tag', 'TAG', 10),
- 'id':
- ReportColumn('id', 'IMAGE ID', 12),
- 'created':
- ReportColumn('created', 'CREATED', 12),
- 'size':
- ReportColumn('size', 'SIZE', 8),
- 'repoDigests':
- ReportColumn('repoDigests', 'DIGESTS', 35),
- })
-
- def list(self):
- """List images."""
- images = sorted(
- self.client.images.list(),
- key=operator.attrgetter(self._args.sort))
- if len(images) == 0:
- return 0
-
- rows = list()
- for image in images:
- fields = dict(image)
- fields.update({
- 'created':
- humanize.naturaldate(podman.datetime_parse(image.created)),
- 'size':
- humanize.naturalsize(int(image.size)),
- 'repoDigests':
- ' '.join(image.repoDigests),
- })
-
- for r in image.repoTags:
- name, tag = r.split(':', 1)
- fields.update({
- 'name': name,
- 'tag': tag,
- })
- rows.append(fields)
-
- if not self._args.digests:
- del self.columns['repoDigests']
-
- with Report(self.columns, heading=self._args.heading) as report:
- report.layout(
- rows, self.columns.keys(), truncate=self._args.truncate)
- for row in rows:
- report.row(**row)