@@ -92,7 +92,10 @@ def rewrite_file(infilename, rewritefunc, ctxt):
92
92
infile .close ()
93
93
outfile .close ()
94
94
if not ctxt ["nodelete" ]:
95
- os .remove (infilename )
95
+ if ctxt ["backup" ]:
96
+ os .rename (infilename , infilename + ".bak" )
97
+ else :
98
+ os .remove (infilename )
96
99
os .rename (outfilename , infilename )
97
100
98
101
@@ -105,6 +108,8 @@ def main():
105
108
parser .add_argument ("version" , help = "New version number to add" )
106
109
parser .add_argument ("-n" , "--nodelete" , action = "store_true" ,
107
110
help = "Do not delete existing files, leave new files with .new extension" )
111
+ parser .add_argument ("-b" , "--backup" , action = "store_true" ,
112
+ help = "Keep old versions of files around with a .bak extension" )
108
113
109
114
args = parser .parse_args ()
110
115
@@ -113,7 +118,7 @@ def main():
113
118
print ("Invalid version number {0}: must be three numeric values separated by dots\n " .format (args .version ))
114
119
return 1
115
120
116
- ctxt = {"version" : args .version , "nodelete" : args .nodelete }
121
+ ctxt = {"version" : args .version , "nodelete" : args .nodelete , "backup" : args . backup }
117
122
rewrite_file ("README.md" , readme_rewriter , ctxt )
118
123
rewrite_file ("docs/changelog.rst" , changelog_rewriter , ctxt )
119
124
rewrite_file ("docs/conf.py" , doc_conf_rewriter , ctxt )
0 commit comments