diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2016-08-11 19:46:34 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2016-08-11 19:48:53 +0200 |
commit | 2ced9d0717ee84169f9b1f190fb6694e1134572d (patch) | |
tree | 3b16cf6cf9bd11b1c205eeee7037deb5a5bb128a | |
parent | 23b2a3072238546da2a2f8e48ce09db85a59feef (diff) | |
download | gitlab-2ced9d0717ee84169f9b1f190fb6694e1134572d.tar.gz |
Move the constants at the gitlab root level
-rw-r--r-- | docs/gl_objects/groups.py | 6 | ||||
-rw-r--r-- | docs/gl_objects/projects.py | 12 | ||||
-rw-r--r-- | gitlab/__init__.py | 1 | ||||
-rw-r--r-- | gitlab/const.py | 26 | ||||
-rw-r--r-- | gitlab/objects.py | 22 |
5 files changed, 47 insertions, 20 deletions
diff --git a/docs/gl_objects/groups.py b/docs/gl_objects/groups.py index 913c934..8b4e888 100644 --- a/docs/gl_objects/groups.py +++ b/docs/gl_objects/groups.py @@ -45,15 +45,15 @@ members = group.members.get(member_id) # member create member = gl.group_members.create({'user_id': user_id, - 'access_level': Group.GUEST_ACCESS}, + 'access_level': gitlab.GUEST_ACCESS}, group_id=1) # or member = group.members.create({'user_id': user_id, - 'access_level': Group.GUEST_ACCESS}) + 'access_level': gitlab.GUEST_ACCESS}) # end member create # member update -member.access_level = Group.DEVELOPER_ACCESS +member.access_level = gitlab.DEVELOPER_ACCESS member.save() # end member update diff --git a/docs/gl_objects/projects.py b/docs/gl_objects/projects.py index ea7c8f8..bcce530 100644 --- a/docs/gl_objects/projects.py +++ b/docs/gl_objects/projects.py @@ -94,15 +94,15 @@ member = project.members.get(1) # members add member = gl.project_members.create({'user_id': user.id, 'access_level': - gitlab.Group.DEVELOPER_ACCESS}, + gitlab.DEVELOPER_ACCESS}, project_id=1) # or member = project.members.create({'user_id': user.id, 'access_level': - gitlab.Group.DEVELOPER_ACCESS}) + gitlab.DEVELOPER_ACCESS}) # end members add # members update -member.access_level = gitlab.Group.MASTER_ACCESS +member.access_level = gitlab.MASTER_ACCESS member.save() # end members update @@ -115,7 +115,7 @@ member.delete() # end members delete # share -project.share(group.id, group.DEVELOPER_ACCESS) +project.share(group.id, gitlab.DEVELOPER_ACCESS) # end share # hook list @@ -291,14 +291,14 @@ snippet = gl.project_snippets.create({'title': 'sample 1', 'file_name': 'foo.py', 'code': 'import gitlab', 'visibility_level': - Project.VISIBILITY_PRIVATE}, + gitlab.VISIBILITY_PRIVATE}, project_id=1) # or snippet = project.snippets.create({'title': 'sample 1', 'file_name': 'foo.py', 'code': 'import gitlab', 'visibility_level': - Project.VISIBILITY_PRIVATE}) + gitlab.VISIBILITY_PRIVATE}) # end snippets create # snippets content diff --git a/gitlab/__init__.py b/gitlab/__init__.py index c672c23..0109935 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -28,6 +28,7 @@ import requests import six import gitlab.config +from gitlab.const import * # noqa from gitlab.exceptions import * # noqa from gitlab.objects import * # noqa diff --git a/gitlab/const.py b/gitlab/const.py new file mode 100644 index 0000000..7930c0b --- /dev/null +++ b/gitlab/const.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2016 Gauvain Pocentek <gauvain@pocentek.net> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +GUEST_ACCESS = 10 +REPORTER_ACCESS = 20 +DEVELOPER_ACCESS = 30 +MASTER_ACCESS = 40 +OWNER_ACCESS = 50 + +VISIBILITY_PRIVATE = 0 +VISIBILITY_INTERNAL = 10 +VISIBILITY_PUBLIC = 20 diff --git a/gitlab/objects.py b/gitlab/objects.py index d537d6a..715c58e 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -795,15 +795,15 @@ class Group(GitlabObject): ('projects', GroupProjectManager, [('group_id', 'id')]), ('issues', GroupIssueManager, [('group_id', 'id')])] - GUEST_ACCESS = 10 - REPORTER_ACCESS = 20 - DEVELOPER_ACCESS = 30 - MASTER_ACCESS = 40 - OWNER_ACCESS = 50 + GUEST_ACCESS = gitlab.GUEST_ACCESS + REPORTER_ACCESS = gitlab.REPORTER_ACCESS + DEVELOPER_ACCESS = gitlab.DEVELOPER_ACCESS + MASTER_ACCESS = gitlab.MASTER_ACCESS + OWNER_ACCESS = gitlab.OWNER_ACCESS - VISIBILITY_PRIVATE = 0 - VISIBILITY_INTERNAL = 10 - VISIBILITY_PUBLIC = 20 + VISIBILITY_PRIVATE = gitlab.VISIBILITY_PRIVATE + VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL + VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC def Member(self, id=None, **kwargs): warnings.warn("`Member` is deprecated, use `members` instead", @@ -1787,9 +1787,9 @@ class Project(GitlabObject): ('variables', ProjectVariableManager, [('project_id', 'id')]), ] - VISIBILITY_PRIVATE = 0 - VISIBILITY_INTERNAL = 10 - VISIBILITY_PUBLIC = 20 + VISIBILITY_PRIVATE = gitlab.VISIBILITY_PRIVATE + VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL + VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC def Branch(self, id=None, **kwargs): warnings.warn("`Branch` is deprecated, use `branches` instead", |