mirror of
https://github.com/chocolate-doom/statcheck.git
synced 2024-11-10 07:12:09 +00:00
Split config read function out to separate file.
This commit is contained in:
parent
3243cc4968
commit
4cdadc9b94
2 changed files with 19 additions and 15 deletions
17
common.py
Normal file
17
common.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
from os.path import dirname, join, exists
|
||||
import yaml
|
||||
|
||||
def read_config(path):
|
||||
if path == '':
|
||||
return {}
|
||||
|
||||
# Config deeper in the hierarchy can override config files from
|
||||
# higher up in the hierarchy:
|
||||
result = read_config(dirname(path))
|
||||
config_file = join(path, ".democonfig")
|
||||
if exists(config_file):
|
||||
with open(config_file) as f:
|
||||
result.update(yaml.safe_load(f))
|
||||
|
||||
return result
|
17
testrunner
17
testrunner
|
@ -1,24 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
from os.path import dirname, basename, join, exists
|
||||
from os.path import join
|
||||
import shlex
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
def read_config(path):
|
||||
if path == '':
|
||||
return {}
|
||||
|
||||
# Config deeper in the hierarchy can override config files from
|
||||
# higher up in the hierarchy:
|
||||
result = read_config(dirname(path))
|
||||
config_file = join(path, ".democonfig")
|
||||
if exists(config_file):
|
||||
with open(config_file) as f:
|
||||
result.update(yaml.safe_load(f))
|
||||
|
||||
return result
|
||||
from common import *
|
||||
|
||||
source_port = os.getenv("SOURCE_PORT")
|
||||
assert source_port != "", "SOURCE_PORT environment variable not set."
|
||||
|
|
Loading…
Reference in a new issue