Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DNC (isFixed) #105

Merged
merged 1 commit into from
Jul 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions kibom/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,40 +322,30 @@ def isFitted(self):

return include and not exclude

# Determine if a component is FIXED or not
def isFixed(self):

check = self.getField(self.prefs.configField).lower()
""" Determine if a component is FIXED or not.
Fixed components shouldn't be replaced without express authorization """

# Check the value field first
if self.getValue().lower() in DNC:
return False
return True

check = self.getField(self.prefs.configField).lower()
# Empty is not fixed
if check == "":
return True
return False

opts = check.split(" ")
for opt in opts:
if opt.lower() in DNC:
return False
return True

opts = check.split(",")

result = False

for opt in opts:
# Options that start with '-' are explicitly removed from certain configurations
if opt.startswith('-') and opt[1:].lower() == self.prefs.pcbConfig.lower():
result = False
break
if opt.startswith("+"):
result = False
if opt[1:].lower() == self.prefs.pcbConfig.lower():
result = True
if opt.lower() in DNC:
return True

# by default, part is not fixed
return result
return False

# Test if this part should be included, based on any regex expressions provided in the preferences
def testRegExclude(self):
Expand Down Expand Up @@ -593,7 +583,7 @@ def updateFields(self, usealt=False, wrapN=None):
self.fields[ColumnList.COL_GRP_QUANTITY] = "{n}{dnf}{dnc}".format(
n=q,
dnf=" (DNF)" if not self.isFitted() else "",
dnc=" (DNC)" if not self.isFixed() else "")
dnc=" (DNC)" if self.isFixed() else "")

self.fields[ColumnList.COL_GRP_BUILD_QUANTITY] = str(q * self.prefs.boards) if self.isFitted() else "0"
self.fields[ColumnList.COL_VALUE] = self.components[0].getValue()
Expand Down