Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
UsersViewTests.test_detail_view_role_assignments_tab
(self)
Test the role assignments tab of the detail view .
Test the role assignments tab of the detail view .
def test_detail_view_role_assignments_tab(self): """Test the role assignments tab of the detail view .""" domain = self._get_default_domain() user = self.users.get(id="1") tenant = self.tenants.get(id=user.project_id) user_role_assignments = self.role_assignments.filter( ...
[ "def", "test_detail_view_role_assignments_tab", "(", "self", ")", ":", "domain", "=", "self", ".", "_get_default_domain", "(", ")", "user", "=", "self", ".", "users", ".", "get", "(", "id", "=", "\"1\"", ")", "tenant", "=", "self", ".", "tenants", ".", "...
[ 956, 4 ]
[ 1017, 63 ]
python
en
['en', 'en', 'en']
True
UsersViewTests.test_detail_view_role_assignments_tab_with_exception
(self)
Test the role assignments tab with exception. The table is displayed empty and an error message pop if the role assignment request fails.
Test the role assignments tab with exception.
def test_detail_view_role_assignments_tab_with_exception(self): """Test the role assignments tab with exception. The table is displayed empty and an error message pop if the role assignment request fails. """ domain = self._get_default_domain() user = self.users.get(id="...
[ "def", "test_detail_view_role_assignments_tab_with_exception", "(", "self", ")", ":", "domain", "=", "self", ".", "_get_default_domain", "(", ")", "user", "=", "self", ".", "users", ".", "get", "(", "id", "=", "\"1\"", ")", "tenant", "=", "self", ".", "tenan...
[ 1023, 4 ]
[ 1061, 31 ]
python
en
['en', 'en', 'en']
True
UsersViewTests.test_detail_view_groups_tab
(self)
Test the groups tab of the detail view .
Test the groups tab of the detail view .
def test_detail_view_groups_tab(self): """Test the groups tab of the detail view .""" domain = self._get_default_domain() user = self.users.get(id="1") tenant = self.tenants.get(id=user.project_id) groups = self.groups.list() self.mock_domain_get.return_value = domain ...
[ "def", "test_detail_view_groups_tab", "(", "self", ")", ":", "domain", "=", "self", ".", "_get_default_domain", "(", ")", "user", "=", "self", ".", "users", ".", "get", "(", "id", "=", "\"1\"", ")", "tenant", "=", "self", ".", "tenants", ".", "get", "(...
[ 1067, 4 ]
[ 1102, 66 ]
python
en
['en', 'en', 'en']
True
UsersViewTests.test_detail_view_groups_tab_with_exception
(self)
Test the groups tab of the detail view . The table is displayed empty and an error message pop if the groups request fails.
Test the groups tab of the detail view .
def test_detail_view_groups_tab_with_exception(self): """Test the groups tab of the detail view . The table is displayed empty and an error message pop if the groups request fails. """ domain = self._get_default_domain() user = self.users.get(id="1") tenant = sel...
[ "def", "test_detail_view_groups_tab_with_exception", "(", "self", ")", ":", "domain", "=", "self", ".", "_get_default_domain", "(", ")", "user", "=", "self", ".", "users", ".", "get", "(", "id", "=", "\"1\"", ")", "tenant", "=", "self", ".", "tenants", "."...
[ 1108, 4 ]
[ 1143, 66 ]
python
en
['en', 'en', 'en']
True
default_subprocess_runner
(cmd, cwd=None, extra_environ=None)
The default method of calling the wrapper subprocess.
The default method of calling the wrapper subprocess.
def default_subprocess_runner(cmd, cwd=None, extra_environ=None): """The default method of calling the wrapper subprocess.""" env = os.environ.copy() if extra_environ: env.update(extra_environ) check_call(cmd, cwd=cwd, env=env)
[ "def", "default_subprocess_runner", "(", "cmd", ",", "cwd", "=", "None", ",", "extra_environ", "=", "None", ")", ":", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "extra_environ", ":", "env", ".", "update", "(", "extra_environ", ")", ...
[ 59, 0 ]
[ 65, 37 ]
python
en
['en', 'en', 'en']
True
quiet_subprocess_runner
(cmd, cwd=None, extra_environ=None)
A method of calling the wrapper subprocess while suppressing output.
A method of calling the wrapper subprocess while suppressing output.
def quiet_subprocess_runner(cmd, cwd=None, extra_environ=None): """A method of calling the wrapper subprocess while suppressing output.""" env = os.environ.copy() if extra_environ: env.update(extra_environ) check_output(cmd, cwd=cwd, env=env, stderr=STDOUT)
[ "def", "quiet_subprocess_runner", "(", "cmd", ",", "cwd", "=", "None", ",", "extra_environ", "=", "None", ")", ":", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "extra_environ", ":", "env", ".", "update", "(", "extra_environ", ")", "c...
[ 68, 0 ]
[ 74, 54 ]
python
en
['en', 'en', 'en']
True
norm_and_check
(source_tree, requested)
Normalise and check a backend path. Ensure that the requested backend path is specified as a relative path, and resolves to a location under the given source tree. Return an absolute version of the requested path.
Normalise and check a backend path.
def norm_and_check(source_tree, requested): """Normalise and check a backend path. Ensure that the requested backend path is specified as a relative path, and resolves to a location under the given source tree. Return an absolute version of the requested path. """ if os.path.isabs(requested): ...
[ "def", "norm_and_check", "(", "source_tree", ",", "requested", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "requested", ")", ":", "raise", "ValueError", "(", "\"paths must be relative\"", ")", "abs_source", "=", "os", ".", "path", ".", "abspath", ...
[ 77, 0 ]
[ 98, 24 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.subprocess_runner
(self, runner)
A context manager for temporarily overriding the default subprocess runner.
A context manager for temporarily overriding the default subprocess runner.
def subprocess_runner(self, runner): """A context manager for temporarily overriding the default subprocess runner. """ prev = self._subprocess_runner self._subprocess_runner = runner try: yield finally: self._subprocess_runner = prev
[ "def", "subprocess_runner", "(", "self", ",", "runner", ")", ":", "prev", "=", "self", ".", "_subprocess_runner", "self", ".", "_subprocess_runner", "=", "runner", "try", ":", "yield", "finally", ":", "self", ".", "_subprocess_runner", "=", "prev" ]
[ 138, 4 ]
[ 147, 42 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.get_requires_for_build_wheel
(self, config_settings=None)
Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["wheel >= 0.25", "setuptools"] This does not include requirements specified in pyproject.toml. It returns the result of calling the equivalently named hook in a subprocess. ...
Identify packages required for building a wheel
def get_requires_for_build_wheel(self, config_settings=None): """Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["wheel >= 0.25", "setuptools"] This does not include requirements specified in pyproject.toml. It returns the...
[ "def", "get_requires_for_build_wheel", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_wheel'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 149, 4 ]
[ 161, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.prepare_metadata_for_build_wheel
( self, metadata_directory, config_settings=None, _allow_fallback=True)
Prepare a *.dist-info folder with metadata for this project. Returns the name of the newly created folder. If the build backend defines a hook with this name, it will be called in a subprocess. If not, the backend will be asked to build a wheel, and the dist-info extracted from that (u...
Prepare a *.dist-info folder with metadata for this project.
def prepare_metadata_for_build_wheel( self, metadata_directory, config_settings=None, _allow_fallback=True): """Prepare a *.dist-info folder with metadata for this project. Returns the name of the newly created folder. If the build backend defines a hook with this name,...
[ "def", "prepare_metadata_for_build_wheel", "(", "self", ",", "metadata_directory", ",", "config_settings", "=", "None", ",", "_allow_fallback", "=", "True", ")", ":", "return", "self", ".", "_call_hook", "(", "'prepare_metadata_for_build_wheel'", ",", "{", "'metadata_...
[ 163, 4 ]
[ 179, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.build_wheel
( self, wheel_directory, config_settings=None, metadata_directory=None)
Build a wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_wheel' hook in the backend. However, if that was previously called by 'prepare_metadata_for_build_wheel', and the same metadata_directory is used, the previously b...
Build a wheel from this project.
def build_wheel( self, wheel_directory, config_settings=None, metadata_directory=None): """Build a wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_wheel' hook in the backend. However, if that was previou...
[ "def", "build_wheel", "(", "self", ",", "wheel_directory", ",", "config_settings", "=", "None", ",", "metadata_directory", "=", "None", ")", ":", "if", "metadata_directory", "is", "not", "None", ":", "metadata_directory", "=", "abspath", "(", "metadata_directory",...
[ 181, 4 ]
[ 199, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.get_requires_for_build_sdist
(self, config_settings=None)
Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["setuptools >= 26"] This does not include requirements specified in pyproject.toml. It returns the result of calling the equivalently named hook in a subprocess.
Identify packages required for building a wheel
def get_requires_for_build_sdist(self, config_settings=None): """Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["setuptools >= 26"] This does not include requirements specified in pyproject.toml. It returns the result of ...
[ "def", "get_requires_for_build_sdist", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_sdist'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 201, 4 ]
[ 213, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.build_sdist
(self, sdist_directory, config_settings=None)
Build an sdist from this project. Returns the name of the newly created file. This calls the 'build_sdist' backend hook in a subprocess.
Build an sdist from this project.
def build_sdist(self, sdist_directory, config_settings=None): """Build an sdist from this project. Returns the name of the newly created file. This calls the 'build_sdist' backend hook in a subprocess. """ return self._call_hook('build_sdist', { 'sdist_directory': a...
[ "def", "build_sdist", "(", "self", ",", "sdist_directory", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'build_sdist'", ",", "{", "'sdist_directory'", ":", "abspath", "(", "sdist_directory", ")", ",", "'config_setting...
[ 215, 4 ]
[ 225, 10 ]
python
en
['en', 'en', 'en']
True
email_is_not_mit_mailing_list
(email: str)
Prevent MIT mailing lists from signing up for Zulip
Prevent MIT mailing lists from signing up for Zulip
def email_is_not_mit_mailing_list(email: str) -> None: """Prevent MIT mailing lists from signing up for Zulip""" if "@mit.edu" in email: username = email.rsplit("@", 1)[0] # Check whether the user exists and can get mail. try: DNS.dnslookup(f"{username}.pobox.ns.athena.mit.ed...
[ "def", "email_is_not_mit_mailing_list", "(", "email", ":", "str", ")", "->", "None", ":", "if", "\"@mit.edu\"", "in", "email", ":", "username", "=", "email", ".", "rsplit", "(", "\"@\"", ",", "1", ")", "[", "0", "]", "# Check whether the user exists and can ge...
[ 67, 0 ]
[ 78, 60 ]
python
en
['en', 'en', 'en']
True
HomepageForm.clean_email
(self)
Returns the email if and only if the user's email address is allowed to join the realm they are trying to join.
Returns the email if and only if the user's email address is allowed to join the realm they are trying to join.
def clean_email(self) -> str: """Returns the email if and only if the user's email address is allowed to join the realm they are trying to join.""" email = self.cleaned_data["email"] # Otherwise, the user is trying to join a specific realm. realm = self.realm from_multiu...
[ "def", "clean_email", "(", "self", ")", "->", "str", ":", "email", "=", "self", ".", "cleaned_data", "[", "\"email\"", "]", "# Otherwise, the user is trying to join a specific realm.", "realm", "=", "self", ".", "realm", "from_multiuse_invite", "=", "self", ".", "...
[ 166, 4 ]
[ 210, 20 ]
python
en
['en', 'en', 'en']
True
ZulipPasswordResetForm.save
( self, domain_override: Optional[bool] = None, subject_template_name: str = "registration/password_reset_subject.txt", email_template_name: str = "registration/password_reset_email.html", use_https: bool = False, token_generator: PasswordResetTokenGenerator = default_tok...
If the email address has an account in the target realm, generates a one-use only link for resetting password and sends to the user. We send a different email if an associated account does not exist in the database, or an account does exist, but not in the realm. Note:...
If the email address has an account in the target realm, generates a one-use only link for resetting password and sends to the user.
def save( self, domain_override: Optional[bool] = None, subject_template_name: str = "registration/password_reset_subject.txt", email_template_name: str = "registration/password_reset_email.html", use_https: bool = False, token_generator: PasswordResetTokenGenerator = def...
[ "def", "save", "(", "self", ",", "domain_override", ":", "Optional", "[", "bool", "]", "=", "None", ",", "subject_template_name", ":", "str", "=", "\"registration/password_reset_subject.txt\"", ",", "email_template_name", ":", "str", "=", "\"registration/password_rese...
[ 262, 4 ]
[ 354, 13 ]
python
en
['en', 'error', 'th']
False
OurAuthenticationForm.add_prefix
(self, field_name: str)
Disable prefix, since Zulip doesn't use this Django forms feature (and django-two-factor does use it), and we'd like both to be happy with this form.
Disable prefix, since Zulip doesn't use this Django forms feature (and django-two-factor does use it), and we'd like both to be happy with this form.
def add_prefix(self, field_name: str) -> str: """Disable prefix, since Zulip doesn't use this Django forms feature (and django-two-factor does use it), and we'd like both to be happy with this form. """ return field_name
[ "def", "add_prefix", "(", "self", ",", "field_name", ":", "str", ")", "->", "str", ":", "return", "field_name" ]
[ 432, 4 ]
[ 437, 25 ]
python
en
['en', 'en', 'en']
True
MultiEmailField.to_python
(self, emails: str)
Normalize data to a list of strings.
Normalize data to a list of strings.
def to_python(self, emails: str) -> List[str]: """Normalize data to a list of strings.""" if not emails: return [] return [email.strip() for email in emails.split(",")]
[ "def", "to_python", "(", "self", ",", "emails", ":", "str", ")", "->", "List", "[", "str", "]", ":", "if", "not", "emails", ":", "return", "[", "]", "return", "[", "email", ".", "strip", "(", ")", "for", "email", "in", "emails", ".", "split", "("...
[ 453, 4 ]
[ 458, 61 ]
python
en
['en', 'en', 'en']
True
MultiEmailField.validate
(self, emails: List[str])
Check if value consists only of valid emails.
Check if value consists only of valid emails.
def validate(self, emails: List[str]) -> None: """Check if value consists only of valid emails.""" super().validate(emails) for email in emails: validate_email(email)
[ "def", "validate", "(", "self", ",", "emails", ":", "List", "[", "str", "]", ")", "->", "None", ":", "super", "(", ")", ".", "validate", "(", "emails", ")", "for", "email", "in", "emails", ":", "validate_email", "(", "email", ")" ]
[ 460, 4 ]
[ 464, 33 ]
python
en
['en', 'en', 'en']
True
parse_marker
(marker_string)
Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, and a string not contained in quotes is a...
Parse a marker string and return a dictionary containing a marker expression.
def parse_marker(marker_string): """ Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, a...
[ "def", "parse_marker", "(", "marker_string", ")", ":", "def", "marker_var", "(", "remaining", ")", ":", "# either identifier, or literal string", "m", "=", "IDENTIFIER", ".", "match", "(", "remaining", ")", "if", "m", ":", "result", "=", "m", ".", "groups", ...
[ 55, 0 ]
[ 141, 32 ]
python
en
['en', 'error', 'th']
False
parse_requirement
(req)
Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement.
Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement.
def parse_requirement(req): """ Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement. """ remaining = req.strip() if not remaining or remaining.startswith('#'): return None m = IDENTIFIER.match(remaining) if n...
[ "def", "parse_requirement", "(", "req", ")", ":", "remaining", "=", "req", ".", "strip", "(", ")", "if", "not", "remaining", "or", "remaining", ".", "startswith", "(", "'#'", ")", ":", "return", "None", "m", "=", "IDENTIFIER", ".", "match", "(", "remai...
[ 144, 0 ]
[ 262, 63 ]
python
en
['en', 'error', 'th']
False
get_resources_dests
(resources_root, rules)
Find destinations for resources files
Find destinations for resources files
def get_resources_dests(resources_root, rules): """Find destinations for resources files""" def get_rel_path(root, path): # normalizes and returns a lstripped-/-separated path root = root.replace(os.path.sep, '/') path = path.replace(os.path.sep, '/') assert path.startswith(root...
[ "def", "get_resources_dests", "(", "resources_root", ",", "rules", ")", ":", "def", "get_rel_path", "(", "root", ",", "path", ")", ":", "# normalizes and returns a lstripped-/-separated path", "root", "=", "root", ".", "replace", "(", "os", ".", "path", ".", "se...
[ 265, 0 ]
[ 288, 23 ]
python
en
['en', 'en', 'en']
True
convert_path
(pathname)
Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we ca...
Return 'pathname' as a name that will work on the native filesystem.
def convert_path(pathname): """Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to th...
[ "def", "convert_path", "(", "pathname", ")", ":", "if", "os", ".", "sep", "==", "'/'", ":", "return", "pathname", "if", "not", "pathname", ":", "return", "pathname", "if", "pathname", "[", "0", "]", "==", "'/'", ":", "raise", "ValueError", "(", "\"path...
[ 450, 0 ]
[ 474, 31 ]
python
en
['en', 'en', 'en']
True
get_cache_base
(suffix=None)
Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then it is assumed to be a directory, and ...
Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided.
def get_cache_base(suffix=None): """ Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then i...
[ "def", "get_cache_base", "(", "suffix", "=", "None", ")", ":", "if", "suffix", "is", "None", ":", "suffix", "=", "'.distlib'", "if", "os", ".", "name", "==", "'nt'", "and", "'LOCALAPPDATA'", "in", "os", ".", "environ", ":", "result", "=", "os", ".", ...
[ 739, 0 ]
[ 777, 39 ]
python
en
['en', 'error', 'th']
False
path_to_cache_dir
(path)
Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended.
Convert an absolute path to a directory name for use in a cache.
def path_to_cache_dir(path): """ Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended. """ d, p ...
[ "def", "path_to_cache_dir", "(", "path", ")", ":", "d", ",", "p", "=", "os", ".", "path", ".", "splitdrive", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "if", "d", ":", "d", "=", "d", ".", "replace", "(", "':'", ",", "'---'",...
[ 780, 0 ]
[ 794, 27 ]
python
en
['en', 'error', 'th']
False
split_filename
(filename, project_name=None)
Extract name, version, python version from a filename (no extension) Return name, version, pyver or None
Extract name, version, python version from a filename (no extension)
def split_filename(filename, project_name=None): """ Extract name, version, python version from a filename (no extension) Return name, version, pyver or None """ result = None pyver = None filename = unquote(filename).replace(' ', '-') m = PYTHON_VERSION.search(filename) if m: ...
[ "def", "split_filename", "(", "filename", ",", "project_name", "=", "None", ")", ":", "result", "=", "None", "pyver", "=", "None", "filename", "=", "unquote", "(", "filename", ")", ".", "replace", "(", "' '", ",", "'-'", ")", "m", "=", "PYTHON_VERSION", ...
[ 838, 0 ]
[ 860, 17 ]
python
en
['en', 'error', 'th']
False
parse_name_and_version
(p)
A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple.
A utility method used to get name and version from a string.
def parse_name_and_version(p): """ A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple. """ m = NAME_VERSION_RE.match(p) if not m: raise DistlibException('...
[ "def", "parse_name_and_version", "(", "p", ")", ":", "m", "=", "NAME_VERSION_RE", ".", "match", "(", "p", ")", "if", "not", "m", ":", "raise", "DistlibException", "(", "'Ill-formed name/version string: \\'%s\\''", "%", "p", ")", "d", "=", "m", ".", "groupdic...
[ 866, 0 ]
[ 879, 46 ]
python
en
['en', 'error', 'th']
False
zip_dir
(directory)
zip a directory tree into a BytesIO object
zip a directory tree into a BytesIO object
def zip_dir(directory): """zip a directory tree into a BytesIO object""" result = io.BytesIO() dlen = len(directory) with ZipFile(result, "w") as zf: for root, dirs, files in os.walk(directory): for name in files: full = os.path.join(root, name) rel = ...
[ "def", "zip_dir", "(", "directory", ")", ":", "result", "=", "io", ".", "BytesIO", "(", ")", "dlen", "=", "len", "(", "directory", ")", "with", "ZipFile", "(", "result", ",", "\"w\"", ")", "as", "zf", ":", "for", "root", ",", "dirs", ",", "files", ...
[ 1252, 0 ]
[ 1263, 17 ]
python
en
['en', 'en', 'en']
True
iglob
(path_glob)
Extended globbing function that supports ** and {opt1,opt2,opt3}.
Extended globbing function that supports ** and {opt1,opt2,opt3}.
def iglob(path_glob): """Extended globbing function that supports ** and {opt1,opt2,opt3}.""" if _CHECK_RECURSIVE_GLOB.search(path_glob): msg = """invalid glob %r: recursive glob "**" must be used alone""" raise ValueError(msg % path_glob) if _CHECK_MISMATCH_SET.search(path_glob): ms...
[ "def", "iglob", "(", "path_glob", ")", ":", "if", "_CHECK_RECURSIVE_GLOB", ".", "search", "(", "path_glob", ")", ":", "msg", "=", "\"\"\"invalid glob %r: recursive glob \"**\" must be used alone\"\"\"", "raise", "ValueError", "(", "msg", "%", "path_glob", ")", "if", ...
[ 1370, 0 ]
[ 1378, 28 ]
python
en
['en', 'en', 'en']
True
normalize_name
(name)
Normalize a python package name a la PEP 503
Normalize a python package name a la PEP 503
def normalize_name(name): """Normalize a python package name a la PEP 503""" # https://www.python.org/dev/peps/pep-0503/#normalized-names return re.sub('[-_.]+', '-', name).lower()
[ "def", "normalize_name", "(", "name", ")", ":", "# https://www.python.org/dev/peps/pep-0503/#normalized-names", "return", "re", ".", "sub", "(", "'[-_.]+'", ",", "'-'", ",", "name", ")", ".", "lower", "(", ")" ]
[ 1757, 0 ]
[ 1760, 46 ]
python
en
['es', 'en', 'en']
True
FileOperator.newer
(self, source, target)
Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'source'. Raise PackagingFileError if 'source' ...
Tell if the target is newer than the source.
def newer(self, source, target): """Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'so...
[ "def", "newer", "(", "self", ",", "source", ",", "target", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "source", ")", ":", "raise", "DistlibException", "(", "\"file '%r' does not exist\"", "%", "os", ".", "path", ".", "abspath", "(", ...
[ 492, 4 ]
[ 510, 66 ]
python
en
['en', 'en', 'en']
True
FileOperator.copy_file
(self, infile, outfile, check=True)
Copy a file respecting dry-run and force flags.
Copy a file respecting dry-run and force flags.
def copy_file(self, infile, outfile, check=True): """Copy a file respecting dry-run and force flags. """ self.ensure_dir(os.path.dirname(outfile)) logger.info('Copying %s to %s', infile, outfile) if not self.dry_run: msg = None if check: if...
[ "def", "copy_file", "(", "self", ",", "infile", ",", "outfile", ",", "check", "=", "True", ")", ":", "self", ".", "ensure_dir", "(", "os", ".", "path", ".", "dirname", "(", "outfile", ")", ")", "logger", ".", "info", "(", "'Copying %s to %s'", ",", "...
[ 512, 4 ]
[ 527, 39 ]
python
en
['en', 'en', 'en']
True
FileOperator.commit
(self)
Commit recorded changes, turn off recording, return changes.
Commit recorded changes, turn off recording, return changes.
def commit(self): """ Commit recorded changes, turn off recording, return changes. """ assert self.record result = self.files_written, self.dirs_created self._init_record() return result
[ "def", "commit", "(", "self", ")", ":", "assert", "self", ".", "record", "result", "=", "self", ".", "files_written", ",", "self", ".", "dirs_created", "self", ".", "_init_record", "(", ")", "return", "result" ]
[ 632, 4 ]
[ 640, 21 ]
python
en
['en', 'error', 'th']
False
Cache.__init__
(self, base)
Initialise an instance. :param base: The base directory where the cache should be located.
Initialise an instance.
def __init__(self, base): """ Initialise an instance. :param base: The base directory where the cache should be located. """ # we use 'isdir' instead of 'exists', because we want to # fail if there's a file with that name if not os.path.isdir(base): # pragma: no...
[ "def", "__init__", "(", "self", ",", "base", ")", ":", "# we use 'isdir' instead of 'exists', because we want to", "# fail if there's a file with that name", "if", "not", "os", ".", "path", ".", "isdir", "(", "base", ")", ":", "# pragma: no cover", "os", ".", "makedir...
[ 947, 4 ]
[ 959, 59 ]
python
en
['en', 'error', 'th']
False
Cache.prefix_to_dir
(self, prefix)
Converts a resource prefix to a directory name in the cache.
Converts a resource prefix to a directory name in the cache.
def prefix_to_dir(self, prefix): """ Converts a resource prefix to a directory name in the cache. """ return path_to_cache_dir(prefix)
[ "def", "prefix_to_dir", "(", "self", ",", "prefix", ")", ":", "return", "path_to_cache_dir", "(", "prefix", ")" ]
[ 961, 4 ]
[ 965, 40 ]
python
en
['en', 'error', 'th']
False
Cache.clear
(self)
Clear the cache.
Clear the cache.
def clear(self): """ Clear the cache. """ not_removed = [] for fn in os.listdir(self.base): fn = os.path.join(self.base, fn) try: if os.path.islink(fn) or os.path.isfile(fn): os.remove(fn) elif os.path.is...
[ "def", "clear", "(", "self", ")", ":", "not_removed", "=", "[", "]", "for", "fn", "in", "os", ".", "listdir", "(", "self", ".", "base", ")", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "fn", ")", "try", ":",...
[ 967, 4 ]
[ 981, 26 ]
python
en
['en', 'error', 'th']
False
EventMixin.add
(self, event, subscriber, append=True)
Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend the subscriber to an existing subscri...
Add a subscriber for an event.
def add(self, event, subscriber, append=True): """ Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend th...
[ "def", "add", "(", "self", ",", "event", ",", "subscriber", ",", "append", "=", "True", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "subs", "[", "event", "]", "=", "deque", "(", "[", "subscriber", "]...
[ 991, 4 ]
[ 1009, 41 ]
python
en
['en', 'error', 'th']
False
EventMixin.remove
(self, event, subscriber)
Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed.
Remove a subscriber for an event.
def remove(self, event, subscriber): """ Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. """ subs = self._subscribers if event not in subs: raise ValueError('No subscribers: %r' % ...
[ "def", "remove", "(", "self", ",", "event", ",", "subscriber", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "raise", "ValueError", "(", "'No subscribers: %r'", "%", "event", ")", "subs", "[", "event", "]", ...
[ 1011, 4 ]
[ 1021, 38 ]
python
en
['en', 'error', 'th']
False
EventMixin.get_subscribers
(self, event)
Return an iterator for the subscribers for an event. :param event: The event to return subscribers for.
Return an iterator for the subscribers for an event. :param event: The event to return subscribers for.
def get_subscribers(self, event): """ Return an iterator for the subscribers for an event. :param event: The event to return subscribers for. """ return iter(self._subscribers.get(event, ()))
[ "def", "get_subscribers", "(", "self", ",", "event", ")", ":", "return", "iter", "(", "self", ".", "_subscribers", ".", "get", "(", "event", ",", "(", ")", ")", ")" ]
[ 1023, 4 ]
[ 1028, 53 ]
python
en
['en', 'error', 'th']
False
EventMixin.publish
(self, event, *args, **kwargs)
Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The keyword arguments to pass to the event's ...
Publish a event and return a list of values returned by its subscribers.
def publish(self, event, *args, **kwargs): """ Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The k...
[ "def", "publish", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "for", "subscriber", "in", "self", ".", "get_subscribers", "(", "event", ")", ":", "try", ":", "value", "=", "subscriber", "(...
[ 1030, 4 ]
[ 1051, 21 ]
python
en
['en', 'error', 'th']
False
Configurator.inc_convert
(self, value)
Default converter for the inc:// protocol.
Default converter for the inc:// protocol.
def inc_convert(self, value): """Default converter for the inc:// protocol.""" if not os.path.isabs(value): value = os.path.join(self.base, value) with codecs.open(value, 'r', encoding='utf-8') as f: result = json.load(f) return result
[ "def", "inc_convert", "(", "self", ",", "value", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "value", ")", ":", "value", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "value", ")", "with", "codecs", ".", "...
[ 1702, 4 ]
[ 1708, 21 ]
python
en
['en', 'en', 'en']
True
SubprocessMixin.reader
(self, stream, context)
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
def reader(self, stream, context): """ Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. """ progress = self.progress verbose = self.verbose while True: s = st...
[ "def", "reader", "(", "self", ",", "stream", ",", "context", ")", ":", "progress", "=", "self", ".", "progress", "verbose", "=", "self", ".", "verbose", "while", "True", ":", "s", "=", "stream", ".", "readline", "(", ")", "if", "not", "s", ":", "br...
[ 1719, 4 ]
[ 1738, 22 ]
python
en
['en', 'error', 'th']
False
show_formats
()
Print list of available formats (arguments to "--format" option).
Print list of available formats (arguments to "--format" option).
def show_formats(): """Print list of available formats (arguments to "--format" option). """ from distutils.fancy_getopt import FancyGetopt formats = [] for format in bdist.format_commands: formats.append(("formats=" + format, None, bdist.format_command[format][1])) ...
[ "def", "show_formats", "(", ")", ":", "from", "distutils", ".", "fancy_getopt", "import", "FancyGetopt", "formats", "=", "[", "]", "for", "format", "in", "bdist", ".", "format_commands", ":", "formats", ".", "append", "(", "(", "\"formats=\"", "+", "format",...
[ 11, 0 ]
[ 20, 72 ]
python
en
['en', 'en', 'en']
True
RequestEncodingMixin.path_url
(self)
Build the path URL to use.
Build the path URL to use.
def path_url(self): """Build the path URL to use.""" url = [] p = urlsplit(self.url) path = p.path if not path: path = '/' url.append(path) query = p.query if query: url.append('?') url.append(query) return...
[ "def", "path_url", "(", "self", ")", ":", "url", "=", "[", "]", "p", "=", "urlsplit", "(", "self", ".", "url", ")", "path", "=", "p", ".", "path", "if", "not", "path", ":", "path", "=", "'/'", "url", ".", "append", "(", "path", ")", "query", ...
[ 61, 4 ]
[ 79, 27 ]
python
en
['en', 'en', 'en']
True
RequestEncodingMixin._encode_params
(data)
Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict.
Encode parameters in a piece of data.
def _encode_params(data): """Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. """ if isinstance(data...
[ "def", "_encode_params", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "(", "str", ",", "bytes", ")", ")", ":", "return", "data", "elif", "hasattr", "(", "data", ",", "'read'", ")", ":", "return", "data", "elif", "hasattr", "(", "data"...
[ 82, 4 ]
[ 106, 23 ]
python
en
['en', 'en', 'en']
True
RequestEncodingMixin._encode_files
(files, data)
Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tuples (filename, fileobj), 3-tuples (filenam...
Build the body for a multipart/form-data request.
def _encode_files(files, data): """Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tu...
[ "def", "_encode_files", "(", "files", ",", "data", ")", ":", "if", "(", "not", "files", ")", ":", "raise", "ValueError", "(", "\"Files must be provided.\"", ")", "elif", "isinstance", "(", "data", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\...
[ 109, 4 ]
[ 170, 33 ]
python
en
['en', 'en', 'en']
True
RequestHooksMixin.register_hook
(self, event, hook)
Properly register a hook.
Properly register a hook.
def register_hook(self, event, hook): """Properly register a hook.""" if event not in self.hooks: raise ValueError('Unsupported event specified, with event name "%s"' % (event)) if isinstance(hook, Callable): self.hooks[event].append(hook) elif hasattr(hook, '__...
[ "def", "register_hook", "(", "self", ",", "event", ",", "hook", ")", ":", "if", "event", "not", "in", "self", ".", "hooks", ":", "raise", "ValueError", "(", "'Unsupported event specified, with event name \"%s\"'", "%", "(", "event", ")", ")", "if", "isinstance...
[ 174, 4 ]
[ 183, 80 ]
python
en
['en', 'da', 'en']
True
RequestHooksMixin.deregister_hook
(self, event, hook)
Deregister a previously registered hook. Returns True if the hook existed, False if not.
Deregister a previously registered hook. Returns True if the hook existed, False if not.
def deregister_hook(self, event, hook): """Deregister a previously registered hook. Returns True if the hook existed, False if not. """ try: self.hooks[event].remove(hook) return True except ValueError: return False
[ "def", "deregister_hook", "(", "self", ",", "event", ",", "hook", ")", ":", "try", ":", "self", ".", "hooks", "[", "event", "]", ".", "remove", "(", "hook", ")", "return", "True", "except", "ValueError", ":", "return", "False" ]
[ 185, 4 ]
[ 194, 24 ]
python
en
['en', 'da', 'en']
True
Request.prepare
(self)
Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.
Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.
def prepare(self): """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.""" p = PreparedRequest() p.prepare( method=self.method, url=self.url, headers=self.headers, files=self.files, data=self.data,...
[ "def", "prepare", "(", "self", ")", ":", "p", "=", "PreparedRequest", "(", ")", "p", ".", "prepare", "(", "method", "=", "self", ".", "method", ",", "url", "=", "self", ".", "url", ",", "headers", "=", "self", ".", "headers", ",", "files", "=", "...
[ 253, 4 ]
[ 268, 16 ]
python
en
['en', 'co', 'en']
True
PreparedRequest.prepare
(self, method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None)
Prepares the entire request with the given parameters.
Prepares the entire request with the given parameters.
def prepare(self, method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None): """Prepares the entire request with the given parameters.""" self.prepare_method(method) self.prepare_url(url, params) self...
[ "def", "prepare", "(", "self", ",", "method", "=", "None", ",", "url", "=", "None", ",", "headers", "=", "None", ",", "files", "=", "None", ",", "data", "=", "None", ",", "params", "=", "None", ",", "auth", "=", "None", ",", "cookies", "=", "None...
[ 307, 4 ]
[ 323, 33 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_method
(self, method)
Prepares the given HTTP method.
Prepares the given HTTP method.
def prepare_method(self, method): """Prepares the given HTTP method.""" self.method = method if self.method is not None: self.method = to_native_string(self.method.upper())
[ "def", "prepare_method", "(", "self", ",", "method", ")", ":", "self", ".", "method", "=", "method", "if", "self", ".", "method", "is", "not", "None", ":", "self", ".", "method", "=", "to_native_string", "(", "self", ".", "method", ".", "upper", "(", ...
[ 339, 4 ]
[ 343, 63 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_url
(self, url, params)
Prepares the given HTTP URL.
Prepares the given HTTP URL.
def prepare_url(self, url, params): """Prepares the given HTTP URL.""" #: Accept objects that have string representations. #: We're unable to blindly call unicode/str functions #: as this will include the bytestring indicator (b'') #: on python 3.x. #: https://github.com/...
[ "def", "prepare_url", "(", "self", ",", "url", ",", "params", ")", ":", "#: Accept objects that have string representations.", "#: We're unable to blindly call unicode/str functions", "#: as this will include the bytestring indicator (b'')", "#: on python 3.x.", "#: https://github.com/ps...
[ 355, 4 ]
[ 439, 22 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_headers
(self, headers)
Prepares the given HTTP headers.
Prepares the given HTTP headers.
def prepare_headers(self, headers): """Prepares the given HTTP headers.""" self.headers = CaseInsensitiveDict() if headers: for header in headers.items(): # Raise exception on invalid header value. check_header_validity(header) name, v...
[ "def", "prepare_headers", "(", "self", ",", "headers", ")", ":", "self", ".", "headers", "=", "CaseInsensitiveDict", "(", ")", "if", "headers", ":", "for", "header", "in", "headers", ".", "items", "(", ")", ":", "# Raise exception on invalid header value.", "c...
[ 441, 4 ]
[ 450, 60 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_body
(self, data, files, json=None)
Prepares the given HTTP body data.
Prepares the given HTTP body data.
def prepare_body(self, data, files, json=None): """Prepares the given HTTP body data.""" # Check if file, fo, generator, iterator. # If not, run through normal process. # Nottin' on you. body = None content_type = None if not data and json is not None: ...
[ "def", "prepare_body", "(", "self", ",", "data", ",", "files", ",", "json", "=", "None", ")", ":", "# Check if file, fo, generator, iterator.", "# If not, run through normal process.", "# Nottin' on you.", "body", "=", "None", "content_type", "=", "None", "if", "not",...
[ 452, 4 ]
[ 519, 24 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_content_length
(self, body)
Prepare Content-Length header based on request method and body
Prepare Content-Length header based on request method and body
def prepare_content_length(self, body): """Prepare Content-Length header based on request method and body""" if body is not None: length = super_len(body) if length: # If length exists, set it. Otherwise, we fallback # to Transfer-Encoding: chunked...
[ "def", "prepare_content_length", "(", "self", ",", "body", ")", ":", "if", "body", "is", "not", "None", ":", "length", "=", "super_len", "(", "body", ")", "if", "length", ":", "# If length exists, set it. Otherwise, we fallback", "# to Transfer-Encoding: chunked.", ...
[ 521, 4 ]
[ 532, 48 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_auth
(self, auth, url='')
Prepares the given HTTP auth data.
Prepares the given HTTP auth data.
def prepare_auth(self, auth, url=''): """Prepares the given HTTP auth data.""" # If no Auth is explicitly provided, extract it from the URL first. if auth is None: url_auth = get_auth_from_url(self.url) auth = url_auth if any(url_auth) else None if auth: ...
[ "def", "prepare_auth", "(", "self", ",", "auth", ",", "url", "=", "''", ")", ":", "# If no Auth is explicitly provided, extract it from the URL first.", "if", "auth", "is", "None", ":", "url_auth", "=", "get_auth_from_url", "(", "self", ".", "url", ")", "auth", ...
[ 534, 4 ]
[ 554, 50 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_cookies
(self, cookies)
Prepares the given HTTP cookie data. This function eventually generates a ``Cookie`` header from the given cookies using cookielib. Due to cookielib's design, the header will not be regenerated if it already exists, meaning this function can only be called once for the life of the ...
Prepares the given HTTP cookie data.
def prepare_cookies(self, cookies): """Prepares the given HTTP cookie data. This function eventually generates a ``Cookie`` header from the given cookies using cookielib. Due to cookielib's design, the header will not be regenerated if it already exists, meaning this function ca...
[ "def", "prepare_cookies", "(", "self", ",", "cookies", ")", ":", "if", "isinstance", "(", "cookies", ",", "cookielib", ".", "CookieJar", ")", ":", "self", ".", "_cookies", "=", "cookies", "else", ":", "self", ".", "_cookies", "=", "cookiejar_from_dict", "(...
[ 556, 4 ]
[ 574, 50 ]
python
en
['en', 'en', 'en']
True
PreparedRequest.prepare_hooks
(self, hooks)
Prepares the given hooks.
Prepares the given hooks.
def prepare_hooks(self, hooks): """Prepares the given hooks.""" # hooks can be passed as None to the prepare method and to this # method. To prevent iterating over None, simply use an empty list # if hooks is False-y hooks = hooks or [] for event in hooks: sel...
[ "def", "prepare_hooks", "(", "self", ",", "hooks", ")", ":", "# hooks can be passed as None to the prepare method and to this", "# method. To prevent iterating over None, simply use an empty list", "# if hooks is False-y", "hooks", "=", "hooks", "or", "[", "]", "for", "event", ...
[ 576, 4 ]
[ 583, 51 ]
python
en
['en', 'en', 'en']
True
Response.__bool__
(self)
Returns True if :attr:`status_code` is less than 400. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code, is between 200 and 400, this will return True. This is **not** a check to see i...
Returns True if :attr:`status_code` is less than 400.
def __bool__(self): """Returns True if :attr:`status_code` is less than 400. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code, is between 200 and 400, this will return True. This ...
[ "def", "__bool__", "(", "self", ")", ":", "return", "self", ".", "ok" ]
[ 668, 4 ]
[ 676, 22 ]
python
en
['en', 'en', 'en']
True
Response.__nonzero__
(self)
Returns True if :attr:`status_code` is less than 400. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code, is between 200 and 400, this will return True. This is **not** a check to see i...
Returns True if :attr:`status_code` is less than 400.
def __nonzero__(self): """Returns True if :attr:`status_code` is less than 400. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code, is between 200 and 400, this will return True. This ...
[ "def", "__nonzero__", "(", "self", ")", ":", "return", "self", ".", "ok" ]
[ 678, 4 ]
[ 686, 22 ]
python
en
['en', 'en', 'en']
True
Response.__iter__
(self)
Allows you to use a response as an iterator.
Allows you to use a response as an iterator.
def __iter__(self): """Allows you to use a response as an iterator.""" return self.iter_content(128)
[ "def", "__iter__", "(", "self", ")", ":", "return", "self", ".", "iter_content", "(", "128", ")" ]
[ 688, 4 ]
[ 690, 37 ]
python
en
['en', 'en', 'en']
True
Response.ok
(self)
Returns True if :attr:`status_code` is less than 400, False if not. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code is between 200 and 400, this will return True. This is **not** a c...
Returns True if :attr:`status_code` is less than 400, False if not.
def ok(self): """Returns True if :attr:`status_code` is less than 400, False if not. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code is between 200 and 400, this will return True. Th...
[ "def", "ok", "(", "self", ")", ":", "try", ":", "self", ".", "raise_for_status", "(", ")", "except", "HTTPError", ":", "return", "False", "return", "True" ]
[ 693, 4 ]
[ 705, 19 ]
python
en
['en', 'en', 'en']
True
Response.is_redirect
(self)
True if this Response is a well-formed HTTP redirect that could have been processed automatically (by :meth:`Session.resolve_redirects`).
True if this Response is a well-formed HTTP redirect that could have been processed automatically (by :meth:`Session.resolve_redirects`).
def is_redirect(self): """True if this Response is a well-formed HTTP redirect that could have been processed automatically (by :meth:`Session.resolve_redirects`). """ return ('location' in self.headers and self.status_code in REDIRECT_STATI)
[ "def", "is_redirect", "(", "self", ")", ":", "return", "(", "'location'", "in", "self", ".", "headers", "and", "self", ".", "status_code", "in", "REDIRECT_STATI", ")" ]
[ 708, 4 ]
[ 712, 82 ]
python
en
['en', 'en', 'en']
True
Response.is_permanent_redirect
(self)
True if this Response one of the permanent versions of redirect.
True if this Response one of the permanent versions of redirect.
def is_permanent_redirect(self): """True if this Response one of the permanent versions of redirect.""" return ('location' in self.headers and self.status_code in (codes.moved_permanently, codes.permanent_redirect))
[ "def", "is_permanent_redirect", "(", "self", ")", ":", "return", "(", "'location'", "in", "self", ".", "headers", "and", "self", ".", "status_code", "in", "(", "codes", ".", "moved_permanently", ",", "codes", ".", "permanent_redirect", ")", ")" ]
[ 715, 4 ]
[ 717, 119 ]
python
en
['en', 'en', 'en']
True
Response.next
(self)
Returns a PreparedRequest for the next request in a redirect chain, if there is one.
Returns a PreparedRequest for the next request in a redirect chain, if there is one.
def next(self): """Returns a PreparedRequest for the next request in a redirect chain, if there is one.""" return self._next
[ "def", "next", "(", "self", ")", ":", "return", "self", ".", "_next" ]
[ 720, 4 ]
[ 722, 25 ]
python
en
['en', 'en', 'en']
True
Response.apparent_encoding
(self)
The apparent encoding, provided by the chardet library.
The apparent encoding, provided by the chardet library.
def apparent_encoding(self): """The apparent encoding, provided by the chardet library.""" return chardet.detect(self.content)['encoding']
[ "def", "apparent_encoding", "(", "self", ")", ":", "return", "chardet", ".", "detect", "(", "self", ".", "content", ")", "[", "'encoding'", "]" ]
[ 725, 4 ]
[ 727, 55 ]
python
en
['en', 'en', 'en']
True
Response.iter_content
(self, chunk_size=1, decode_unicode=False)
Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can ...
Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can ...
def iter_content(self, chunk_size=1, decode_unicode=False): """Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is no...
[ "def", "iter_content", "(", "self", ",", "chunk_size", "=", "1", ",", "decode_unicode", "=", "False", ")", ":", "def", "generate", "(", ")", ":", "# Special case for urllib3.", "if", "hasattr", "(", "self", ".", "raw", ",", "'stream'", ")", ":", "try", "...
[ 729, 4 ]
[ 782, 21 ]
python
en
['en', 'en', 'en']
True
Response.iter_lines
(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None)
Iterates over the response data, one line at a time. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. .. note:: This method is not reentrant safe.
Iterates over the response data, one line at a time. When stream=True is set on the request, this avoids reading the content at once into memory for large responses.
def iter_lines(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None): """Iterates over the response data, one line at a time. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. .. note:: This method is not ...
[ "def", "iter_lines", "(", "self", ",", "chunk_size", "=", "ITER_CHUNK_SIZE", ",", "decode_unicode", "=", "False", ",", "delimiter", "=", "None", ")", ":", "pending", "=", "None", "for", "chunk", "in", "self", ".", "iter_content", "(", "chunk_size", "=", "c...
[ 784, 4 ]
[ 813, 25 ]
python
en
['en', 'en', 'en']
True
Response.content
(self)
Content of the response, in bytes.
Content of the response, in bytes.
def content(self): """Content of the response, in bytes.""" if self._content is False: # Read the contents. if self._content_consumed: raise RuntimeError( 'The content for this response was already consumed') if self.status_code =...
[ "def", "content", "(", "self", ")", ":", "if", "self", ".", "_content", "is", "False", ":", "# Read the contents.", "if", "self", ".", "_content_consumed", ":", "raise", "RuntimeError", "(", "'The content for this response was already consumed'", ")", "if", "self", ...
[ 816, 4 ]
[ 833, 28 ]
python
en
['en', 'en', 'en']
True
Response.text
(self)
Content of the response, in unicode. If Response.encoding is None, encoding will be guessed using ``chardet``. The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of non-HTTP knowledge to m...
Content of the response, in unicode.
def text(self): """Content of the response, in unicode. If Response.encoding is None, encoding will be guessed using ``chardet``. The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of ...
[ "def", "text", "(", "self", ")", ":", "# Try charset from content-type", "content", "=", "None", "encoding", "=", "self", ".", "encoding", "if", "not", "self", ".", "content", ":", "return", "str", "(", "''", ")", "# Fallback to auto-detected encoding.", "if", ...
[ 836, 4 ]
[ 871, 22 ]
python
en
['en', 'en', 'en']
True
Response.json
(self, **kwargs)
r"""Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. :raises ValueError: If the response body does not contain valid json.
r"""Returns the json-encoded content of a response, if any.
def json(self, **kwargs): r"""Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. :raises ValueError: If the response body does not contain valid json. """ if not self.encoding and self.content and len(self.co...
[ "def", "json", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "encoding", "and", "self", ".", "content", "and", "len", "(", "self", ".", "content", ")", ">", "3", ":", "# No encoding set. JSON RFC 4627 section 3 states we should ex...
[ 873, 4 ]
[ 897, 53 ]
python
en
['en', 'en', 'en']
True
Response.links
(self)
Returns the parsed header links of the response, if any.
Returns the parsed header links of the response, if any.
def links(self): """Returns the parsed header links of the response, if any.""" header = self.headers.get('link') # l = MultiDict() l = {} if header: links = parse_header_links(header) for link in links: key = link.get('rel') or link.ge...
[ "def", "links", "(", "self", ")", ":", "header", "=", "self", ".", "headers", ".", "get", "(", "'link'", ")", "# l = MultiDict()", "l", "=", "{", "}", "if", "header", ":", "links", "=", "parse_header_links", "(", "header", ")", "for", "link", "in", "...
[ 900, 4 ]
[ 915, 16 ]
python
en
['en', 'en', 'en']
True
Response.raise_for_status
(self)
Raises :class:`HTTPError`, if one occurred.
Raises :class:`HTTPError`, if one occurred.
def raise_for_status(self): """Raises :class:`HTTPError`, if one occurred.""" http_error_msg = '' if isinstance(self.reason, bytes): # We attempt to decode utf-8 first because some servers # choose to localize their reason strings. If the string # isn't utf-8...
[ "def", "raise_for_status", "(", "self", ")", ":", "http_error_msg", "=", "''", "if", "isinstance", "(", "self", ".", "reason", ",", "bytes", ")", ":", "# We attempt to decode utf-8 first because some servers", "# choose to localize their reason strings. If the string", "# i...
[ 917, 4 ]
[ 940, 58 ]
python
en
['en', 'en', 'en']
True
Response.close
(self)
Releases the connection back to the pool. Once this method has been called the underlying ``raw`` object must not be accessed again. *Note: Should not normally need to be called explicitly.*
Releases the connection back to the pool. Once this method has been called the underlying ``raw`` object must not be accessed again.
def close(self): """Releases the connection back to the pool. Once this method has been called the underlying ``raw`` object must not be accessed again. *Note: Should not normally need to be called explicitly.* """ if not self._content_consumed: self.raw.close() ...
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "_content_consumed", ":", "self", ".", "raw", ".", "close", "(", ")", "release_conn", "=", "getattr", "(", "self", ".", "raw", ",", "'release_conn'", ",", "None", ")", "if", "release_conn...
[ 942, 4 ]
[ 953, 26 ]
python
en
['en', 'en', 'en']
True
TestPDB.test_pdb_unittest_skip
(self, testdir)
Test for issue #2137
Test for issue #2137
def test_pdb_unittest_skip(self, testdir): """Test for issue #2137""" p1 = testdir.makepyfile(""" import unittest @unittest.skipIf(True, 'Skipping also with pdb active') class MyTestCase(unittest.TestCase): def test_one(self): asser...
[ "def", "test_pdb_unittest_skip", "(", "self", ",", "testdir", ")", ":", "p1", "=", "testdir", ".", "makepyfile", "(", "\"\"\"\n import unittest\n @unittest.skipIf(True, 'Skipping also with pdb active')\n class MyTestCase(unittest.TestCase):\n ...
[ 128, 4 ]
[ 141, 25 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.pop
(self, key, default=__marker)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.
def pop(self, key, default=__marker): """D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. """ # Using the MutableMapping function directly fails due to the private marker. # Us...
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "__marker", ")", ":", "# Using the MutableMapping function directly fails due to the private marker.", "# Using ordinary dict.pop would expose the internal structures.", "# So let's reinvent the wheel.", "try", ":", "value...
[ 190, 4 ]
[ 205, 24 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.add
(self, key, val)
Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz'
Adds a (name, value) pair, doesn't overwrite the value if it already exists.
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = [ke...
[ "def", "add", "(", "self", ",", "key", ",", "val", ")", ":", "key_lower", "=", "key", ".", "lower", "(", ")", "new_vals", "=", "[", "key", ",", "val", "]", "# Keep the common case aka no item present as fast as possible", "vals", "=", "self", ".", "_containe...
[ 213, 4 ]
[ 227, 28 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.extend
(self, *args, **kwargs)
Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__
Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__
def extend(self, *args, **kwargs): """Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ """ if len(args) > 1: raise TypeError( "extend...
[ "def", "extend", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "1", ":", "raise", "TypeError", "(", "\"extend() takes at most 1 positional \"", "\"arguments ({0} given)\"", ".", "format", "(", "len", ...
[ 229, 4 ]
[ 255, 32 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.getlist
(self, key, default=__marker)
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.
def getlist(self, key, default=__marker): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = self._container[key.lower()] except KeyError: if default is self.__marker: return [] ...
[ "def", "getlist", "(", "self", ",", "key", ",", "default", "=", "__marker", ")", ":", "try", ":", "vals", "=", "self", ".", "_container", "[", "key", ".", "lower", "(", ")", "]", "except", "KeyError", ":", "if", "default", "is", "self", ".", "__mar...
[ 257, 4 ]
[ 267, 27 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.iteritems
(self)
Iterate over all header lines, including duplicate ones.
Iterate over all header lines, including duplicate ones.
def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = self._container[key.lower()] for val in vals[1:]: yield vals[0], val
[ "def", "iteritems", "(", "self", ")", ":", "for", "key", "in", "self", ":", "vals", "=", "self", ".", "_container", "[", "key", ".", "lower", "(", ")", "]", "for", "val", "in", "vals", "[", "1", ":", "]", ":", "yield", "vals", "[", "0", "]", ...
[ 293, 4 ]
[ 298, 34 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.itermerged
(self)
Iterate over all headers, merging duplicate ones together.
Iterate over all headers, merging duplicate ones together.
def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = self._container[key.lower()] yield val[0], ", ".join(val[1:])
[ "def", "itermerged", "(", "self", ")", ":", "for", "key", "in", "self", ":", "val", "=", "self", ".", "_container", "[", "key", ".", "lower", "(", ")", "]", "yield", "val", "[", "0", "]", ",", "\", \"", ".", "join", "(", "val", "[", "1", ":", ...
[ 300, 4 ]
[ 304, 44 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.from_httplib
(cls, message)
Read headers from a Python 2 httplib message object.
Read headers from a Python 2 httplib message object.
def from_httplib(cls, message): # Python 2 """Read headers from a Python 2 httplib message object.""" # python2.7 does not expose a proper API for exporting multiheaders # efficiently. This function re-reads raw lines from the message # object and extracts the multiheaders properly. ...
[ "def", "from_httplib", "(", "cls", ",", "message", ")", ":", "# Python 2", "# python2.7 does not expose a proper API for exporting multiheaders", "# efficiently. This function re-reads raw lines from the message", "# object and extracts the multiheaders properly.", "obs_fold_continued_leader...
[ 310, 4 ]
[ 335, 27 ]
python
en
['en', 'en', 'en']
True
PasswordMixin.clean
(self)
Check to make sure password fields match.
Check to make sure password fields match.
def clean(self): '''Check to make sure password fields match.''' data = super(PasswordMixin, self).clean() if 'password' in data and 'confirm_password' in data: if data['password'] != data['confirm_password']: raise ValidationError(_('Passwords do not match.')) ...
[ "def", "clean", "(", "self", ")", ":", "data", "=", "super", "(", "PasswordMixin", ",", "self", ")", ".", "clean", "(", ")", "if", "'password'", "in", "data", "and", "'confirm_password'", "in", "data", ":", "if", "data", "[", "'password'", "]", "!=", ...
[ 51, 4 ]
[ 57, 19 ]
python
en
['en', 'en', 'en']
True
run
()
Run the script in sys.argv[1] as if it had been invoked naturally.
Run the script in sys.argv[1] as if it had been invoked naturally.
def run(): """ Run the script in sys.argv[1] as if it had been invoked naturally. """ __builtins__ script_name = sys.argv[1] namespace = dict( __file__=script_name, __name__='__main__', __doc__=None, ) sys.argv[:] = sys.argv[1:] open_ = getattr(tokenize, ...
[ "def", "run", "(", ")", ":", "__builtins__", "script_name", "=", "sys", ".", "argv", "[", "1", "]", "namespace", "=", "dict", "(", "__file__", "=", "script_name", ",", "__name__", "=", "'__main__'", ",", "__doc__", "=", "None", ",", ")", "sys", ".", ...
[ 12, 0 ]
[ 31, 25 ]
python
en
['en', 'error', 'th']
False
pyfile_with_warnings
(testdir, request)
Create a test file which calls a function in a module which generates warnings.
Create a test file which calls a function in a module which generates warnings.
def pyfile_with_warnings(testdir, request): """ Create a test file which calls a function in a module which generates warnings. """ testdir.syspathinsert() test_name = request.function.__name__ module_name = test_name.lstrip('test_') + '_module' testdir.makepyfile(**{ module_name: ''...
[ "def", "pyfile_with_warnings", "(", "testdir", ",", "request", ")", ":", "testdir", ".", "syspathinsert", "(", ")", "test_name", "=", "request", ".", "function", ".", "__name__", "module_name", "=", "test_name", ".", "lstrip", "(", "'test_'", ")", "+", "'_mo...
[ 12, 0 ]
[ 32, 6 ]
python
en
['en', 'error', 'th']
False
test_normal_flow
(testdir, pyfile_with_warnings)
Check that the warnings section is displayed, containing test node ids followed by all warnings generated by that test node.
Check that the warnings section is displayed, containing test node ids followed by all warnings generated by that test node.
def test_normal_flow(testdir, pyfile_with_warnings): """ Check that the warnings section is displayed, containing test node ids followed by all warnings generated by that test node. """ result = testdir.runpytest() result.stdout.fnmatch_lines([ '*== %s ==*' % WARNINGS_SUMMARY_HEADER, ...
[ "def", "test_normal_flow", "(", "testdir", ",", "pyfile_with_warnings", ")", ":", "result", "=", "testdir", ".", "runpytest", "(", ")", "result", ".", "stdout", ".", "fnmatch_lines", "(", "[", "'*== %s ==*'", "%", "WARNINGS_SUMMARY_HEADER", ",", "'*test_normal_flo...
[ 36, 0 ]
[ 54, 75 ]
python
en
['en', 'error', 'th']
False
test_py2_unicode_ascii
(testdir)
Ensure that our warning about 'unicode warnings containing non-ascii messages' does not trigger with ascii-convertible messages
Ensure that our warning about 'unicode warnings containing non-ascii messages' does not trigger with ascii-convertible messages
def test_py2_unicode_ascii(testdir): """Ensure that our warning about 'unicode warnings containing non-ascii messages' does not trigger with ascii-convertible messages""" testdir.makeini('[pytest]') testdir.makepyfile(''' import pytest import warnings @pytest.mark.filterwarnings...
[ "def", "test_py2_unicode_ascii", "(", "testdir", ")", ":", "testdir", ".", "makeini", "(", "'[pytest]'", ")", "testdir", ".", "makepyfile", "(", "'''\n import pytest\n import warnings\n\n @pytest.mark.filterwarnings('always')\n def test_func():\n ...
[ 174, 0 ]
[ 191, 6 ]
python
en
['en', 'en', 'en']
True
test_works_with_filterwarnings
(testdir)
Ensure our warnings capture does not mess with pre-installed filters (#2430).
Ensure our warnings capture does not mess with pre-installed filters (#2430).
def test_works_with_filterwarnings(testdir): """Ensure our warnings capture does not mess with pre-installed filters (#2430).""" testdir.makepyfile(''' import warnings class MyWarning(Warning): pass warnings.filterwarnings("error", category=MyWarning) class TestWar...
[ "def", "test_works_with_filterwarnings", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "'''\n import warnings\n\n class MyWarning(Warning):\n pass\n\n warnings.filterwarnings(\"error\", category=MyWarning)\n\n class TestWarnings(object):\n ...
[ 194, 0 ]
[ 215, 6 ]
python
en
['en', 'en', 'en']
True
test_filterwarnings_mark
(testdir, default_config)
Test ``filterwarnings`` mark works and takes precedence over command line and ini options.
Test ``filterwarnings`` mark works and takes precedence over command line and ini options.
def test_filterwarnings_mark(testdir, default_config): """ Test ``filterwarnings`` mark works and takes precedence over command line and ini options. """ if default_config == 'ini': testdir.makeini(""" [pytest] filterwarnings = always """) testdir.makepyfile("...
[ "def", "test_filterwarnings_mark", "(", "testdir", ",", "default_config", ")", ":", "if", "default_config", "==", "'ini'", ":", "testdir", ".", "makeini", "(", "\"\"\"\n [pytest]\n filterwarnings = always\n \"\"\"", ")", "testdir", ".", "makepyf...
[ 219, 0 ]
[ 244, 75 ]
python
en
['en', 'error', 'th']
False
test_non_string_warning_argument
(testdir)
Non-str argument passed to warning breaks pytest (#2956)
Non-str argument passed to warning breaks pytest (#2956)
def test_non_string_warning_argument(testdir): """Non-str argument passed to warning breaks pytest (#2956)""" testdir.makepyfile(""" import warnings import pytest def test(): warnings.warn(UserWarning(1, u'foo')) """) result = testdir.runpytest('-W', 'always') re...
[ "def", "test_non_string_warning_argument", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import warnings\n import pytest\n\n def test():\n warnings.warn(UserWarning(1, u'foo'))\n \"\"\"", ")", "result", "=", "testdir", ".", ...
[ 247, 0 ]
[ 257, 65 ]
python
en
['en', 'en', 'en']
True
common_context
(user: UserProfile)
Common context used for things like outgoing emails that don't have a request.
Common context used for things like outgoing emails that don't have a request.
def common_context(user: UserProfile) -> Dict[str, Any]: """Common context used for things like outgoing emails that don't have a request. """ return { "realm_uri": user.realm.uri, "realm_name": user.realm.name, "root_domain_uri": settings.ROOT_DOMAIN_URI, "external_uri_s...
[ "def", "common_context", "(", "user", ":", "UserProfile", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "\"realm_uri\"", ":", "user", ".", "realm", ".", "uri", ",", "\"realm_name\"", ":", "user", ".", "realm", ".", "name", ",", ...
[ 37, 0 ]
[ 48, 5 ]
python
en
['en', 'en', 'en']
True
zulip_default_context
(request: HttpRequest)
Context available to all Zulip Jinja2 templates that have a request passed in. Designed to provide the long list of variables at the bottom of this function in a wide range of situations: logged-in or logged-out, subdomains or not, etc. The main variable in the below is whether we know what realm the ...
Context available to all Zulip Jinja2 templates that have a request passed in. Designed to provide the long list of variables at the bottom of this function in a wide range of situations: logged-in or logged-out, subdomains or not, etc.
def zulip_default_context(request: HttpRequest) -> Dict[str, Any]: """Context available to all Zulip Jinja2 templates that have a request passed in. Designed to provide the long list of variables at the bottom of this function in a wide range of situations: logged-in or logged-out, subdomains or not, e...
[ "def", "zulip_default_context", "(", "request", ":", "HttpRequest", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "realm", "=", "get_realm_from_request", "(", "request", ")", "if", "realm", "is", "None", ":", "realm_uri", "=", "settings", ".", "ROOT...
[ 74, 0 ]
[ 176, 18 ]
python
en
['en', 'en', 'en']
True
check
(actions, request, target=None)
Check user permission. Check if the user has permission to the action according to policy setting. :param actions: list of scope and action to do policy checks on, the composition of which is (scope, action). Multiple actions are treated as a logical AND. * scope: service type man...
Check user permission.
def check(actions, request, target=None): """Check user permission. Check if the user has permission to the action according to policy setting. :param actions: list of scope and action to do policy checks on, the composition of which is (scope, action). Multiple actions are treated as ...
[ "def", "check", "(", "actions", ",", "request", ",", "target", "=", "None", ")", ":", "if", "target", "is", "None", ":", "target", "=", "{", "}", "user", "=", "auth_utils", ".", "get_user", "(", "request", ")", "# Several service policy engines default to a ...
[ 94, 0 ]
[ 194, 15 ]
python
en
['en', 'it', 'en']
True
TestLastFailed.test_non_serializable_parametrize
(self, testdir)
Test that failed parametrized tests with unmarshable parameters don't break pytest-cache.
Test that failed parametrized tests with unmarshable parameters don't break pytest-cache.
def test_non_serializable_parametrize(self, testdir): """Test that failed parametrized tests with unmarshable parameters don't break pytest-cache. """ testdir.makepyfile(r""" import pytest @pytest.mark.parametrize('val', [ b'\xac\x10\x02G', ...
[ "def", "test_non_serializable_parametrize", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "r\"\"\"\n import pytest\n\n @pytest.mark.parametrize('val', [\n b'\\xac\\x10\\x02G',\n ])\n def test_fail(val):\n ...
[ 326, 4 ]
[ 340, 52 ]
python
en
['en', 'en', 'en']
True
TestLastFailed.test_cache_cumulative
(self, testdir)
Test workflow where user fixes errors gradually file by file using --lf.
Test workflow where user fixes errors gradually file by file using --lf.
def test_cache_cumulative(self, testdir): """ Test workflow where user fixes errors gradually file by file using --lf. """ # 1. initial run test_bar = testdir.makepyfile(test_bar=""" def test_bar_1(): pass def test_bar_2(): ...
[ "def", "test_cache_cumulative", "(", "self", ",", "testdir", ")", ":", "# 1. initial run", "test_bar", "=", "testdir", ".", "makepyfile", "(", "test_bar", "=", "\"\"\"\n def test_bar_1():\n pass\n def test_bar_2():\n assert 0\n ...
[ 555, 4 ]
[ 604, 57 ]
python
en
['en', 'error', 'th']
False
get_abi3_suffix
()
Return the file extension for an abi3-compliant Extension()
Return the file extension for an abi3-compliant Extension()
def get_abi3_suffix(): """Return the file extension for an abi3-compliant Extension()""" for suffix in EXTENSION_SUFFIXES: if '.abi3' in suffix: # Unix return suffix elif suffix == '.pyd': # Windows return suffix
[ "def", "get_abi3_suffix", "(", ")", ":", "for", "suffix", "in", "EXTENSION_SUFFIXES", ":", "if", "'.abi3'", "in", "suffix", ":", "# Unix", "return", "suffix", "elif", "suffix", "==", "'.pyd'", ":", "# Windows", "return", "suffix" ]
[ 65, 0 ]
[ 71, 25 ]
python
en
['en', 'en', 'en']
True
build_ext.run
(self)
Build extensions in build directory, then copy if --inplace
Build extensions in build directory, then copy if --inplace
def run(self): """Build extensions in build directory, then copy if --inplace""" old_inplace, self.inplace = self.inplace, 0 _build_ext.run(self) self.inplace = old_inplace if old_inplace: self.copy_extensions_to_source()
[ "def", "run", "(", "self", ")", ":", "old_inplace", ",", "self", ".", "inplace", "=", "self", ".", "inplace", ",", "0", "_build_ext", ".", "run", "(", "self", ")", "self", ".", "inplace", "=", "old_inplace", "if", "old_inplace", ":", "self", ".", "co...
[ 75, 4 ]
[ 81, 44 ]
python
en
['en', 'en', 'en']
True
build_ext.links_to_dynamic
(self, ext)
Return true if 'ext' links to a dynamic lib in the same package
Return true if 'ext' links to a dynamic lib in the same package
def links_to_dynamic(self, ext): """Return true if 'ext' links to a dynamic lib in the same package""" # XXX this should check to ensure the lib is actually being built # XXX as dynamic, and not just using a locally-found version or a # XXX static-compiled version libnames = dict...
[ "def", "links_to_dynamic", "(", "self", ",", "ext", ")", ":", "# XXX this should check to ensure the lib is actually being built", "# XXX as dynamic, and not just using a locally-found version or a", "# XXX static-compiled version", "libnames", "=", "dict", ".", "fromkeys", "(", "[...
[ 202, 4 ]
[ 209, 74 ]
python
en
['en', 'en', 'en']
True
tempdir_registry
()
Provides a scoped global tempdir registry that can be used to dictate whether directories should be deleted.
Provides a scoped global tempdir registry that can be used to dictate whether directories should be deleted.
def tempdir_registry(): # type: () -> Iterator[TempDirectoryTypeRegistry] """Provides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. """ global _tempdir_registry old_tempdir_registry = _tempdir_registry _tempdir_registry = TempDirectoryTyp...
[ "def", "tempdir_registry", "(", ")", ":", "# type: () -> Iterator[TempDirectoryTypeRegistry]", "global", "_tempdir_registry", "old_tempdir_registry", "=", "_tempdir_registry", "_tempdir_registry", "=", "TempDirectoryTypeRegistry", "(", ")", "try", ":", "yield", "_tempdir_regist...
[ 75, 0 ]
[ 86, 48 ]
python
en
['en', 'en', 'en']
True
TempDirectoryTypeRegistry.set_delete
(self, kind, value)
Indicate whether a TempDirectory of the given kind should be auto-deleted.
Indicate whether a TempDirectory of the given kind should be auto-deleted.
def set_delete(self, kind, value): # type: (str, bool) -> None """Indicate whether a TempDirectory of the given kind should be auto-deleted. """ self._should_delete[kind] = value
[ "def", "set_delete", "(", "self", ",", "kind", ",", "value", ")", ":", "# type: (str, bool) -> None", "self", ".", "_should_delete", "[", "kind", "]", "=", "value" ]
[ 56, 4 ]
[ 61, 41 ]
python
en
['en', 'en', 'en']
True