From cde8b08cba186567276400a65b7c36d956aeecde Mon Sep 17 00:00:00 2001 From: Bradd Szonye Date: Sun, 6 Feb 2022 13:47:41 -0800 Subject: [PATCH] Fix --expansion-reset-tabs limitations (#369) The --expansion-reset-tabs option was previously incompatible with --include-blanks because it handles low card counts specially, and blanks leave the "extras" card count unset. I fixed the code by defaulting to a count of 0 in this case. The option was also previously dependent on --expansion-dividers, and silently ignored if the latter was not set. As there wasn't a clear technical reason for the limitation, I removed it and moved --expansion-reset-tabs from the Expansion Dividers group to the Divider Tab group. --- src/domdiv/draw.py | 11 +++-------- src/domdiv/main.py | 14 +++++++------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/domdiv/draw.py b/src/domdiv/draw.py index c99956c2..ba557cb5 100644 --- a/src/domdiv/draw.py +++ b/src/domdiv/draw.py @@ -1905,20 +1905,15 @@ def setupCardPlots(self, options, cards=[]): items = [] nextTabIndex = CardPlot.tabRestart() lastCardSet = None - reset_expansion_tabs = ( - options.expansion_dividers and options.expansion_reset_tabs - ) for card in cards: # Check if tab needs to be reset to the start - if reset_expansion_tabs and not card.isExpansion(): + if options.expansion_reset_tabs and not card.isExpansion(): if lastCardSet != card.cardset_tag: # In a new expansion, so reset the tabs to start over nextTabIndex = CardPlot.tabRestart() - if ( - options.tab_number > Card.sets[card.cardset_tag]["count"] - and Card.sets[card.cardset_tag]["count"] > 0 - ): + cardset_count = Card.sets[card.cardset_tag].get("count", 0) + if options.tab_number > cardset_count and cardset_count > 0: # Limit to the number of tabs to the number of dividers in the expansion CardPlot.tabSetup( diff --git a/src/domdiv/main.py b/src/domdiv/main.py index 55d4b316..bf9a2f23 100644 --- a/src/domdiv/main.py +++ b/src/domdiv/main.py @@ -358,6 +358,13 @@ def parse_opts(cmdline_args=None): dest="use_set_icon", help="Use set icon instead of a card icon. Applies to Promo cards.", ) + group_tab.add_argument( + "--expansion-reset-tabs", + action="store_true", + dest="expansion_reset_tabs", + help="When set, the tabs are restarted (left/right) at the beginning of each expansion. " + "If not set, the tab pattern will continue from one expansion to the next. ", + ) # Expanion Dividers group_expansion = parser.add_argument_group( @@ -382,13 +389,6 @@ def parse_opts(cmdline_args=None): dest="full_expansion_dividers", help="Full width expansion dividers.", ) - group_expansion.add_argument( - "--expansion-reset-tabs", - action="store_true", - dest="expansion_reset_tabs", - help="When set, the tabs are restarted (left/right) at the beginning of each expansion. " - "If not set, the tab pattern will continue from one expansion to the next. ", - ) group_expansion.add_argument( "--expansion-dividers-long-name", action="store_true",