text
stringlengths
0
828
if sys.version_info >= (2, 7):
name = 'python -m ' + this_module.rsplit('.', 1)[0]
else:
name = 'python -m ' + this_module
# This module is always executed as ""python -m flask.run"" and as such
# we need to ensure that we restore the actual command line so that
# the reloader can properly operate.
sys.argv = ['-m', this_module] + sys.argv[1:]
else:
name = None
cli.main(args=args, prog_name=name)"
1637,"def init_app(self, app, entry_point_group='invenio_queues.queues'):
""""""Flask application initialization.""""""
self.init_config(app)
app.extensions['invenio-queues'] = _InvenioQueuesState(
app,
app.config['QUEUES_CONNECTION_POOL'],
entry_point_group=entry_point_group
)
return app"
1638,"def parse_result(result):
""""""parse_result(json result) -- print the web query according to the type
of result from duckduckgo.
""""""
if(result['Type'] == 'D'):
print """"""There is more than one answer for this. Try making your query\
more specific. For example, if you want to learn about apple the company\
and not apple the fruit, try something like apple inc or apple computers.
""""""
elif(result['Type'] == 'A'):
print result['AbstractText']
print '\nResults from DuckDuckGo'
elif(result['Type'] == 'C'):
for entry in result['RelatedTopics']:
print entry['Text']
print ""\n""
else:
print ""I do not know how to process this query at the moment."""
1639,"def query(string):
""""""query(user string) -- make http request to duckduckgo api, to get result
in json format, then call parse_result.
""""""
url = ""https://api.duckduckgo.com/?q=""
formating = ""&format=json""
query_string = url+'+'.join(string)+formating
try:
result = json.loads(requests.get(query_string).text)
except:
print ""I'm sorry! Something went wrong. Maybe we could try again later.""
return
parse_result(result)"
1640,"def parse_gpx(gpx_element, gpx_extensions_parser=None,
metadata_extensions_parser=None,
waypoint_extensions_parser=None,
route_extensions_parser=None,
track_extensions_parser=None,
segment_extensions_parser=None,
gpxns=None):
""""""Parse a GPX file into a GpxModel.
Args:
gpx_element: gpx_element: The root <gpx> element of an XML document
containing a version attribute. GPX versions 1.1 is supported.
gpx_extensions_parser: An optional callable which accepts an Element
with the 'extensions' tag and returns a list of model objects
representing the extensions. If not specified, extensions are
ignored.
metadata_extensions_parser: An optional callable which accepts an
Element with the 'extensions' tag and returns a list of model
objects representing the extensions. If not specified, extensions
are ignored.
waypoint_extensions_parser: An optional callable which accepts an
Element with the 'extensions' tag and returns a list of model
objects representing the extensions. If not specified, extensions
are ignored.
route_extensions_parser: An optional callable which accepts an Element
with the 'extensions' tag and returns a list of model objects
representing the extensions. If not specified, extensions are
ignored.
track_extensions_parser: An optional callable which accepts an Element
with the 'extensions' tag and returns a list of model objects
representing the extensions. If not specified, extensions are
ignored.
segment_extensions_parser: An optional callable which accepts an
Element with the 'extensions' tag and returns a list of model
objects representing the extensions. If not specified, extensions
are ignored.