|
8 | 8 |
|
9 | 9 | from pcbnew import *
|
10 | 10 |
|
| 11 | +# sub folder for our resource files |
| 12 | +_RESOURCE_DIRECTORY = os.path.join("..", "resource") |
| 13 | + |
| 14 | +#https://stackoverflow.com/a/50914550 |
| 15 | +def resource_path(relative_path): |
| 16 | + """ Get absolute path to resource, works for dev and for PyInstaller """ |
| 17 | + base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) |
| 18 | + return os.path.join(base_path, _RESOURCE_DIRECTORY, relative_path) |
| 19 | + |
| 20 | +def get_version(rel_path: str) -> str: |
| 21 | + try: |
| 22 | + with open(resource_path(rel_path), encoding='utf-8') as fp: |
| 23 | + for line in fp.read().splitlines(): |
| 24 | + if line.startswith("__version__"): |
| 25 | + delim = '"' if '"' in line else "'" |
| 26 | + return line.split(delim)[1] |
| 27 | + raise RuntimeError("Unable to find version string.") |
| 28 | + except: |
| 29 | + raise RuntimeError("Unable to find _version.py.") |
| 30 | + |
| 31 | +_APP_VERSION = get_version("_version.py") |
| 32 | + |
11 | 33 | class CAMmer():
|
12 | 34 | def __init__(self):
|
13 | 35 | pass
|
14 | 36 |
|
15 | 37 | def args_parse(self, args):
|
16 | 38 | # set up command-line arguments parser
|
17 | 39 | parser = ArgumentParser(description="A script to generate and zip PCB Gerber and drill files.")
|
| 40 | + parser.add_argument( |
| 41 | + "-v", "--version", action="version", version="%(prog)s " + _APP_VERSION |
| 42 | + ) |
18 | 43 | parser.add_argument(
|
19 | 44 | "-p", "--path", help="Path to the *.kicad_pcb file"
|
20 | 45 | )
|
|
0 commit comments