GitLabPy 0.6.1__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ dist/*
2
+ GitLabPy.egg-info/*
3
+ .pypirc
4
+ .env
5
+ __pycache__/*
6
+ server-output/*
7
+ build/*
8
+ build/lib/GitLabPy.py
9
+ .venv/
10
+ .pytest_cache/
11
+ *.egg-info/
12
+ __pycache__/
@@ -1,121 +1,125 @@
1
- import json
2
-
3
- class GitLab:
4
- """
5
- Instantiate with 1 argument, parsed json string <string>
6
- """
7
- def __init__(self, arg1):
8
- self.json_data = arg1
9
-
10
- # Types of build and issue JSON from GitLab Webhook
11
- self.issue_types = ["open", "update", "closed"]
12
-
13
- # Below is for common JSON objects
14
- self.object_kind = arg1.get("object_kind", "")
15
- self.project_id = arg1.get("project_id", "")
16
- self.ref = arg1.get("ref", "")
17
- self.project_name = arg1.get("project_name", "")
18
- self.user = arg1.get("user", "")
19
- self.commit = arg1.get("commit", "")
20
- self.object_attributes = arg1.get("object_attributes", "")
21
- self.build_status = arg1.get("build_status", "")
22
-
23
- repo_obj = arg1.get("repository", "")
24
- if repo_obj != "":
25
- self.repository = repo_obj
26
- self.repo_name = repo_obj.get("name", "")
27
- self.repo_homepage = repo_obj.get("homepage", "")
28
-
29
- def check_repository_atttr(self):
30
- if self.repository == "":
31
- return False
32
- else:
33
- return True
34
-
35
- def get_url(self, url=None):
36
- """
37
- Arguments:
38
- - url : type of url to return <string>
39
- * input types:
40
- - "http" : retrieve git http url
41
- - "ssh" : retrieve git ssh url
42
- - "homepage" : retrieve homepage url
43
- - (no input) : retrieve default git url, which is: "repository": {"url": <url>}
44
- """
45
- if check_repository_atttr():
46
- return False
47
- if url.lower() == "ssh":
48
- return self.repository.get("git_ssh_url")
49
- elif url.lower() == "http":
50
- return self.repository.get("git_http_url")
51
- elif url.lower() == "homepage":
52
- return self.repository.get("homepage")
53
- else:
54
- return self.repository.get("url")
55
-
56
- def get_repo_description(self):
57
- """
58
- Arguments: None
59
- Checks to see if the key 'description' is in the webhook
60
- """
61
- if check_repository_atttr():
62
- return self.repository.get("description")
63
- else:
64
- return False
65
-
66
- def build(self, *args):
67
- """
68
- Checks to see if JSON data from GitLab is build data and also checks to see that you want build data. If so, return True
69
- Arguments: *args <bool><string><list>
70
- - can be a list of certain build data you want
71
- - build types are 'success', 'failed', 'runnning'
72
- """
73
- if self.object_kind == "build" and self.build_status in args:
74
- return True
75
- else:
76
- return False
77
-
78
- def note(self, note_types=False):
79
- """
80
- Checks to see if JSON data is a note (comment) and you want note JSON data. If so, return True
81
- Arguments: note_types <bool>
82
- - Returns True if you want note type JSON data to return True and JSON data is a note
83
- - Default - False
84
- """
85
- if note_types and self.object_kind == "note":
86
- return True
87
- else:
88
- return False
89
-
90
- def merge_request(self, merge_request_types=False):
91
- """
92
- Checks to see if JSON data is a merge request and if you want merge_request data. If so, return True
93
- Arguments: merge_request_types <bool>
94
- - True if you want merge request data from GitLab to be returned if JSON data is merge request.
95
- - Default - False
96
- """
97
- if merge_request_types and self.object_kind == "merge_request":
98
- return True
99
- else:
100
- return False
101
-
102
- def issue(self, *args):
103
- """
104
- Checks to see if JSON data is an issue from GitLabJSON
105
- Arguments: *args <bool><string><list>
106
- - can be list of issue types or boolean
107
- - issue types are 'open', 'update', 'closed'
108
- - True if you want all issues pass this conditional function
109
- """
110
- if self.object_kind != "issue":
111
- return False
112
-
113
- if "open" in args or "closed" in args:
114
- if self.object_attributes.get("state") == "closed" and "closed" in args:
115
- return True
116
- elif self.object_attributes.get("action") == "open" and "open" in args:
117
- return True
118
- elif "update" in args and self.object_attributes.get("action") == "update":
119
- return True
120
- else:
121
- return False
1
+ import json
2
+
3
+ class GitLab:
4
+ """
5
+ Instantiate with 1 argument, parsed json string <string>
6
+ """
7
+ def __init__(self, arg1):
8
+ self.json_data = arg1
9
+
10
+ # Types of build and issue JSON from GitLab Webhook
11
+ self.issue_types = ["open", "update", "closed"]
12
+
13
+ # Below is for common JSON objects
14
+ self.object_kind = arg1.get("object_kind", "")
15
+ self.project_id = arg1.get("project_id", "")
16
+ self.ref = arg1.get("ref", "")
17
+ self.project_name = arg1.get("project_name", "")
18
+ self.user = arg1.get("user", "")
19
+ self.commit = arg1.get("commit", "")
20
+ self.object_attributes = arg1.get("object_attributes", "")
21
+ self.build_status = arg1.get("build_status", "")
22
+
23
+ self.repository = ""
24
+ self.repo_name = ""
25
+ self.repo_homepage = ""
26
+
27
+ repo_obj = arg1.get("repository", "")
28
+ if repo_obj != "":
29
+ self.repository = repo_obj
30
+ self.repo_name = repo_obj.get("name", "")
31
+ self.repo_homepage = repo_obj.get("homepage", "")
32
+
33
+ def check_repository_atttr(self):
34
+ if self.repository == "":
35
+ return False
36
+ else:
37
+ return True
38
+
39
+ def get_url(self, url=None):
40
+ """
41
+ Arguments:
42
+ - url : type of url to return <string>
43
+ * input types:
44
+ - "http" : retrieve git http url
45
+ - "ssh" : retrieve git ssh url
46
+ - "homepage" : retrieve homepage url
47
+ - (no input) : retrieve default git url, which is: "repository": {"url": <url>}
48
+ """
49
+ if not self.check_repository_atttr():
50
+ return False
51
+ if url is None:
52
+ return self.repository.get("url")
53
+ if url.lower() == "ssh":
54
+ return self.repository.get("git_ssh_url")
55
+ elif url.lower() == "http":
56
+ return self.repository.get("git_http_url")
57
+ elif url.lower() == "homepage":
58
+ return self.repository.get("homepage")
59
+ else:
60
+ return self.repository.get("url")
61
+
62
+ def get_repo_description(self):
63
+ """
64
+ Arguments: None
65
+ Checks to see if the key 'description' is in the webhook
66
+ """
67
+ if self.check_repository_atttr():
68
+ return self.repository.get("description")
69
+ else:
70
+ return False
71
+
72
+ def build(self, *args):
73
+ """
74
+ Checks to see if JSON data from GitLab is build data and also checks to see that you want build data. If so, return True
75
+ Arguments: *args <bool><string><list>
76
+ - can be a list of certain build data you want
77
+ - build types are 'success', 'failed', 'runnning'
78
+ """
79
+ if self.object_kind == "build" and self.build_status in args:
80
+ return True
81
+ else:
82
+ return False
83
+
84
+ def note(self, note_types=False):
85
+ """
86
+ Checks to see if JSON data is a note (comment) and you want note JSON data. If so, return True
87
+ Arguments: note_types <bool>
88
+ - Returns True if you want note type JSON data to return True and JSON data is a note
89
+ - Default - False
90
+ """
91
+ if note_types and self.object_kind == "note":
92
+ return True
93
+ else:
94
+ return False
95
+
96
+ def merge_request(self, merge_request_types=False):
97
+ """
98
+ Checks to see if JSON data is a merge request and if you want merge_request data. If so, return True
99
+ Arguments: merge_request_types <bool>
100
+ - True if you want merge request data from GitLab to be returned if JSON data is merge request.
101
+ - Default - False
102
+ """
103
+ if merge_request_types and self.object_kind == "merge_request":
104
+ return True
105
+ else:
106
+ return False
107
+
108
+ def issue(self, *args):
109
+ """
110
+ Checks to see if JSON data is an issue from GitLabJSON
111
+ Arguments: *args <bool><string><list>
112
+ - can be list of issue types or boolean
113
+ - issue types are 'open', 'update', 'closed'
114
+ - True if you want all issues pass this conditional function
115
+ """
116
+ if self.object_kind != "issue":
117
+ return False
118
+
119
+ if "closed" in args and self.object_attributes.get("state") == "closed":
120
+ return True
121
+ if "open" in args and self.object_attributes.get("action") == "open":
122
+ return True
123
+ if "update" in args and self.object_attributes.get("action") == "update":
124
+ return True
125
+ return False
gitlabpy-0.7.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Dixon Begay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.5
2
+ Name: GitLabPy
3
+ Version: 0.7.0
4
+ Summary: A Python module to sort GitLab's Webhooks
5
+ Project-URL: Homepage, https://github.com/dixonbegay/GitLabPy
6
+ Project-URL: Issues, https://github.com/dixonbegay/GitLabPy/issues
7
+ Author-email: Dixon Begay <dixon@dixon-labs.net>
8
+ Maintainer-email: Dixon Begay <dixon@dixon-labs.net>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: gitlabpy
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+
18
+ # GitLabPy
19
+ A Python module to help sort GitLab's Webhooks
20
+
21
+ Some of the JSON data coming from GitLab's webhooks are set as attributes to the GitLab class. There are functions within the GitLab class that allow for easy handling of the JSON data.
22
+
23
+ ## Requirements
24
+ * Python >= 3.10
25
+
26
+ ## Install
27
+ * `pip install GitLabPy`
28
+
29
+ ## How to use
30
+ Check out the [wiki](https://github.com/shadez95/GitLabPy/wiki) for information.
31
+
32
+ ### Example
33
+ An example of how to utilize this can be found [here](https://github.com/shadez95/GitLabPy/tree/master/examples/Django-App)
34
+
35
+ ## Development
36
+ This project uses [uv](https://docs.astral.sh/uv/) for dependency management, building, and publishing.
37
+
38
+ ```bash
39
+ # Install dependencies (including dev dependencies)
40
+ uv sync
41
+
42
+ # Run the test suite
43
+ uv run pytest
44
+
45
+ # Build the sdist and wheel
46
+ uv build
47
+ ```
48
+
49
+ ## Releasing
50
+ Releases are published manually from a local machine (no CI publish step).
51
+
52
+ ```bash
53
+ # 1. Bump the version in pyproject.toml, then build
54
+ uv build
55
+
56
+ # 2. Publish to PyPI
57
+ uv publish
58
+
59
+ # 3. Create the GitHub release (tags and publishes the release)
60
+ gh release create vX.Y.Z --generate-notes
61
+ ```
@@ -0,0 +1,44 @@
1
+ # GitLabPy
2
+ A Python module to help sort GitLab's Webhooks
3
+
4
+ Some of the JSON data coming from GitLab's webhooks are set as attributes to the GitLab class. There are functions within the GitLab class that allow for easy handling of the JSON data.
5
+
6
+ ## Requirements
7
+ * Python >= 3.10
8
+
9
+ ## Install
10
+ * `pip install GitLabPy`
11
+
12
+ ## How to use
13
+ Check out the [wiki](https://github.com/shadez95/GitLabPy/wiki) for information.
14
+
15
+ ### Example
16
+ An example of how to utilize this can be found [here](https://github.com/shadez95/GitLabPy/tree/master/examples/Django-App)
17
+
18
+ ## Development
19
+ This project uses [uv](https://docs.astral.sh/uv/) for dependency management, building, and publishing.
20
+
21
+ ```bash
22
+ # Install dependencies (including dev dependencies)
23
+ uv sync
24
+
25
+ # Run the test suite
26
+ uv run pytest
27
+
28
+ # Build the sdist and wheel
29
+ uv build
30
+ ```
31
+
32
+ ## Releasing
33
+ Releases are published manually from a local machine (no CI publish step).
34
+
35
+ ```bash
36
+ # 1. Bump the version in pyproject.toml, then build
37
+ uv build
38
+
39
+ # 2. Publish to PyPI
40
+ uv publish
41
+
42
+ # 3. Create the GitHub release (tags and publishes the release)
43
+ gh release create vX.Y.Z --generate-notes
44
+ ```
@@ -0,0 +1,3 @@
1
+ This Django app example shows that you can retrieve a GitLab webhook post request, filter out which data is passed, and post to a discord-app channel through discord's webhooks.
2
+
3
+ `discord\views.py` contains the example.
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "GitLabPy"
7
+ version = "0.7.0"
8
+ description = "A Python module to sort GitLab's Webhooks"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "Dixon Begay", email = "dixon@dixon-labs.net" },
14
+ ]
15
+ maintainers = [
16
+ { name = "Dixon Begay", email = "dixon@dixon-labs.net" },
17
+ ]
18
+ keywords = ["gitlabpy"]
19
+ classifiers = [
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Software Development",
22
+ "Programming Language :: Python :: 3",
23
+ ]
24
+ dependencies = []
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/dixonbegay/GitLabPy"
28
+ Issues = "https://github.com/dixonbegay/GitLabPy/issues"
29
+
30
+ [dependency-groups]
31
+ dev = [
32
+ "pytest>=9.0.3",
33
+ ]
34
+
35
+ [tool.hatch.build.targets.wheel]
36
+ include = ["GitLabPy.py"]
37
+
38
+ [tool.hatch.build.targets.sdist]
39
+ include = ["GitLabPy.py", "README.md", "LICENSE"]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
@@ -1,34 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: GitLabPy
3
- Version: 0.6.1
4
- Summary: A Python module to sort GitLab's Webhooks
5
- Home-page: https://github.com/shadez95/GitLabPy
6
- Author: Dixon Begay
7
- Author-email: dixonbegay@gmail.com
8
- Maintainer: Dixon Begay
9
- License: MIT
10
- Description: # GitLabPy
11
- A Python module to help sort GitLab's Webhooks
12
-
13
- Some of the JSON data coming from GitLab's webhooks are set as attributes to the GitLab class. There are functions within the GitLab class that allow for easy handling of the JSON data.
14
-
15
- ## Requirements
16
- * Python3 (has only been tested with Python 3.5.2)
17
-
18
-
19
- ## Install
20
- * `pip install GitLabPy`
21
-
22
- ## How to use
23
- Check out the [wiki](https://github.com/shadez95/GitLabPy/wiki) for information.
24
-
25
- ### Example
26
- An example of how to utilize this can be found [here](https://github.com/shadez95/GitLabPy/tree/master/examples/Django-App)
27
-
28
- Keywords: gitlabpy
29
- Platform: UNKNOWN
30
- Classifier: Development Status :: 3 - Alpha
31
- Classifier: Intended Audience :: Developers
32
- Classifier: Topic :: Software Development
33
- Classifier: Programming Language :: Python :: 3.5
34
- Description-Content-Type: text/markdown
@@ -1,8 +0,0 @@
1
- GitLabPy.py
2
- README.md
3
- setup.cfg
4
- setup.py
5
- GitLabPy.egg-info/PKG-INFO
6
- GitLabPy.egg-info/SOURCES.txt
7
- GitLabPy.egg-info/dependency_links.txt
8
- GitLabPy.egg-info/top_level.txt
@@ -1 +0,0 @@
1
- GitLabPy
GitLabPy-0.6.1/PKG-INFO DELETED
@@ -1,34 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: GitLabPy
3
- Version: 0.6.1
4
- Summary: A Python module to sort GitLab's Webhooks
5
- Home-page: https://github.com/shadez95/GitLabPy
6
- Author: Dixon Begay
7
- Author-email: dixonbegay@gmail.com
8
- Maintainer: Dixon Begay
9
- License: MIT
10
- Description: # GitLabPy
11
- A Python module to help sort GitLab's Webhooks
12
-
13
- Some of the JSON data coming from GitLab's webhooks are set as attributes to the GitLab class. There are functions within the GitLab class that allow for easy handling of the JSON data.
14
-
15
- ## Requirements
16
- * Python3 (has only been tested with Python 3.5.2)
17
-
18
-
19
- ## Install
20
- * `pip install GitLabPy`
21
-
22
- ## How to use
23
- Check out the [wiki](https://github.com/shadez95/GitLabPy/wiki) for information.
24
-
25
- ### Example
26
- An example of how to utilize this can be found [here](https://github.com/shadez95/GitLabPy/tree/master/examples/Django-App)
27
-
28
- Keywords: gitlabpy
29
- Platform: UNKNOWN
30
- Classifier: Development Status :: 3 - Alpha
31
- Classifier: Intended Audience :: Developers
32
- Classifier: Topic :: Software Development
33
- Classifier: Programming Language :: Python :: 3.5
34
- Description-Content-Type: text/markdown
GitLabPy-0.6.1/README.md DELETED
@@ -1,17 +0,0 @@
1
- # GitLabPy
2
- A Python module to help sort GitLab's Webhooks
3
-
4
- Some of the JSON data coming from GitLab's webhooks are set as attributes to the GitLab class. There are functions within the GitLab class that allow for easy handling of the JSON data.
5
-
6
- ## Requirements
7
- * Python3 (has only been tested with Python 3.5.2)
8
-
9
-
10
- ## Install
11
- * `pip install GitLabPy`
12
-
13
- ## How to use
14
- Check out the [wiki](https://github.com/shadez95/GitLabPy/wiki) for information.
15
-
16
- ### Example
17
- An example of how to utilize this can be found [here](https://github.com/shadez95/GitLabPy/tree/master/examples/Django-App)
GitLabPy-0.6.1/setup.cfg DELETED
@@ -1,10 +0,0 @@
1
- [bdist_wheel]
2
- universal = 0
3
-
4
- [metadata]
5
- description-file = README.md
6
-
7
- [egg_info]
8
- tag_build =
9
- tag_date = 0
10
-
GitLabPy-0.6.1/setup.py DELETED
@@ -1,28 +0,0 @@
1
- from setuptools import setup, find_packages
2
- from os import path
3
-
4
- # Get the long description from the README file
5
- with open(path.join(path.dirname(__file__), 'README.md'), encoding='utf-8') as f:
6
- long_description = f.read()
7
-
8
- setup(
9
- name='GitLabPy',
10
- version='0.6.1',
11
- py_modules=['GitLabPy'],
12
- description="A Python module to sort GitLab's Webhooks",
13
- long_description=long_description,
14
- long_description_content_type="text/markdown",
15
- author='Dixon Begay',
16
- author_email='dixonbegay@gmail.com',
17
- maintainer='Dixon Begay',
18
- url='https://github.com/shadez95/GitLabPy',
19
- classifiers=[
20
- 'Development Status :: 3 - Alpha',
21
- 'Intended Audience :: Developers',
22
- 'Topic :: Software Development',
23
- 'Programming Language :: Python :: 3.5'
24
- ],
25
- license='MIT',
26
- keywords='gitlabpy',
27
- install_requires=[]
28
- )