Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shawn Webb
Git Lab
Commits
0cb2e8b1
Unverified
Commit
0cb2e8b1
authored
May 25, 2021
by
Jonah Brüchert
Browse files
Fix compatibility with python < 3.9
Fixes #12
parent
4bdea72b
Changes
1
Hide whitespace changes
Inline
Side-by-side
lab/utils.py
View file @
0cb2e8b1
...
...
@@ -20,6 +20,19 @@ from git import Repo
from
git.exc
import
InvalidGitRepositoryError
def
removesuffix
(
string
:
str
,
suffix
:
str
)
->
str
:
"""
Compatiblity function for python < 3.9
"""
if
sys
.
version_info
>=
(
3
,
9
):
return
string
.
removesuffix
(
suffix
)
if
string
.
endswith
(
suffix
):
return
string
[:
-
len
(
suffix
)]
return
string
class
LogType
(
Enum
):
"""
Enum representing the type of log message
...
...
@@ -59,8 +72,8 @@ class Utils:
Returns the url encoded string id for a repository
"""
normalized_url
:
str
=
Utils
.
normalize_url
(
url
)
normalized_url
=
normalized_url
.
removesuffix
(
".git"
)
normalized_url
=
normalized_url
.
removesuffix
(
"/"
)
normalized_url
=
removesuffix
(
normalized_url
,
".git"
)
normalized_url
=
removesuffix
(
normalized_url
,
"/"
)
repository_url
:
ParseResult
=
urlparse
(
normalized_url
)
return
quote_plus
(
repository_url
.
path
[
1
:])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment