Simplified the code that detects KiCad v6
This commit is contained in:
parent
927ed3c99e
commit
6e5176b273
|
|
@ -73,7 +73,7 @@ logger = log.init()
|
|||
from .docopt import docopt
|
||||
from .gs import (GS)
|
||||
from .misc import (NO_PCB_FILE, NO_SCH_FILE, EXIT_BAD_ARGS, W_VARSCH, W_VARCFG, W_VARPCB, NO_PCBNEW_MODULE,
|
||||
KICAD_VERSION_5_99, W_NOKIVER, hide_stderr)
|
||||
W_NOKIVER, hide_stderr)
|
||||
from .pre_base import (BasePreFlight)
|
||||
from .config_reader import (CfgYamlReader, print_outputs_help, print_output_help, print_preflights_help, create_example,
|
||||
print_filters_help)
|
||||
|
|
@ -249,7 +249,7 @@ def detect_kicad():
|
|||
# KICAD_PATH isn't good on my system.
|
||||
# The kicad-nightly package overwrites the regular package!!
|
||||
GS.kicad_share_path = '/usr/share/kicad'
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
GS.kicad_conf_path = pcbnew.GetSettingsManager().GetUserSettingsPath()
|
||||
if nightly:
|
||||
# Nightly Debian packages uses `/usr/share/kicad-nightly/kicad-nightly.env` as an environment extension
|
||||
|
|
|
|||
10
kibot/gs.py
10
kibot/gs.py
|
|
@ -138,7 +138,7 @@ class GS(object):
|
|||
|
||||
@staticmethod
|
||||
def get_pcb_comment(title_block, num):
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
# Backward compatibility ... what's this?
|
||||
return title_block.GetComment(num)
|
||||
if num == 1:
|
||||
|
|
@ -151,13 +151,13 @@ class GS(object):
|
|||
|
||||
@staticmethod
|
||||
def get_modules():
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
return GS.board.GetFootprints()
|
||||
return GS.board.GetModules()
|
||||
|
||||
@staticmethod
|
||||
def get_modules_board(board):
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
return board.GetFootprints()
|
||||
return board.GetModules()
|
||||
|
||||
|
|
@ -165,6 +165,10 @@ class GS(object):
|
|||
def ki6():
|
||||
return GS.kicad_version_n >= KICAD_VERSION_5_99
|
||||
|
||||
@staticmethod
|
||||
def ki5():
|
||||
return GS.kicad_version_n < KICAD_VERSION_5_99
|
||||
|
||||
@staticmethod
|
||||
def load_pcb_title_block():
|
||||
if GS.pcb_title is not None:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from collections import OrderedDict
|
|||
|
||||
from .gs import GS
|
||||
from .misc import (PLOT_ERROR, MISSING_TOOL, CMD_EESCHEMA_DO, URL_EESCHEMA_DO, CORRUPTED_PCB,
|
||||
EXIT_BAD_ARGS, CORRUPTED_SCH, EXIT_BAD_CONFIG, WRONG_INSTALL, UI_SMD, UI_VIRTUAL, KICAD_VERSION_5_99,
|
||||
EXIT_BAD_ARGS, CORRUPTED_SCH, EXIT_BAD_CONFIG, WRONG_INSTALL, UI_SMD, UI_VIRTUAL,
|
||||
MOD_SMD, MOD_THROUGH_HOLE, MOD_VIRTUAL, W_PCBNOSCH, W_NONEEDSKIP, W_WRONGCHAR, name2make, W_TIMEOUT,
|
||||
W_KIAUTO)
|
||||
from .error import PlotError, KiPlotConfigurationError, config_error, trace_dump
|
||||
|
|
@ -276,7 +276,7 @@ def get_board_comps_data(comps):
|
|||
c.bottom = m.IsFlipped()
|
||||
c.footprint_rot = m.GetOrientationDegrees()
|
||||
attrs = m.GetAttributes()
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
# KiCad 5
|
||||
if attrs == UI_SMD:
|
||||
c.smd = True
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
import pcbnew
|
||||
from .optionable import Optionable
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99, W_NOTASCII
|
||||
from .misc import W_NOTASCII
|
||||
from re import match
|
||||
from .error import (PlotError, KiPlotConfigurationError)
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
|
|
@ -189,7 +189,7 @@ class Layer(Optionable):
|
|||
elif layer in Layer._pcb_layers:
|
||||
ext = [Layer.create_layer(layer)]
|
||||
# Give compatibility for the KiCad 5 default names (automagically renamed by KiCad 6)
|
||||
elif GS.kicad_version_n >= KICAD_VERSION_5_99 and layer in Layer.KICAD6_RENAME: # pragma: no cover (Ki6)
|
||||
elif GS.ki6() and layer in Layer.KICAD6_RENAME: # pragma: no cover (Ki6)
|
||||
ext = [Layer.create_layer(Layer.KICAD6_RENAME[layer])]
|
||||
elif layer in Layer.DEFAULT_LAYER_NAMES:
|
||||
ext = [Layer.create_layer(layer)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from pcbnew import (PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER, PLOT
|
|||
PLOT_FORMAT_PDF, wxPoint)
|
||||
from .optionable import (Optionable, BaseOptions)
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99
|
||||
from .macros import macros, document # noqa: F401
|
||||
from . import log
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ class DrillReport(Optionable):
|
|||
|
||||
|
||||
def get_aux_origin(board):
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
settings = board.GetDesignSettings()
|
||||
return settings.GetAuxOrigin()
|
||||
return board.GetAuxOrigin()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from .out_base import BaseOutput, VariantOptions
|
|||
from .error import PlotError, KiPlotConfigurationError
|
||||
from .layer import Layer
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99, W_NOLAYER
|
||||
from .misc import W_NOLAYER
|
||||
from .macros import macros, document # noqa: F401
|
||||
from . import log
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class AnyLayerOptions(VariantOptions):
|
|||
po.SetPlotValue(self.plot_footprint_values)
|
||||
po.SetPlotInvisibleText(self.force_plot_invisible_refs_vals)
|
||||
po.SetExcludeEdgeLayer(self.exclude_edge_layer)
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
po.SetPlotPadsOnSilkLayer(not self.exclude_pads_from_silkscreen)
|
||||
po.SetPlotViaOnMaskLayer(not self.tent_vias)
|
||||
# Only useful for gerber outputs
|
||||
|
|
@ -230,7 +230,7 @@ class AnyLayerOptions(VariantOptions):
|
|||
self.force_plot_invisible_refs_vals = po.GetPlotInvisibleText()
|
||||
# viasonmask
|
||||
self.tent_vias = not po.GetPlotViaOnMaskLayer()
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
# padsonsilk
|
||||
self.exclude_pads_from_silkscreen = not po.GetPlotPadsOnSilkLayer()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import os
|
|||
from copy import deepcopy
|
||||
from .gs import GS
|
||||
from .kiplot import load_sch, get_board_comps_data
|
||||
from .misc import Rect, KICAD_VERSION_5_99, W_WRONGPASTE
|
||||
from .misc import Rect, W_WRONGPASTE
|
||||
if not GS.kicad_version_n:
|
||||
# When running the regression tests we need it
|
||||
from kibot.__main__ import detect_kicad
|
||||
detect_kicad()
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
# New name, no alias ...
|
||||
from pcbnew import FP_SHAPE, wxPoint, LSET
|
||||
else:
|
||||
|
|
@ -184,7 +184,7 @@ class VariantOptions(BaseOptions):
|
|||
|
||||
@staticmethod
|
||||
def create_module_element(m):
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99:
|
||||
if GS.ki6():
|
||||
return FP_SHAPE(m) # pragma: no cover (Ki6)
|
||||
return EDGE_MODULE(m)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ from pcbnew import PLOT_FORMAT_DXF, SKETCH, FILLED
|
|||
from .out_any_layer import AnyLayer
|
||||
from .drill_marks import DrillMarks
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
|
||||
if GS.ki6(): # pragma: no cover (Ki6)
|
||||
from pcbnew import DXF_UNITS_MILLIMETERS, DXF_UNITS_INCHES
|
||||
else:
|
||||
DXF_UNITS_MILLIMETERS = 1
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
# Adapted from: https://github.com/johnbeard/kiplot
|
||||
from pcbnew import (PLOT_FORMAT_GERBER, FromMM, ToMM)
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99
|
||||
from .out_any_layer import (AnyLayer, AnyLayerOptions)
|
||||
from .error import KiPlotConfigurationError
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
|
|
@ -62,7 +61,7 @@ class GerberOptions(AnyLayerOptions):
|
|||
po.SetIncludeGerberNetlistInfo(self.use_gerber_net_attributes)
|
||||
po.SetUseAuxOrigin(self.use_aux_axis_as_origin)
|
||||
po.SetDrillMarksType(0)
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
po.SetLineWidth(FromMM(self.line_width))
|
||||
else:
|
||||
po.SetDisableGerberMacros(self.disable_aperture_macros) # pragma: no cover (Ki6)
|
||||
|
|
@ -84,7 +83,7 @@ class GerberOptions(AnyLayerOptions):
|
|||
self.subtract_mask_from_silk = po.GetSubtractMaskFromSilk()
|
||||
# useauxorigin
|
||||
self.use_aux_axis_as_origin = po.GetUseAuxOrigin()
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
# linewidth
|
||||
self.line_width = ToMM(po.GetLineWidth())
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from pcbnew import (PLOT_FORMAT_PDF, FromMM, ToMM)
|
|||
from .out_any_layer import AnyLayer
|
||||
from .drill_marks import DrillMarks
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
from . import log
|
||||
|
||||
|
|
@ -31,14 +30,14 @@ class PDFOptions(DrillMarks):
|
|||
def _configure_plot_ctrl(self, po, output_dir):
|
||||
super()._configure_plot_ctrl(po, output_dir)
|
||||
po.SetMirror(self.mirror_plot)
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
po.SetLineWidth(FromMM(self.line_width))
|
||||
po.SetNegative(self.negative_plot)
|
||||
|
||||
def read_vals_from_po(self, po):
|
||||
super().read_vals_from_po(po)
|
||||
self.mirror_plot = po.GetMirror()
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
self.line_width = ToMM(po.GetLineWidth())
|
||||
self.negative_plot = po.GetNegative()
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from .pre_base import BasePreFlight
|
|||
from .error import (KiPlotConfigurationError)
|
||||
from .gs import (GS)
|
||||
from .kiplot import check_script, exec_with_retry, add_extra_options
|
||||
from .misc import (CMD_PCBNEW_PRINT_LAYERS, URL_PCBNEW_PRINT_LAYERS, PDF_PCB_PRINT, KICAD_VERSION_5_99)
|
||||
from .misc import (CMD_PCBNEW_PRINT_LAYERS, URL_PCBNEW_PRINT_LAYERS, PDF_PCB_PRINT)
|
||||
from .out_base import VariantOptions
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
from .layer import Layer
|
||||
|
|
@ -65,7 +65,7 @@ class PDF_Pcb_PrintOptions(VariantOptions):
|
|||
|
||||
@staticmethod
|
||||
def _copy_project(fname):
|
||||
pro_ext = '.kicad_pro' if GS.kicad_version_n >= KICAD_VERSION_5_99 else '.pro'
|
||||
pro_ext = '.kicad_pro' if GS.ki6() else '.pro'
|
||||
pro_name = GS.pcb_file.replace('.kicad_pcb', pro_ext)
|
||||
if not os.path.isfile(pro_name):
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from datetime import datetime
|
|||
from pcbnew import IU_PER_MM, IU_PER_MILS
|
||||
from collections import OrderedDict
|
||||
from .gs import GS
|
||||
from .misc import UI_SMD, UI_VIRTUAL, KICAD_VERSION_5_99, MOD_THROUGH_HOLE, MOD_SMD, MOD_EXCLUDE_FROM_POS_FILES
|
||||
from .misc import UI_SMD, UI_VIRTUAL, MOD_THROUGH_HOLE, MOD_SMD, MOD_EXCLUDE_FROM_POS_FILES
|
||||
from .optionable import Optionable
|
||||
from .out_base import VariantOptions
|
||||
from .error import KiPlotConfigurationError
|
||||
|
|
@ -201,7 +201,7 @@ class PositionOptions(VariantOptions):
|
|||
|
||||
@staticmethod
|
||||
def get_attr_tests():
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
return PositionOptions.is_pure_smd_5, PositionOptions.is_not_virtual_5
|
||||
return PositionOptions.is_pure_smd_6, PositionOptions.is_not_virtual_6 # pragma: no cover (Ki6)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ from .misc import AUTO_SCALE
|
|||
from .out_any_layer import AnyLayer
|
||||
from .drill_marks import DrillMarks
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ class PSOptions(DrillMarks):
|
|||
po.SetFineScaleAdjustX(self.scale_adjust_y)
|
||||
po.SetA4Output(self.a4_output)
|
||||
po.SetPlotMode(SKETCH if self.sketch_plot else FILLED)
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
po.SetLineWidth(FromMM(self.line_width))
|
||||
po.SetNegative(self.negative_plot)
|
||||
po.SetMirror(self.mirror_plot)
|
||||
|
|
@ -65,7 +64,7 @@ class PSOptions(DrillMarks):
|
|||
self.scale_adjust_y = po.GetFineScaleAdjustX()
|
||||
self.a4_output = po.GetA4Output()
|
||||
self.sketch_plot = po.GetPlotMode() == SKETCH
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
self.line_width = ToMM(po.GetLineWidth())
|
||||
self.negative_plot = po.GetNegative()
|
||||
self.mirror_plot = po.GetMirror()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from pcbnew import (PLOT_FORMAT_SVG, FromMM, ToMM)
|
|||
from .out_any_layer import AnyLayer
|
||||
from .drill_marks import DrillMarks
|
||||
from .gs import GS
|
||||
from .misc import KICAD_VERSION_5_99
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
|
||||
|
||||
|
|
@ -28,13 +27,13 @@ class SVGOptions(DrillMarks):
|
|||
def _configure_plot_ctrl(self, po, output_dir):
|
||||
super()._configure_plot_ctrl(po, output_dir)
|
||||
po.SetMirror(self.mirror_plot)
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
po.SetLineWidth(FromMM(self.line_width))
|
||||
po.SetNegative(self.negative_plot)
|
||||
|
||||
def read_vals_from_po(self, po):
|
||||
super().read_vals_from_po(po)
|
||||
if GS.kicad_version_n < KICAD_VERSION_5_99:
|
||||
if GS.ki5():
|
||||
self.line_width = ToMM(po.GetLineWidth())
|
||||
self.negative_plot = po.GetNegative()
|
||||
self.mirror_plot = po.GetMirror()
|
||||
|
|
|
|||
Loading…
Reference in New Issue