From b50aaf7806420b3dbecbcd75a42da617699266fe Mon Sep 17 00:00:00 2001 From: SET Date: Thu, 13 Aug 2020 13:11:27 -0300 Subject: [PATCH] Added support for locale's decimal point. --- kiplot/__main__.py | 2 ++ kiplot/bom/units.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kiplot/__main__.py b/kiplot/__main__.py index 20aa47bc..94d9b12d 100644 --- a/kiplot/__main__.py +++ b/kiplot/__main__.py @@ -47,6 +47,7 @@ __status__ = 'beta' import os import sys import gzip +import locale from glob import glob from logging import DEBUG @@ -163,6 +164,7 @@ def solve_board_file(schematic, a_board_file): def main(): + locale.setlocale(locale.LC_ALL, '') ver = 'KiPlot '+__version__+' - '+__copyright__+' - License: '+__license__ args = docopt(__doc__, version=ver, options_first=True) diff --git a/kiplot/bom/units.py b/kiplot/bom/units.py index 4e65409b..943ce335 100644 --- a/kiplot/bom/units.py +++ b/kiplot/bom/units.py @@ -100,9 +100,13 @@ def comp_match(component): original = component # Convert the decimal point from the current locale to a '.' global decimal_point - if not decimal_point: + if decimal_point is None: decimal_point = locale.localeconv()['decimal_point'] - if decimal_point and decimal_point != '.': + logger.debug('Decimal point `{}`'.format(decimal_point)) + # Avoid conversions for '.' + if decimal_point == '.': + decimal_point = '' + if decimal_point: component = component.replace(decimal_point, ".") # Remove any commas