text stringlengths 0 828 |
|---|
---------- |
*tags : str |
Regional tags. Can be preceded by a ``-`` to select regions |
without that tag. |
Returns |
------- |
an :class:`ApiQuery` of a list of :class:`Region` |
"""""" |
if len(tags) > 10: |
raise ValueError('You can specify up to 10 tags') |
if not tags: |
raise ValueError('No tags specified') |
# We don't check for invalid tags here because the behaviour is |
# fairly intuitive - quering for a non-existent tag returns no |
# regions, excluding it returns all of them. |
@api_query('regionsbytag', tags=','.join(tags)) |
async def result(_, root): |
text = root.find('REGIONS').text |
return ([aionationstates.Region(r) for r in text.split(',')] |
if text else []) |
return result(self)" |
4277,"def dispatch(self, id): |
""""""Dispatch by id. |
Parameters |
---------- |
id : int |
Dispatch id. |
Returns |
------- |
an :class:`ApiQuery` of :class:`Dispatch` |
Raises |
------ |
:class:`NotFound` |
If a dispatch with the requested id doesn't exist. |
"""""" |
@api_query('dispatch', dispatchid=str(id)) |
async def result(_, root): |
elem = root.find('DISPATCH') |
if not elem: |
raise NotFound(f'No dispatch found with id {id}') |
return Dispatch(elem) |
return result(self)" |
4278,"def dispatchlist(self, *, author=None, category=None, |
subcategory=None, sort='new'): |
""""""Find dispatches by certain criteria. |
Parameters |
---------- |
author : str |
Name of the nation authoring the dispatch. |
category : str |
Dispatch's primary category. |
subcategory : str |
Dispatch's secondary category. |
sort : str |
Sort order, 'new' or 'best'. |
Returns |
------- |
an :class:`ApiQuery` of a list of :class:`DispatchThumbnail` |
"""""" |
params = {'sort': sort} |
if author: |
params['dispatchauthor'] = author |
# Here we do need to ensure that our categories are valid, cause |
# NS just ignores the categories it doesn't recognise and returns |
# whatever it feels like. |
if category and subcategory: |
if (category not in dispatch_categories or |
subcategory not in dispatch_categories[category]): |
raise ValueError('Invalid category/subcategory') |
params['dispatchcategory'] = f'{category}:{subcategory}' |
elif category: |
if category not in dispatch_categories: |
raise ValueError('Invalid category') |
params['dispatchcategory'] = category |
else: |
raise ValueError('Cannot request subcategory without category') |
@api_query('dispatchlist', **params) |
async def result(_, root): |
return [ |
DispatchThumbnail._from_elem(elem) |
for elem in root.find('DISPATCHLIST') |
] |
return result(self)" |
4279,"def poll(self, id): |
""""""Poll with a given id. |
Parameters |
---------- |
id : int |
Poll id. |
Returns |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.