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

Ipn templates #46

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
7 changes: 4 additions & 3 deletions inventree_part_import/part_importer.py
Original file line number Diff line number Diff line change
@@ -379,7 +379,7 @@ def setup_parameters(self, part, api_part: ApiPart, update_existing=True):
if existing_parameter := existing_parameters.get(name):
if update_existing and existing_parameter.data != value:
async_results.append(thread_pool.apply_async(
update_parameter, (existing_parameter, name, value)
update_parameter, (existing_parameter, value)
))
else:
if parameter_template := self.parameter_templates.get(name):
@@ -454,12 +454,13 @@ def create_parameter(inventree_api, part, parameter_template, value):
msg = e.args[0]["body"]
return f"failed to create parameter '{parameter_template.name}' with '{msg}'"

def update_parameter(parameter, name, value):
def update_parameter(parameter, value):
try:
parameter.save({"data": value})
except HTTPError as e:
msg = e.args[0]["body"]
return f"failed to update parameter '{name}' to '{value}' with '{msg}'"
parameter_name = parameter.template_detail["name"]
return f"failed to update parameter '{parameter_name}' to '{value}' with '{msg}'"

SANITIZE_PARAMETER = re.compile("±")