Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62956066
config.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, May 16, 18:38
Size
1 KB
Mime Type
text/x-python
Expires
Sat, May 18, 18:38 (2 d)
Engine
blob
Format
Raw Data
Handle
17712308
Attached To
rNIETZSCHEPYTHON nietzsche-python
config.py
View Options
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import
getpass
from
os.path
import
isfile
,
isdir
,
exists
import
re
PROJECT_NAME
=
'tln'
PROJECT_URL
=
'http://www.knora.org/ontology/0068/nietzsche'
DATA_URL
=
'http://rdfh.ch/projects/0068'
ONTOLOGY_DIR
=
'./ontologies'
if
getpass
.
getuser
()
==
'knister0'
else
'./ontologies'
# local onotology dir, script will read only
KNORA_BASE_ONTOLOGY_FILE
=
'{}/knora-ontologies/knora-base.ttl'
.
format
(
ONTOLOGY_DIR
)
SHARED_ONTOLOGIES_DIR
=
'{}/Ontologies-shared'
.
format
(
ONTOLOGY_DIR
)
PROJECT_ONTOLOGY_FILE
=
'./Friedrich-Nietzsche-late-work-ontology.ttl'
PROJECT_ONTOLOGY_FILE_URL
=
'https://raw.githubusercontent.com/knisterstern/nietzsche-stub/main/Friedrich-Nietzsche-late-work-ontology.ttl'
DATATYPES_DIR
=
'./svgscripts/datatypes'
# optional in config file, can be overwritten by passing a <dir> to py2ttl/py2ttl.py
def
check_config_files_exist
():
"""Checks whether all files exist that are specified in this file by uppercase variables ending in 'DIR' or 'FILE'.
:return: exit code (int)
"""
for
key
in
[
key
for
key
in
globals
()
.
keys
()
if
re
.
match
(
r'^[A-Z_-]+(DIR|FILE)$'
,
key
)
]:
if
not
exists
(
globals
()
.
get
(
key
)):
raise
FileNotFoundError
(
'Key {} does not specify an existing file or directory'
.
format
(
key
))
if
key
.
endswith
(
'DIR'
)
and
not
isdir
(
globals
()
.
get
(
key
)):
raise
NotADirectoryError
(
'Key {} does not specify an existing directory'
.
format
(
key
))
return
0
def
get_datatypes_dir
():
"""Returns value of DATATYPES_DIR if set, else None.
"""
if
'DATATYPES_DIR'
in
globals
()
.
keys
():
return
DATATYPES_DIR
.
replace
(
'./'
,
''
)
else
:
None
Event Timeline
Log In to Comment