text
stringlengths
0
828
it works more like:
a,b,a,b,a,b,a
until one of the pipes ends '''
try:
for p in cycle(map(iter, pipes)):
yield next(p)
except StopIteration:
pass"
4685,"def matches():
""""""This resource returns a list of the currently running WvW matches, with
the participating worlds included in the result. Further details about a
match can be requested using the ``match_details`` function.
The response is a list of match objects, each of which contains the
following properties:
wvw_match_id (string):
The WvW match id.
red_world_id (number):
The world id of the red world.
blue_world_id (number):
The world id of the blue world.
green_world_id (number):
The world id of the green world.
start_time (datetime):
A timestamp of when the match started.
end_time (datetime):
A timestamp of when the match ends.
""""""
wvw_matches = get_cached(""wvw/matches.json"", False).get(""wvw_matches"")
for match in wvw_matches:
match[""start_time""] = parse_datetime(match[""start_time""])
match[""end_time""] = parse_datetime(match[""end_time""])
return wvw_matches"
4686,"def objective_names(lang=""en""):
""""""This resource returns a list of the localized WvW objective names for
the specified language.
:param lang: The language to query the names for.
:return: A dictionary mapping the objective Ids to the names.
*Note that these are not the names displayed in the game, but rather the
abstract type.*
""""""
params = {""lang"": lang}
cache_name = ""objective_names.%(lang)s.json"" % params
data = get_cached(""wvw/objective_names.json"", cache_name, params=params)
return dict([(objective[""id""], objective[""name""]) for objective in data])"
4687,"def _parse_data(self, data, charset):
"""""" Parse the xml data into dictionary. """"""
builder = TreeBuilder(numbermode=self._numbermode)
if isinstance(data,basestring):
xml.sax.parseString(data, builder)
else:
xml.sax.parse(data, builder)
return builder.root[self._root_element_name()]"
4688,"def _format_data(self, data, charset):
"""""" Format data into XML. """"""
if data is None or data == '':
return u''
stream = StringIO.StringIO()
xml = SimplerXMLGenerator(stream, charset)
xml.startDocument()
xml.startElement(self._root_element_name(), {})
self._to_xml(xml, data)
xml.endElement(self._root_element_name())
xml.endDocument()
return stream.getvalue()"
4689,"def _to_xml(self, xml, data, key=None):
"""""" Recursively convert the data into xml.
This function was originally copied from the
`Piston project <https://bitbucket.org/jespern/django-piston/>`_
It has been modified since.
:param xml: the xml document
:type xml: SimplerXMLGenerator
:param data: data to be formatted
:param key: name of the parent element (for root this is ``None``)
""""""
if isinstance(data, (list, tuple)):
for item in data:
elemname = self._list_item_element_name(key)
xml.startElement(elemname, {})
self._to_xml(xml, item)
xml.endElement(elemname)
elif isinstance(data, dict):
for key, value in data.iteritems():
xml.startElement(key, {})