Skip to content

Commit

Permalink
Merge pull request #139 from n0dyjeff/ref-sep
Browse files Browse the repository at this point in the history
Reference Designator Separators
  • Loading branch information
SchrodingersGat committed Sep 19, 2020
2 parents 6b8149d + 8cadf17 commit ea9e538
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ BoM generation options can be configured (on a per-project basis) by editing the
* `group_connectors` : If this option is set, connector comparison based on the 'Value' field is ignored. This allows multiple connectors which are named for their function (e.g. "Power", "ICP" etc) can be grouped together.
* `test_regex` : If this option is set, each component group row is test against a list of (user configurable) regular expressions. If any matches are found, that row is excluded from the output BoM file.
* `merge_blank_field` : If this option is set, blank fields are able to be merged with non-blank fields (and do not count as a 'conflict')
* `ref_separator` : This is the character used to separate reference designators in the output, when grouped. Defaults to " ".
* `fit_field` : This is the name of the part field used to determine if the component is fitted, or not.
* `output_file_name` : A string that allows arbitrary specification of the output file name with field replacements. Fields available:
- `%O` : The base output file name (pulled from kicad, or specified on command line when calling script).
Expand Down
3 changes: 2 additions & 1 deletion kibom/component.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ def isFixed(self):

def getRefs(self):
# Return a list of the components
return " ".join([c.getRef() for c in self.components])
separator = self.prefs.refSeparator
return separator.join([c.getRef() for c in self.components])

def getAltRefs(self):
S = joiner()
Expand Down
6 changes: 6 additions & 0 deletions kibom/preferences.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BomPref:
OPT_CONFIG_FIELD = "fit_field"
OPT_HIDE_HEADERS = "hide_headers"
OPT_HIDE_PCB_INFO = "hide_pcb_info"
OPT_REF_SEPARATOR = "ref_separator"

def __init__(self):
# List of headings to ignore in BoM generation
Expand All @@ -67,6 +68,7 @@ def __init__(self):
self.hidePcbInfo = False
self.configField = "Config" # Default field used for part fitting config
self.pcbConfig = ["default"]
self.refSeparator = " "

self.backup = "%O.tmp"

Expand Down Expand Up @@ -154,6 +156,7 @@ def Read(self, file, verbose=False):
self.outputFileName = self.checkStr(self.OPT_OUTPUT_FILE_NAME, default=self.outputFileName)
self.variantFileNameFormat = self.checkStr(self.OPT_VARIANT_FILE_NAME_FORMAT,
default=self.variantFileNameFormat)
self.refSeparator = self.checkStr(self.OPT_REF_SEPARATOR, default=self.refSeparator).strip("\'\"")

if cf.has_option(self.SECTION_GENERAL, self.OPT_CONFIG_FIELD):
self.configField = cf.get(self.SECTION_GENERAL, self.OPT_CONFIG_FIELD)
Expand Down Expand Up @@ -246,6 +249,9 @@ def Write(self, file):
cf.set(self.SECTION_GENERAL, '; Field name used to determine if a particular part is to be fitted')
cf.set(self.SECTION_GENERAL, self.OPT_CONFIG_FIELD, self.configField)

cf.set(self.SECTION_GENERAL, '; Character used to separate reference designators in output')
cf.set(self.SECTION_GENERAL, self.OPT_REF_SEPARATOR, self.refSeparator)

cf.set(self.SECTION_GENERAL, '; Make a backup of the bom before generating the new one, using the following template')
cf.set(self.SECTION_GENERAL, self.OPT_BACKUP, self.backup)

Expand Down

0 comments on commit ea9e538

Please sign in to comment.