You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

import os
import glob
def getFootprinLibrarys(pathTofootprints):
cwd = os.getcwd()
os.chdir(footprintPath)
footprintList = []
files = os.listdir()
# append all .pretty folders
for f in files:
if f.endswith(".pretty"):
footprintList.append(f)
os.chdir(cwd)
return footprintList
def getSymbolsLibrarys(pathToSymbols):
search_pattern = os.path.join(pathToSymbols, "*.kicad_sym")
return glob.glob(search_pattern)
pathToProjectFolder = input("enter path to KiCad project folder:")
# move one directory back into the main KicED library folder
# https://stackoverflow.com/questions/12280143/how-to-move-to-one-folder-back-in-python
os.path.normpath(os.getcwd() + os.sep + os.pardir)
cwd = os.getcwd()
print(pathToProjectFolder)
print(cwd)
# find common path
commonPath = os.path.commonprefix([cwd, pathToProjectFolder])
# KicED library paths
footprintPath = os.path.join(cwd, "footprints")
symbolsPath = os.path.join(cwd, "symbols")
# create relative path from KiCad project and the KicED library
relative_path = os.path.relpath(cwd, pathToProjectFolder)
print(relative_path)
baseRelativeBasePath = os.path.join("${KIPRJMOD}", relative_path)
print(baseRelativeBasePath)
fps = getFootprinLibrarys(footprintPath)
for f in fps:
print(f)
sps = getSymbolsLibrarys(symbolsPath)
for f in sps:
print(f)