|
|
|
@ -13,6 +13,21 @@ PATH_WIN_DESKTOP = Path("/mnt/c/Users/Holgi/Desktop")
@@ -13,6 +13,21 @@ PATH_WIN_DESKTOP = Path("/mnt/c/Users/Holgi/Desktop")
|
|
|
|
|
|
|
|
|
|
TODAY = datetime.now().strftime("%y%m%d") |
|
|
|
|
|
|
|
|
|
CRLF = "\r\n" |
|
|
|
|
|
|
|
|
|
EXCEL_CHANGELOGS = { |
|
|
|
|
"changes_hyb_workbook": "J1", |
|
|
|
|
"changes_qc_cy5_workbook": "J1", |
|
|
|
|
"changes_qc_dry_workbook": "L1", |
|
|
|
|
"changes_qc_workbook": "J1", |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
EXCEL_CHANGELOG_HEADERS = [ |
|
|
|
|
"Sheet\tWell\tContents\tComment", |
|
|
|
|
"-----\t----\t--------\t-------", |
|
|
|
|
"", |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _folder_content(folder): |
|
|
|
|
nondotted = (i for i in folder.iterdir() if not i.stem.startswith(".")) |
|
|
|
@ -30,6 +45,55 @@ def get_latest_version(parent=PATH_ISSUES):
@@ -30,6 +45,55 @@ def get_latest_version(parent=PATH_ISSUES):
|
|
|
|
|
return versions[-1] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_next_version(parent=PATH_ISSUES, echo_current=True): |
|
|
|
|
latest = get_latest_version(parent) |
|
|
|
|
if echo_current: |
|
|
|
|
print("current version:", latest) |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
head, tail = latest.rsplit(".", 1) |
|
|
|
|
next_minor = int(tail) + 1 |
|
|
|
|
next_version = f"{head}.{next_minor}" |
|
|
|
|
except: |
|
|
|
|
next_version = "" |
|
|
|
|
|
|
|
|
|
return next_version |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_new_version_folder(new_version, parent=PATH_ISSUES): |
|
|
|
|
new_folder_path = parent / new_version |
|
|
|
|
if new_folder_path.exists(): |
|
|
|
|
print(f"Folder for version {new_version} already exists, aborting") |
|
|
|
|
return |
|
|
|
|
new_folder_path.mkdir() |
|
|
|
|
return new_folder_path |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_excel_changelogs(new_version, parent): |
|
|
|
|
for name, cell in EXCEL_CHANGELOGS.items(): |
|
|
|
|
new_file = parent / f"{name}_{new_version}.txt" |
|
|
|
|
with new_file.open("w") as fh: |
|
|
|
|
data_line = "\t".join(["Settings", cell, new_version, ""]) |
|
|
|
|
content_lines = EXCEL_CHANGELOG_HEADERS + [data_line, "", ""] |
|
|
|
|
fh.write(CRLF.join(content_lines)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_changelog_entry(new_version, parent=PATH_ISSUES): |
|
|
|
|
textfiles = _files_in_folder(parent, ".txt") |
|
|
|
|
changelog = next(f for f in textfiles if f.stem.lower().startswith("change")) |
|
|
|
|
content = [] |
|
|
|
|
with changelog.open("r") as fh: |
|
|
|
|
stripped_lines = (line.rstrip() for line in fh) |
|
|
|
|
for line in stripped_lines: |
|
|
|
|
content.append(line) |
|
|
|
|
if line.startswith("----"): |
|
|
|
|
content.append("") |
|
|
|
|
content.append(f"{new_version}, work in progress:") |
|
|
|
|
content.append(" - describe your changes here") |
|
|
|
|
with changelog.open("w") as fh: |
|
|
|
|
fh.write(CRLF.join(content)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copy_changelog(destination, date, latest): |
|
|
|
|
textfiles = _files_in_folder(PATH_ISSUES, ".txt") |
|
|
|
|
changelog = next(f for f in textfiles if f.stem.lower().startswith("change")) |
|
|
|
@ -60,7 +124,28 @@ def copy_workbooks(destination, date, latest):
@@ -60,7 +124,28 @@ def copy_workbooks(destination, date, latest):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command() |
|
|
|
|
def cli(): |
|
|
|
|
@click.option( |
|
|
|
|
"-v", |
|
|
|
|
"--version", |
|
|
|
|
required=True, |
|
|
|
|
prompt="new version", |
|
|
|
|
default=get_next_version, |
|
|
|
|
show_default="next minor version", |
|
|
|
|
) |
|
|
|
|
def sg_mbp_new_version(version): |
|
|
|
|
""" |
|
|
|
|
creates a new version folder, new excel changes files and modifies the overall changelog |
|
|
|
|
in "E:\Safeguard-MBP-issues" |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
folder = create_new_version_folder(version) |
|
|
|
|
if folder is not None: |
|
|
|
|
create_excel_changelogs(version, folder) |
|
|
|
|
create_changelog_entry(version) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command() |
|
|
|
|
def sg_mbp_release(): |
|
|
|
|
""" |
|
|
|
|
Before running this command: |
|
|
|
|
|
|
|
|
|