[Diff] Added mechanism to specify the PCB/Schematic in memory
- Now this is the default Closes #295
This commit is contained in:
parent
de4daddc52
commit
a8e48031c8
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -29,7 +29,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- remove_solder_paste_for_dnp
|
||||
- hide_excluded (default value)
|
||||
- Mechanism to give more priority to local globals. (See #291)
|
||||
- Diff: mechanism to compare using a variant (See #278)
|
||||
- Diff:
|
||||
- Mechanism to compare using a variant (See #278)
|
||||
- Mechanism to specify the current PCB/Schematic in memory (See #295)
|
||||
- Sch Variant:
|
||||
- Option to copy the project. Needed for text variables.
|
||||
- Option to change the title (similar to PCB Variant)
|
||||
|
|
@ -45,7 +47,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
(#289 #290)
|
||||
|
||||
### Changed
|
||||
- Diff: when comparing a file now the links says Current/FILE instead of None
|
||||
- Diff:
|
||||
- When comparing a file now the links says Current/FILE instead of None
|
||||
- The default was to compare the current file on storage, now is the current
|
||||
file on memory. It includes the zone refill indicated in the preflights.
|
||||
(See #295)
|
||||
- Now the global `dir` option also applies to the preflights, can be disabled
|
||||
using `use_dir_for_preflights`. (#292)
|
||||
- When importing globals now options that are lists or dicts are merged, not
|
||||
|
|
|
|||
|
|
@ -661,6 +661,7 @@ global:
|
|||
KiCad 6: you should set this in the Board Setup -> Physical Stackup.
|
||||
- `cross_footprints_for_dnp`: [boolean=true] Draw a cross for excluded components in the `Fab` layer.
|
||||
- `cross_no_body`: [boolean=false] Cross components even when they don't have a body. Only for KiCad 6.
|
||||
- `csv_accept_no_ref`: [boolean=false] Accept aggregating CSV files without references (Experimental).
|
||||
- `date_format`: [string='%Y-%m-%d'] Format used for the day we started the script.
|
||||
Is also used for the PCB/SCH date formatting when `time_reformat` is enabled (default behavior).
|
||||
Uses the `strftime` format.
|
||||
|
|
@ -1665,7 +1666,8 @@ Notes:
|
|||
- `fuzz`: [number=5] [0,100] Color tolerance (fuzzyness) for the `stats` mode.
|
||||
- `new`: [string|list(string)] The file you want to compare. Leave it blank for the current PCB/SCH.
|
||||
A list is accepted only for the `multivar` type.
|
||||
- `new_type`: [string='file'] [git,file,output,multivar] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
- `new_type`: [string='current'] [git,file,output,multivar,current] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
Use `current` for the currently loaded PCB/Schematic.
|
||||
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
|
||||
Use `multivar` to compare a set of variants, in this mode `new` is the list of variants.
|
||||
If `old` is also `multivar` then it becomes the reference, otherwise we compare using pairs of variants.
|
||||
|
|
|
|||
|
|
@ -474,11 +474,12 @@ outputs:
|
|||
# [string|list(string)] The file you want to compare. Leave it blank for the current PCB/SCH.
|
||||
# A list is accepted only for the `multivar` type
|
||||
new: ''
|
||||
# [string='file'] [git,file,output,multivar] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
# [string='current'] [git,file,output,multivar,current] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
# Use `current` for the currently loaded PCB/Schematic.
|
||||
# Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
|
||||
# Use `multivar` to compare a set of variants, in this mode `new` is the list of variants.
|
||||
# If `old` is also `multivar` then it becomes the reference, otherwise we compare using pairs of variants
|
||||
new_type: 'file'
|
||||
new_type: 'current'
|
||||
# [string='HEAD'] Reference file. When using git use `HEAD` to refer to the last commit.
|
||||
# Use `HEAD~` to refer the previous to the last commit.
|
||||
# As `HEAD` is for the whole repo you can use `KIBOT_LAST-n` to make
|
||||
|
|
|
|||
|
|
@ -679,7 +679,8 @@ class VariantOptions(BaseOptions):
|
|||
else:
|
||||
m.SetValue(data)
|
||||
|
||||
def save_tmp_board(self, dir=None):
|
||||
@staticmethod
|
||||
def save_tmp_board(dir=None):
|
||||
""" Save the PCB to a temporal file.
|
||||
Advantage: all relative paths inside the file remains valid
|
||||
Disadvantage: the name of the file gets altered """
|
||||
|
|
@ -692,7 +693,8 @@ class VariantOptions(BaseOptions):
|
|||
GS.copy_project(fname)
|
||||
return fname
|
||||
|
||||
def save_tmp_dir_board(self, id):
|
||||
@staticmethod
|
||||
def save_tmp_dir_board(id):
|
||||
""" Save the PCB to a temporal dir.
|
||||
Disadvantage: all relative paths inside the file becomes useless
|
||||
Aadvantage: the name of the file remains the same """
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ from .gs import GS
|
|||
from .kiplot import load_any_sch, run_command, config_output, get_output_dir, run_output
|
||||
from .layer import Layer
|
||||
from .optionable import BaseOptions
|
||||
from .out_base import VariantOptions
|
||||
from .registrable import RegOutput
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
from . import log
|
||||
|
|
@ -60,8 +61,9 @@ class DiffOptions(BaseOptions):
|
|||
self.new = ''
|
||||
""" [string|list(string)] The file you want to compare. Leave it blank for the current PCB/SCH.
|
||||
A list is accepted only for the `multivar` type """
|
||||
self.new_type = 'file'
|
||||
""" [git,file,output,multivar] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
self.new_type = 'current'
|
||||
""" [git,file,output,multivar,current] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
Use `current` for the currently loaded PCB/Schematic.
|
||||
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
|
||||
Use `multivar` to compare a set of variants, in this mode `new` is the list of variants.
|
||||
If `old` is also `multivar` then it becomes the reference, otherwise we compare using pairs of variants """
|
||||
|
|
@ -337,11 +339,26 @@ class DiffOptions(BaseOptions):
|
|||
self.git_hash = out.options.variant.file_id if self.use_file_id else out.options.variant.name+'_variant'
|
||||
return res
|
||||
|
||||
def cache_current(self):
|
||||
""" The file as we interpreted it """
|
||||
if self.pcb:
|
||||
fname, dir_name = VariantOptions.save_tmp_dir_board('diff')
|
||||
else:
|
||||
dir_name = mkdtemp()
|
||||
fname = GS.sch.save_variant(dir_name)
|
||||
try:
|
||||
res = self.cache_file(os.path.join(dir_name, fname))
|
||||
finally:
|
||||
rmtree(dir_name)
|
||||
return res
|
||||
|
||||
def cache_obj(self, name, type):
|
||||
if type == 'git':
|
||||
return self.cache_git(name)
|
||||
if type == 'file':
|
||||
return self.cache_file(name)
|
||||
if type == 'current':
|
||||
return self.cache_current()
|
||||
return self.cache_output(name)
|
||||
|
||||
def create_layers_incl(self, layers):
|
||||
|
|
|
|||
Loading…
Reference in New Issue