Compare commits
No commits in common. "e82fd99a164ba09b7aa08b46d2b08337a838ee6f" and "16020e8fbb20588652371bf07054c05ed3ad7937" have entirely different histories.
e82fd99a16
...
16020e8fbb
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,3 @@ build/
|
||||
.idea/
|
||||
.venv
|
||||
userconfig.egg-info/
|
||||
*.swp
|
||||
|
@ -19,7 +19,6 @@ def main():
|
||||
cmdline = parser.parse_args()
|
||||
cfg = Conf(cmdline.file)
|
||||
debug = Debug()
|
||||
debug.set_verbose(cmdline.verbose)
|
||||
cfg.set_debug(debug)
|
||||
uc = Userconfig(cfg)
|
||||
|
||||
|
@ -7,14 +7,13 @@ class Conf(object):
|
||||
_cfgfiles = []
|
||||
debug = None
|
||||
|
||||
def __init__(self, filename=None, debug=None, force_filename=False):
|
||||
def __init__(self, filename=None, debug=None):
|
||||
if debug:
|
||||
self.set_debug(debug)
|
||||
filenames = []
|
||||
if filename:
|
||||
filenames.append(filename)
|
||||
if not force_filename:
|
||||
filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
|
||||
filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
|
||||
ret = self.set_filenames(filenames)
|
||||
if not ret:
|
||||
raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')
|
||||
|
@ -38,12 +38,12 @@ def get_config(filename, cfg):
|
||||
cfg.debug.stderr("Error reading config file %s" % filename)
|
||||
return False
|
||||
# check for DEST parameter
|
||||
if not ret.check(section="Main", option="dest"):
|
||||
if not ret.check("Main", "dest"):
|
||||
cfg.debug.stderr("No dest in config file %s" % filename)
|
||||
return False
|
||||
# make sure DEST ends with /
|
||||
if not ret.get(section="Main", option="dest").endswith("/"):
|
||||
ret.set(section="Main", option="dest", value=ret.get(section="Main", option="dest")+"/")
|
||||
if not ret.get("Main", "dest").endswith("/"):
|
||||
ret.set("Main", "dest", ret.get("Main", "dest")+"/")
|
||||
return ret
|
||||
|
||||
|
||||
@ -95,14 +95,14 @@ def user_config_generated(filename, cfg):
|
||||
# filename does not exist, so it was not generated by userconfig
|
||||
return False
|
||||
|
||||
if not cfg.check("stamp"):
|
||||
if not cfg.check("Main", "stamp"):
|
||||
# no STAMP in userconfig.cfg, so no way to check if file was generated by userconfig
|
||||
return False
|
||||
|
||||
fp = open(filename, "r")
|
||||
|
||||
for line in fp:
|
||||
if re.search(re.escape(cfg.get("stamp")), line):
|
||||
if re.search(re.escape(cfg.get("Main", "stamp")), line):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user