some pep8 fixes, simplify if check lines, fix/add some help messages, unify line endings to be unix
This commit is contained in:
parent
b79ad84851
commit
02c5be2555
@ -329,7 +329,8 @@ class DominionTabs:
|
|||||||
x, coinHeight, 16, 16, preserveAspectRatio=True, mask='auto')
|
x, coinHeight, 16, 16, preserveAspectRatio=True, mask='auto')
|
||||||
if card.potcost:
|
if card.potcost:
|
||||||
self.canvas.drawImage(os.path.join(self.filedir, 'images', 'potion.png'), x + 17,
|
self.canvas.drawImage(os.path.join(self.filedir, 'images', 'potion.png'), x + 17,
|
||||||
potHeight, potSize, potSize, preserveAspectRatio=True, mask=[255, 255, 255, 255, 255, 255])
|
potHeight, potSize, potSize, preserveAspectRatio=True,
|
||||||
|
mask=[255, 255, 255, 255, 255, 255])
|
||||||
width += potSize
|
width += potSize
|
||||||
|
|
||||||
self.canvas.setFont('MinionPro-Bold', 12)
|
self.canvas.setFont('MinionPro-Bold', 12)
|
||||||
@ -399,7 +400,6 @@ class DominionTabs:
|
|||||||
textInsetRight = 6
|
textInsetRight = 6
|
||||||
if self.options.use_text_set_icon:
|
if self.options.use_text_set_icon:
|
||||||
setImageHeight = card.getType().getTabTextHeightOffset()
|
setImageHeight = card.getType().getTabTextHeightOffset()
|
||||||
#self.canvas.rect(self.tabLabelWidth - 20, setImageHeight, 20, 20, 1 )
|
|
||||||
setText = card.setTextIcon()
|
setText = card.setTextIcon()
|
||||||
self.canvas.setFont('MinionPro-Oblique', 8)
|
self.canvas.setFont('MinionPro-Oblique', 8)
|
||||||
if setText is None:
|
if setText is None:
|
||||||
@ -450,7 +450,9 @@ class DominionTabs:
|
|||||||
h -= h / 2
|
h -= h / 2
|
||||||
|
|
||||||
words = line.split()
|
words = line.split()
|
||||||
if (not self.options.tab_name_align == "right") and (self.options.tab_name_align == "centre" or rightSide or not self.options.tab_name_align == "edge" ):
|
if (not self.options.tab_name_align == "right") and (self.options.tab_name_align == "centre" or
|
||||||
|
rightSide or
|
||||||
|
not self.options.tab_name_align == "edge"):
|
||||||
if self.options.tab_name_align == "centre":
|
if self.options.tab_name_align == "centre":
|
||||||
w = self.tabLabelWidth / 2 - self.nameWidth(line, fontSize) / 2
|
w = self.tabLabelWidth / 2 - self.nameWidth(line, fontSize) / 2
|
||||||
else:
|
else:
|
||||||
@ -551,7 +553,7 @@ class DominionTabs:
|
|||||||
# figure out whether the tab should go on the right side or not
|
# figure out whether the tab should go on the right side or not
|
||||||
if self.options.tab_side == "right":
|
if self.options.tab_side == "right":
|
||||||
rightSide = useExtra
|
rightSide = useExtra
|
||||||
elif self.options.tab_side == "left" or self.options.tab_side == "full":
|
elif self.options.tab_side in ["left", "full"]:
|
||||||
rightSide = not useExtra
|
rightSide = not useExtra
|
||||||
else:
|
else:
|
||||||
# alternate the cards
|
# alternate the cards
|
||||||
@ -671,7 +673,7 @@ class DominionTabs:
|
|||||||
def read_card_defs(self, fname, fileobject=None):
|
def read_card_defs(self, fname, fileobject=None):
|
||||||
cards = []
|
cards = []
|
||||||
f = open(fname)
|
f = open(fname)
|
||||||
carddef = re.compile("^\d+\t+(?P<name>[\w\-'/ ]+)\t+(?P<set>[\w ]+)\t+(?P<type>[-\w ]+)\t+\$(?P<cost>(\d+(\+|\*)?|\*))( (?P<potioncost>\d)+P)?\t+(?P<description>.*)",
|
carddef = re.compile("^\d+\t+(?P<name>[\w\-'/ ]+)\t+(?P<set>[\w ]+)\t+(?P<type>[-\w ]+)\t+\$(?P<cost>(\d+(\+|\*)?|\*))( (?P<potioncost>\d)+P)?\t+(?P<description>.*)", # noqa
|
||||||
re.UNICODE)
|
re.UNICODE)
|
||||||
currentCard = None
|
currentCard = None
|
||||||
for line in f:
|
for line in f:
|
||||||
@ -758,7 +760,7 @@ class DominionTabs:
|
|||||||
cards = split(cards, self.numTabsVertical * self.numTabsHorizontal)
|
cards = split(cards, self.numTabsVertical * self.numTabsHorizontal)
|
||||||
|
|
||||||
# Starting with tabs on the left or the right?
|
# Starting with tabs on the left or the right?
|
||||||
if self.options.tab_side == "right-alternate" or self.options.tab_side == "right":
|
if self.options.tab_side in ["right-alternate", "right"]:
|
||||||
self.odd = True
|
self.odd = True
|
||||||
else:
|
else:
|
||||||
# left-alternate, left, full
|
# left-alternate, left, full
|
||||||
@ -829,12 +831,16 @@ class DominionTabs:
|
|||||||
" the name is less likely to be hidden by the tab in front"
|
" the name is less likely to be hidden by the tab in front"
|
||||||
" (edge will revert to left when tab_side is full since there is no edge in that case);"
|
" (edge will revert to left when tab_side is full since there is no edge in that case);"
|
||||||
" default:left")
|
" default:left")
|
||||||
parser.add_option("--tab_side", type="choice", choices=["left", "right", "left-alternate", "right-alternate", "full"],
|
parser.add_option("--tab_side", type="choice", choices=["left",
|
||||||
|
"right",
|
||||||
|
"left-alternate",
|
||||||
|
"right-alternate",
|
||||||
|
"full"],
|
||||||
dest="tab_side", default="right-alternate",
|
dest="tab_side", default="right-alternate",
|
||||||
help="Alignment of tab. choices: left, right, left-alternate, right-alternate, full;"
|
help="Alignment of tab. choices: left, right, left-alternate, right-alternate, full;"
|
||||||
" left/right forces all tabs to left/right side;"
|
" left/right forces all tabs to left/right side;"
|
||||||
" left-alternate will start on the left and then toggle between left and right for the tabs;"
|
" left-alternate will start on the left and then toggle between left and right for the tabs;"
|
||||||
" right-alternate will start on the right and then toggle between right and left for the tabs;"
|
" right-alternate will start on the right and then toggle between right and left for the tabs;" # noqa
|
||||||
" full will force all label tabs to be full width of the divider"
|
" full will force all label tabs to be full width of the divider"
|
||||||
" default:right-alternate")
|
" default:right-alternate")
|
||||||
parser.add_option("--tabwidth", type="float", default=4,
|
parser.add_option("--tabwidth", type="float", default=4,
|
||||||
@ -877,14 +883,13 @@ class DominionTabs:
|
|||||||
help='centre the tabs on expansion dividers')
|
help='centre the tabs on expansion dividers')
|
||||||
parser.add_option("--num_pages", type="int", default=-1,
|
parser.add_option("--num_pages", type="int", default=-1,
|
||||||
help="stop generating after this many pages, -1 for all")
|
help="stop generating after this many pages, -1 for all")
|
||||||
parser.add_option(
|
parser.add_option("--language", default='en_us', help="language of card texts")
|
||||||
"--language", default='en_us', help="language of card texts")
|
|
||||||
parser.add_option("--include_blanks", action="store_true",
|
parser.add_option("--include_blanks", action="store_true",
|
||||||
help="include a few dividers with extra text")
|
help="include a few dividers with extra text")
|
||||||
parser.add_option("--exclude_events", action="store_true",
|
parser.add_option("--exclude_events", action="store_true",
|
||||||
default=False, help="exclude individual dividers for events")
|
default=False, help="exclude individual dividers for events")
|
||||||
parser.add_option("--exclude_card_groups", action="store_true",
|
parser.add_option("--special_card_groups", action="store_true",
|
||||||
default=False, help="exclude individual dividers for events")
|
default=False, help="group some cards under special dividers (e.g. Shelters, Prizes)")
|
||||||
parser.add_option("--exclude_prizes", action="store_true",
|
parser.add_option("--exclude_prizes", action="store_true",
|
||||||
default=False, help="exclude individual dividers for prizes (cornucopia)")
|
default=False, help="exclude individual dividers for prizes (cornucopia)")
|
||||||
parser.add_option("--cardlist", type="string", dest="cardlist", default=None,
|
parser.add_option("--cardlist", type="string", dest="cardlist", default=None,
|
||||||
@ -968,7 +973,6 @@ class DominionTabs:
|
|||||||
for line in cardfile:
|
for line in cardfile:
|
||||||
self.cardlist.add(line.strip())
|
self.cardlist.add(line.strip())
|
||||||
|
|
||||||
|
|
||||||
if self.options.orientation == "vertical":
|
if self.options.orientation == "vertical":
|
||||||
self.tabWidth, self.tabBaseHeight = dominionCardHeight, dominionCardWidth
|
self.tabWidth, self.tabBaseHeight = dominionCardHeight, dominionCardWidth
|
||||||
else:
|
else:
|
||||||
@ -979,6 +983,7 @@ class DominionTabs:
|
|||||||
|
|
||||||
if self.options.tab_side == "full" and self.options.tab_name_align == "edge":
|
if self.options.tab_side == "full" and self.options.tab_name_align == "edge":
|
||||||
# This case does not make sense since there are two tab edges in this case. So picking left edge.
|
# This case does not make sense since there are two tab edges in this case. So picking left edge.
|
||||||
|
print >>sys.stderr, "** Warning: Aligning card name as 'left' for 'full' tabs **"
|
||||||
self.options.tab_name_align == "left"
|
self.options.tab_name_align == "left"
|
||||||
|
|
||||||
fixedMargins = False
|
fixedMargins = False
|
||||||
@ -1113,9 +1118,12 @@ class DominionTabs:
|
|||||||
else:
|
else:
|
||||||
cards = [card for card in cards if not isBaseExpansionCard(card)]
|
cards = [card for card in cards if not isBaseExpansionCard(card)]
|
||||||
|
|
||||||
if self.options.exclude_card_groups:
|
if self.options.special_card_groups:
|
||||||
# Load the card groupos file
|
# Load the card groups file
|
||||||
card_groups = self.read_card_groups(os.path.join(self.filedir, "card_db", options.language, "card_groups.txt"))
|
card_groups = self.read_card_groups(os.path.join(self.filedir,
|
||||||
|
"card_db",
|
||||||
|
options.language,
|
||||||
|
"card_groups.txt"))
|
||||||
# pull out any cards which are a subcard, and rename the master card
|
# pull out any cards which are a subcard, and rename the master card
|
||||||
new_cards = []
|
new_cards = []
|
||||||
all_subcards = []
|
all_subcards = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user