parent
70fb334856
commit
9e4adf5286
|
|
@ -34,8 +34,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- New expansion patterns:
|
||||
- **%g** the `file_id` of the global variant.
|
||||
- **%G** the `name` of the global variant.
|
||||
- **%bc**, **%bd**, **%bf**, **%bF**, **%bp** and **%br** board data
|
||||
- **%sc**, **%sd**, **%sf**, **%sF**, **%sp** and **%sr** schematic data
|
||||
- **%C1**, **%C2**, **%C3** and **%C4** the comments in the sch/pcb title
|
||||
block.
|
||||
- **%bc**, **%bC1**, **%bC2**, **%bC3**, **%bC4**, **%bd**, **%bf**,
|
||||
**%bF**, **%bp** and **%br** board data
|
||||
- **%sc**, **%sC1**, **%sC2**, **%sC3**, **%sC4**, **%sd**, **%sf**,
|
||||
**%sF**, **%sp** and **%sr** schematic data
|
||||
- Now patterns are also expanded in the out_dir name.
|
||||
- Global options to control the date format.
|
||||
- Outputs can use the options of other outputs as base (extend them). (#112)
|
||||
|
|
|
|||
|
|
@ -204,6 +204,10 @@ You can always choose the file name for a particular output.
|
|||
The pattern uses the following expansions:
|
||||
|
||||
- **%c** company from pcb/sch metadata.
|
||||
- **%C1** comments line 1 from pcb/sch metadata.
|
||||
- **%C2** comments line 2 from pcb/sch metadata.
|
||||
- **%C3** comments line 3 from pcb/sch metadata.
|
||||
- **%C4** comments line 4 from pcb/sch metadata.
|
||||
- **%d** pcb/sch date from metadata if available, file modification date otherwise.
|
||||
- **%D** date the script was started.
|
||||
- **%f** original pcb/sch file name without extension.
|
||||
|
|
@ -227,7 +231,7 @@ global:
|
|||
output: '%f_rev_%r-%i.%x'
|
||||
```
|
||||
|
||||
Note that the following patterns: **%c**, **%d**, **%f**, **%F**, **%p** and **%r** depends on the context.
|
||||
Note that the following patterns: **%c**, **%C1**, **%C2**, **%C3**, **%C4**, **%d**, **%f**, **%F**, **%p** and **%r** depends on the context.
|
||||
If you use them for an output related to the PCB these values will be obtained from the PCB.
|
||||
If you need to force the origin of the data you can use **%bX** for the PCB and **%sX** for the schematic, where
|
||||
**X** is the pattern to expand.
|
||||
|
|
|
|||
|
|
@ -183,6 +183,10 @@ You can always choose the file name for a particular output.
|
|||
The pattern uses the following expansions:
|
||||
|
||||
- **%c** company from pcb/sch metadata.
|
||||
- **%C1** comments line 1 from pcb/sch metadata.
|
||||
- **%C2** comments line 2 from pcb/sch metadata.
|
||||
- **%C3** comments line 3 from pcb/sch metadata.
|
||||
- **%C4** comments line 4 from pcb/sch metadata.
|
||||
- **%d** pcb/sch date from metadata if available, file modification date otherwise.
|
||||
- **%D** date the script was started.
|
||||
- **%f** original pcb/sch file name without extension.
|
||||
|
|
@ -206,7 +210,7 @@ global:
|
|||
output: '%f_rev_%r-%i.%x'
|
||||
```
|
||||
|
||||
Note that the following patterns: **%c**, **%d**, **%f**, **%F**, **%p** and **%r** depends on the context.
|
||||
Note that the following patterns: **%c**, **%C1**, **%C2**, **%C3**, **%C4**, **%d**, **%f**, **%F**, **%p** and **%r** depends on the context.
|
||||
If you use them for an output related to the PCB these values will be obtained from the PCB.
|
||||
If you need to force the origin of the data you can use **%bX** for the PCB and **%sX** for the schematic, where
|
||||
**X** is the pattern to expand.
|
||||
|
|
|
|||
20
kibot/gs.py
20
kibot/gs.py
|
|
@ -50,11 +50,19 @@ class GS(object):
|
|||
sch_date = None
|
||||
sch_rev = None
|
||||
sch_comp = None
|
||||
sch_com1 = None
|
||||
sch_com2 = None
|
||||
sch_com3 = None
|
||||
sch_com4 = None
|
||||
# Data from the board title block
|
||||
pcb_title = None
|
||||
pcb_date = None
|
||||
pcb_rev = None
|
||||
pcb_comp = None
|
||||
pcb_com1 = None
|
||||
pcb_com2 = None
|
||||
pcb_com3 = None
|
||||
pcb_com4 = None
|
||||
# Current variant/s
|
||||
variant = None
|
||||
# All the outputs
|
||||
|
|
@ -108,6 +116,10 @@ class GS(object):
|
|||
GS.sch_date = GS.sch.date
|
||||
GS.sch_rev = GS.sch.revision
|
||||
GS.sch_comp = GS.sch.company
|
||||
GS.sch_com1 = GS.sch.comment1
|
||||
GS.sch_com2 = GS.sch.comment2
|
||||
GS.sch_com3 = GS.sch.comment3
|
||||
GS.sch_com4 = GS.sch.comment4
|
||||
|
||||
@staticmethod
|
||||
def load_pcb_title_block():
|
||||
|
|
@ -128,10 +140,18 @@ class GS(object):
|
|||
GS.pcb_title = GS.pcb_basename
|
||||
GS.pcb_rev = title_block.GetRevision()
|
||||
GS.pcb_comp = title_block.GetCompany()
|
||||
GS.pcb_com1 = title_block.GetComment1()
|
||||
GS.pcb_com2 = title_block.GetComment2()
|
||||
GS.pcb_com3 = title_block.GetComment3()
|
||||
GS.pcb_com4 = title_block.GetComment4()
|
||||
logger.debug("PCB title: `{}`".format(GS.pcb_title))
|
||||
logger.debug("PCB date: `{}`".format(GS.pcb_date))
|
||||
logger.debug("PCB revision: `{}`".format(GS.pcb_rev))
|
||||
logger.debug("PCB company: `{}`".format(GS.pcb_comp))
|
||||
logger.debug("PCB comment 1: `{}`".format(GS.pcb_com1))
|
||||
logger.debug("PCB comment 2: `{}`".format(GS.pcb_com2))
|
||||
logger.debug("PCB comment 3: `{}`".format(GS.pcb_com3))
|
||||
logger.debug("PCB comment 4: `{}`".format(GS.pcb_com4))
|
||||
|
||||
@staticmethod
|
||||
def check_pcb():
|
||||
|
|
|
|||
|
|
@ -1440,10 +1440,14 @@ class Schematic(object):
|
|||
while True:
|
||||
line = f.get_line()
|
||||
if line.startswith('$EndDescr'):
|
||||
self.title = self.title_block['Title'] if 'Title' in self.title_block else ''
|
||||
self.date = self.title_block['Date'] if 'Date' in self.title_block else ''
|
||||
self.revision = self.title_block['Rev'] if 'Rev' in self.title_block else ''
|
||||
self.company = self.title_block['Comp'] if 'Comp' in self.title_block else ''
|
||||
self.title = self.title_block.get('Title', '')
|
||||
self.date = self.title_block.get('Date', '')
|
||||
self.revision = self.title_block.get('Rev', '')
|
||||
self.company = self.title_block.get('Comp', '')
|
||||
self.comment1 = self.title_block.get('Comment1', '')
|
||||
self.comment2 = self.title_block.get('Comment2', '')
|
||||
self.comment3 = self.title_block.get('Comment3', '')
|
||||
self.comment4 = self.title_block.get('Comment4', '')
|
||||
return
|
||||
elif line.startswith('encoding'):
|
||||
if line[9:14] != 'utf-8':
|
||||
|
|
|
|||
|
|
@ -218,6 +218,10 @@ class Optionable(object):
|
|||
name = name.replace('%bf', GS.pcb_basename)
|
||||
name = name.replace('%bp', GS.pcb_title)
|
||||
name = name.replace('%br', GS.pcb_rev)
|
||||
name = name.replace('%bC1', GS.pcb_com1)
|
||||
name = name.replace('%bC2', GS.pcb_com2)
|
||||
name = name.replace('%bC3', GS.pcb_com3)
|
||||
name = name.replace('%bC4', GS.pcb_com4)
|
||||
if GS.solved_global_variant:
|
||||
name = name.replace('%g', GS.solved_global_variant.file_id)
|
||||
name = name.replace('%G', GS.solved_global_variant.name)
|
||||
|
|
@ -229,6 +233,10 @@ class Optionable(object):
|
|||
name = name.replace('%sf', GS.sch_basename)
|
||||
name = name.replace('%sp', GS.sch_title)
|
||||
name = name.replace('%sr', GS.sch_rev)
|
||||
name = name.replace('%sC1', GS.sch_com1)
|
||||
name = name.replace('%sC2', GS.sch_com2)
|
||||
name = name.replace('%sC3', GS.sch_com3)
|
||||
name = name.replace('%sC4', GS.sch_com4)
|
||||
name = name.replace('%D', GS.n.strftime(GS.global_date_format))
|
||||
name = name.replace('%T', GS.n.strftime(GS.global_time_format))
|
||||
if self:
|
||||
|
|
@ -247,7 +255,7 @@ class Optionable(object):
|
|||
parent = self._parent
|
||||
logger.debug('Expanding `{}` in PCB context for {} parent: {}'.format(name, self, parent))
|
||||
# Determine if we need to expand SCH and/or PCB related data
|
||||
has_dep_exp = any(map(lambda x: x in name, ['%c', '%d', '%F', '%f', '%p', '%r']))
|
||||
has_dep_exp = any(map(lambda x: x in name, ['%c', '%d', '%F', '%f', '%p', '%r', '%C1', '%C2', '%C3', '%C4']))
|
||||
do_sch = is_sch and has_dep_exp
|
||||
# logger.error(name + ' is_sch ' +str(is_sch)+" "+ str(do_sch))
|
||||
# raise
|
||||
|
|
@ -270,6 +278,10 @@ class Optionable(object):
|
|||
name = name.replace('%f', GS.pcb_basename)
|
||||
name = name.replace('%p', GS.pcb_title)
|
||||
name = name.replace('%r', GS.pcb_rev)
|
||||
name = name.replace('%C1', GS.pcb_com1)
|
||||
name = name.replace('%C2', GS.pcb_com2)
|
||||
name = name.replace('%C3', GS.pcb_com3)
|
||||
name = name.replace('%C4', GS.pcb_com4)
|
||||
if GS.sch and do_sch:
|
||||
name = name.replace('%c', GS.sch_comp)
|
||||
name = name.replace('%d', GS.sch_date)
|
||||
|
|
@ -277,6 +289,10 @@ class Optionable(object):
|
|||
name = name.replace('%f', GS.sch_basename)
|
||||
name = name.replace('%p', GS.sch_title)
|
||||
name = name.replace('%r', GS.sch_rev)
|
||||
name = name.replace('%C1', GS.sch_com1)
|
||||
name = name.replace('%C2', GS.sch_com2)
|
||||
name = name.replace('%C3', GS.sch_com3)
|
||||
name = name.replace('%C4', GS.sch_com4)
|
||||
# sanitize the name to avoid characters illegal in file systems
|
||||
name = name.replace('\\', '/')
|
||||
name = re.sub(r'[?%*:|"<>]', '_', name)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
)
|
||||
|
||||
(page A4)
|
||||
(title_block
|
||||
(comment 2 The_C2)
|
||||
)
|
||||
|
||||
(layers
|
||||
(0 F.Cu signal)
|
||||
(31 B.Cu signal)
|
||||
|
|
|
|||
|
|
@ -856,3 +856,12 @@ def test_disable_default_1(test_dir):
|
|||
ctx.expect_out_file(POS_DIR+'/test_v5_(both_pos).csv')
|
||||
ctx.dont_expect_out_file(POS_DIR+'/test_v5_(bottom_pos).csv')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_expand_comment_1(test_dir):
|
||||
""" Disable in the same file and out-of-order """
|
||||
prj = 'test_v5'
|
||||
ctx = context.TestContext(test_dir, 'test_expand_comment_1', prj, 'expand_comment_1', '')
|
||||
ctx.run(extra=[])
|
||||
ctx.expect_out_file(POS_DIR+'/test_v5_(Comment 1)_(The_C2).csv')
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
kibot:
|
||||
version: 1
|
||||
|
||||
global:
|
||||
output: '%f_(%sC1)_(%bC2).%x'
|
||||
|
||||
outputs:
|
||||
- name: 'position'
|
||||
type: position
|
||||
dir: positiondir
|
||||
options:
|
||||
format: CSV # CSV or ASCII format
|
||||
units: millimeters # millimeters or inches
|
||||
separate_files_for_front_and_back: false
|
||||
only_smd: true
|
||||
Loading…
Reference in New Issue