Skip to content

Commit

Permalink
Eliminate all dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouni committed Aug 8, 2024
1 parent 3bc706c commit 2370b08
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 181 deletions.
148 changes: 0 additions & 148 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

PLUGIN_PATH = os.path.split(os.path.abspath(__file__))[0]

THT = 0
SMD = 1
EXCLUDE_FROM_POS = 2
EXCLUDE_FROM_BOM = 3
NOT_IN_SCHEMATIC = 4


def is_version8(version: str) -> bool:
Expand Down Expand Up @@ -94,25 +91,6 @@ def loadIconScaled(filename, scale=1.0):
return wx.Icon(bmp)


def GetListIcon(value, scale_factor):
"""Get check or cross icon depending on passed value."""
if value == 0:
return wx.dataview.DataViewIconText(
"",
loadIconScaled(
"mdi-check-color.png",
scale_factor,
),
)
return wx.dataview.DataViewIconText(
"",
loadIconScaled(
"mdi-close-color.png",
scale_factor,
),
)


def natural_sort_collation(a, b):
"""Natural sort collation for use in sqlite."""
if a == b:
Expand Down Expand Up @@ -162,19 +140,6 @@ def get_valid_footprints(board):
return footprints


def get_footprint_keys(fp):
"""Get keys from footprint for sorting."""
try:
package = str(fp.GetFPID().GetLibItemName())
except ValueError:
package = ""
try:
reference = int(re.search(r"\d+", fp.GetReference())[0])
except ValueError:
reference = 0
return (package, reference)


def get_bit(value, bit):
"""Get the nth bit of a byte."""
return value & (1 << bit)
Expand All @@ -195,22 +160,6 @@ def toggle_bit(value, bit):
return value ^ (1 << bit)


def get_tht(footprint):
"""Get the THT property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
return bool(get_bit(val, THT))


def get_smd(footprint):
"""Get the SMD property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
return bool(get_bit(val, SMD))


def get_exclude_from_pos(footprint):
"""Get the 'exclude from POS' property of a footprint."""
if not footprint:
Expand All @@ -227,93 +176,6 @@ def get_exclude_from_bom(footprint):
return bool(get_bit(val, EXCLUDE_FROM_BOM))


def get_not_in_schematic(footprint):
"""Get the 'not in schematic' property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
return bool(get_bit(val, NOT_IN_SCHEMATIC))


def set_tht(footprint):
"""Set the THT property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
val = set_bit(val, THT)
footprint.SetAttributes(val)
return bool(get_bit(val, THT))


def set_smd(footprint):
"""Set the SMD property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
val = set_bit(val, SMD)
footprint.SetAttributes(val)
return bool(get_bit(val, SMD))


def set_exclude_from_pos(footprint, v):
"""Set the 'exclude from POS' property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
if v:
val = set_bit(val, EXCLUDE_FROM_POS)
else:
val = clear_bit(val, EXCLUDE_FROM_POS)
footprint.SetAttributes(val)
return bool(get_bit(val, EXCLUDE_FROM_POS))


def set_exclude_from_bom(footprint, v):
"""Set the 'exclude from BOM' property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
if v:
val = set_bit(val, EXCLUDE_FROM_BOM)
else:
val = clear_bit(val, EXCLUDE_FROM_BOM)
footprint.SetAttributes(val)
return bool(get_bit(val, EXCLUDE_FROM_BOM))


def set_not_in_schematic(footprint, v):
"""Set the 'not in schematic' property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
if v:
val = set_bit(val, NOT_IN_SCHEMATIC)
else:
val = clear_bit(val, NOT_IN_SCHEMATIC)
footprint.SetAttributes(val)
return bool(get_bit(val, NOT_IN_SCHEMATIC))


def toggle_tht(footprint):
"""Toggle the THT property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
val = toggle_bit(val, THT)
footprint.SetAttributes(val)
return bool(get_bit(val, THT))


def toggle_smd(footprint):
"""Toggle the SMD property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
val = toggle_bit(val, SMD)
footprint.SetAttributes(val)
return bool(get_bit(val, SMD))


