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
Compare revisions
1.0.2 to 1.1.0
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
dariah-de/textgridrep/repdav
Select target project
No results found
1.1.0
Select Git revision
Swap
Target
dariah-de/textgridrep/repdav
Select target project
dariah-de/textgridrep/repdav
1 result
1.0.2
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.py
+1
-1
1 addition, 1 deletion
src/main.py
src/repdav/textgrid_dav_provider.py
+1
-0
1 addition, 0 deletions
src/repdav/textgrid_dav_provider.py
src/repdav/textgrid_named_dav_provider.py
+186
-0
186 additions, 0 deletions
src/repdav/textgrid_named_dav_provider.py
with
188 additions
and
1 deletion
src/main.py
View file @
9dc9a589
...
@@ -32,7 +32,7 @@ config = {
...
@@ -32,7 +32,7 @@ config = {
"
host
"
:
os
.
getenv
(
"
host
"
)
or
"
localhost
"
,
"
host
"
:
os
.
getenv
(
"
host
"
)
or
"
localhost
"
,
"
port
"
:
int
(
os
.
getenv
(
"
port
"
)
or
"
8080
"
),
"
port
"
:
int
(
os
.
getenv
(
"
port
"
)
or
"
8080
"
),
"
provider_mapping
"
:
{
"
provider_mapping
"
:
{
"
/
"
:
{
"
class
"
:
"
repdav.textgrid_dav_provider.TextgridResourceProvider
"
},
"
/
"
:
{
"
class
"
:
"
repdav.textgrid_
named_
dav_provider.Textgrid
Named
ResourceProvider
"
},
},
},
"
verbose
"
:
4
,
"
verbose
"
:
4
,
"
http_authenticator
"
:
{
"
http_authenticator
"
:
{
...
...
This diff is collapsed.
Click to expand it.
src/repdav/textgrid_dav_provider.py
View file @
9dc9a589
...
@@ -264,6 +264,7 @@ class TextgridResource(DAVNonCollection):
...
@@ -264,6 +264,7 @@ class TextgridResource(DAVNonCollection):
return
self
.
_info
[
self
.
name
][
"
format
"
]
return
self
.
_info
[
self
.
name
][
"
format
"
]
def
get_content
(
self
):
def
get_content
(
self
):
_logger
.
debug
(
"
Called TextgridResource.get_content(self) with path: %s
"
,
self
.
path
)
config
=
TextgridConfig
()
config
=
TextgridConfig
()
crud
=
TextgridCRUD
(
config
.
crud
)
crud
=
TextgridCRUD
(
config
.
crud
)
return
io
.
BytesIO
(
crud
.
read_data
(
self
.
path
.
split
(
"
/
"
)[
-
1
],
self
.
_sid
).
content
)
return
io
.
BytesIO
(
crud
.
read_data
(
self
.
path
.
split
(
"
/
"
)[
-
1
],
self
.
_sid
).
content
)
...
...
This diff is collapsed.
Click to expand it.
src/repdav/textgrid_named_dav_provider.py
0 → 100644
View file @
9dc9a589
import
io
import
logging
import
threading
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
,
TextgridResource
,
TextgridResourceProvider
,
TextgridRoot
,
)
_logger
=
logging
.
getLogger
(
__name__
)
# ============================================================================
# TextgridNamedResourceProvider
# ============================================================================
class
TextgridNamedResourceProvider
(
TextgridResourceProvider
):
"""
DAV provider that serves Textgrid resources.
"""
def
get_resource_inst
(
self
,
path
,
environ
):
_logger
.
debug
(
"
Called TextgridNamedResourceProvider.get_resource_inst(self, %s, %s).
"
,
path
,
pformat
(
environ
),
)
self
.
_count_get_resource_inst
+=
1
root
=
TextgridNamedRoot
(
"
/
"
,
environ
)
# an instance of _DAVResource (i.e. either DAVCollection or DAVNonCollection)
return
root
.
resolve
(
"
/
"
,
path
)
class
TextgridNamedRoot
(
TextgridRoot
):
"""
Top level collection that incorporates Textgrid projects.
This is implemented as READ-ONLY as projects may not be created with webDAV.
"""
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).
"
)
projects
=
[]
for
project
in
tuple
(
self
.
_auth
.
list_assigned_projects
(
self
.
_sid
)):
projects
.
append
(
self
.
_auth
.
get_project_description
(
project
).
name
+
"
[
"
+
project
+
"
]
"
)
_logger
.
debug
(
"
MY PROJECTS: %s
"
,
projects
)
return
projects
def
get_member
(
self
,
name
):
_logger
.
debug
(
"
Called TextgridRoot.get_member(self, %s).
"
,
name
)
return
TextgridNamedProject
(
join_uri
(
self
.
path
,
name
),
self
.
environ
)
class
TextgridNamedProject
(
TextgridProject
):
def
__init__
(
self
,
path
,
environ
):
_logger
.
debug
(
"
Called TextgridNamedProject.__init__(self, %s, environ).
"
,
path
)
super
().
__init__
(
path
,
environ
)
self
.
_tgmeta
=
TextgridMetadata
()
def
get_member_names
(
self
):
_logger
.
debug
(
"
Called TextgridNamedProject.get_member_names(self).
"
)
# names = []
# the item keys are textgrid uris but we want the resource titles only
# for _, member_dict in self._resources.items():
# names.append(member_dict.get("title"))
# return names
#
# path resolution has to be rewritten before we can work with resource titles
name
=
self
.
path
.
split
(
"
/
"
)[
-
1
]
project_id
=
name
[
name
.
rfind
(
"
[
"
)
+
1
:
name
.
rfind
(
"
]
"
)]
response
=
self
.
_tgsearch
.
list_project_root
(
project_id
,
self
.
_sid
)
names
=
[]
for
result
in
response
.
result
:
names
.
append
(
self
.
_tgmeta
.
filename_from_metadata
(
result
))
return
names
def
get_member
(
self
,
name
):
_logger
.
debug
(
"
Called TextgridNamedProject.get_member(self, %s).
"
,
name
)
tguri
=
"
textgrid:
"
+
self
.
_tgmeta
.
id_from_filename
(
name
)
response
=
self
.
_tgsearch
.
info
(
tguri
,
self
.
_sid
)
info
=
{
name
:
{
"
title
"
:
response
.
result
[
0
].
object_value
.
generic
.
provided
.
title
,
"
format
"
:
response
.
result
[
0
].
object_value
.
generic
.
provided
.
format
,
"
extent
"
:
response
.
result
[
0
].
object_value
.
generic
.
generated
.
extent
,
}
}
_logger
.
info
(
"
INFO: %s
"
,
info
)
if
"
aggregation
"
in
info
[
name
][
"
format
"
]:
return
TextgridNamedAggregation
(
join_uri
(
self
.
path
,
name
),
self
.
environ
,
info
,
self
.
_tgmeta
)
return
TextgridNamedResource
(
join_uri
(
self
.
path
,
name
),
self
.
environ
,
info
,
self
.
_tgmeta
)
class
TextgridNamedAggregation
(
TextgridAggregation
):
def
__init__
(
self
,
path
,
environ
,
info
,
tgmeta
):
_logger
.
debug
(
"
Called TextgridNamedAggregation.__init__(self, %s, environ, info).
"
,
path
)
super
().
__init__
(
path
,
environ
,
info
)
self
.
_tgmeta
=
tgmeta
def
get_member_names
(
self
):
_logger
.
debug
(
"
Called TextgridNamedAggregation.get_member_names(self).
"
)
tguri
=
"
textgrid:
"
+
self
.
_tgmeta
.
id_from_filename
(
self
.
path
.
split
(
"
/
"
)[
-
1
])
response
=
self
.
_tgsearch
.
list_aggregation
(
tguri
,
self
.
_sid
)
names
=
[]
for
result
in
response
.
result
:
names
.
append
(
self
.
_tgmeta
.
filename_from_metadata
(
result
))
return
names
def
get_member
(
self
,
name
):
_logger
.
debug
(
"
Called TextgridNamedAggregation.get_member(self, %s).
"
,
name
)
tguri
=
"
textgrid:
"
+
self
.
_tgmeta
.
id_from_filename
(
name
)
response
=
self
.
_tgsearch
.
info
(
tguri
,
self
.
_sid
)
info
=
{
name
:
{
"
title
"
:
response
.
result
[
0
].
object_value
.
generic
.
provided
.
title
,
"
format
"
:
response
.
result
[
0
].
object_value
.
generic
.
provided
.
format
,
"
extent
"
:
response
.
result
[
0
].
object_value
.
generic
.
generated
.
extent
,
}
}
_logger
.
info
(
"
INFO: %s
"
,
info
)
if
"
aggregation
"
in
info
[
name
][
"
format
"
]:
return
TextgridNamedAggregation
(
join_uri
(
self
.
path
,
name
),
self
.
environ
,
info
,
self
.
_tgmeta
)
return
TextgridNamedResource
(
join_uri
(
self
.
path
,
name
),
self
.
environ
,
info
,
self
.
_tgmeta
)
class
TextgridNamedResource
(
TextgridResource
):
"""
Non-Aggregation resources.
"""
def
__init__
(
self
,
path
,
environ
,
info
,
tgmeta
):
_logger
.
debug
(
"
Called TextgridNamedResource.__init__(self, %s, environ).
"
,
path
)
super
().
__init__
(
path
,
environ
,
info
)
self
.
_tgmeta
=
tgmeta
config
=
TextgridConfig
()
self
.
_crud
=
TextgridCRUD
(
config
.
crud
)
def
get_content
(
self
):
_logger
.
debug
(
"
Called TextgridNamedResource.get_content(self) with path: %s
"
,
self
.
path
)
# TODO: make tguri (super!) class member
tguri
=
"
textgrid:
"
+
self
.
_tgmeta
.
id_from_filename
(
self
.
path
.
split
(
"
/
"
)[
-
1
])
return
io
.
BytesIO
(
self
.
_crud
.
read_data
(
tguri
,
self
.
_sid
).
content
)
def
begin_write
(
self
,
content_type
=
None
):
_logger
.
debug
(
"
Called TextgridResource.begin_write(self, content_type=%s).
"
,
content_type
)
queue
=
FileLikeQueue
(
int
(
self
.
_size
))
tguri
=
"
textgrid:
"
+
self
.
_tgmeta
.
id_from_filename
(
self
.
path
.
split
(
"
/
"
)[
-
1
])
metadata
=
self
.
_crud
.
read_metadata
(
tguri
,
self
.
_sid
).
content
def
worker
():
_logger
.
debug
(
"
Called TextgridResource.begin_write.worker().
"
)
self
.
_crud
.
update_resource
(
self
.
_sid
,
tguri
,
queue
,
metadata
)
thread
=
threading
.
Thread
(
target
=
worker
)
thread
.
setDaemon
(
True
)
thread
.
start
()
self
.
upload_thread
=
thread
return
queue
This diff is collapsed.
Click to expand it.
Prev
1
2
Next