Skip to content

Commit

Permalink
Exclude empty subcategories
Browse files Browse the repository at this point in the history
  • Loading branch information
maksz42 authored and yaqwsx committed Jan 24, 2024
1 parent ca25ee6 commit 039b07d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jlcparts/datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,16 @@ def _map_category(val: MapCategoryParams):
return None
if val.subcatName.strip() == "":
return None

lib = PartLibraryDb(val.libraryPath)
components = lib.getCategoryComponents(val.catName, val.subcatName, stockNewerThan=val.ignoreoldstock)
if not components:
return None

filebase = val.catName + val.subcatName
filebase = filebase.replace("&", "and").replace("/", "aka")
filebase = re.sub('[^A-Za-z0-9]', '_', filebase)

lib = PartLibraryDb(val.libraryPath)
components = lib.getCategoryComponents(val.catName, val.subcatName, stockNewerThan=val.ignoreoldstock)

dataTable = buildDatatable(components)
dataTable.update({"category": val.catName, "subcategory": val.subcatName})
dataHash = saveJson(dataTable, os.path.join(val.outdir, f"{filebase}.json.gz"),
Expand Down

0 comments on commit 039b07d

Please sign in to comment.