Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
74f96a33
Verified
Commit
74f96a33
authored
4 months ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
WIP: mypy
parent
9ae5cd87
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!175
BUG: Request responses without the "Set-Cookie" header no longer overwrite the...
,
!164
Fix mypy errors
Pipeline
#58009
failed
4 months ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/linkahead/common/versioning.py
+8
-5
8 additions, 5 deletions
src/linkahead/common/versioning.py
src/linkahead/connection/connection.py
+12
-9
12 additions, 9 deletions
src/linkahead/connection/connection.py
src/linkahead/utils/git_utils.py
+9
-9
9 additions, 9 deletions
src/linkahead/utils/git_utils.py
with
29 additions
and
23 deletions
src/linkahead/common/versioning.py
+
8
−
5
View file @
74f96a33
...
...
@@ -101,11 +101,14 @@ class Version():
# pylint: disable=redefined-builtin
def
__init__
(
self
,
id
:
Optional
[
str
]
=
None
,
date
:
Optional
[
str
]
=
None
,
username
:
Optional
[
str
]
=
None
,
realm
:
Optional
[
str
]
=
None
,
predecessors
:
Optional
[
List
[
Version
]]
=
None
,
successors
:
Optional
[
List
[
Version
]]
=
None
,
predecessors
:
Optional
[
List
[
Version
]]
=
None
,
successors
:
Optional
[
List
[
Version
]]
=
None
,
is_head
:
Union
[
bool
,
str
,
None
]
=
False
,
is_complete_history
:
Union
[
bool
,
str
,
None
]
=
False
):
"""
Typically the `predecessors` or `successors` should not
"
link back
"
to an existing Version
object.
"""
"""
Typically the `predecessors` or `successors` should not
"
link back
"
to an existing
Version object.
"""
self
.
id
=
id
self
.
date
=
date
self
.
username
=
username
...
...
@@ -205,8 +208,8 @@ class Version():
version : Version
a new version instance
"""
predecessors
=
[
Version
.
from_xml
(
p
)
for
p
in
xml
if
p
.
tag
.
lower
()
==
"
predecessor
"
]
successors
=
[
Version
.
from_xml
(
s
)
for
s
in
xml
if
s
.
tag
.
lower
()
==
"
successor
"
]
predecessors
=
[
Version
.
from_xml
(
p
)
for
p
in
xml
if
str
(
p
.
tag
)
.
lower
()
==
"
predecessor
"
]
successors
=
[
Version
.
from_xml
(
s
)
for
s
in
xml
if
str
(
s
.
tag
)
.
lower
()
==
"
successor
"
]
return
Version
(
id
=
xml
.
get
(
"
id
"
),
date
=
xml
.
get
(
"
date
"
),
is_head
=
xml
.
get
(
"
head
"
),
is_complete_history
=
xml
.
get
(
"
completeHistory
"
),
...
...
This diff is collapsed.
Click to expand it.
src/linkahead/connection/connection.py
+
12
−
9
View file @
74f96a33
...
...
@@ -103,9 +103,12 @@ class _WrappedHTTPResponse(CaosDBHTTPResponse):
if
len
(
self
.
_buffer
)
>=
size
:
# still enough bytes in the buffer
# FIXME: `chunk`` is used before definition
result
=
chunk
[:
size
]
self
.
_buffer
=
chunk
[
size
:]
return
result
raise
NotImplementedError
(
"
chunk is undefined
"
)
# # old code:
# result = chunk[:size]
# self._buffer = chunk[size:]
# return result
if
self
.
_generator
is
None
:
# first call to this method
...
...
@@ -218,7 +221,7 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection):
"
Connection failed. Network or server down?
"
+
str
(
conn_err
)
)
def
configure
(
self
,
**
config
):
def
configure
(
self
,
**
config
)
->
None
:
"""
configure.
Configure the http connection.
...
...
@@ -551,9 +554,9 @@ class _Connection(object): # pylint: disable=useless-object-inheritance
__instance
=
None
def
__init__
(
self
):
def
__init__
(
self
)
->
None
:
self
.
_delegate_connection
:
Optional
[
CaosDBServerConnection
]
=
None
self
.
_authenticator
:
Optional
[
Credentials
Authenticator
]
=
None
self
.
_authenticator
:
Optional
[
Abstract
Authenticator
]
=
None
self
.
is_configured
=
False
@classmethod
...
...
@@ -563,7 +566,7 @@ class _Connection(object): # pylint: disable=useless-object-inheritance
return
cls
.
__instance
def
configure
(
self
,
**
config
):
def
configure
(
self
,
**
config
)
->
_Connection
:
self
.
is_configured
=
True
if
"
implementation
"
not
in
config
:
...
...
@@ -571,8 +574,7 @@ class _Connection(object): # pylint: disable=useless-object-inheritance
"
Missing CaosDBServerConnection implementation. You did not
"
"
specify an `implementation` for the connection.
"
)
try
:
self
.
_delegate_connection
:
CaosDBServerConnection
=
config
[
"
implementation
"
](
)
self
.
_delegate_connection
=
config
[
"
implementation
"
]()
if
not
isinstance
(
self
.
_delegate_connection
,
CaosDBServerConnection
):
...
...
@@ -762,6 +764,7 @@ class _Connection(object): # pylint: disable=useless-object-inheritance
if
self
.
_authenticator
is
None
:
raise
ValueError
(
"
No authenticator set. Please call configure_connection() first.
"
)
assert
isinstance
(
self
.
_authenticator
,
CredentialsAuthenticator
)
if
self
.
_authenticator
.
_credentials_provider
is
None
:
raise
ValueError
(
"
No credentials provider set. Please call configure_connection() first.
"
)
...
...
This diff is collapsed.
Click to expand it.
src/linkahead/utils/git_utils.py
+
9
−
9
View file @
74f96a33
...
...
@@ -36,9 +36,9 @@ logger = logging.getLogger(__name__)
def
get_origin_url_in
(
folder
:
str
):
"""
return the Fetch URL of the git repository in the given folder.
"""
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
mode
=
"
w
"
)
as
t
:
call
([
"
git
"
,
"
remote
"
,
"
show
"
,
"
origin
"
],
stdout
=
t
,
cwd
=
folder
)
with
open
(
t
.
name
,
"
r
"
)
as
t
:
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
mode
=
"
w
"
,
encoding
=
"
utf8
"
)
as
t
empf
:
call
([
"
git
"
,
"
remote
"
,
"
show
"
,
"
origin
"
],
stdout
=
t
empf
,
cwd
=
folder
)
with
open
(
t
empf
.
name
,
"
r
"
,
encoding
=
"
utf8
"
)
as
t
:
urlString
=
"
Fetch URL:
"
for
line
in
t
.
readlines
():
...
...
@@ -63,9 +63,9 @@ def get_branch_in(folder: str):
The command
"
git branch
"
is called in the given folder and the
output is returned
"""
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
mode
=
"
w
"
)
as
t
:
call
([
"
git
"
,
"
rev-parse
"
,
"
--abbrev-ref
"
,
"
HEAD
"
],
stdout
=
t
,
cwd
=
folder
)
with
open
(
t
.
name
,
"
r
"
)
as
t
:
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
mode
=
"
w
"
)
as
t
empf
:
call
([
"
git
"
,
"
rev-parse
"
,
"
--abbrev-ref
"
,
"
HEAD
"
],
stdout
=
t
empf
,
cwd
=
folder
)
with
open
(
t
empf
.
name
,
"
r
"
)
as
t
:
return
t
.
readline
().
strip
()
...
...
@@ -76,7 +76,7 @@ def get_commit_in(folder: str):
and the output is returned
"""
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
mode
=
"
w
"
)
as
t
:
call
([
"
git
"
,
"
log
"
,
"
-1
"
,
"
--format=%h
"
],
stdout
=
t
,
cwd
=
folder
)
with
open
(
t
.
name
,
"
r
"
)
as
t
:
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
mode
=
"
w
"
)
as
t
empf
:
call
([
"
git
"
,
"
log
"
,
"
-1
"
,
"
--format=%h
"
],
stdout
=
t
empf
,
cwd
=
folder
)
with
open
(
t
empf
.
name
,
"
r
"
)
as
t
:
return
t
.
readline
().
strip
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment