File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 10
10
pj = os .path .join
11
11
12
12
13
- def backup (src , prefix = "." ):
13
+ def _backup (src , prefix = "." ):
14
14
"""Backup (copy) `src` to <src><prefix><num>, where <num> is an integer
15
15
starting at 0 which is incremented until there is no destination with that
16
16
name.
@@ -43,9 +43,12 @@ def backup(src, prefix="."):
43
43
copy (src , dst )
44
44
45
45
46
- def file_write (fn , txt ):
46
+ def file_write (fn , txt , backup = False ):
47
47
if os .path .exists (fn ):
48
- backup (fn , prefix = ".bak" )
48
+ if backup :
49
+ _backup (fn , prefix = ".bak" )
50
+ else :
51
+ raise Exception (f"file exists: { fn } " )
49
52
with open (fn , "w" ) as fd :
50
53
fd .write (txt )
51
54
@@ -422,4 +425,4 @@ def main():
422
425
package_name = package_name ,
423
426
bar = bar ,
424
427
)
425
- file_write (index_fn , txt )
428
+ file_write (index_fn , txt , backup = True )
You can’t perform that action at this time.
0 commit comments