Files
create/src/Tools/WinVersion.py
Chris Hennes e2bb84fd2f [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

49 lines
1.2 KiB
Python

#! python
# -*- coding: utf-8 -*-
# (c) 2012 Juergen Riegel LGPL
#
# Script to create files used in Windows build
# uses SubWCRev.py for version detection#
import SubWCRev,getopt,sys,string
def main():
input=""
output="."
try:
opts, args = getopt.getopt(sys.argv[1:], "dso:", ["dir=","src=","out="])
except getopt.GetoptError:
pass
for o, a in opts:
if o in ("-d", "--dir"):
print ("The %s option is deprecated. Ignoring." % (o))
if o in ("-s", "--src"):
input = a
if o in ("-o", "--out"):
output = a
git = SubWCRev.GitControl()
if(git.extractInfo(input)):
print(git.hash)
print(git.branch)
print(git.rev[0:4])
print(git.date)
print(git.url)
print(input)
print(output)
f = open(input,'r')
o = open(output,'w')
for line in f.readlines():
line = string.replace(line,'$WCREV$',git.rev[0:4])
line = string.replace(line,'$WCDATE$',git.date)
line = string.replace(line,'$WCURL$',git.url)
o.write(line)
if __name__ == "__main__":
main()