获取数据源码
本文最后更新于1830天前,其中的信息可能已经有所发展或是发生改变。
def get_argument(self, name: str, default: str, strip: bool = True) -> str:

pass

@overload # noqa: F811

def get_argument(

self, name: str, default: _ArgDefaultMarker = _ARG_DEFAULT, strip: bool = True

) -> str:

pass

@overload # noqa: F811

def get_argument(

self, name: str, default: None, strip: bool = True

) -> Optional[str]:

pass

[docs] def get_argument( # noqa: F811

self,

name: str,

default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,

strip: bool = True,

) -> Optional[str]:

"""Returns the value of the argument with the given name.

If default is not provided, the argument is considered to be

required, and we raise a `MissingArgumentError` if it is missing.

If the argument appears in the request more than once, we return the

last value.

This method searches both the query and body arguments.

"""

return self._get_argument(name, default, self.request.arguments, strip)

[docs] def get_arguments(self, name: str, strip: bool = True) -> List[str]:

"""Returns a list of the arguments with the given name.

If the argument is not present, returns an empty list.

This method searches both the query and body arguments.

"""

# Make sure `get_arguments` isn't accidentally being called with a

# positional argument that's assumed to be a default (like in

# `get_argument`.)

assert isinstance(strip, bool)

return self._get_arguments(name, self.request.arguments, strip)

[docs] def get_body_argument(

self,

name: str,

default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,

strip: bool = True,

) -> Optional[str]:

"""Returns the value of the argument with the given name

from the request body.

If default is not provided, the argument is considered to be

required, and we raise a `MissingArgumentError` if it is missing.

If the argument appears in the url more than once, we return the

last value.

.. versionadded:: 3.2

"""

return self._get_argument(name, default, self.request.body_arguments, strip)

[docs] def get_body_arguments(self, name: str, strip: bool = True) -> List[str]:

"""Returns a list of the body arguments with the given name.

If the argument is not present, returns an empty list.

.. versionadded:: 3.2

"""

return self._get_arguments(name, self.request.body_arguments, strip)

[docs] def get_query_argument(

self,

name: str,

default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,

strip: bool = True,

) -> Optional[str]:

"""Returns the value of the argument with the given name

from the request query string.

If default is not provided, the argument is considered to be

required, and we raise a `MissingArgumentError` if it is missing.

If the argument appears in the url more than once, we return the

last value.

.. versionadded:: 3.2

"""

return self._get_argument(name, default, self.request.query_arguments, strip)

[docs] def get_query_arguments(self, name: str, strip: bool = True) -> List[str]:

"""Returns a list of the query arguments with the given name.

If the argument is not present, returns an empty list.

.. versionadded:: 3.2

"""

return self._get_arguments(name, self.request.query_arguments, strip)

def _get_argument(

self,

name: str,

default: Union[None, str, _ArgDefaultMarker],

source: Dict[str, List[bytes]],

strip: bool = True,

) -> Optional[str]:

args = self._get_arguments(name, source, strip=strip)

if not args:

if isinstance(default, _ArgDefaultMarker):

raise MissingArgumentError(name)

return default

return args[-1]

def _get_arguments(

self, name: str, source: Dict[str, List[bytes]], strip: bool = True

) -> List[str]:

values = []

for v in source.get(name, []):

s = self.decode_argument(v, name=name)

if isinstance(s, unicode_type):

# Get rid of any weird control chars (unless decoding gave

# us bytes, in which case leave it alone)

s = RequestHandler._remove_control_chars_regex.sub(" ", s)

if strip:

s = s.strip()

values.append(s)

return values

点击数:198

    暂无评论

    发送评论 编辑评论

    
    				
    |´・ω・)ノ
    ヾ(≧∇≦*)ゝ
    (☆ω☆)
    (╯‵□′)╯︵┴─┴
     ̄﹃ ̄
    (/ω\)
    ∠( ᐛ 」∠)_
    (๑•̀ㅁ•́ฅ)
    →_→
    ୧(๑•̀⌄•́๑)૭
    ٩(ˊᗜˋ*)و
    (ノ°ο°)ノ
    (´இ皿இ`)
    ⌇●﹏●⌇
    (ฅ´ω`ฅ)
    (╯°A°)╯︵○○○
    φ( ̄∇ ̄o)
    ヾ(´・ ・`。)ノ"
    ( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
    (ó﹏ò。)
    Σ(っ °Д °;)っ
    ( ,,´・ω・)ノ"(´っω・`。)
    ╮(╯▽╰)╭
    o(*////▽////*)q
    >﹏<
    ( ๑´•ω•) "(ㆆᴗㆆ)
    😂
    😀
    😅
    😊
    🙂
    🙃
    😌
    😍
    😘
    😜
    😝
    😏
    😒
    🙄
    😳
    😡
    😔
    😫
    😱
    😭
    💩
    👻
    🙌
    🖕
    👍
    👫
    👬
    👭
    🌚
    🌝
    🙈
    💊
    😶
    🙏
    🍦
    🍉
    😣
    Source: github.com/k4yt3x/flowerhd
    颜文字
    Emoji
    小恐龙
    花!
    上一篇
    下一篇