Now GS.ki5() and GS.ki6() are just GS.ki5 and GS.ki6

- The version doesn't change during execution ;-)
This commit is contained in:
Salvador E. Tropea 2022-07-31 17:45:55 -03:00
parent 19789cb6a3
commit 6c7e0cebe0
28 changed files with 86 additions and 92 deletions

View File

@ -185,13 +185,15 @@ def detect_kicad():
GS.kicad_version_minor = int(m.group(2))
GS.kicad_version_patch = int(m.group(3))
GS.kicad_version_n = GS.kicad_version_major*1000000+GS.kicad_version_minor*1000+GS.kicad_version_patch
GS.ki6 = GS.kicad_version_major >= 6
GS.ki5 = GS.kicad_version_major < 6
logger.debug('Detected KiCad v{}.{}.{} ({} {})'.format(GS.kicad_version_major, GS.kicad_version_minor,
GS.kicad_version_patch, GS.kicad_version, GS.kicad_version_n))
# Used to look for plug-ins.
# 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.ki6():
if GS.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

View File

@ -68,7 +68,7 @@ class Environment(Optionable):
def config(self, parent):
super().config(parent)
defs = {}
if GS.ki5():
if GS.ki5:
self.define_k5_vars(defs)
else:
self.define_k6_vars(defs)
@ -282,7 +282,7 @@ class Globals(FiltersOptions):
logger.debug("- Copper thickness: "+self.copper_thickness)
def config(self, parent):
if GS.ki6() and GS.pcb_file and os.path.isfile(GS.pcb_file):
if GS.ki6 and GS.pcb_file and os.path.isfile(GS.pcb_file):
self.get_stack_up()
super().config(parent)
# Transfer options to the GS globals

View File

@ -15,7 +15,7 @@ except ImportError:
from datetime import datetime, date
from sys import exit
from shutil import copy2
from .misc import EXIT_BAD_ARGS, W_DATEFORMAT, KICAD_VERSION_5_99, W_UNKVAR
from .misc import EXIT_BAD_ARGS, W_DATEFORMAT, W_UNKVAR
from .log import get_logger
logger = get_logger(__name__)
@ -196,7 +196,7 @@ class GS(object):
@staticmethod
def get_pcb_comment(title_block, num):
if GS.ki6():
if GS.ki6:
# Backward compatibility ... what's this?
# Also: Maintaining the same numbers used before (and found in the file) is asking too much?
return title_block.GetComment(num)
@ -212,13 +212,13 @@ class GS(object):
@staticmethod
def get_modules():
if GS.ki6():
if GS.ki6:
return GS.board.GetFootprints()
return GS.board.GetModules()
@staticmethod
def get_modules_board(board):
if GS.ki6():
if GS.ki6:
return board.GetFootprints()
return board.GetModules()
@ -226,20 +226,20 @@ class GS(object):
def get_aux_origin():
if GS.board is None:
return (0, 0)
if GS.ki6():
if GS.ki6:
settings = GS.board.GetDesignSettings()
return settings.GetAuxOrigin()
return GS.board.GetAuxOrigin()
@staticmethod
def get_center(m):
if GS.ki5():
if GS.ki5:
return m.GetCenter()
return m.GetPosition()
@staticmethod
def get_fp_size(m):
if GS.ki5():
if GS.ki5:
pads = m.Pads()
r = pcbnew.EDA_RECT()
for pad in pads:
@ -268,21 +268,13 @@ class GS(object):
os.remove(bkp)
os.rename(fname, bkp)
@staticmethod
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 zones():
return pcbnew.ZONES() if GS.ki6() else pcbnew.ZONE_CONTAINERS()
return pcbnew.ZONES() if GS.ki6 else pcbnew.ZONE_CONTAINERS()
@staticmethod
def layers_contains(layers, id):
if GS.ki6():
if GS.ki6:
return layers.Contains(id)
return id in layers.Seq()
@ -333,7 +325,7 @@ class GS(object):
logger.debug("PCB date: `{}`".format(GS.pcb_date))
logger.debug("PCB revision: `{}`".format(GS.pcb_rev))
logger.debug("PCB company: `{}`".format(GS.pcb_comp))
for num in range(4 if GS.ki5() else 9):
for num in range(4 if GS.ki5 else 9):
logger.debug("PCB comment {}: `{}`".format(num+1, GS.pcb_com[num]))
@staticmethod

View File

