Skip to content

Commit

Permalink
[Position][Added] quote_all option
Browse files Browse the repository at this point in the history
- To quote all columns in the CSV output

Closes #456
  • Loading branch information
set-soft committed Jun 26, 2023
1 parent c5c1fc5 commit 7e6154d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `skip_not_run`: used to skip outputs not generated in default runs.
- Compress:
- `skip_not_run`: used to skip outputs not generated in default runs.
- Position:
- `quote_all`: forces quotes to all values in the CSV output. (See #456)

### Changed
- Command line:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4233,6 +4233,7 @@ Notes:
For KiCad 6+ we replace this concept by the option to exclude from position file.
- `pre_transform`: [string|list(string)='_none'] Name of the filter to transform fields before applying other filters.
A short-cut to use for simple cases where a variant is an overkill.
- `quote_all`: [boolean=false] When generating the CSV quote all values, even numbers.
- `right_digits`: [number=4] number of digits for mantissa part of coordinates (0 is auto).
- `use_aux_axis_as_origin`: [boolean=true] Use the auxiliary axis as origin for coordinates (KiCad default).
- `variant`: [string=''] Board variant to apply.
Expand Down
2 changes: 2 additions & 0 deletions docs/samples/generic_plot.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,8 @@ outputs:
# [string|list(string)='_none'] Name of the filter to transform fields before applying other filters.
# A short-cut to use for simple cases where a variant is an overkill
pre_transform: '_none'
# [boolean=false] When generating the CSV quote all values, even numbers
quote_all: false
# [number=4] number of digits for mantissa part of coordinates (0 is auto)
right_digits: 4
# [boolean=true] Generate two separated files, one for the top and another for the bottom
Expand Down
12 changes: 8 additions & 4 deletions kibot/out_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def __init__(self):
""" Include virtual components. For special purposes, not pick & place.
Note that virtual components is a KiCad 5 concept.
For KiCad 6+ we replace this concept by the option to exclude from position file """
self.quote_all = False
""" When generating the CSV quote all values, even numbers """
super().__init__()
self._expand_id = 'position'

Expand Down Expand Up @@ -234,6 +236,7 @@ def run(self, fname):
modules_side = []
is_pure_smd, is_not_virtual = self.get_attr_tests()
quote_char = '"' if self.format == 'CSV' else ''
quote_char_extra = quote_char if self.quote_all else ''
x_origin = 0.0
y_origin = 0.0
if self.use_aux_axis_as_origin:
Expand Down Expand Up @@ -285,13 +288,14 @@ def run(self, fname):
pos_x = (center_x - x_origin) * conv
if self.bottom_negative_x and is_bottom:
pos_x = -pos_x
row.append(float_format.format(pos_x, rd=self.right_digits))
row.append(quote_char_extra+float_format.format(pos_x, rd=self.right_digits)+quote_char_extra)
elif k == 'PosY':
row.append(float_format.format(-(center_y - y_origin) * conv, rd=self.right_digits))
row.append(quote_char_extra+float_format.format(-(center_y - y_origin) * conv, rd=self.right_digits) +
quote_char_extra)
elif k == 'Rot':
row.append(float_format.format(rotation, rd=self.right_digits))
row.append(quote_char_extra+float_format.format(rotation, rd=self.right_digits)+quote_char_extra)
elif k == 'Side':
row.append("bottom" if is_bottom else "top")
row.append(quote_char_extra+("bottom" if is_bottom else "top")+quote_char_extra)
modules.append(row)
modules_side.append(is_bottom)
else:
Expand Down

0 comments on commit 7e6154d

Please sign in to comment.