def toggle_exclude_from_pos(footprint):
"""Toggle the 'exclude from POS' property of a footprint."""
if not footprint:
Expand All @@ -332,13 +194,3 @@ def toggle_exclude_from_bom(footprint):
val = toggle_bit(val, EXCLUDE_FROM_BOM)
footprint.SetAttributes(val)
return bool(get_bit(val, EXCLUDE_FROM_BOM))


def toggle_not_in_schematic(footprint):
"""Toggle the 'not in schematic' property of a footprint."""
if not footprint:
return None
val = footprint.GetAttributes()
val = toggle_bit(val, NOT_IN_SCHEMATIC)
footprint.SetAttributes(val)
return bool(get_bit(val, NOT_IN_SCHEMATIC))
22 changes: 0 additions & 22 deletions library.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class LibraryState(Enum):
class Library:
"""A storage class to get data from a sqlite database and write it back."""

# no longer works
CSV_URL = "https://jlcpcb.com/componentSearch/uploadComponentInfo"

def __init__(self, parent):
self.logger = logging.getLogger(__name__)
self.parent = parent
Expand Down Expand Up @@ -355,32 +352,13 @@ def get_all_mapping_data(self):
).fetchall()
]

def update_meta_data(self, filename, size, partcount, date, last_update):
"""Update the meta data table."""
with contextlib.closing(sqlite3.connect(self.partsdb_file)) as con, con as cur:
cur.execute("DELETE from meta")
cur.commit()
cur.execute(
"INSERT INTO meta VALUES (?, ?, ?, ?, ?)",
(filename, size, partcount, date, last_update),
)
cur.commit()

def create_parts_table(self, columns):
"""Create the parts table."""
with contextlib.closing(sqlite3.connect(self.partsdb_file)) as con, con as cur:
cols = ",".join([f" '{c}'" for c in columns])
cur.execute(f"CREATE TABLE IF NOT EXISTS parts ({cols})")
cur.commit()

def insert_parts(self, data, cols):
"""Insert many parts at once."""
with contextlib.closing(sqlite3.connect(self.partsdb_file)) as con:
cols = ",".join(["?"] * cols)
query = f"INSERT INTO parts VALUES ({cols})"
con.executemany(query, data)
con.commit()

def get_part_details(self, number: str) -> dict:
"""Get the part details for a LCSC number using optimized FTS5 querying."""
with contextlib.closing(sqlite3.connect(self.partsdb_file)) as con:
Expand Down
11 changes: 0 additions & 11 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def __init__(self, parent, kicad_provider=KicadProvider()):
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX,
)
self.pcbnew = kicad_provider.get_pcbnew()
self.KicadBuildVersion = self.pcbnew.GetBuildVersion()
self.window = wx.GetTopLevelParent(self)
self.SetSize(HighResWxSize(self.window, wx.Size(1300, 800)))
self.scale_factor = GetScaleFactor(self.window)
Expand All @@ -104,8 +103,6 @@ def __init__(self, parent, kicad_provider=KicadProvider()):
self.schematic_name = f"{self.board_name.split('.')[0]}.kicad_sch"
self.hide_bom_parts = False
self.hide_pos_parts = False
self.manufacturers = []
self.packages = []
self.library: Library
self.store: Store
self.settings = {}
Expand Down Expand Up @@ -668,11 +665,6 @@ def OnFootprintSelected(self, *_):
# cause pcbnew to refresh the board with the changes to the selected footprint(s)
self.pcbnew.Refresh()

def enable_all_buttons(self, state):
"""Control state of all the buttons."""
self.enable_top_buttons(state)
self.enable_part_specific_toolbar_buttons(state)

def enable_top_buttons(self, state):
"""Control the state of all the buttons in the top section."""
for button in (ID_GENERATE, ID_DOWNLOAD, ID_LAYERS):
Expand Down Expand Up @@ -810,9 +802,6 @@ def save_settings(self):
) as j:
json.dump(self.settings, j)

def calculate_costs(self, *_):
"""Hopefully we will be able to calculate the part costs in the future."""

def select_part(self, *_):
"""Select a part from the library and assign it to the selected footprint(s)."""
selection = {}
Expand Down

0 comments on commit 2370b08

Please sign in to comment.