More fixing paragraph text quotes etc
This commit is contained in:
39
sm2gen.py
39
sm2gen.py
@@ -293,6 +293,43 @@ def get_translation(message="Hello", language="french"):
|
||||
quit()
|
||||
return translated_message
|
||||
|
||||
def check_file_version(filename):
|
||||
#
|
||||
# check modified versusu creation date of file and return +".new" if modified since creation
|
||||
#
|
||||
try:
|
||||
with open(filename, 'r') as file:
|
||||
# Read the first three lines
|
||||
header_lines = [file.readline().strip() for _ in range(3)]
|
||||
|
||||
# Extract the timestamp
|
||||
for line in header_lines:
|
||||
if 'at' in line:
|
||||
# Split at 'at', expect the timestamp to be in the third part
|
||||
timestamp_str = line.split('at')[2].strip()
|
||||
break
|
||||
else:
|
||||
raise ValueError("Invalid file format: no timestamp found.")
|
||||
|
||||
# Convert the string timestamp to a datetime object
|
||||
file_timestamp = datetime.strptime(timestamp_str, '%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# Get the last modified time of the file
|
||||
file_modified_time = datetime.fromtimestamp(os.path.getmtime(filename))
|
||||
|
||||
# Compare the timestamps
|
||||
if file_modified_time > file_timestamp:
|
||||
return f"{filename}.new"
|
||||
else:
|
||||
return filename
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"Error: The file '{filename}' does not exist.")
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def convert_lex_to_dict(pairs_string):
|
||||
# Splitting pairs string by comma and newline, excluding empty lines
|
||||
@@ -315,7 +352,7 @@ if __name__ == "__main__":
|
||||
version_match = re.search(version_pattern, python_version)
|
||||
python_version = version_match.group(0) if version_match else "Unknown"
|
||||
current_datetime = datetime.now()
|
||||
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M")
|
||||
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S")
|
||||
strVersion = (
|
||||
"SM2Gen version:"
|
||||
+ SME2Gen_version
|
||||
|
Reference in New Issue
Block a user