Skip to content

Commit

Permalink
Merge pull request #2662 from MarkusHackspacher/codestyle
Browse files Browse the repository at this point in the history
change to the .format() function
  • Loading branch information
squiddy committed May 3, 2017
2 parents cef0f7e + 31fa7de commit 0bce731
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions horizons/gui/tabs/barrackstabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ def init_widget(self):

def build_groundunit_info(self, index, groundunit, prodline):
size = (260, 90)
widget = Container(name='showcase_%s' % index, position=(0, 20 + index*90),
widget = Container(name='showcase_{}'.format(index), position=(0, 20 + index*90),
min_size=size, max_size=size, size=size)
bg_icon = Icon(image='content/gui/images/background/square_80.png', name='bg_%s'%index)
bg_icon = Icon(image='content/gui/images/background/square_80.png', name='bg_{}'.format(index))
widget.addChild(bg_icon)

image = 'content/gui/images/objects/groundunit/76/{unit_id}.png'.format(unit_id=groundunit)
helptext = self.instance.session.db.get_unit_tooltip(groundunit)
unit_icon = Icon(image=image, name='icon_%s'%index, position=(2, 2),
unit_icon = Icon(image=image, name='icon_{}'.format(index), position=(2, 2),
helptext=helptext)
widget.addChild(unit_icon)

# if not buildable, this returns string with reason why to be displayed as helptext
#groundunit_unbuildable = self.is_groundunit_unbuildable(groundunit)
groundunit_unbuildable = False
if not groundunit_unbuildable:
button = OkButton(position=(60, 50), name='ok_%s'%index, helptext=T('Build this groundunit!'))
button = OkButton(position=(60, 50), name='ok_{}'.index(index), helptext=T('Build this groundunit!'))
button.capture(Callback(self.start_production, prodline))
else:
button = CancelButton(position=(60, 50), name='ok_%s'%index,
button = CancelButton(position=(60, 50), name='ok_{}'.format(index),
helptext=groundunit_unbuildable)

widget.addChild(button)
Expand All @@ -96,7 +96,7 @@ def build_groundunit_info(self, index, groundunit, prodline):
icon = create_resource_icon(res, self.instance.session.db)
icon.max_size = icon.min_size = icon.size = (16, 16)
icon.position = (xoffset, yoffset)
label = Label(name='cost_%s_%s' % (index, i))
label = Label(name='cost_{}_{}'.format(index, i))
if res == RES.GOLD:
label.text = str(-amount)
else:
Expand Down
8 changes: 4 additions & 4 deletions horizons/gui/tabs/boatbuildertabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,23 @@ def build_ship_info(self, index, ship, prodline):
size = (260, 90)
widget = Container(name='showcase_%s' % index, position=(0, 20 + index*90),
min_size=size, max_size=size, size=size)
bg_icon = Icon(image='content/gui/images/background/square_80.png', name='bg_%s'%index)
bg_icon = Icon(image='content/gui/images/background/square_80.png', name='bg_{}'.format(index))
widget.addChild(bg_icon)

image = 'content/gui/images/objects/ships/76/{unit_id}.png'.format(unit_id=ship)
helptext = self.instance.session.db.get_unit_tooltip(ship)
unit_icon = Icon(image=image, name='icon_%s'%index, position=(2, 2),
unit_icon = Icon(image=image, name='icon_{}'.format(index), position=(2, 2),
helptext=helptext)
widget.addChild(unit_icon)

# if not buildable, this returns string with reason why to be displayed as helptext
#ship_unbuildable = self.is_ship_unbuildable(ship)
ship_unbuildable = False
if not ship_unbuildable:
button = OkButton(position=(60, 50), name='ok_%s'%index, helptext=T('Build this ship!'))
button = OkButton(position=(60, 50), name='ok_{}'.format(index), helptext=T('Build this ship!'))
button.capture(Callback(self.start_production, prodline))
else:
button = CancelButton(position=(60, 50), name='ok_%s'%index,
button = CancelButton(position=(60, 50), name='ok_{}'.format(index),
helptext=ship_unbuildable)

widget.addChild(button)
Expand Down
10 changes: 5 additions & 5 deletions horizons/gui/widgets/resourceoverviewbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ def _update_stats(self):
data.balance
]
for (i, numbers) in enumerate(figures):
label = self.stats_gui.child_finder("resbar_stats_entry_%s" % i)
label.text = "%+d" % numbers
label = self.stats_gui.child_finder("resbar_stats_entry_{}".format(i))
label.text = "{:+d}".format(numbers)

def _hide_stats(self):
"""Inverse of show_stats"""
Expand Down Expand Up @@ -622,15 +622,15 @@ def _init_stats_gui(self):
# Keep in sync with comment there until we can use that data:
# ./content/gui/xml/ingame/hud/resource_overview_bar_stats.xml
box = HBox(padding=0, min_size=(70, 0))
box.name = "resbar_stats_line_%s" % num
box.name = "resbar_stats_line_{}".format(num)
box.helptext = helptext
#TODO Fix icon size; looks like not 16x16 a surprising amount of times.
box.addChild(Icon(image=image))
box.addChild(Spacer())
box.addChild(Label(name="resbar_stats_entry_%s"%num))
box.addChild(Label(name="resbar_stats_entry_{}".format(num)))
#TODO This label is a workaround for some fife font bug,
# probably http://github.com/fifengine/fifengine/issues/666.
templabel = Label(name="resbar_stats_whatever_%s"%num)
templabel = Label(name="resbar_stats_whatever_{}".format(num))
box.addChild(templabel)
if num == len(images) - 1:
# The balance line (last one) gets bold font.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ attr=!long,!gui
[pycodestyle]
exclude=horizons/ext/
count=1
select = W291, W391, E113, E125, E225, E70, E713
select = W291, W391, E113, E125, E225, E227, E228, E70, E713
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
ignore = E101, W191, W503, E241
max-line-length = 100

0 comments on commit 0bce731

Please sign in to comment.