text
stringlengths
0
828
else:
return rollList"
852,"def _re_flatten(p):
''' Turn all capturing groups in a regular expression pattern into
non-capturing groups. '''
if '(' not in p: return p
return re.sub(r'(\\*)(\(\?P<[^>]*>|\((?!\?))',
lambda m: m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:', p)"
853,"def cookies(self):
"""""" Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT
decoded. Use :meth:`get_cookie` if you expect signed cookies. """"""
cookies = SimpleCookie(self.environ.get('HTTP_COOKIE','')).values()
if len(cookies) > self.MAX_PARAMS:
raise HTTPError(413, 'Too many cookies')
return FormsDict((c.key, c.value) for c in cookies)"
854,"def query(self):
''' The :attr:`query_string` parsed into a :class:`FormsDict`. These
values are sometimes called ""URL arguments"" or ""GET parameters"", but
not to be confused with ""URL wildcards"" as they are provided by the
:class:`Router`. '''
get = self.environ['bottle.get'] = FormsDict()
pairs = _parse_qsl(self.environ.get('QUERY_STRING', ''))
if len(pairs) > self.MAX_PARAMS:
raise HTTPError(413, 'Too many parameters')
for key, value in pairs:
get[key] = value
return get"
855,"def copy(self):
''' Returns a copy of self. '''
# TODO
copy = Response()
copy.status = self.status
copy._headers = dict((k, v[:]) for (k, v) in self._headers.items())
return copy"
856,"def annotated_references(obj):
""""""
Return known information about references held by the given object.
Returns a mapping from referents to lists of descriptions. Note that there
may be more than one edge leading to any particular referent; hence the
need for a list. Descriptions are currently strings.
""""""
references = KeyTransformDict(transform=id, default_factory=list)
for type_ in type(obj).__mro__:
if type_ in type_based_references:
type_based_references[type_](obj, references)
add_attr(obj, ""__dict__"", references)
add_attr(obj, ""__class__"", references)
if isinstance(obj, type):
add_attr(obj, ""__mro__"", references)
return references"
857,"def object_annotation(obj):
""""""
Return a string to be used for Graphviz nodes. The string
should be short but as informative as possible.
""""""
# For basic types, use the repr.
if isinstance(obj, BASE_TYPES):
return repr(obj)
if type(obj).__name__ == 'function':
return ""function\\n{}"".format(obj.__name__)
elif isinstance(obj, types.MethodType):
if six.PY2:
im_class = obj.im_class
if im_class is None:
im_class_name = ""<None>""
else:
im_class_name = im_class.__name__
try:
func_name = obj.__func__.__name__
except AttributeError:
func_name = ""<anonymous>""
return ""instancemethod\\n{}.{}"".format(
im_class_name,
func_name,
)
else:
try:
func_name = obj.__func__.__qualname__
except AttributeError:
func_name = ""<anonymous>""
return ""instancemethod\\n{}"".format(func_name)
elif isinstance(obj, list):
return ""list[{}]"".format(len(obj))
elif isinstance(obj, tuple):
return ""tuple[{}]"".format(len(obj))
elif isinstance(obj, dict):
return ""dict[{}]"".format(len(obj))
elif isinstance(obj, types.ModuleType):
return ""module\\n{}"".format(obj.__name__)
elif isinstance(obj, type):
return ""type\\n{}"".format(obj.__name__)
elif six.PY2 and isinstance(obj, types.InstanceType):
return ""instance\\n{}"".format(obj.__class__.__name__)
elif isinstance(obj, weakref.ref):