[Added] Expansion pattern **%M**
- Directory where the pcb/sch resides. Only the last component i.e. /a/b/c/name.kicad_pcb -> c Closes #421
This commit is contained in:
parent
3b0a26c7ab
commit
124fc8e7b5
|
|
@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Support for time stamp in the date (i.e. 2023-04-02T09:22-03:00)
|
||||
- Support to pass variables to the 3D models download URL (#414)
|
||||
- Support for netclass flags (#418)
|
||||
- Expansion patterns:
|
||||
- **%M** directory where the pcb/sch resides. Only the last component
|
||||
i.e. /a/b/c/name.kicad_pcb -> c (#421)
|
||||
- Command line:
|
||||
- `--banner N` Option to display a banner
|
||||
- `--log FILE` Option to log to a file, in addition to the stderr
|
||||
|
|
|
|||
|
|
@ -619,7 +619,8 @@ The pattern uses the following expansions:
|
|||
- **%G** the `name` of the global variant.
|
||||
- **%i** a contextual ID, depends on the output type.
|
||||
- **%I** an ID defined by the user for this output.
|
||||
- **%p** pcb/sch title from pcb metadata.
|
||||
- **%M** directory where the pcb/sch resides. Only the last component i.e. /a/b/c/name.kicad_pcb -> c
|
||||
- **%p** title from pcb/sch metadata.
|
||||
- **%r** revision from pcb/sch metadata.
|
||||
- **%S** sub-PCB name (related to multiboards).
|
||||
- **%T** time the script was started.
|
||||
|
|
|
|||
|
|
@ -387,7 +387,8 @@ The pattern uses the following expansions:
|
|||
- **%G** the `name` of the global variant.
|
||||
- **%i** a contextual ID, depends on the output type.
|
||||
- **%I** an ID defined by the user for this output.
|
||||
- **%p** pcb/sch title from pcb metadata.
|
||||
- **%M** directory where the pcb/sch resides. Only the last component i.e. /a/b/c/name.kicad_pcb -> c
|
||||
- **%p** title from pcb/sch metadata.
|
||||
- **%r** revision from pcb/sch metadata.
|
||||
- **%S** sub-PCB name (related to multiboards).
|
||||
- **%T** time the script was started.
|
||||
|
|
|
|||
|
|
@ -50,15 +50,18 @@ class GS(object):
|
|||
pcb_no_ext = None # /.../dir/pcb
|
||||
pcb_dir = None # /.../dir
|
||||
pcb_basename = None # pcb
|
||||
pcb_last_dir = None # dir
|
||||
# SCH name and useful parts
|
||||
sch_file = None # /.../dir/file.sch
|
||||
sch_no_ext = None # /.../dir/file
|
||||
sch_dir = None # /.../dir
|
||||
sch_last_dir = None # dir
|
||||
sch_basename = None # file
|
||||
# Project and useful parts
|
||||
pro_file = None # /.../dir/file.kicad_pro (or .pro)
|
||||
pro_no_ext = None # /.../dir/file
|
||||
pro_dir = None # /.../dir
|
||||
pro_last_dir = None # dir
|
||||
pro_basename = None # file
|
||||
pro_ext = '.pro'
|
||||
pro_variables = None # KiCad 6 text variables defined in the project
|
||||
|
|
@ -184,6 +187,7 @@ class GS(object):
|
|||
GS.sch_basename = os.path.splitext(os.path.basename(name))[0]
|
||||
GS.sch_no_ext = os.path.splitext(name)[0]
|
||||
GS.sch_dir = os.path.dirname(name)
|
||||
GS.sch_last_dir = os.path.basename(GS.sch_dir)
|
||||
|
||||
@staticmethod
|
||||
def set_pcb(name):
|
||||
|
|
@ -193,6 +197,7 @@ class GS(object):
|
|||
GS.pcb_basename = os.path.splitext(os.path.basename(name))[0]
|
||||
GS.pcb_no_ext = os.path.splitext(name)[0]
|
||||
GS.pcb_dir = os.path.dirname(name)
|
||||
GS.pcb_last_dir = os.path.basename(GS.pcb_dir)
|
||||
|
||||
@staticmethod
|
||||
def set_pro(name):
|
||||
|
|
@ -202,6 +207,7 @@ class GS(object):
|
|||
GS.pro_basename = os.path.splitext(os.path.basename(name))[0]
|
||||
GS.pro_no_ext = os.path.splitext(name)[0]
|
||||
GS.pro_dir = os.path.dirname(name)
|
||||
GS.pro_last_dir = os.path.basename(GS.pro_dir)
|
||||
|
||||
@staticmethod
|
||||
def load_pro_variables():
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from . import log
|
|||
logger = log.get_logger()
|
||||
HEX_DIGIT = '[A-Fa-f0-9]{2}'
|
||||
INVALID_CHARS = r'[?%*:|"<>]'
|
||||
PATTERNS_DEP = ['%c', '%d', '%F', '%f', '%p', '%r']
|
||||
PATTERNS_DEP = ['%c', '%d', '%F', '%f', '%M', '%p', '%r']
|
||||
for n in range(1, 10):
|
||||
PATTERNS_DEP.append('%C'+str(n))
|
||||
|
||||
|
|
@ -370,6 +370,7 @@ class Optionable(object):
|
|||
name = name.replace('%d', _cl(GS.pcb_date))
|
||||
name = name.replace('%F', GS.pcb_no_ext)
|
||||
name = name.replace('%f', GS.pcb_basename)
|
||||
name = name.replace('%M', GS.pcb_last_dir)
|
||||
name = name.replace('%p', _cl(GS.pcb_title))
|
||||
name = name.replace('%r', _cl(GS.pcb_rev))
|
||||
for num, val in enumerate(GS.pcb_com):
|
||||
|
|
@ -379,6 +380,7 @@ class Optionable(object):
|
|||
name = name.replace('%d', _cl(GS.sch_date))
|
||||
name = name.replace('%F', GS.sch_no_ext)
|
||||
name = name.replace('%f', GS.sch_basename)
|
||||
name = name.replace('%M', GS.sch_last_dir)
|
||||
name = name.replace('%p', _cl(GS.sch_title))
|
||||
name = name.replace('%r', _cl(GS.sch_rev))
|
||||
for num, val in enumerate(GS.sch_com):
|
||||
|
|
|
|||
Loading…
Reference in New Issue