De-convolute my attempt at broadening MoveEffectProperty.

This commit is contained in:
Lynn "Zhorken" Vaughan 2012-08-05 20:39:03 -04:00
parent d689bd3de3
commit b3ade1ecf1
2 changed files with 11 additions and 22 deletions

View file

@ -128,26 +128,18 @@ class MoveEffectProperty(object):
Use `MoveEffectPropertyMap` for dict-like association proxies.
"""
def __init__(self, *effect_columns):
self.effect_columns = effect_columns
def __init__(self, effect_column, relationship='move_effect'):
self.effect_column = effect_column
self.relationship = relationship
def __get__(self, obj, cls):
if obj is None:
return self
if obj.move_effect is None:
return None
props = []
for prop, column in self.effect_columns:
prop = getattr(obj, prop)
if prop is None:
continue
column = getattr(prop, column)
if column is None:
print(prop)
props.append(column)
return _markdownify_effect_text(obj, ' '.join(prop for prop in props))
thing = getattr(obj, self.relationship)
prop = getattr(thing, self.effect_column)
return _markdownify_effect_text(obj, prop)
class MoveEffectPropertyMap(MoveEffectProperty):
"""Similar to `MoveEffectProperty`, but works on dict-like association

View file

@ -2063,14 +2063,11 @@ ConquestMoveData.range = relationship(ConquestMoveRange,
innerjoin=True,
backref='move_data')
ConquestMoveData.effect = markdown.MoveEffectProperty(('move_effect', 'effect'))
ConquestMoveData.effect_map = markdown.MoveEffectPropertyMap(('move_effect', 'effect_map'))
ConquestMoveData.short_effect = markdown.MoveEffectProperty(
('move_effect', 'short_effect'),
('move_displacement', 'short_effect')
)
ConquestMoveData.short_effect_map = markdown.MoveEffectPropertyMap(('move_effect', 'short_effect_map'))
ConquestMoveData.displacement = markdown.MoveEffectProperty(('move_displacement', 'effect'))
ConquestMoveData.effect = markdown.MoveEffectProperty('effect')
ConquestMoveData.effect_map = markdown.MoveEffectPropertyMap('effect_map')
ConquestMoveData.short_effect = markdown.MoveEffectProperty('short_effect')
ConquestMoveData.short_effect_map = markdown.MoveEffectPropertyMap('short_effect_map')
ConquestMoveData.displacement = markdown.MoveEffectProperty('effect', relationship='move_displacement')
ConquestPokemonEvolution.gender = relationship(Gender,
backref='conquest_evolutions')