More verbose Object representation in json format

This commit is contained in:
Eriks Karls 2019-08-26 09:47:04 +03:00
parent 411b158487
commit 7e05e35ebf

View File

@ -156,6 +156,14 @@ class MyCompanies:
raise ErepublikException("Wrong function call") raise ErepublikException("Wrong function call")
@property
def __dict__(self):
ret = {}
for key in dir(self):
if not key.startswith('_'):
ret[key] = getattr(self, key)
return ret
class SlowRequests(Session): class SlowRequests(Session):
last_time: datetime.datetime last_time: datetime.datetime
@ -285,33 +293,13 @@ class Config:
def wt(self): def wt(self):
return self.work and self.train return self.work and self.train
@property
def __dict__(self) -> Dict[str, Union[bool, str, List[str]]]: def __dict__(self) -> Dict[str, Union[bool, str, List[str]]]:
return dict( ret = {}
email=self.email, for key in dir(self):
password=self.password, if not key.startswith('_'):
work=self.work, ret[key] = getattr(self, key)
train=self.train, return ret
wam=self.wam,
auto_sell=self.auto_sell,
auto_sell_all=self.auto_sell_all,
employees=self.employees,
fight=self.fight,
air=self.air,
ground=self.ground,
all_in=self.all_in,
next_energy=self.next_energy,
boosters=self.boosters,
travel_to_fight=self.travel_to_fight,
epic_hunt=self.epic_hunt,
epic_hunt_ebs=self.epic_hunt_ebs,
rw_def_side=self.rw_def_side,
interactive=self.interactive,
continuous_fighting=self.continuous_fighting,
auto_buy_raw=self.auto_buy_raw,
force_wam=self.force_wam,
sort_battles_time=self.sort_battles_time,
force_travel=self.force_travel,
)
class Energy: class Energy:
@ -360,13 +348,11 @@ class Energy:
@property @property
def __dict__(self): def __dict__(self):
return dict( ret = {}
limit=self.limit, for key in dir(self):
interval=self.interval, if not key.startswith('_'):
recoverable=self.recoverable, ret[key] = getattr(self, key)
recovered=self.recovered, return ret
reference_time=self.reference_time
)
class Details(object): class Details(object):
@ -412,6 +398,14 @@ class Details(object):
next_level_up = (1 + (self.xp // 10)) * 10 next_level_up = (1 + (self.xp // 10)) * 10
return next_level_up - self.xp return next_level_up - self.xp
@property
def __dict__(self):
ret = {}
for key in dir(self):
if not key.startswith('_'):
ret[key] = getattr(self, key)
return ret
class Politics: class Politics:
is_party_member: bool = False is_party_member: bool = False
@ -422,6 +416,14 @@ class Politics:
is_congressman: bool = False is_congressman: bool = False
is_country_president: bool = False is_country_president: bool = False
@property
def __dict__(self):
ret = {}
for key in dir(self):
if not key.startswith('_'):
ret[key] = getattr(self, key)
return ret
class House(object): class House(object):
quality = None quality = None
@ -1006,6 +1008,14 @@ class BattleSide:
self.allies = [int(ally) for ally in allies] self.allies = [int(ally) for ally in allies]
self.deployed = [int(ally) for ally in deployed] self.deployed = [int(ally) for ally in deployed]
@property
def __dict__(self):
ret = {}
for key in dir(self):
if not key.startswith('_'):
ret[key] = getattr(self, key)
return ret
class BattleDivision: class BattleDivision:
end: datetime.datetime end: datetime.datetime
@ -1023,6 +1033,14 @@ class BattleDivision:
self.dom_pts = dict({"inv": inv_pts, "def": def_pts}) self.dom_pts = dict({"inv": inv_pts, "def": def_pts})
self.wall = dict({"for": wall_for, "dom": wall_dom}) self.wall = dict({"for": wall_for, "dom": wall_dom})
@property
def __dict__(self):
ret = {}
for key in dir(self):
if not key.startswith('_'):
ret[key] = getattr(self, key)
return ret
class Battle(object): class Battle(object):
id: int = 0 id: int = 0
@ -1083,6 +1101,14 @@ class Battle(object):
self.id, utils.COUNTRIES[self.invader.id], utils.COUNTRIES[self.defender.id], self.zone_id, time_part self.id, utils.COUNTRIES[self.invader.id], utils.COUNTRIES[self.defender.id], self.zone_id, time_part
) )
@property
def __dict__(self):
ret = {}
for key in dir(self):
if not key.startswith('_'):
ret[key] = getattr(self, key)
return ret
class EnergyToFight: class EnergyToFight:
energy: int = 0 energy: int = 0