|
|
@ -14,9 +14,11 @@ col_start = "A" |
|
|
|
row_start = 8 |
|
|
|
row_start = 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def text_to_changelog(raw_text, sheet, start_column, start_row): |
|
|
|
def text_to_changelog(raw_text, sheet, start_column, start_row, compact=False): |
|
|
|
cells = [line.split("\t") for line in raw_text.splitlines()] |
|
|
|
cells = [line.split("\t") for line in raw_text.splitlines()] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xls_sep = "!" if compact else "\t" |
|
|
|
|
|
|
|
|
|
|
|
output = [] |
|
|
|
output = [] |
|
|
|
current_row = 1 |
|
|
|
current_row = 1 |
|
|
|
columns_start_index = EXCEL_COLUMNS.index(start_column) |
|
|
|
columns_start_index = EXCEL_COLUMNS.index(start_column) |
|
|
@ -24,13 +26,14 @@ def text_to_changelog(raw_text, sheet, start_column, start_row): |
|
|
|
|
|
|
|
|
|
|
|
for row, line in enumerate(cells, start=start_row): |
|
|
|
for row, line in enumerate(cells, start=start_row): |
|
|
|
if row != current_row: |
|
|
|
if row != current_row: |
|
|
|
|
|
|
|
if not compact: |
|
|
|
output.append("") |
|
|
|
output.append("") |
|
|
|
current_row = row |
|
|
|
current_row = row |
|
|
|
for column, cell in zip(columns_used, line): |
|
|
|
for column, cell in zip(columns_used, line): |
|
|
|
cell = cell.strip() |
|
|
|
cell = cell.strip() |
|
|
|
if not cell: |
|
|
|
if not cell: |
|
|
|
continue |
|
|
|
continue |
|
|
|
output.append(f"{sheet}\t{column}{row}\t{cell}") |
|
|
|
output.append(f"{sheet}{xls_sep}{column}{row}\t{cell}") |
|
|
|
|
|
|
|
|
|
|
|
iterator = iter(output) |
|
|
|
iterator = iter(output) |
|
|
|
prev = next(iterator) |
|
|
|
prev = next(iterator) |
|
|
@ -42,9 +45,9 @@ def text_to_changelog(raw_text, sheet, start_column, start_row): |
|
|
|
prev = current |
|
|
|
prev = current |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clipboard_to_changelog(sheet, start_column, start_row): |
|
|
|
def clipboard_to_changelog(sheet, start_column, start_row, compact=False): |
|
|
|
xls = pyperclip.paste() |
|
|
|
xls = pyperclip.paste() |
|
|
|
result = list(text_to_changelog(xls, sheet, start_column, start_row)) |
|
|
|
result = list(text_to_changelog(xls, sheet, start_column, start_row, compact)) |
|
|
|
line_count = len(result) |
|
|
|
line_count = len(result) |
|
|
|
if line_count == 1: |
|
|
|
if line_count == 1: |
|
|
|
print(f"Copied one line to the clipboard") |
|
|
|
print(f"Copied one line to the clipboard") |
|
|
@ -63,7 +66,8 @@ def clipboard_to_changelog(sheet, start_column, start_row): |
|
|
|
@click.command() |
|
|
|
@click.command() |
|
|
|
@click.option("-s", "--sheet", prompt=True, required=True, default="Input_Data_*") |
|
|
|
@click.option("-s", "--sheet", prompt=True, required=True, default="Input_Data_*") |
|
|
|
@click.option("-w", "--well", prompt=True, required=True, default="A1") |
|
|
|
@click.option("-w", "--well", prompt=True, required=True, default="A1") |
|
|
|
def cli(sheet, well): |
|
|
|
@click.option("-c", "--compact", is_flag=True) |
|
|
|
|
|
|
|
def cli(sheet, well, compact): |
|
|
|
regex_well = r"(?P<column>[A-Z]{1,2})(?P<row>\d+)" |
|
|
|
regex_well = r"(?P<column>[A-Z]{1,2})(?P<row>\d+)" |
|
|
|
match = re.match(regex_well, well.upper()) |
|
|
|
match = re.match(regex_well, well.upper()) |
|
|
|
if match is None: |
|
|
|
if match is None: |
|
|
@ -71,4 +75,4 @@ def cli(sheet, well): |
|
|
|
regex_result = match.groupdict() |
|
|
|
regex_result = match.groupdict() |
|
|
|
start_column = regex_result["column"] |
|
|
|
start_column = regex_result["column"] |
|
|
|
start_row = int(regex_result["row"]) |
|
|
|
start_row = int(regex_result["row"]) |
|
|
|
clipboard_to_changelog(sheet, start_column, start_row) |
|
|
|
clipboard_to_changelog(sheet, start_column, start_row, compact) |
|
|
|