Skip to content

Commit

Permalink
Running module should back up existing files only
Browse files Browse the repository at this point in the history
Also reduces NULL padding of new files
  • Loading branch information
rdipardo committed Jan 8, 2022
1 parent 7af3547 commit 41a8116
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rplugin/pythonx/cpywrite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def main():
if license_text:
if not path.exists(generator.out_file):
with open(generator.out_file, 'w') as src:
src.truncate(1024)
src.truncate(8)

print("Created new %s file: %s"
% (generator.lang, generator.out_file))

with open(generator.out_file + '.bak', 'w') as bak:
with open(generator.out_file, 'rt') as source:
source_file = source.read()
bak.write(source_file)
else:
with open(generator.out_file + '.bak', 'w') as bak:
with open(generator.out_file, 'rt') as source:
source_file = source.read()
bak.write(source_file)

_, tmp_source = tempfile.mkstemp(text=True)

Expand Down

0 comments on commit 41a8116

Please sign in to comment.