@ -59,7 +59,7 @@ def parse_color(val):
def load_color_theme(name):
logger.debug('Looking for color theme `{}`'.format(name))
is_built_in = name in BUILT_IN
if not is_built_in and GS.ki5():
if not is_built_in and GS.ki5:
logger.warning(W_COLORTHEME, "KiCad 5 doesn't support color themes ({})".format(name))
return None
if is_built_in:

View File

@ -136,7 +136,7 @@ class KiConf(object):
cfg = ''
if GS.kicad_conf_path:
cfg = os.path.join(GS.kicad_conf_path, KICAD_COMMON)
if GS.ki6():
if GS.ki6:
cfg += '.json'
if os.path.isfile(cfg):
return cfg
@ -184,7 +184,7 @@ class KiConf(object):
return None
def guess_symbol_dir():
if GS.ki5():
if GS.ki5:
order = ['library', 'symbols']
else:
order = ['symbols', 'library']
@ -194,7 +194,7 @@ class KiConf(object):
return guess
def guess_footprint_dir():
if GS.ki5():
if GS.ki5:
order = ['modules', 'footprints']
else:
order = ['footprints', 'modules']
@ -208,7 +208,7 @@ class KiConf(object):
def guess_3d_dir():
modules3d = os.path.join('modules', 'packages3d')
if GS.ki5():
if GS.ki5:
order = [modules3d, '3dmodels']
else:
order = ['3dmodels', modules3d]
@ -223,7 +223,7 @@ class KiConf(object):
home = os.environ.get('HOME')
if home is None:
return None
if GS.ki6():
if GS.ki6:
name = os.path.join(home, '.local', 'share', 'kicad', '6.0', 'template')
if os.path.isdir(name):
return name
@ -299,7 +299,7 @@ class KiConf(object):
if not no_dir:
base_name += '_DIR'
names = []
if GS.ki6() and ki6_diff:
if GS.ki6 and ki6_diff:
# KiCad 6 specific name goes first when using KiCad 6
names.append('KICAD6_'+base_name)
# KiCad 5 names, allowed even when using KiCad 6
@ -341,7 +341,7 @@ class KiConf(object):
""" Sets the environment and the internal list """
if not no_dir:
base_name += '_DIR'
if GS.ki6() and ki6_diff:
if GS.ki6 and ki6_diff:
name = 'KICAD6_'+base_name
else:
name = 'KICAD_'+base_name
@ -350,7 +350,7 @@ class KiConf(object):
logger.debug('Using {}="{}" (guessed)'.format(name, val))
def _solve_var(name, member, desc, guesser, old=None, only_old=False, ki6_diff=True, only_k6=False, no_dir=False):
if only_k6 and GS.ki5():
if only_k6 and GS.ki5:
return
val = KiConf._look_env_var(name, old, only_old, ki6_diff, no_dir)
if val is not None:
@ -373,7 +373,7 @@ class KiConf(object):
# Get the environment variables
logger.debug('Reading KiCad config from `{}`'.format(cfg))
KiConf.config_dir = os.path.dirname(cfg)
if GS.ki5():
if GS.ki5:
# All environment vars should be here
KiConf.load_ki5_env(cfg)
else:
@ -521,7 +521,7 @@ class KiConf(object):
if not project:
return None, None
KiConf.init(GS.pcb_file)
if GS.ki5():
if GS.ki5:
return KiConf.fix_page_layout_k5(project, dry)
return KiConf.fix_page_layout_k6(project, dry)

View File

@ -20,7 +20,7 @@ if not GS.kicad_version_n:
# When running the regression tests we need it
from kibot.__main__ import detect_kicad
detect_kicad()
if GS.ki6():
if GS.ki6:
from pcbnew import PCB_SHAPE, PCB_TEXT, FILL_T_FILLED_SHAPE, SHAPE_T_POLY
else:
from pcbnew import DRAWSEGMENT, TEXTE_PCB
@ -168,7 +168,7 @@ class WksLine(WksDrawing):
st, sti = p.solve_ref(e.start, e.incrx, e.incry, e.start_ref)
en, eni = p.solve_ref(e.end, e.incrx, e.incry, e.end_ref)
for _ in range(e.repeat):
if GS.ki5() and e.shape:
if GS.ki5 and e.shape:
# Using KiCad 5 I always get a line. Why? What's missing?
e.draw_line(p, st, wxPoint(en.x, st.y))
e.draw_line(p, wxPoint(en.x, st.y), wxPoint(en.x, en.y))
@ -418,7 +418,7 @@ class WksBitmap(WksDrawing):
x = pos.x-round(w/2)
y = pos.y-round(h/2)
img.moveto(x, y)
if GS.ki5():
if GS.ki5:
# KiCad 5 uses Inches and with less resolution
img.scale(KICAD5_SVG_SCALE)
# Put the image in a group

