mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-15 09:44:47 +02:00
52 lines
1.4 KiB
Python
Executable File
52 lines
1.4 KiB
Python
Executable File
#!/usr/bin/python3
|
|
# Python script to create an empty file
|
|
# with current date as name.
|
|
|
|
# importing datetime module
|
|
from datetime import datetime
|
|
import os
|
|
|
|
# datetime.datetime.now() to get
|
|
# current date as filename.
|
|
# TimeNow = datetime.datetime.now()
|
|
|
|
FILESUBVERSION="../bin/subversion.txt"
|
|
FILEDATE="../bin/date.txt"
|
|
|
|
# create empty file
|
|
def create_file():
|
|
fmt = "%Y-%m-%d %H:%M:%S.%f"
|
|
str1 = datetime.utcnow().strftime(fmt)[:-3]
|
|
|
|
# Function creates an empty file
|
|
# %d - date, %B - month, %Y - Year
|
|
with open(FILEDATE, "w") as file:
|
|
file.write(str1)
|
|
file.close()
|
|
|
|
def set_version():
|
|
filename=FILESUBVERSION
|
|
build=0
|
|
mode = 'r' if os.path.exists(filename) else 'w+'
|
|
with open(filename, encoding="utf8", mode=mode) as file_in:
|
|
_str_build = file_in.read()
|
|
file_in.close()
|
|
try:
|
|
build = int(_str_build)
|
|
except ValueError as err:
|
|
print("Build.__setVers(): при конвертировании строки в число, err=", err)
|
|
finally:
|
|
pass
|
|
build += 1
|
|
str_build = str(build)
|
|
while len(str_build) < 5:
|
|
str_build = "0" + str_build
|
|
print("Build.set_version(): new build=", str_build)
|
|
with open(filename, "w", encoding="utf8") as file_in:
|
|
file_in.write(str_build)
|
|
file_in.close()
|
|
|
|
|
|
# Driver Code
|
|
create_file()
|
|
set_version() |