Page MenuHomec4science

config.py
No OneTemporary

File Metadata

Created
Tue, May 14, 05:50

config.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import getpass
from os.path import isfile, isdir, exists
import re
KNORA_BASE = 'http://www.knora.org/ontology/knora-base#'
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