Files
create/src/Tools/catfiles.py
Chris Hennes 62bfb44a0d [Tools] Fix static analyis issues
This commit addresses issues identified by LGTM for the various
independent (and mostly-independent) files in the Tools subdirectory.
The vast majority of the issues are trivial, and are things like unused
imports or catching BaseException. There was one true bug identified, a
global variable being changed in a function where it was not marked
global, but it only affected output quantity (the variable is named
"VERBOSE"). A couple of other issues identified variables that appear to
represent no-longer-existing options in the code. The options were left,
but a deprecation printout replaces the variable in the event the option
is provided.
2021-02-28 17:53:04 +01:00

41 lines
1019 B
Python

#! python
# -*- coding: utf-8 -*-
# (c) 2018 Werner Mayer LGPL
#
import sys,getopt
#import os # The code that needs this is commented out
import shutil
def main():
outputfile=""
try:
opts, args = getopt.getopt(sys.argv[1:], "o:", ["outputfile="])
except getopt.GetoptError:
pass
for o, a in opts:
if o in ("-o", "--outputfile"):
outputfile = a
#if os.path.exists(outputfile):
# do_not_create = True
# ts = os.path.getmtime(outputfile)
# for f in args:
# if os.path.getmtime(f) > ts:
# do_not_create = False
# break
#
# if do_not_create:
# print ("Up-to-date file {0}".format(outputfile))
# return
with open(outputfile,'wb') as wfd:
for f in args:
with open(f,'rb') as fd:
shutil.copyfileobj(fd, wfd, 1024*1024*10)
print ("Created file {0}".format(outputfile))
if __name__ == "__main__":
main()