FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab-submodule/gitlab_submodule/objects.py at main · mertemba/python-gitlab-submodule · GitHub
mertemba
/
python-gitlab-submodule
Public
forked from
ValentinFrancois/python-gitlab-submodule
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab-submodule
/
gitlab_submodule
/
objects.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
108 lines (87 loc) · 3.34 KB
Breadcrumbs
python-gitlab-submodule
/
gitlab_submodule
/
objects.py
Copy path
File metadata and controls
108 lines (87 loc) · 3.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from
typing
import
Optional
,
Union
from
gitlab
.
v4
.
objects
import
Project
,
ProjectCommit
from
gitlab_submodule
.
string_utils
import
lstrip
class
Submodule
:
def
__init__
(
self
,
parent_project
:
Project
,
parent_ref
:
str
,
name
:
str
,
path
:
str
,
url
:
str
):
self
.
parent_project
=
parent_project
self
.
parent_ref
=
parent_ref
self
.
name
=
name
self
.
path
=
path
self
.
url
=
url
def
keys
(
self
):
return
{
'parent_project'
,
'parent_ref'
,
'name'
,
'path'
,
'url'
}
def
__getitem__
(
self
,
key
):
if
key
in
self
.
keys
():
return
getattr
(
self
,
key
)
else
:
raise
KeyError
(
key
)
def
__str__
(
self
):
keys
=
sorted
(
self
.
keys
())
class_part
=
f"<class '
{
self
.
__class__
.
__name__
}
'>"
def
to_str
(
key
):
if
isinstance
(
self
[
key
],
str
):
return
f"'
{
self
[
key
]
}
'"
else
:
return
str
(
self
[
key
])
attributes
=
[
f"'
{
key
}
':
{
to_str
(
key
)
}
"
for
key
in
keys
]
return
class_part
+
' => {'
+
', '
.
join
(
attributes
)
+
'}'
def
__repr__
(
self
):
return
'{} ({}, {}, {}, {}, {})'
.
format
(
self
.
__class__
.
__name__
,
repr
(
self
.
parent_project
),
f"'
{
self
.
parent_ref
}
'"
,
f"'
{
self
.
name
}
'"
,
f"'
{
self
.
path
}
'"
,
f"'
{
self
.
url
}
'"
,
)
class
Commit
:
def
__init__
(
self
,
_id
)
->
None
:
self
.
id
=
id
class
Subproject
:
def
__init__
(
self
,
submodule
:
Submodule
,
project
:
Optional
[
Project
],
commit
:
Optional
[
Union
[
ProjectCommit
,
Commit
]]):
self
.
submodule
=
submodule
self
.
project
=
project
self
.
commit
=
commit
def
__getattribute__
(
self
,
item
:
str
):
try
:
return
super
().
__getattribute__
(
item
)
except
AttributeError
:
for
attribute
in
{
'submodule'
,
'project'
,
'commit'
}:
if
item
.
startswith
(
f'
{
attribute
}
_'
):
return
getattr
(
super
().
__getattribute__
(
attribute
),
lstrip
(
item
,
f'
{
attribute
}
_'
))
raise
AttributeError
(
"'{} object has no attribute '{}'"
.
format
(
self
.
__class__
.
__name__
,
item
))
def
__setattr__
(
self
,
key
,
value
):
for
attribute
in
{
'submodule'
,
'project'
,
'commit'
}:
if
key
==
attribute
:
return
super
().
__setattr__
(
key
,
value
)
if
key
.
startswith
(
f'
{
attribute
}
_'
):
return
setattr
(
getattr
(
self
,
attribute
),
lstrip
(
key
,
f'
{
attribute
}
_'
),
value
)
try
:
super
().
__setattr__
(
key
,
value
)
except
AttributeError
:
raise
AttributeError
(
"'{} object has no attribute '{}'"
.
format
(
self
.
__class__
.
__name__
,
key
))
def
__str__
(
self
):
class_part
=
f"<class '
{
self
.
__class__
.
__name__
}
'>"
attributes
=
[
f"
\n
'
{
key
}
':
{
getattr
(
self
,
key
)
}
"
for
key
in
[
'submodule'
,
'project'
,
'commit'
]]
return
class_part
+
' => {'
+
','
.
join
(
attributes
)
+
'
\n
}'
def
__repr__
(
self
):
return
'{} (
\n
{},
\n
{},
\n
{}
\n
)'
.
format
(
self
.
__class__
.
__name__
,
repr
(
self
.
submodule
),
repr
(
self
.
project
),
repr
(
self
.
commit
),
)
Back
|
FazBrowse Home
|
New Git URL