View File

@ -189,7 +189,7 @@ def load_board(pcb_file=None):
board = pcbnew.LoadBoard(pcb_file)
if BasePreFlight.get_option('check_zone_fills'):
pcbnew.ZONE_FILLER(board).Fill(board.Zones())
if GS.global_units and GS.ki6():
if GS.global_units and GS.ki6:
# In KiCad 6 "dimensions" has units.
# The default value is DIM_UNITS_MODE_AUTOMATIC.
# But this has a meaning only in the GUI where you have default units.
@ -270,7 +270,7 @@ def get_board_comps_data(comps):
c.footprint_y = center.y
(c.footprint_w, c.footprint_h) = GS.get_fp_size(m)
attrs = m.GetAttributes()
if GS.ki5():
if GS.ki5:
# KiCad 5
if attrs == UI_SMD:
c.smd = True
@ -603,7 +603,7 @@ def solve_schematic(base_dir, a_schematic=None, a_board_file=None, config=None,
schematic = sch
if not schematic:
schematics = glob(os.path.join(base_dir, '*.sch'))
if GS.ki6():
if GS.ki6:
schematics += glob(os.path.join(base_dir, '*.kicad_sch'))
if len(schematics) == 1:
schematic = schematics[0]
@ -621,7 +621,7 @@ def solve_schematic(base_dir, a_schematic=None, a_board_file=None, config=None,
sch = os.path.join(base_dir, config+'.sch')
if os.path.isfile(sch):
schematic = sch
elif GS.ki6():
elif GS.ki6:
# Try KiCad 6
sch = os.path.join(base_dir, config+'.kicad_sch')
if os.path.isfile(sch):
@ -637,7 +637,7 @@ def solve_schematic(base_dir, a_schematic=None, a_board_file=None, config=None,
break
else:
# No way to select one, just take the first
if GS.ki6():
if GS.ki6:
schematic = guess_ki6_sch(schematics)
if not schematic:
schematic = schematics[0]
@ -719,7 +719,7 @@ def look_for_used_layers():
for e in list(GS.board.Zones()):
layers.add(e.GetLayer())
# Tracks and vias
via_type = 'VIA' if GS.ki5() else 'PCB_VIA'
via_type = 'VIA' if GS.ki5 else 'PCB_VIA'
for e in GS.board.GetTracks():
if e.GetClass() == via_type:
for id in e.GetLayerSet().Seq():

View File

@ -241,7 +241,7 @@ class Layer(Optionable):
elif layer in Layer._pcb_layers:
ext = [cls.create_layer(layer)]
# Give compatibility for the KiCad 5 default names (automagically renamed by KiCad 6)
elif GS.ki6() and layer in Layer.KICAD6_RENAME:
elif GS.ki6 and layer in Layer.KICAD6_RENAME:
ext = [cls.create_layer(Layer.KICAD6_RENAME[layer])]
elif layer in Layer.DEFAULT_LAYER_NAMES:
ext = [cls.create_layer(layer)]
@ -339,7 +339,7 @@ class Layer(Optionable):
@staticmethod
def id2def_name(id):
if GS.ki5():
if GS.ki5:
return Layer.ID_2_DEFAULT_NAME[id]
return pcbnew.LayerName(id)
@ -349,7 +349,7 @@ for i in range(1, 30):
name = 'In'+str(i)+'.Cu'
Layer.DEFAULT_LAYER_NAMES[name] = pcbnew.In1_Cu+i-1
Layer.DEFAULT_LAYER_DESC[name] = 'Inner layer '+str(i)
if GS.ki6():
if GS.ki6:
# Add all the User.N layers
for i in range(1, 10):
name = 'User.'+str(i)

View File

@ -117,7 +117,7 @@ class AnyDrill(BaseOptions):
""" Get the ID for all the generated files.
It includes buried/blind vias. """
groups = [''] if unified else ['PTH', 'NPTH']
via_type = 'VIA' if GS.ki5() else 'PCB_VIA'
via_type = 'VIA' if GS.ki5 else 'PCB_VIA'
pairs = set()
for t in GS.board.GetTracks():
tclass = t.GetClass()

View File

@ -81,12 +81,12 @@ class AnyLayerOptions(VariantOptions):
def _configure_plot_ctrl(self, po, output_dir):
logger.debug("Configuring plot controller for output")
po.SetOutputDirectory(output_dir)
po.SetPlotFrameRef(self.plot_sheet_reference and (not GS.ki5()))
po.SetPlotFrameRef(self.plot_sheet_reference and (not GS.ki5))
po.SetPlotReference(self.plot_footprint_refs)
po.SetPlotValue(self.plot_footprint_values)
po.SetPlotInvisibleText(self.force_plot_invisible_refs_vals)
po.SetExcludeEdgeLayer(self.exclude_edge_layer)
if GS.ki5():
if GS.ki5:
po.SetPlotPadsOnSilkLayer(not self.exclude_pads_from_silkscreen)
po.SetPlotViaOnMaskLayer(not self.tent_vias)
# Only useful for gerber outputs
@ -231,7 +231,7 @@ class AnyLayerOptions(VariantOptions):
self.force_plot_invisible_refs_vals = po.GetPlotInvisibleText()
# viasonmask
self.tent_vias = not po.GetPlotViaOnMaskLayer()
if GS.ki5():
if GS.ki5:
# padsonsilk
self.exclude_pads_from_silkscreen = not po.GetPlotPadsOnSilkLayer()

View File

@ -98,7 +98,7 @@ class Any_PCB_PrintOptions(VariantOptions):
cmd, video_remove = add_extra_options(cmd)
# Add the layers
cmd.extend([la.layer for la in self._layers])
if GS.ki6() and self.force_edge_cuts and not self.separated:
if GS.ki6 and self.force_edge_cuts and not self.separated:
cmd.append('Edge.Cuts')
# Execute it
ret = exec_with_retry(cmd)

View File

@ -14,7 +14,7 @@ if not GS.kicad_version_n:
# When running the regression tests we need it
from kibot.__main__ import detect_kicad
detect_kicad()
if GS.ki6():
if GS.ki6:
# New name, no alias ...
from pcbnew import FP_SHAPE, wxPoint, LSET
else:
@ -222,7 +222,7 @@ class VariantOptions(BaseOptions):
@staticmethod
def create_module_element(m):
if GS.ki6():
if GS.ki6:
return FP_SHAPE(m)
return EDGE_MODULE(m)
@ -439,7 +439,7 @@ class VariantOptions(BaseOptions):
properties = {f.name: f.value for f in comp.fields}
old_value = m.GetValue()
m.SetValue(properties['Value'])
if GS.ki6():
if GS.ki6:
old_properties = m.GetProperties()
m.SetProperties(properties)
if has_GetFPIDAsString:
@ -461,7 +461,7 @@ class VariantOptions(BaseOptions):
ref = m.GetReference()
data = self.sch_fields_to_pcb_bkp.get(ref, None)
if data is not None:
if GS.ki6():
if GS.ki6:
m.SetValue(data[0])
m.SetProperties(data[1])
if has_GetFPIDAsString:

View File

@ -50,7 +50,7 @@ def pad_sort_key(pad):
def convert(pcb, brd):
# Board outline
outlines = SHAPE_POLY_SET()
if GS.ki5():
if GS.ki5:
pcb.GetBoardPolygonOutlines(outlines, "")
outline = outlines.Outline(0)
outline_points = [outline.Point(n) for n in range(outline.PointCount())]
@ -84,7 +84,7 @@ def convert(pcb, brd):
brd.write("NETS: {count}\n"
.format(count=len(net_items)))
for net_item in net_items:
code = net_item.GetNet() if GS.ki5() else net_item.GetNetCode()
code = net_item.GetNet() if GS.ki5 else net_item.GetNetCode()
brd.write("{code} {name}\n"
.format(code=code,
name=net_item.GetNetname().replace(" ", u"\u00A0")))

View File

@ -8,7 +8,7 @@ from .out_any_layer import AnyLayer
from .drill_marks import DrillMarks
from .gs import GS
from .macros import macros, document, output_class # noqa: F401
if GS.ki6():
if GS.ki6:
from pcbnew import DXF_UNITS_MILLIMETERS, DXF_UNITS_INCHES
else:
DXF_UNITS_MILLIMETERS = 1

View File

@ -66,7 +66,7 @@ class GerberOptions(AnyLayerOptions):
po.SetIncludeGerberNetlistInfo(self.use_gerber_net_attributes)
po.SetUseAuxOrigin(self.use_aux_axis_as_origin)
po.SetDrillMarksType(0)
if GS.ki5():
if GS.ki5:
po.SetLineWidth(FromMM(self.line_width))
else:
po.SetDisableGerberMacros(self.disable_aperture_macros)
@ -88,7 +88,7 @@ class GerberOptions(AnyLayerOptions):
self.subtract_mask_from_silk = po.GetSubtractMaskFromSilk()
# useauxorigin
self.use_aux_axis_as_origin = po.GetUseAuxOrigin()
if GS.ki5():
if GS.ki5:
# linewidth
self.line_width = ToMM(po.GetLineWidth())
else:

View File

@ -302,7 +302,7 @@ class PCB_PrintOptions(VariantOptions):
self.validate_color(member)
else:
setattr(self, member, getattr(self._color_theme, color))
if self.frame_plot_mechanism == 'plot' and GS.ki5():
if self.frame_plot_mechanism == 'plot' and GS.ki5:
raise KiPlotConfigurationError("You can't use `plot` for `frame_plot_mechanism` with KiCad 5. It will crash.")
KiConf.init(GS.pcb_file)
if self.sheet_reference_layout:
@ -505,7 +505,7 @@ class PCB_PrintOptions(VariantOptions):
found = True
if found:
zones.append(e)
via_type = 'VIA' if GS.ki5() else 'PCB_VIA'
via_type = 'VIA' if GS.ki5 else 'PCB_VIA'
for e in GS.board.GetTracks():
if e.GetClass() == via_type:
vias.append((e, e.GetDrill(), e.GetWidth()))
@ -576,7 +576,7 @@ class PCB_PrintOptions(VariantOptions):
found = True
if found:
zones.append(e)
via_type = 'VIA' if GS.ki5() else 'PCB_VIA'
via_type = 'VIA' if GS.ki5 else 'PCB_VIA'
for e in GS.board.GetTracks():
if e.GetClass() == via_type:
if e.GetViaType() == via_t:
@ -718,7 +718,7 @@ class PCB_PrintOptions(VariantOptions):
new_layer = svgutils.fromstring(load_svg(file, color, p.colored_holes, p.holes_color, p.monochrome))
width, height = get_size(new_layer)
# Workaround for polygon fill on KiCad 5
if GS.ki5() and file.endswith('frame.svg'):
if GS.ki5 and file.endswith('frame.svg'):
if p.monochrome:
color = to_gray_hex(color)
self.fill_polygons(new_layer, color)
@ -789,7 +789,7 @@ class PCB_PrintOptions(VariantOptions):
# This the autocenter computation used by KiCad
scale_x = scale_y = scale
board_center = GS.board.GetBoundingBox().GetCenter()
if GS.ki5():
if GS.ki5:
# KiCad 5 uses a different precision, we must adjust
board_center.x = round(board_center.x*KICAD5_SVG_SCALE)
board_center.y = round(board_center.y*KICAD5_SVG_SCALE)
@ -941,7 +941,7 @@ class PCB_PrintOptions(VariantOptions):
p.scaling = self.set_scaling(po, p.scaling)
po.SetNegative(p.negative_plot)
po.SetPlotViaOnMaskLayer(not p.tent_vias)
if GS.ki5():
if GS.ki5:
po.SetLineWidth(FromMM(p.line_width))
po.SetPlotPadsOnSilkLayer(not p.exclude_pads_from_silkscreen)
filelist = []
@ -1034,7 +1034,7 @@ class PCB_Print(BaseOutput): # noqa: F821
@staticmethod
def get_conf_examples(name, layers, templates):
outs = []
if len(DRAWING_LAYERS) < 10 and GS.ki6():
if len(DRAWING_LAYERS) < 10 and GS.ki6:
DRAWING_LAYERS.extend(['User.'+str(c+1) for c in range(9)])
extra = {la._id for la in Layer.solve(EXTRA_LAYERS)}
disabled = set()

View File

@ -30,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.ki5():
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.ki5():
if GS.ki5:
self.line_width = ToMM(po.GetLineWidth())
self.negative_plot = po.GetNegative()

View File

@ -215,7 +215,7 @@ class PositionOptions(VariantOptions):
@staticmethod
def get_attr_tests():
if GS.ki5():
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

View File

@ -45,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.ki5():
if GS.ki5:
po.SetLineWidth(FromMM(self.line_width))
po.SetNegative(self.negative_plot)
po.SetMirror(self.mirror_plot)
@ -64,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.ki5():
if GS.ki5:
self.line_width = ToMM(po.GetLineWidth())
self.negative_plot = po.GetNegative()
self.mirror_plot = po.GetMirror()

View File

@ -380,7 +380,7 @@ class QR_LibOptions(BaseOptions):
os.remove(tmp_pcb)
GS.make_bkp(GS.pcb_file)
prl = None
if GS.ki6():
if GS.ki6:
# KiCad 6 is destroying the PRL ...
prl_name = GS.pcb_no_ext+'.kicad_prl'
if os.path.isfile(prl_name):
@ -497,7 +497,7 @@ class QR_LibOptions(BaseOptions):
qr._text_pcb = self.expand_filename_both(qr.text, is_sch=False, make_safe=False)
qr._code_pcb = qrcodegen.QrCode.encode_text(qr._text_pcb, QR_ECCS[qr.correction_level])
# Create the symbols
if GS.ki5():
if GS.ki5:
self.symbol_lib_k5()
else:
self.symbol_lib_k6()
@ -520,7 +520,7 @@ class QR_LibOptions(BaseOptions):
# PCB
self.update_footprints(known_qrs)
# Schematic
if GS.ki6():
if GS.ki6:
# KiCad 5 reads the lib, but KiCad 6 is more like the PCB
assert GS.sch_file is not None
sheets = self.load_k6_sheets(GS.sch_file)

View File

@ -424,14 +424,14 @@ class ReportOptions(BaseOptions):
return not (m.GetAttributes() & MOD_EXCLUDE_FROM_POS_FILES)
def get_attr_tests(self):
if GS.ki5():
if GS.ki5:
return self.is_pure_smd_5, self.is_not_virtual_5
return self.is_pure_smd_6, self.is_not_virtual_6
def measure_pcb(self, board):
edge_layer = board.GetLayerID('Edge.Cuts')
x1 = y1 = x2 = y2 = None
draw_type = 'DRAWSEGMENT' if GS.ki5() else 'PCB_SHAPE'
draw_type = 'DRAWSEGMENT' if GS.ki5 else 'PCB_SHAPE'
for d in board.GetDrawings():
if d.GetClass() == draw_type and d.GetLayer() == edge_layer:
if x1 is None:
@ -508,8 +508,8 @@ class ReportOptions(BaseOptions):
self._vias = {}
self._tracks_m = {}
self._drills_real = {}
track_type = 'TRACK' if GS.ki5() else 'PCB_TRACK'
via_type = 'VIA' if GS.ki5() else 'PCB_VIA'
track_type = 'TRACK' if GS.ki5 else 'PCB_TRACK'
via_type = 'VIA' if GS.ki5 else 'PCB_VIA'
for t in tracks:
tclass = t.GetClass()
if tclass == track_type:
@ -527,7 +527,7 @@ class ReportOptions(BaseOptions):
###########################################################
# Drill (min)
###########################################################
modules = board.GetModules() if GS.ki5() else board.GetFootprints()
modules = board.GetModules() if GS.ki5 else board.GetFootprints()
self._drills = {}
self._drills_oval = {}
self.oar_pads = self.pad_drill = self.pad_drill_real = INF
@ -536,7 +536,7 @@ class ReportOptions(BaseOptions):
top_layer = board.GetLayerID('F.Cu')
bottom_layer = board.GetLayerID('B.Cu')
is_pure_smd, is_not_virtual = self.get_attr_tests()
npth_attrib = 3 if GS.ki5() else pcbnew.PAD_ATTRIB_NPTH
npth_attrib = 3 if GS.ki5 else pcbnew.PAD_ATTRIB_NPTH
min_oar = 0.1*pcbnew.IU_PER_MM
for m in modules:
layer = m.GetLayer()
@ -599,7 +599,7 @@ class ReportOptions(BaseOptions):
self.via_pad_min = min(self.via_pad_d, self.via_pad)
# Via Drill size
self._vias_m = sorted(self._vias.keys())
self.via_drill_d = ds.m_ViasMinDrill if GS.ki5() else ds.m_MinThroughDrill
self.via_drill_d = ds.m_ViasMinDrill if GS.ki5 else ds.m_MinThroughDrill
self.via_drill = self._vias_m[0][0] if self._vias_m else INF
self.via_drill_min = min(self.via_drill_d, self.via_drill)
# Via Drill size before platting
@ -608,8 +608,8 @@ class ReportOptions(BaseOptions):
self.via_drill_real_min = adjust_drill(self.via_drill_min)
# Pad Drill
# No minimum defined (so no _d)
self.pad_drill_min = self.pad_drill if GS.ki5() else ds.m_MinThroughDrill
self.pad_drill_real_min = self.pad_drill_real if GS.ki5() else adjust_drill(ds.m_MinThroughDrill, False)
self.pad_drill_min = self.pad_drill if GS.ki5 else ds.m_MinThroughDrill
self.pad_drill_real_min = self.pad_drill_real if GS.ki5 else adjust_drill(ds.m_MinThroughDrill, False)
# Drill overall
self.drill_d = min(self.via_drill_d, self.pad_drill)
self.drill = min(self.via_drill, self.pad_drill)

View File

@ -27,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.ki5():
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.ki5():
if GS.ki5:
self.line_width = ToMM(po.GetLineWidth())
self.negative_plot = po.GetNegative()
self.mirror_plot = po.GetMirror()

View File

@ -36,7 +36,7 @@ class SVG_PCB_PrintOptions(Any_PCB_PrintOptions):
def run(self, output):
super().run(output, svg=True)
if (GS.ki6() and self.enable_ki6_page_fix) or (GS.ki5() and self.enable_ki5_page_fix):
if (GS.ki6 and self.enable_ki6_page_fix) or (GS.ki5 and self.enable_ki5_page_fix):
# KiCad 6.0.2 bug: https://gitlab.com/kicad/code/kicad/-/issues/11033
o = self._parent
out_files = o.get_targets(o.expand_dirname(os.path.join(GS.out_dir, o.dir)))

View File

@ -215,7 +215,7 @@ class Annotate_PCB(BasePreFlight): # noqa: F821
for m in modules:
old_ref = m.ref_prefix+str(m.ref_suffix)
new_ref = m.ref_prefix+str(m.new_ref_suffix)
if GS.ki6():
if GS.ki6:
changes[old_ref] = new_ref
else:
changes[old_ref] = m.new_ref_suffix
@ -230,7 +230,7 @@ class Annotate_PCB(BasePreFlight): # noqa: F821
if not GS.sch:
return
logger.debug('- Transferring changes to the schematic')
if GS.ki5():
if GS.ki5:
self.annotate_ki5(changes)
else:
self.annotate_ki6(changes)

View File

@ -68,7 +68,7 @@ class Annotate_Power(BasePreFlight): # noqa: F821
if not GS.sch.annotation_error:
logger.warning(W_NOANNO+"No annotation problems, skipping power annotation")
return
if GS.ki5():
if GS.ki5:
self.annotate_ki5()
else:
self.annotate_ki6()

View File

@ -56,7 +56,7 @@ class SCH_Replace(Base_Replace): # noqa: F821
if o.date_command:
# Convert it into another replacement
t = TagReplaceSCH()
if GS.ki5():
if GS.ki5:
t.tag = r'^Date ("(?:[^"]|\\")*")$'
t.before = 'Date "'
t.after = '"'

View File

@ -96,7 +96,7 @@ class Set_Text_Variables(BasePreFlight): # noqa: F821
o = self._value
if len(o) == 0:
return
if GS.ki5():
if GS.ki5:
raise KiPlotConfigurationError("The `set_text_variables` preflight is for KiCad 6 or newer")
pro_name = GS.pro_file
if not pro_name or not os.path.isfile(pro_name):

View File

@ -46,7 +46,7 @@ ALL_LAYERS = ['B_Adhes',
]
detect_kicad()
# New layer names in KiCad 6
if GS.ki6():
if GS.ki6:
ALL_LAYERS = [ki5_2_ki6(la) for la in ALL_LAYERS]
ALL_EXTS = ['gba',
'gbr',
@ -133,7 +133,7 @@ def check_layers_exist(ctx, dir, prefix, layers, suffix):
def check_components(ctx, dir, prefix, layers, suffix, exclude, include):
if GS.ki6():
if GS.ki6:
layers = [ki5_2_ki6(la) for la in layers]
for layer in layers:
fname = compose_fname(dir, prefix, layer, suffix)