text stringlengths 0 828 |
|---|
result['Black Market (estimated)'] = float(elem.find('BLACKMARKET').text) |
result['Government'] = float(elem.find('GOVERNMENT').text) |
result['Private Industry'] = float(elem.find('INDUSTRY').text) |
result['State-Owned Industry'] = float(elem.find('PUBLIC').text) |
return result" |
4136,"async def deaths(self, root): |
""""""Causes of death in the nation, as percentages. |
Returns |
------- |
an :class:`ApiQuery` of dict with keys of str and values of float |
"""""" |
return { |
elem.get('type'): float(elem.text) |
for elem in root.find('DEATHS') |
}" |
4137,"async def endorsements(self, root): |
""""""Regional neighbours endorsing the nation. |
Returns |
------- |
an :class:`ApiQuery` of a list of :class:`Nation` |
"""""" |
text = root.find('ENDORSEMENTS').text |
return [Nation(name) for name in text.split(',')] if text else []" |
4138,"def verify(self, checksum, *, token=None): |
""""""Interface to the `NationStates Verification API |
<https://www.nationstates.net/pages/api.html#verification>`_. |
Parameters |
---------- |
checksum : str |
The user-supplied verification code. Expires if the nation |
logs out, if it performs a significant in-game action such |
as moving regions or endorsing another nation, and after it |
is successfully verified. |
token : str |
A token specific to your service and the nation being verified. |
Returns |
------- |
an :class:`ApiQuery` of bool |
"""""" |
params = {'a': 'verify', 'checksum': checksum} |
if token: |
params['token'] = token |
# Needed so that we get output in xml, as opposed to |
# plain text. It doesn't actually matter what the |
# q param is, it's just important that it's not empty. |
@api_query('i_need_the_output_in_xml', **params) |
async def result(self, root): |
return bool(int(root.find('VERIFY').text)) |
return result(self)" |
4139,"async def description(self): |
""""""Nation's full description, as seen on its in-game page. |
Returns |
------- |
an awaitable of str |
"""""" |
resp = await self._call_web(f'nation={self.id}') |
return html.unescape( |
re.search( |
'<div class=""nationsummary"">(.+?)<p class=""nationranktext"">', |
resp.text, |
flags=re.DOTALL |
) |
.group(1) |
.replace('\n', '') |
.replace('</p>', '') |
.replace('<p>', '\n\n') |
.strip() |
)" |
4140,"def accept(self): |
""""""Accept the option. |
Returns |
------- |
an awaitable of :class:`IssueResult` |
"""""" |
return self._issue._nation._accept_issue(self._issue.id, self._id)" |
4141,"def list_all_promotions(cls, **kwargs): |
""""""List Promotions |
Return a list of Promotions |
This method makes a synchronous HTTP request by default. To make an |
asynchronous HTTP request, please pass async=True |
>>> thread = api.list_all_promotions(async=True) |
>>> result = thread.get() |
:param async bool |
:param int page: page number |
:param int size: page size |
:param str sort: page order |
:return: page[Promotion] |
If the method is called asynchronously, |
returns the request thread. |
"""""" |
kwargs['_return_http_data_only'] = True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.