mirror of
https://github.com/zerwes/ansible-fqcn-converter.git
synced 2025-02-25 18:55:30 -06:00
implemented extrafqcnmapfile
This commit is contained in:
@@ -187,6 +187,12 @@ argparser.add_argument(
|
||||
default=False,
|
||||
help="update the fqcn-map-file"
|
||||
)
|
||||
argparser.add_argument(
|
||||
'-X', '--extra-fqcn-map-file',
|
||||
dest='extrafqcnmapfile',
|
||||
default='extra-fqcn-map.yml',
|
||||
help="add the extra fqcn map while updating the fqcn-map-file"
|
||||
)
|
||||
argparser.add_argument(
|
||||
'-D', '--debug',
|
||||
dest='debug',
|
||||
@@ -252,6 +258,25 @@ if not fqcnmapfile or args.updatefqcnmapfile:
|
||||
else:
|
||||
fqcndict[nonfqcn].append(fqcn)
|
||||
print('%s : %s -> %s' % (modname, nonfqcn, fqcn))
|
||||
|
||||
if args.extrafqcnmapfile:
|
||||
try:
|
||||
with open(args.extrafqcnmapfile, "r", encoding="utf-8") as xfqcnf:
|
||||
print('loading extra fqcn map from %s ...' % args.extrafqcnmapfile)
|
||||
xfqcndict = yaml.load(xfqcnf, Loader=yaml.BaseLoader)
|
||||
for nonfqcn, fqcnlist in xfqcndict.items():
|
||||
if nonfqcn not in fqcndict.keys():
|
||||
fqcndict[nonfqcn] = []
|
||||
for fqcn in fqcnlist:
|
||||
if fqcn not in fqcndict[nonfqcn]:
|
||||
# this defines the precedence of the replacements made
|
||||
if fqcn.startswith('ansible.'):
|
||||
fqcndict[nonfqcn].insert(0, fqcn)
|
||||
else:
|
||||
fqcndict[nonfqcn].append(fqcn)
|
||||
except (FileNotFoundError, KeyError) as fqcnmapfilerror:
|
||||
print(fqcnmapfilerror)
|
||||
|
||||
with open(args.fqcnmapfile, "w", encoding="utf-8") as fqcnmapfile:
|
||||
fqcnmapfile.write(
|
||||
yaml.dump(
|
||||
|
||||
Reference in New Issue
Block a user