Page MenuHomec4science

config.py
No OneTemporary

File Metadata

Created
Thu, May 16, 18:38

config.py

#!/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