implemented warnings for ambiguous replacements as comments (closes #4)

This commit is contained in:
Klaus Zerwes 2022-09-08 15:43:26 +02:00
parent 40a757e6ad
commit 282e6e8903

View File

@ -101,6 +101,13 @@ argparser.add_argument(
default=False,
help="write back changed files"
)
argparser.add_argument(
'-W', '--no-write-warnings',
dest='writewarnings',
action='store_false',
default=True,
help="do not write warnings as comments to files and diff"
)
argparser.add_argument(
'-b', '--backup-extension',
dest='backupextension',
@ -264,10 +271,14 @@ for f in parsefiles:
else:
print('*', file=sys.stderr, end='', flush=True)
if len(fqcndict[fqcnmodule]) > 1:
warnings.append(
'alternative replacement of %s : %s' %
(fqcnmodule, ' | '.join(fqcndict[fqcnmodule]),)
)
wtxt = ('possible ambiguous replacement: %s : %s' %
(fqcnmodule, ' | '.join(fqcndict[fqcnmodule])))
warnings.append(wtxt)
if args.writewarnings:
if args.writefiles:
print('# %s\n' % wtxt)
if args.printdiff:
changedlines.append('# %s\n' % wtxt)
else:
print('.', file=sys.stderr, end='', flush=True)