Compare commits
4 Commits
b5c898035a
...
ac41bc7fb6
Author | SHA1 | Date | |
---|---|---|---|
ac41bc7fb6 | |||
d8bb56cb7b | |||
ee19f4b1b1 | |||
7ed282057f |
@ -17,10 +17,9 @@ def main():
|
|||||||
help='userconfig2.cfg config file',
|
help='userconfig2.cfg config file',
|
||||||
dest='file', action='store')
|
dest='file', action='store')
|
||||||
cmdline = parser.parse_args()
|
cmdline = parser.parse_args()
|
||||||
cfg = Conf(cmdline.file)
|
|
||||||
debug = Debug()
|
debug = Debug()
|
||||||
debug.set_verbose(cmdline.verbose)
|
debug.set_verbose(cmdline.verbose)
|
||||||
cfg.set_debug(debug)
|
cfg = Conf(filename=cmdline.file, debug=debug)
|
||||||
uc = Userconfig(cfg)
|
uc = Userconfig(cfg)
|
||||||
|
|
||||||
cfg.debug.stdout(f"Verbose level is {cfg.debug.get_verbose()}", 1)
|
cfg.debug.stdout(f"Verbose level is {cfg.debug.get_verbose()}", 1)
|
||||||
|
@ -14,3 +14,6 @@ userconfig = "cli:main"
|
|||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
packages = [ "userconfig", "cli" ]
|
packages = [ "userconfig", "cli" ]
|
||||||
|
|
||||||
|
[tool.setuptools.data-files]
|
||||||
|
"etc" = [ "userconfig2.conf" ]
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
[Main]
|
|
||||||
configdir = $HOME/.userconfig
|
|
||||||
configfile = userconfig.cfg
|
|
||||||
debug = 0
|
|
||||||
stamp = %userconfig_generated 1.0%
|
|
||||||
stampreplace = $userconfig_stamp$
|
|
@ -1,5 +1,6 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Conf(object):
|
class Conf(object):
|
||||||
@ -14,7 +15,10 @@ class Conf(object):
|
|||||||
if filename:
|
if filename:
|
||||||
filenames.append(filename)
|
filenames.append(filename)
|
||||||
if not force_filename:
|
if not force_filename:
|
||||||
|
if os.path.isfile(f'{os.environ.get("HOME")}/etc/userconfig2.conf'):
|
||||||
filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
|
filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
|
||||||
|
if os.path.isfile(f'{sys.prefix}/etc/userconfig2.conf'):
|
||||||
|
filenames.append(f'{sys.prefix}/etc/userconfig2.conf')
|
||||||
ret = self.set_filenames(filenames)
|
ret = self.set_filenames(filenames)
|
||||||
if not ret:
|
if not ret:
|
||||||
raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')
|
raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')
|
||||||
|
6
userconfig2.conf
Normal file
6
userconfig2.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[userconfig]
|
||||||
|
configdir = %(HOME)s/.userconfig
|
||||||
|
configfile = userconfig2.cfg
|
||||||
|
debug = 0
|
||||||
|
stamp = %%userconfig_generated 1.0%%
|
||||||
|
stampreplace = $userconfig_stamp$
|
Loading…
Reference in New Issue
Block a user