Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65148445
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
Sat, Jun 1, 05:35
Size
1 KB
Mime Type
text/x-python
Expires
Mon, Jun 3, 05:35 (2 d)
Engine
blob
Format
Raw Data
Handle
18012393
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'
ONTOLOGY_DIR
=
'./ontologies'
if
getpass
.
getuser
()
==
'knister0'
else
'./ontologies'
# local onotology dir, script will read only
SHARED_ONTOLOGIES_DIR
=
'{}/Ontologies-shared'
.
format
(
ONTOLOGY_DIR
)
PROJECT_ONTOLOGY_FILE
=
'{}/project-ontologies/nietzsche-ontology.ttl'
.
format
(
ONTOLOGY_DIR
)
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