Skip to content

Commit ea79bdc

Browse files
author
Gauvain Pocentek
committed
build submanagers for v3 only
1 parent afe4b05 commit ea79bdc

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

gitlab/__init__.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,22 @@ def __init__(self, url, private_token=None, email=None, password=None,
118118
else:
119119
self.dockerfiles = objects.DockerfileManager(self)
120120

121-
# build the "submanagers"
122-
for parent_cls in six.itervalues(vars(objects)):
123-
if (not inspect.isclass(parent_cls)
124-
or not issubclass(parent_cls, objects.GitlabObject)
125-
or parent_cls == objects.CurrentUser):
126-
continue
127-
128-
if not parent_cls.managers:
129-
continue
130-
131-
for var, cls_name, attrs in parent_cls.managers:
132-
var_name = '%s_%s' % (self._cls_to_manager_prefix(parent_cls),
133-
var)
134-
manager = getattr(objects, cls_name)(self)
135-
setattr(self, var_name, manager)
121+
if self._api_version == '3':
122+
# build the "submanagers"
123+
for parent_cls in six.itervalues(vars(objects)):
124+
if (not inspect.isclass(parent_cls)
125+
or not issubclass(parent_cls, objects.GitlabObject)
126+
or parent_cls == objects.CurrentUser):
127+
continue
128+
129+
if not parent_cls.managers:
130+
continue
131+
132+
for var, cls_name, attrs in parent_cls.managers:
133+
prefix = self._cls_to_manager_prefix(parent_cls)
134+
var_name = '%s_%s' % (perfix, var)
135+
manager = getattr(objects, cls_name)(self)
136+
setattr(self, var_name, manager)
136137

137138
@property
138139
def api_version(self):

0 commit comments

Comments
 (0)