text
stringlengths 0
828
|
|---|
author_name = get_text('author')
|
email = get_text('email')
|
author = Person(author_name, email)
|
url = get_text('url')
|
urlname = get_text('urlname')
|
links = make_links(url, urlname)
|
time = get_text('time')
|
keywords = get_text('keywords')
|
bounds_element = gpx_element.find(gpxns+'bounds')
|
bounds = nullable(parse_bounds)(bounds_element)
|
metadata = Metadata(name=name, description=description, author=author,
|
links=links, time=time, keywords=keywords, bounds=bounds)
|
waypoint_elements = gpx_element.findall(gpxns+'wpt')
|
waypoints = [parse_waypoint(waypoint_element, gpxns) for waypoint_element in waypoint_elements]
|
route_elements = gpx_element.findall(gpxns+'rte')
|
routes = [parse_route(route_element, gpxns) for route_element in route_elements]
|
track_elements = gpx_element.findall(gpxns+'trk')
|
tracks = [parse_track(track_element, gpxns) for track_element in track_elements]
|
# TODO : Private elements
|
gpx_model = GpxModel(creator, metadata, waypoints, routes, tracks)
|
return gpx_model"
|
849,"def add_log_handler(log, handler=None, debug=None, fmt=None):
|
""""""为一个 :class:`logging.Logger` 的实例增加 handler。
|
:param Logger log: 需要处理的 :class:`logging.Logger` 的实例。
|
:param Handler handler: 一个 :class:`logging.Handler` 的实例。
|
:param int debug: Debug 级别。
|
:param str fmt: Handler 的 Formatter。
|
""""""
|
if debug:
|
log.setLevel(debug)
|
if handler:
|
# if not fmt:
|
# fmt = __LOG_FMT
|
if fmt:
|
handler.setFormatter(fmt)
|
log.addHandler(handler)"
|
850,"def __wrap(self, func):
|
'''This decorator overrides the default arguments of a function.
|
For each keyword argument in the function, the decorator first checks
|
if the argument has been overridden by the caller, and uses that value instead if so.
|
If not, the decorator consults the Preset object for an override value.
|
If both of the above cases fail, the decorator reverts to the function's native
|
default parameter value.
|
'''
|
def deffunc(*args, **kwargs):
|
'''The decorated function'''
|
# Get the list of function arguments
|
if hasattr(inspect, 'signature'):
|
# Python 3.5
|
function_args = inspect.signature(func).parameters
|
else:
|
function_args = inspect.getargspec(func).args
|
# Construct a dict of those kwargs which appear in the function
|
filtered_kwargs = kwargs.copy()
|
# look at all relevant keyword arguments for this function
|
for param in function_args:
|
if param in kwargs:
|
# Did the user override the default?
|
filtered_kwargs[param] = kwargs[param]
|
elif param in self._defaults:
|
# Do we have a clobbering value in the default dict?
|
filtered_kwargs[param] = self._defaults[param]
|
# Call the function with the supplied args and the filtered kwarg dict
|
return func(*args, **filtered_kwargs) # pylint: disable=W0142
|
wrapped = functools.update_wrapper(deffunc, func)
|
# force-mangle the docstring here
|
wrapped.__doc__ = ('WARNING: this function has been modified by the Presets '
|
'package.\nDefault parameter values described in the '
|
'documentation below may be inaccurate.\n\n{}'.format(wrapped.__doc__))
|
return wrapped"
|
851,"def _sumDiceRolls(self, rollList):
|
""""""convert from dice roll structure to a single integer result""""""
|
if isinstance(rollList, RollList):
|
self.rolls.append(rollList)
|
return rollList.sum()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.