diff options
author | jaseg <git@jaseg.de> | 2023-02-17 00:03:04 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-02-17 00:03:04 +0100 |
commit | f64b03efc752b682b1cbe8cfb114f19e3362ef76 (patch) | |
tree | 182bfb4e9b23766d00f255f4d50b183a4d525bcf /gerbonara/cam.py | |
parent | fb52e104081138a1f6abb8f6c9f7d0c6c2439c1e (diff) | |
download | gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.tar.gz gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.tar.bz2 gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.zip |
Add CLI
Diffstat (limited to 'gerbonara/cam.py')
-rw-r--r-- | gerbonara/cam.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/gerbonara/cam.py b/gerbonara/cam.py index 8a5ad68..a289371 100644 --- a/gerbonara/cam.py +++ b/gerbonara/cam.py @@ -44,17 +44,18 @@ class FileSettings: #: (relative) mode is technically still supported, but exceedingly rare in the wild. notation : str = 'absolute' #: Export unit. :py:attr:`~.utilities.MM` or :py:attr:`~.utilities.Inch` - unit : LengthUnit = MM + unit : LengthUnit = None #: Angle unit. Should be ``'degree'`` unless you really know what you're doing. angle_unit : str = 'degree' - #: Zero suppression settings. See note at :py:class:`.FileSettings` for meaning. + #: Zero suppression settings. Must be one of ``None``, ``'leading'`` or ``'trailing'``. See note at + #: :py:class:`.FileSettings` for meaning. zeros : bool = None #: Number format. ``(integer, decimal)`` tuple of number of integer and decimal digits. At most ``(6,7)`` by spec. - number_format : tuple = (2, 5) + number_format : tuple = (None, None) # input validation def __setattr__(self, name, value): - if name == 'unit' and value not in [MM, Inch]: + if name == 'unit' and value not in [None, MM, Inch]: raise ValueError(f'Unit must be either Inch or MM, not {value}') elif name == 'notation' and value not in ['absolute', 'incremental']: raise ValueError(f'Notation must be either "absolute" or "incremental", not {value}') @@ -141,8 +142,8 @@ class FileSettings: if '.' in value or value == '00': return float(value) - - integer_digits, decimal_digits = self.number_format + + integer_digits, decimal_digits = self.number_format or (2, 5) if self.zeros == 'leading': value = self._pad + value # pad with zeros to ensure we have enough decimals @@ -158,7 +159,7 @@ class FileSettings: if unit is not None: value = self.unit(value, unit) - integer_digits, decimal_digits = self.number_format + integer_digits, decimal_digits = self.number_format or (2, 5) if integer_digits is None: integer_digits = 3 if decimal_digits is None: @@ -188,7 +189,7 @@ class FileSettings: if unit is not None: value = self.unit(value, unit) - integer_digits, decimal_digits = self.number_format + integer_digits, decimal_digits = self.number_format or (2, 5) if integer_digits is None: integer_digits = 2 if decimal_digits is None: |