mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-15 19:22:21 -06:00
37 lines
748 B
Python
37 lines
748 B
Python
import fileinput
|
|
import sys, getopt
|
|
|
|
# Store input and output file names
|
|
infile=''
|
|
outfile=''
|
|
searchExp=''
|
|
replaceExp=''
|
|
|
|
# Read command line args
|
|
myopts, args = getopt.getopt(sys.argv[1:],"i:o:s:r:")
|
|
|
|
###############################
|
|
# o == option
|
|
# a == argument passed to the o
|
|
###############################
|
|
for o, a in myopts:
|
|
if o == '-i':
|
|
infile=a
|
|
elif o == '-o':
|
|
outfile=a
|
|
elif o == '-s':
|
|
searchExp=a
|
|
elif o == '-r':
|
|
replaceExp=a
|
|
else:
|
|
print("Usage: %s -i input -o output" % sys.argv[0])
|
|
|
|
# Display input and output file name passed as the args
|
|
|
|
f1 = open(infile, 'r')
|
|
f2 = open(outfile, 'w')
|
|
for line in f1:
|
|
f2.write(line.replace(searchExp,replaceExp))
|
|
f1.close()
|
|
f2.close()
|