summaryrefslogtreecommitdiff
path: root/gitlab/v4/cli.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-11-01 16:01:40 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2017-11-01 16:01:40 +0100
commit9dd410feec4fe4e85eb735ad0007adcf06fe03cc (patch)
tree7185cb1af206e4a72f2d1908c8f81cd743b68c24 /gitlab/v4/cli.py
parentd415cc0929aed8bf95cbbb54f64d457e42d77696 (diff)
downloadgitlab-9dd410feec4fe4e85eb735ad0007adcf06fe03cc.tar.gz
Fix the CLI for objects without ID (API v4)
Fixes #319
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r--gitlab/v4/cli.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index 6e664b3..939a7cc 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -83,7 +83,7 @@ class GitlabCLI(object):
def do_get(self):
id = None
- if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.cls):
+ if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.mgr_cls):
id = self.args.pop(self.cls._id_attr)
try:
@@ -99,7 +99,9 @@ class GitlabCLI(object):
cli.die("Impossible to destroy object", e)
def do_update(self):
- id = self.args.pop(self.cls._id_attr)
+ id = None
+ if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.mgr_cls):
+ id = self.args.pop(self.cls._id_attr)
try:
return self.mgr.update(id, self.args)
except Exception as e:
@@ -282,15 +284,18 @@ class LegacyPrinter(object):
return
# not a dict, we assume it's a RESTObject
- id = getattr(obj, obj._id_attr, None)
- print('%s: %s' % (obj._id_attr, id))
+ if obj._id_attr:
+ id = getattr(obj, obj._id_attr, None)
+ print('%s: %s' % (obj._id_attr, id))
attrs = obj.attributes
- attrs.pop(obj._id_attr)
+ if obj._id_attr:
+ attrs.pop(obj._id_attr)
display_dict(attrs, padding)
else:
- id = getattr(obj, obj._id_attr)
- print('%s: %s' % (obj._id_attr.replace('_', '-'), id))
+ if obj._id_attr:
+ id = getattr(obj, obj._id_attr)
+ print('%s: %s' % (obj._id_attr.replace('_', '-'), id))
if hasattr(obj, '_short_print_attr'):
value = getattr(obj, obj._short_print_attr)
print('%s: %s' % (obj._short_print_attr, value))