JSON.dump sort_keys parameter throwing mysterious errors
This commit is contained in:
parent
a316f277fb
commit
d483bcbcb9
@ -393,7 +393,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
|||||||
sleep(seconds)
|
sleep(seconds)
|
||||||
|
|
||||||
def to_json(self, indent: bool = False) -> str:
|
def to_json(self, indent: bool = False) -> str:
|
||||||
return utils.json.dumps(self, cls=classes.MyJSONEncoder, indent=4 if indent else None, sort_keys=True)
|
return utils.json.dumps(self, cls=classes.MyJSONEncoder, indent=4 if indent else None)
|
||||||
|
|
||||||
def get_countries_with_regions(self) -> Set[constants.Country]:
|
def get_countries_with_regions(self) -> Set[constants.Country]:
|
||||||
r_json = self._post_main_travel_data().json()
|
r_json = self._post_main_travel_data().json()
|
||||||
@ -1657,7 +1657,7 @@ class CitizenMilitary(CitizenTravel):
|
|||||||
self.write_log("Hits: {:>4} | Damage: {}".format(total_hits, total_damage))
|
self.write_log("Hits: {:>4} | Damage: {}".format(total_hits, total_damage))
|
||||||
ok_to_fight = False
|
ok_to_fight = False
|
||||||
if total_damage:
|
if total_damage:
|
||||||
self.reporter.report_action("FIGHT", dict(battle=battle, side=side, dmg=total_damage,
|
self.reporter.report_action("FIGHT", dict(battle=str(battle), side=str(side), dmg=total_damage,
|
||||||
air=battle.has_air, hits=total_hits))
|
air=battle.has_air, hits=total_hits))
|
||||||
return error_count
|
return error_count
|
||||||
|
|
||||||
|
@ -566,11 +566,11 @@ class Reporter:
|
|||||||
def __bot_update(self, data: dict) -> Response:
|
def __bot_update(self, data: dict) -> Response:
|
||||||
if self.__to_update:
|
if self.__to_update:
|
||||||
for unreported_data in self.__to_update:
|
for unreported_data in self.__to_update:
|
||||||
unreported_data.update(player_id=self.citizen_id, key=self.key)
|
unreported_data.update(player_id=self.citizen.id, key=self.key)
|
||||||
unreported_data = utils.json.load(utils.json.dumps(unreported_data, cls=MyJSONEncoder, sort_keys=True))
|
unreported_data = utils.json.load(utils.json.dumps(unreported_data, cls=MyJSONEncoder))
|
||||||
self._req.post("{}/bot/update".format(self.url), json=unreported_data)
|
self._req.post("{}/bot/update".format(self.url), json=unreported_data)
|
||||||
self.__to_update.clear()
|
self.__to_update.clear()
|
||||||
data = utils.json.loads(utils.json.dumps(data, cls=MyJSONEncoder, sort_keys=True))
|
data = utils.json.loads(utils.json.dumps(data, cls=MyJSONEncoder))
|
||||||
r = self._req.post("{}/bot/update".format(self.url), json=data)
|
r = self._req.post("{}/bot/update".format(self.url), json=data)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ def send_email(name: str, content: List[Any], player=None, local_vars: Dict[str,
|
|||||||
local_vars['citizen'] = repr(local_vars['citizen'])
|
local_vars['citizen'] = repr(local_vars['citizen'])
|
||||||
|
|
||||||
from erepublik.classes import MyJSONEncoder
|
from erepublik.classes import MyJSONEncoder
|
||||||
files.append(('file', ("local_vars.json", json.dumps(local_vars, cls=MyJSONEncoder, sort_keys=True),
|
files.append(('file', ("local_vars.json", json.dumps(local_vars, cls=MyJSONEncoder),
|
||||||
"application/json")))
|
"application/json")))
|
||||||
if isinstance(player, Citizen):
|
if isinstance(player, Citizen):
|
||||||
files.append(('file', ("instance.json", player.to_json(indent=True), "application/json")))
|
files.append(('file', ("instance.json", player.to_json(indent=True), "application/json")))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user