permit overriding config filename/path as argument
This commit is contained in:
parent
1acb693e2b
commit
a5984f0965
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import os.path
|
import os.path
|
||||||
|
import sys
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
@ -30,6 +31,10 @@ class Config:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def load(filename: typing.Optional[str] = None) -> Config:
|
def load(filename: typing.Optional[str] = None) -> Config:
|
||||||
if filename is None:
|
if filename is None:
|
||||||
|
if len(sys.argv) > 0:
|
||||||
|
for name in sys.argv[1:]:
|
||||||
|
if os.path.exists(name):
|
||||||
|
return Config.load(name)
|
||||||
for name in ('capport.yaml', '/etc/capport.yaml'):
|
for name in ('capport.yaml', '/etc/capport.yaml'):
|
||||||
if os.path.exists(name):
|
if os.path.exists(name):
|
||||||
return Config.load(name)
|
return Config.load(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user