Skip to content

Commit

Permalink
- start using argparse instead of optionparser
Browse files Browse the repository at this point in the history
- make all code conform to pep8 once more
- add a unit test to check for pep8 compliance
- delete old ez_setup
  • Loading branch information
sumpfork committed Jul 6, 2016
1 parent 669fa4c commit b70bd37
Show file tree
Hide file tree
Showing 11 changed files with 860 additions and 980 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
# command to install dependencies
install:
- pip install -U setuptools
- pip install -U pycodestyle
- pip install .
# command to run tests
script: nosetests
26 changes: 14 additions & 12 deletions do_release.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import domdiv
from __init__ import __version__
from zipfile import ZipFile,ZIP_DEFLATED
from zipfile import ZipFile, ZIP_DEFLATED

prefix = 'generated/sumpfork_dominion_tabs_'
postfix = 'v' + __version__ + '.pdf'

def doit(args,main):
args = args + ' ' + prefix+main+postfix

def doit(args, main):
args = args + ' ' + prefix + main + postfix
args = args.split()
fname = args[-1]
print ':::Generating ' + fname
domdiv.main(args, '.')
return fname


argsets = [
('',''),
('--orientation=vertical','vertical_'),
('--papersize=A4','A4_'),
('--papersize=A4 --orientation=vertical','vertical_A4_'),
('--size=sleeved','sleeved_'),
('--size=sleeved --orientation=vertical','vertical_sleeved_')
('', ''), ('--orientation=vertical', 'vertical_'),
('--papersize=A4', 'A4_'),
('--papersize=A4 --orientation=vertical', 'vertical_A4_'),
('--size=sleeved', 'sleeved_'),
('--size=sleeved --orientation=vertical', 'vertical_sleeved_')
]
additional = ['--expansion_dividers']

fnames = [doit(args[0] + ' ' + ' '.join(additional),args[1]) for args in argsets]
fnames = [doit(args[0] + ' ' + ' '.join(additional), args[1])
for args in argsets]
print fnames

zip = ZipFile('generated/sumpfork_dominion_tabs_v' + __version__ + '.zip','w',ZIP_DEFLATED)
zip = ZipFile('generated/sumpfork_dominion_tabs_v' + __version__ + '.zip', 'w',
ZIP_DEFLATED)
for f in fnames:
zip.write(f)
zip.close()

563 changes: 339 additions & 224 deletions domdiv/__init__.py

Large diffs are not rendered by default.

65 changes: 32 additions & 33 deletions domdiv/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from reportlab.lib.units import cm


def getType(typespec):
return cardTypes[tuple(typespec)]

Expand Down Expand Up @@ -101,7 +102,6 @@ def getSetText(cls, setName, cardName):
return promoTextIcons[cardName.lower()]
return None


