Skip to content

Commit

Permalink
Fixes for auto_generate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpaletta authored Dec 27, 2023
1 parent 6cd97b3 commit 651a9c1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions generate/auto_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def fread_lines(filename):
"""
Python 2 & 3 agnostic fopen + readlines
"""
if not os.path.exists(filename):
# Safe escape after running clean.
return ""

if version_info[0] >= 3:
f = open(filename, "r", encoding='utf-8', errors='ignore')
else:
Expand All @@ -53,9 +57,10 @@ def fwrite_content(filename, content):
This function will not overwrite the file (and thus not update its modification date)
if the new content is unchanged
"""
old_content = fread_content(filename)
if old_content == content:
return
if os.path.exists(filename):
old_content = fread_content(filename)
if old_content == content:
return

if version_info[0] >= 3:
f = open(filename, "w", encoding='utf-8', errors='ignore')
Expand Down

0 comments on commit 651a9c1

Please sign in to comment.