def __init__(self, fname="", prefs=None): """Initialiser for the genericNetlist class Keywords: fname -- The name of the generic netlist file to open (Optional) """ self.design = None self.components = [] self.libparts = [] self.libraries = [] self.nets = [] # The entire tree is loaded into self.tree self.tree = [] self._curr_element = None if not prefs: prefs = BomPref() #default values self.prefs = prefs if fname != "": self.load(fname)
def __init__(self, prefs=None): self.components = [] self.fields = dict.fromkeys( ColumnList._COLUMNS_DEFAULT) #columns loaded from KiCad if not prefs: prefs = BomPref() self.prefs = prefs
def WriteBoM(filename, groups, net, headings=columns.ColumnList._COLUMNS_DEFAULT, prefs=None): filename = os.path.abspath(filename) #no preferences supplied, use defaults if not prefs: prefs = BomPref() #remove any headings that appear in the ignore[] list headings = [ h for h in headings if not h.lower() in [i.lower() for i in prefs.ignore] ] #if no extension is given, assume .csv (and append!) if len(filename.split('.')) < 2: filename += ".csv" #make a temporary copy of the output file if prefs.backup != False: TmpFileCopy(filename, prefs.backup) ext = filename.split('.')[-1].lower() result = False #CSV file writing if ext in ["csv", "tsv", "txt"]: if WriteCSV(filename, groups, net, headings, prefs): print("CSV Output -> {fn}".format(fn=filename)) result = True else: print("Error writing CSV output") elif ext in ["htm", "html"]: if WriteHTML(filename, groups, net, headings, prefs): print("HTML Output -> {fn}".format(fn=filename)) result = True else: print("Error writing HTML output") elif ext in ["xml"]: if WriteXML(filename, groups, net, headings, prefs): print("XML Output -> {fn}".format(fn=filename)) result = True else: print("Error writing XML output") else: print("Unsupported file extension: {ext}".format(ext=ext)) return result
def __init__(self, xml_element, prefs=None): self.element = xml_element self.libpart = None if not prefs: prefs = BomPref() self.prefs = prefs # Set to true when this component is included in a component group self.grouped = False