glpkg 1.4.1__py3-none-any.whl → 1.4.2__py3-none-any.whl
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.
- gitlab/__init__.py +1 -1
- gitlab/cli_handler.py +2 -20
- gitlab/packages.py +63 -11
- {glpkg-1.4.1.dist-info → glpkg-1.4.2.dist-info}/METADATA +10 -2
- glpkg-1.4.2.dist-info/RECORD +10 -0
- {glpkg-1.4.1.dist-info → glpkg-1.4.2.dist-info}/WHEEL +1 -1
- glpkg-1.4.1.dist-info/RECORD +0 -10
- {glpkg-1.4.1.dist-info → glpkg-1.4.2.dist-info}/entry_points.txt +0 -0
- {glpkg-1.4.1.dist-info → glpkg-1.4.2.dist-info}/licenses/LICENSE.md +0 -0
- {glpkg-1.4.1.dist-info → glpkg-1.4.2.dist-info}/top_level.txt +0 -0
gitlab/__init__.py
CHANGED
gitlab/cli_handler.py
CHANGED
|
@@ -21,9 +21,8 @@ class CLIHandler:
|
|
|
21
21
|
parser = argparse.ArgumentParser(
|
|
22
22
|
description="Toolbox for GitLab generic packages"
|
|
23
23
|
)
|
|
24
|
-
parser.add_argument("-v", "--version", action="
|
|
25
|
-
parser.
|
|
26
|
-
subparsers = parser.add_subparsers()
|
|
24
|
+
parser.add_argument("-v", "--version", action="version", version=__version__)
|
|
25
|
+
subparsers = parser.add_subparsers(required=True)
|
|
27
26
|
list_parser = subparsers.add_parser(
|
|
28
27
|
name="list",
|
|
29
28
|
description="Lists the available version of a package from the "
|
|
@@ -49,23 +48,6 @@ class CLIHandler:
|
|
|
49
48
|
self._register_delete_parser(delete_parser)
|
|
50
49
|
self.args = parser.parse_args()
|
|
51
50
|
|
|
52
|
-
def _print_version(self, _args: argparse.Namespace) -> int:
|
|
53
|
-
"""
|
|
54
|
-
A handler for printing the version of the tool to the console.
|
|
55
|
-
|
|
56
|
-
Parameters
|
|
57
|
-
----------
|
|
58
|
-
_args : argparse.Namespace
|
|
59
|
-
Unused.
|
|
60
|
-
|
|
61
|
-
Return
|
|
62
|
-
------
|
|
63
|
-
int
|
|
64
|
-
Zero when printing to console succeeded.
|
|
65
|
-
"""
|
|
66
|
-
print(__version__)
|
|
67
|
-
return 0
|
|
68
|
-
|
|
69
51
|
def do_it(self) -> int:
|
|
70
52
|
"""
|
|
71
53
|
Executes the requested command.
|
gitlab/packages.py
CHANGED
|
@@ -223,6 +223,36 @@ class Packages:
|
|
|
223
223
|
url = self._parse_header_links(res_headers).get("next")
|
|
224
224
|
return data
|
|
225
225
|
|
|
226
|
+
def _put(
|
|
227
|
+
self, url: str, data: bytes, headers: dict
|
|
228
|
+
) -> tuple[int, bytes, HTTPMessage]:
|
|
229
|
+
"""
|
|
230
|
+
Makes a raw PUT request to the given URL, and returns
|
|
231
|
+
the response status, body, and headers.
|
|
232
|
+
|
|
233
|
+
Parameters
|
|
234
|
+
----------
|
|
235
|
+
url : str
|
|
236
|
+
The URL of the HTTP request to make.
|
|
237
|
+
data : bytes
|
|
238
|
+
The data to PUT
|
|
239
|
+
headers: dict
|
|
240
|
+
The HTTP headers used in the request.
|
|
241
|
+
|
|
242
|
+
Returns
|
|
243
|
+
-------
|
|
244
|
+
int
|
|
245
|
+
The HTTP response code, such as 200
|
|
246
|
+
bytes
|
|
247
|
+
The HTTP response body read as bytes
|
|
248
|
+
HTTPMessage
|
|
249
|
+
The HTTP response headers
|
|
250
|
+
"""
|
|
251
|
+
logger.debug("Putting %s", url)
|
|
252
|
+
req = request.Request(url, method="PUT", data=data, headers=headers)
|
|
253
|
+
with request.urlopen(req) as response:
|
|
254
|
+
return response.status, response.read(), response.headers
|
|
255
|
+
|
|
226
256
|
def put(self, data: bytes, *paths: str, **query_params: str) -> int:
|
|
227
257
|
"""
|
|
228
258
|
Makes a HTTP PUT request to the given GitLab path.
|
|
@@ -244,13 +274,37 @@ class Packages:
|
|
|
244
274
|
"""
|
|
245
275
|
ret = 1
|
|
246
276
|
url = self._url() + self._build_path(*paths) + self.build_query(**query_params)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if res.status == 201: # 201 is created
|
|
251
|
-
ret = 0
|
|
277
|
+
status, _, _ = self._put(url, data, self._get_headers())
|
|
278
|
+
if status == 201: # 201 is created
|
|
279
|
+
ret = 0
|
|
252
280
|
return ret
|
|
253
281
|
|
|
282
|
+
def _delete(self, url, headers):
|
|
283
|
+
"""
|
|
284
|
+
Makes a raw DELETE request to the given URL, and returns
|
|
285
|
+
the response status, body, and headers.
|
|
286
|
+
|
|
287
|
+
Parameters
|
|
288
|
+
----------
|
|
289
|
+
url : str
|
|
290
|
+
The URL of the HTTP request to make.
|
|
291
|
+
headers: dict
|
|
292
|
+
The HTTP headers used in the request.
|
|
293
|
+
|
|
294
|
+
Returns
|
|
295
|
+
-------
|
|
296
|
+
int
|
|
297
|
+
The HTTP response code, such as 200
|
|
298
|
+
bytes
|
|
299
|
+
The HTTP response body read as bytes
|
|
300
|
+
HTTPMessage
|
|
301
|
+
The HTTP response headers
|
|
302
|
+
"""
|
|
303
|
+
logger.debug("Deleting %s", url)
|
|
304
|
+
req = request.Request(url, method="DELETE", headers=headers)
|
|
305
|
+
with request.urlopen(req) as response:
|
|
306
|
+
return response.status, response.read(), response.headers
|
|
307
|
+
|
|
254
308
|
def delete(self, *paths: str, **query_params: str) -> int:
|
|
255
309
|
"""
|
|
256
310
|
Makes a HTTP DELETE request to the given GitLab path.
|
|
@@ -270,12 +324,10 @@ class Packages:
|
|
|
270
324
|
"""
|
|
271
325
|
ret = 1
|
|
272
326
|
url = self._url() + self._build_path(*paths) + self.build_query(**query_params)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
# 204 is no content, that GL responds when file deleted
|
|
278
|
-
ret = 0
|
|
327
|
+
status, _, _ = self._delete(url, self._get_headers())
|
|
328
|
+
if status == 204:
|
|
329
|
+
# 204 is no content, that GL responds when file deleted
|
|
330
|
+
ret = 0
|
|
279
331
|
return ret
|
|
280
332
|
|
|
281
333
|
def get_versions(self, project_id: str, package_name: str) -> list:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: glpkg
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.2
|
|
4
4
|
Summary: Tool to make GitLab generic package registry operations easy.
|
|
5
5
|
Author-email: bugproduction <bugproduction@outlook.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Install the tool from with pip:
|
|
|
25
25
|
pip install glpkg
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
To check the installation and version,
|
|
28
|
+
To check the installation and version, run:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
31
|
glpkg --version
|
|
@@ -35,6 +35,14 @@ If you see a version in the terminal, you're good to go!
|
|
|
35
35
|
|
|
36
36
|
## Usage
|
|
37
37
|
|
|
38
|
+
When in doubt
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
glpkg --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
might help
|
|
45
|
+
|
|
38
46
|
By default, the used GitLab host is gitlab.com. If you use a self-hosted GitLab, use argument `--host my-gitlab.net` with the commands.
|
|
39
47
|
|
|
40
48
|
> Only https scheme is supported.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
gitlab/__init__.py,sha256=zDp9HG0fq7XbOi99n4lMzur9Yeb1uhtfTJoZQxwAW3w,105
|
|
2
|
+
gitlab/__main__.py,sha256=ol-xxwX5PONbnqEsq5w-5_bowDyg9Zu-eJZG5XrJeFc,427
|
|
3
|
+
gitlab/cli_handler.py,sha256=_iQCOUli5jXrXD8trnh8KFCSQQXXOEMZrkTRfmE797Q,13854
|
|
4
|
+
gitlab/packages.py,sha256=lIIo14EVm8lOwgZKug_w7txWppiqx6N0D0zLqpbbJ8c,21729
|
|
5
|
+
glpkg-1.4.2.dist-info/licenses/LICENSE.md,sha256=josGXvZq628dNS0Iru58-DPE7dRpDXzjJxKKT35103g,1065
|
|
6
|
+
glpkg-1.4.2.dist-info/METADATA,sha256=Sh4rBcnF7W47p-K8mw6rA5OTQmONmYAT0LTQUkbD_Gw,7730
|
|
7
|
+
glpkg-1.4.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
glpkg-1.4.2.dist-info/entry_points.txt,sha256=xHPZwx2oShYDZ3AyH7WSIvuhFMssy7QLlQk-JAbje_w,46
|
|
9
|
+
glpkg-1.4.2.dist-info/top_level.txt,sha256=MvIaP8p_Oaf4gO_hXmHkX-5y2deHLp1pe6tJR3ukQ6o,7
|
|
10
|
+
glpkg-1.4.2.dist-info/RECORD,,
|
glpkg-1.4.1.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
gitlab/__init__.py,sha256=1T0uTtX3reNQ2YGbnTeO3F2vueUfxkkK_gkz1OKSZWU,105
|
|
2
|
-
gitlab/__main__.py,sha256=ol-xxwX5PONbnqEsq5w-5_bowDyg9Zu-eJZG5XrJeFc,427
|
|
3
|
-
gitlab/cli_handler.py,sha256=02Yc3yE3jNMGTx_HvUu0rYH5NwxrnTRaaeAGMFh8Mq8,14273
|
|
4
|
-
gitlab/packages.py,sha256=wP0hRLad09LoE9uinUljrvGoBt6KfP49QESqOpxLihQ,20255
|
|
5
|
-
glpkg-1.4.1.dist-info/licenses/LICENSE.md,sha256=josGXvZq628dNS0Iru58-DPE7dRpDXzjJxKKT35103g,1065
|
|
6
|
-
glpkg-1.4.1.dist-info/METADATA,sha256=aQuiPWniN1eGzhFg37_BBLAvjmp9Xenbq-R0dlcCiMo,7678
|
|
7
|
-
glpkg-1.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
glpkg-1.4.1.dist-info/entry_points.txt,sha256=xHPZwx2oShYDZ3AyH7WSIvuhFMssy7QLlQk-JAbje_w,46
|
|
9
|
-
glpkg-1.4.1.dist-info/top_level.txt,sha256=MvIaP8p_Oaf4gO_hXmHkX-5y2deHLp1pe6tJR3ukQ6o,7
|
|
10
|
-
glpkg-1.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|