Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Textgrid Repository WebDAV Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
DARIAH-DE
TextGridRep
Textgrid Repository WebDAV Server
Commits
817c67a2
Verified
Commit
817c67a2
authored
3 years ago
by
Ubbo Veentjer
Browse files
Options
Downloads
Patches
Plain Diff
refactor: dav provider refactoring cont'd
parent
5bef02de
No related branches found
Branches containing commit
Tags
v5.0.0
Tags containing commit
1 merge request
!17
Resolve "refactor dav and named_dav providers to duplicate less code"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/repdav/textgrid_dav_provider.py
+9
-8
9 additions, 8 deletions
src/repdav/textgrid_dav_provider.py
src/repdav/textgrid_named_dav_provider.py
+4
-11
4 additions, 11 deletions
src/repdav/textgrid_named_dav_provider.py
with
13 additions
and
19 deletions
src/repdav/textgrid_dav_provider.py
+
9
−
8
View file @
817c67a2
...
...
@@ -26,15 +26,15 @@ class TextgridRoot(DAVCollection):
def
__init__
(
self
,
path
,
environ
):
DAVCollection
.
__init__
(
self
,
path
,
environ
)
self
.
_sid
=
environ
[
"
wsgidav.auth.user_name
"
]
config
=
TextgridConfig
()
self
.
_auth
=
TextgridAuth
(
config
)
def
get_display_info
(
self
):
return
{
"
type
"
:
"
Textgrid root collection
"
}
def
get_member_names
(
self
):
_logger
.
debug
(
"
Called TextgridRoot.get_member_names(self).
"
)
config
=
TextgridConfig
()
auth
=
TextgridAuth
(
config
)
projects
=
tuple
(
auth
.
list_assigned_projects
(
self
.
_sid
))
projects
=
tuple
(
self
.
_auth
.
list_assigned_projects
(
self
.
_sid
))
_logger
.
debug
(
"
MY PROJECTS: %s
"
,
projects
)
return
projects
...
...
@@ -79,8 +79,9 @@ class TextgridProject(DAVCollection):
_logger
.
debug
(
"
Called TextgridProject.__init__(self, %s, environ).
"
,
path
)
DAVCollection
.
__init__
(
self
,
path
,
environ
)
self
.
_sid
=
environ
[
"
wsgidav.auth.user_name
"
]
self
.
_tgconfig
=
TextgridConfig
()
self
.
_tgsearch
=
TextgridSearch
(
self
.
_tgconfig
.
search
)
config
=
TextgridConfig
()
self
.
_tgsearch
=
TextgridSearch
(
config
.
search
)
self
.
_project_id
=
self
.
path
.
split
(
"
/
"
)[
-
1
]
def
create_empty_resource
(
self
,
name
):
pass
...
...
@@ -100,7 +101,7 @@ class TextgridProject(DAVCollection):
# return names
#
# path resolution has to be rewritten before we can work with resource titles
response
=
self
.
_tgsearch
.
list_project_root
(
self
.
p
ath
.
split
(
"
/
"
)[
-
1
]
,
self
.
_sid
)
response
=
self
.
_tgsearch
.
list_project_root
(
self
.
p
roject_id
,
self
.
_sid
)
names
=
[]
for
result
in
response
.
result
:
names
.
append
(
result
.
object_value
.
generic
.
generated
.
textgrid_uri
.
value
)
...
...
@@ -170,8 +171,8 @@ class TextgridAggregation(DAVCollection):
DAVCollection
.
__init__
(
self
,
path
,
environ
)
self
.
_sid
=
environ
[
"
wsgidav.auth.user_name
"
]
self
.
_info
=
info
self
.
_tg
config
=
TextgridConfig
()
self
.
_tgsearch
=
TextgridSearch
(
self
.
_tg
config
.
search
)
config
=
TextgridConfig
()
self
.
_tgsearch
=
TextgridSearch
(
config
.
search
)
self
.
_tguri
=
self
.
path
.
split
(
"
/
"
)[
-
1
]
def
create_empty_resource
(
self
,
name
):
...
...
This diff is collapsed.
Click to expand it.
src/repdav/textgrid_named_dav_provider.py
+
4
−
11
View file @
817c67a2
import
logging
from
pprint
import
pformat
from
tgclients.config
import
TextgridConfig
from
tgclients.crud
import
TextgridCRUD
from
tgclients.metadata
import
TextgridMetadata
from
tgclients.auth
import
TextgridAuth
from
wsgidav.util
import
join_uri
from
repdav.stream_tools
import
FileLikeQueue
from
repdav.textgrid_dav_provider
import
(
TextgridAggregation
,
TextgridProject
,
...
...
@@ -43,10 +39,7 @@ class TextgridNamedRoot(TextgridRoot):
"""
def
__init__
(
self
,
path
,
environ
):
# TODO: do not overwrite but move to parent class
super
().
__init__
(
path
,
environ
)
config
=
TextgridConfig
()
self
.
_auth
=
TextgridAuth
(
config
)
def
get_member_names
(
self
):
_logger
.
debug
(
"
Called TextgridNamedRoot.get_member_names(self).
"
)
...
...
@@ -68,13 +61,13 @@ class TextgridNamedProject(TextgridProject):
_logger
.
debug
(
"
Called TextgridNamedProject.__init__(self, %s, environ).
"
,
path
)
super
().
__init__
(
path
,
environ
)
self
.
_tgmeta
=
TextgridMetadata
()
name
=
self
.
path
.
split
(
"
/
"
)[
-
1
]
# the projectID is found between square brackets at the end of the name string
self
.
_project_id
=
name
[
name
.
rfind
(
"
[
"
)
+
1
:
name
.
rfind
(
"
]
"
)]
def
get_member_names
(
self
):
_logger
.
debug
(
"
Called TextgridNamedProject.get_member_names(self).
"
)
name
=
self
.
path
.
split
(
"
/
"
)[
-
1
]
# the projectID is found between square brackets at the end of the name string
project_id
=
name
[
name
.
rfind
(
"
[
"
)
+
1
:
name
.
rfind
(
"
]
"
)]
response
=
self
.
_tgsearch
.
list_project_root
(
project_id
,
self
.
_sid
)
response
=
self
.
_tgsearch
.
list_project_root
(
self
.
_project_id
,
self
.
_sid
)
names
=
[]
for
result
in
response
.
result
:
names
.
append
(
self
.
_tgmeta
.
filename_from_metadata
(
result
))
...
...
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