KV
b6c7f806a1
Add BOMEntry type alias
...
This type alias describes the possible types of keys and values in
the dict representing a BOM entry.
2021-04-05 18:56:38 +02:00
KV
d907bb9089
Add function type hints and doc strings
2021-04-05 18:56:38 +02:00
KV
97d537f23f
Replace accumulation loop with sum expressions
...
Make a list from the group iterator for reusage in sum expressions
and to pick first group entry. The expected group sizes are very small,
so performance loss by creating a temporary list should be neglectable.
Alternativly, itertools.tee(group, 3) could be called to triplicate
the iterator, but it was not chosen for readability reasons.
2021-04-05 18:56:38 +02:00
KV
daced29a77
Use a generator expressions and raise exception if failing
...
Seems to be the most popular search alternative:
https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search
Raising StopIteration if not found is better than returning None
to detect such an internal error more easily.
2021-04-05 18:56:38 +02:00
KV
f65243a9f0
Make the BOM grouping function return string tuple for sorting
2021-04-05 18:56:38 +02:00
KV
8f6a28e101
Move BOM sorting above grouping to use groupby()
...
- Use one common entry loop to consume iterator only once.
- Use same key function for sort() and groupby(),
except replace None with empty string when sorting.
2021-04-05 18:56:38 +02:00
KV
467fa74388
Move out code from inner loop into helper functions
2021-04-05 18:56:38 +02:00
KV
4e69372469
Remove parentheses around return expressions
...
https://stackoverflow.com/questions/4978567/should-a-return-statement-have-parentheses
2021-04-05 18:56:37 +02:00
KV
731add070f
Simplify deduplication and sorting of collected designators
2021-04-05 18:56:37 +02:00
KV
6984ca181d
Simplify collecting designators for a joined BOM entry
...
Assign input designators once to a temporary variable for easy reusage.
2021-04-05 18:56:37 +02:00
KV
186cecf7ea
Simplify BOM header row logic
2021-04-05 18:56:37 +02:00
KV
4a77d86fc4
Redefine the common lambda to an ordinary function
2021-04-05 18:56:37 +02:00
KV
f255548df5
Convert dataclass object to dict to use the same lambda
2021-04-05 18:56:37 +02:00
KV
a43271c018
Use the same lambda in get_bom_index() as for deduplicating BOM
...
Move the lambda declaration out of the function scope for common
access from two different functions.
2021-04-05 18:56:37 +02:00
KV
300fc5025f
Simplify get_bom_index() parameters
...
- Use the actual BOM as first parameter instead of the whole harness.
- Use a whole AdditionalComponent as second parameter instead of each
attribute separately.
2021-04-05 18:56:37 +02:00
KV
09b0996cd6
Skip assignment and return expression directly
2021-04-05 18:56:36 +02:00
William Sutton
dec64abaf5
Add support for wire length units
...
Based on #161 , #162 , #171 .
Co-authored-by: stevegt <stevegt@t7a.org>
Co-authored-by: kvid <kvid@users.noreply.github.com>
2020-11-16 17:14:46 +01:00
Daniel Rojas
96bd121403
Create separate modules for BOM and HTML functions
2020-11-15 08:42:57 +01:00