Browse Source

added script for converting windows paths into something readable

master
Holger Frey 2 years ago
parent
commit
e914f7329e
  1. 11
      pyproject.toml
  2. 22
      work_helpers/nice_path.py

11
pyproject.toml

@ -20,11 +20,12 @@ requires = [ @@ -20,11 +20,12 @@ requires = [
[tool.flit.scripts]
nice_path = "work_helpers.nice_path:make_nice_path"
random_password = "work_helpers.password:get_random_password"
sensospot_rename = "work_helpers.sensospot_rename:sensospot_rename"
sg_list_frms = "work_helpers.sg_frm_list:cli"
sg_mbp_new_version = "work_helpers.sg_mbp_release:sg_mbp_new_version"
sg_mbp_release = "work_helpers.sg_mbp_release:sg_mbp_release"
xls2changelog = "work_helpers.excel2changelog:cli"
xls2markdown = "work_helpers.excel2markdown:cli"
xls2pylist = "work_helpers.excel2pylist:cli"
sg_mbp_release = "work_helpers.sg_mbp_release:sg_mbp_release"
sg_mbp_new_version = "work_helpers.sg_mbp_release:sg_mbp_new_version"
sg_list_frms = "work_helpers.sg_frm_list:cli"
random_password = "work_helpers.password:get_random_password"
sensospot_rename = "work_helpers.sensospot_rename:sensospot_rename"

22
work_helpers/nice_path.py

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
""" create a nice path representation from a copied windows path """
import click
import pyperclip
REPLACEMENTS = {
"G:": "Google Drive",
}
def replace(segment, replacements=REPLACEMENTS):
return replacements.get(segment, segment)
@click.command()
@click.option("--separator", default=" / ")
def make_nice_path(separator):
ugly_path = pyperclip.paste()
ugly_segments = ugly_path.split("\\")
pretty_segments = [replace(segment) for segment in ugly_segments]
pretty_path = separator.join(pretty_segments)
pyperclip.copy(pretty_path)
click.echo(f"Copied path '{pretty_path}' to clipboard", err=True)
Loading…
Cancel
Save