def __init__(self, name, cardset, types, cost, description='', potcost=0, debtcost=0, extra='', count=-1):
self.name = name.strip()
self.cardset = cardset.strip()
Expand All @@ -115,13 +115,13 @@ def __init__(self, name, cardset, types, cost, description='', potcost=0, debtco
self.count = getType(self.types).getTypeDefaultCardCount()
else:
self.count = count

def getCardCount(self):
return self.count

def setCardCount(self, value):
self.count = value

def getStackHeight(self, thickness):
# return height of the stacked cards in cm. Using hight in cm of a stack of 60 Copper cards as thickness.
return self.count * cm * (thickness / 60.0) + 2
Expand All @@ -147,11 +147,10 @@ def isLandmark(self):

def isPrize(self):
return 'Prize' in self.getType().getTypeNames()

def isType(self, what):
return what in self.getType().getTypeNames()


def setImage(self):
setImage = Card.getSetImage(self.cardset, self.name)
if setImage is None and self.cardset not in ['base', 'extra'] and not self.isExpansion():
Expand Down Expand Up @@ -215,47 +214,47 @@ def getTabCostHeightOffset(self):
cardTypes = [
CardType(('Action',), 'action.png'),
CardType(('Action', 'Attack'), 'action.png'),
CardType(('Action', 'Attack', 'Prize'), 'action.png',1),
CardType(('Action', 'Attack', 'Prize'), 'action.png', 1),
CardType(('Action', 'Reaction'), 'reaction.png'),
CardType(('Action', 'Victory'), 'action-victory.png',12),
CardType(('Action', 'Duration'), 'duration.png',5),
CardType(('Action', 'Victory'), 'action-victory.png', 12),
CardType(('Action', 'Duration'), 'duration.png', 5),
CardType(('Action', 'Duration', 'Reaction'), 'duration-reaction.png'),
CardType(('Action', 'Attack', 'Duration'), 'duration.png'),
CardType(('Action', 'Looter'), 'action.png'),
CardType(('Action', 'Prize'), 'action.png',1),
CardType(('Action', 'Ruins'), 'ruins.png',10, 0, 1),
CardType(('Action', 'Shelter'), 'action-shelter.png',6),
CardType(('Action', 'Prize'), 'action.png', 1),
CardType(('Action', 'Ruins'), 'ruins.png', 10, 0, 1),
CardType(('Action', 'Shelter'), 'action-shelter.png', 6),
CardType(('Action', 'Attack', 'Duration'), 'duration.png'),
CardType(('Action', 'Attack', 'Looter'), 'action.png'),
CardType(('Action', 'Attack', 'Traveller'), 'action.png',5),
CardType(('Action', 'Reserve'), 'reserve.png',5),
CardType(('Action', 'Reserve', 'Victory'), 'reserve-victory.png',12),
CardType(('Action', 'Traveller'), 'action.png',5),
CardType(('Action', 'Attack', 'Traveller'), 'action.png', 5),
CardType(('Action', 'Reserve'), 'reserve.png', 5),
CardType(('Action', 'Reserve', 'Victory'), 'reserve-victory.png', 12),
CardType(('Action', 'Traveller'), 'action.png', 5),
CardType(('Action', 'Gathering'), 'action.png'),
CardType(('Action', 'Treasure'), 'action-treasure.png'),
CardType(('Prize',), 'action.png',1),
CardType(('Event',), 'event.png',1),
CardType(('Prize',), 'action.png', 1),
CardType(('Event',), 'event.png', 1),
CardType(('Reaction',), 'reaction.png'),
CardType(('Reaction', 'Shelter'), 'reaction-shelter.png',6),
CardType(('Treasure',), 'treasure.png',10, 3, 0),
CardType(('Reaction', 'Shelter'), 'reaction-shelter.png', 6),
CardType(('Treasure',), 'treasure.png', 10, 3, 0),
CardType(('Treasure', 'Attack'), 'treasure.png'),
CardType(('Treasure', 'Victory'), 'treasure-victory.png',12),
CardType(('Treasure', 'Prize'), 'treasure.png',1, 3, 0),
CardType(('Treasure', 'Reaction'), 'treasure-reaction.png',10, 0, 1),
CardType(('Treasure', 'Victory'), 'treasure-victory.png', 12),
CardType(('Treasure', 'Prize'), 'treasure.png', 1, 3, 0),
CardType(('Treasure', 'Reaction'), 'treasure-reaction.png', 10, 0, 1),
CardType(('Treasure', 'Reserve'), 'reserve-treasure.png'),
CardType(('Victory',), 'victory.png',12),
CardType(('Victory', 'Reaction'), 'victory-reaction.png',12, 0, 1),
CardType(('Victory', 'Shelter'), 'victory-shelter.png',6),
CardType(('Victory', 'Castle'), 'victory.png',12),
CardType(('Victory',), 'victory.png', 12),
CardType(('Victory', 'Reaction'), 'victory-reaction.png', 12, 0, 1),
CardType(('Victory', 'Shelter'), 'victory-shelter.png', 6),
CardType(('Victory', 'Castle'), 'victory.png', 12),
CardType(('Curse',), 'curse.png', 30, 3),
CardType(('Trash',), 'action.png', 1),
CardType(('Prizes',), 'action.png',0),
CardType(('Events',), 'event.png',0),
CardType(('Shelters',), 'shelter.png',0),
CardType(('Expansion',), 'expansion.png',0, 4),
CardType(('Prizes',), 'action.png', 0),
CardType(('Events',), 'event.png', 0),
CardType(('Shelters',), 'shelter.png', 0),
CardType(('Expansion',), 'expansion.png', 0, 4),
CardType(('Blank',), ''),
CardType(('Landmark',), 'landmark.png',1),
CardType(('Landmarks',), 'landmark.png',0)
CardType(('Landmark',), 'landmark.png', 1),
CardType(('Landmarks',), 'landmark.png', 0)
]

cardTypes = dict(((c.getTypeNames(), c) for c in cardTypes))
Loading

0 comments on commit b70bd37

Please sign in to comment.