home
·
contact
·
privacy
projects
/
bricksplom
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
49ab918
)
Re-organize, check ldraw mode arguments.
master
author
Plom Heller
<plom@plomlompom.com>
Thu, 30 Jul 2026 10:31:25 +0000
(12:31 +0200)
committer
Plom Heller
<plom@plomlompom.com>
Thu, 30 Jul 2026 10:31:25 +0000
(12:31 +0200)
bricksplom.py
patch
|
blob
|
history
diff --git
a/bricksplom.py
b/bricksplom.py
index e6d4c77a4ee4cdcbc6c129fffae39b6b1ac74ccd..85acfa87978c33dab2630f800b090e7c9a80e745 100755
(executable)
--- a/
bricksplom.py
+++ b/
bricksplom.py
@@
-33,6
+33,7
@@
CHAR_ATTR_EQ = '='
SEP_DESIGN_DESC = ' #'
SEP_DESIGN_ATTR = '|'
CHAR_COLL_INDENT = ' '
SEP_DESIGN_DESC = ' #'
SEP_DESIGN_ATTR = '|'
CHAR_COLL_INDENT = ' '
+CHAR_SEP_LDRAW_MODES = ','
CHAR_COLL_IN = '+'
CHAR_COLL_OUT = '-'
CHAR_COLL_INACTIVE = '#'
CHAR_COLL_IN = '+'
CHAR_COLL_OUT = '-'
CHAR_COLL_INACTIVE = '#'
@@
-47,6
+48,13
@@
PARAM_Q_TEXT = 'text:'
TOK_SORT_BOX = 'box'
TOK_SORT_ID = 'id'
TOK_SORT_BOX = 'box'
TOK_SORT_ID = 'id'
+LDRAW_MODE_FILL_PATHS = 'fill_paths'
+LDRAW_MODE_VERIFY_PATHS = 'verify_paths'
+LDRAW_MODE_VERIFY_N_STUDS = 'verify_n_studs'
+LDRAW_MODES = {LDRAW_MODE_FILL_PATHS,
+ LDRAW_MODE_VERIFY_PATHS,
+ LDRAW_MODE_VERIFY_N_STUDS}
+
BrickListing = tuple[int, str, str] # count, ID, comment
PageColumn = tuple[BrickListing, ...]
Page = tuple[PageColumn, ...]
BrickListing = tuple[int, str, str] # count, ID, comment
PageColumn = tuple[BrickListing, ...]
Page = tuple[PageColumn, ...]
@@
-664,8
+672,8
@@
class BricksDb:
setattr(self, name, cls.from_textfile((path_tables, f'{name}.txt'),
**kwargs))
self._path_ldraw = Path(path_ldraw).joinpath('parts')
setattr(self, name, cls.from_textfile((path_tables, f'{name}.txt'),
**kwargs))
self._path_ldraw = Path(path_ldraw).joinpath('parts')
- self._ldraw_modes = ldraw_modes.split(
','
)
- if
'fill'
in self._ldraw_modes:
+ self._ldraw_modes = ldraw_modes.split(
CHAR_SEP_LDRAW_MODES
)
+ if
LDRAW_MODE_FILL_PATHS
in self._ldraw_modes:
for design in [design for design in self.designs.values()
if not (design.alternate_to or design.ldraw)]:
filename = f'{design.id_}.dat'
for design in [design for design in self.designs.values()
if not (design.alternate_to or design.ldraw)]:
filename = f'{design.id_}.dat'
@@
-765,17
+773,18
@@
class BricksDb:
if v != 0]:
fails += [f'invalid count for brick of ID: {brick_id} ({count})']
if v != 0]:
fails += [f'invalid count for brick of ID: {brick_id} ({count})']
- if 'verify' in self._ldraw_modes:
- for design in [
-
design for design in self.designs.values(
)
- if (not design.alternate_to)
- and design.ldraw and design.ldraw != '!']:
- # hunt for dangling Design.ldraw references
+ for design in [
+ design for design in self.designs.values()
+
if (not design.alternate_to
)
+ and design.ldraw and design.ldraw != '!']:
+ # hunt for dangling Design.ldraw references
+ if LDRAW_MODE_VERIFY_PATHS in self._ldraw_modes:
if not self._path_ldraw.joinpath(design.ldraw).exists():
fails += ['unresolved ldraw reference for design of ID: '
f'{design.id_} ({design.ldraw})']
continue
if not self._path_ldraw.joinpath(design.ldraw).exists():
fails += ['unresolved ldraw reference for design of ID: '
f'{design.id_} ({design.ldraw})']
continue
- # compare n_studs calculations to explicit records
+ # compare n_studs calculations to explicit records
+ if LDRAW_MODE_VERIFY_N_STUDS in self._ldraw_modes:
if design.n_studs <= -1:
continue
studs_counted = self._ldraw_studs_count(design.ldraw)
if design.n_studs <= -1:
continue
studs_counted = self._ldraw_studs_count(design.ldraw)
@@
-853,6
+862,7
@@
def main(
hint_sortmatch = 'use "?" to see what be available for chosen table'
hint_raw = ('only available for tables: '
+ ', '.join(BricksDb.textfiled_tables().keys()))
hint_sortmatch = 'use "?" to see what be available for chosen table'
hint_raw = ('only available for tables: '
+ ', '.join(BricksDb.textfiled_tables().keys()))
+ hint_ldraw = 'allowed: ' + ', '.join(sorted(list(LDRAW_MODES)))
parser.add_argument(
'item_id',
nargs='?', metavar='ITEM_ID')
parser.add_argument(
'item_id',
nargs='?', metavar='ITEM_ID')
@@
-862,15
+872,19
@@
def main(
parser.add_argument(
'-s', '--sort-by',
action='store', help=hint_sortmatch, default=TOK_SORT_ID)
parser.add_argument(
'-s', '--sort-by',
action='store', help=hint_sortmatch, default=TOK_SORT_ID)
- parser.add_argument(
+
action_ldraw =
parser.add_argument(
'-l', '--ldraw',
'-l', '--ldraw',
- action='store', default='')
+ action='store', default='',
+ help=f'comma-separated; {hint_ldraw}')
action_raw = parser.add_argument(
'-r', '--raw',
action='store_true', help=f'NB: {hint_raw}')
args = parser.parse_args()
if args.table not in BricksDb.textfiled_tables() and args.raw:
parser.error(str(ArgumentError(action_raw, hint_raw)))
action_raw = parser.add_argument(
'-r', '--raw',
action='store_true', help=f'NB: {hint_raw}')
args = parser.parse_args()
if args.table not in BricksDb.textfiled_tables() and args.raw:
parser.error(str(ArgumentError(action_raw, hint_raw)))
+ for _ in [m for m in args.ldraw.split(CHAR_SEP_LDRAW_MODES)
+ if m and m not in LDRAW_MODES]:
+ parser.error(str(ArgumentError(action_ldraw, hint_ldraw)))
return args
args = parse_args()
return args
args = parse_args()