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
compatible_tags
()
Return (pyver, abi, arch) tuples compatible with this Python.
Return (pyver, abi, arch) tuples compatible with this Python.
def compatible_tags(): """ Return (pyver, abi, arch) tuples compatible with this Python. """ versions = [VER_SUFFIX] major = VER_SUFFIX[0] for minor in range(sys.version_info[1] - 1, - 1, -1): versions.append(''.join([major, str(minor)])) abis = [] for suffix, _, _ in imp.get_su...
[ "def", "compatible_tags", "(", ")", ":", "versions", "=", "[", "VER_SUFFIX", "]", "major", "=", "VER_SUFFIX", "[", "0", "]", "for", "minor", "in", "range", "(", "sys", ".", "version_info", "[", "1", "]", "-", "1", ",", "-", "1", ",", "-", "1", ")...
[ 960, 0 ]
[ 1037, 22 ]
python
en
['en', 'error', 'th']
False
Wheel.__init__
(self, filename=None, sign=False, verify=False)
Initialise an instance using a (valid) filename.
Initialise an instance using a (valid) filename.
def __init__(self, filename=None, sign=False, verify=False): """ Initialise an instance using a (valid) filename. """ self.sign = sign self.should_verify = verify self.buildver = '' self.pyver = [PYVER] self.abi = ['none'] self.arch = ['any'] ...
[ "def", "__init__", "(", "self", ",", "filename", "=", "None", ",", "sign", "=", "False", ",", "verify", "=", "False", ")", ":", "self", ".", "sign", "=", "sign", "self", ".", "should_verify", "=", "verify", "self", ".", "buildver", "=", "''", "self",...
[ 147, 4 ]
[ 186, 49 ]
python
en
['en', 'error', 'th']
False
Wheel.filename
(self)
Build and return a filename from the various components.
Build and return a filename from the various components.
def filename(self): """ Build and return a filename from the various components. """ if self.buildver: buildver = '-' + self.buildver else: buildver = '' pyver = '.'.join(self.pyver) abi = '.'.join(self.abi) arch = '.'.join(self.arc...
[ "def", "filename", "(", "self", ")", ":", "if", "self", ".", "buildver", ":", "buildver", "=", "'-'", "+", "self", ".", "buildver", "else", ":", "buildver", "=", "''", "pyver", "=", "'.'", ".", "join", "(", "self", ".", "pyver", ")", "abi", "=", ...
[ 189, 4 ]
[ 203, 58 ]
python
en
['en', 'error', 'th']
False
Wheel.build
(self, paths, tags=None, wheel_version=None)
Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel.
Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel.
def build(self, paths, tags=None, wheel_version=None): """ Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel. """ if tags is None: tags = {} libkey = list(filter(lambda o: o in paths, ('purelib', 'p...
[ "def", "build", "(", "self", ",", "paths", ",", "tags", "=", "None", ",", "wheel_version", "=", "None", ")", ":", "if", "tags", "is", "None", ":", "tags", "=", "{", "}", "libkey", "=", "list", "(", "filter", "(", "lambda", "o", ":", "o", "in", ...
[ 336, 4 ]
[ 450, 23 ]
python
en
['en', 'error', 'th']
False
Wheel.skip_entry
(self, arcname)
Determine whether an archive entry should be skipped when verifying or installing.
Determine whether an archive entry should be skipped when verifying or installing.
def skip_entry(self, arcname): """ Determine whether an archive entry should be skipped when verifying or installing. """ # The signature file won't be in RECORD, # and we don't currently don't do anything with it # We also skip directories, as they won't be in R...
[ "def", "skip_entry", "(", "self", ",", "arcname", ")", ":", "# The signature file won't be in RECORD,", "# and we don't currently don't do anything with it", "# We also skip directories, as they won't be in RECORD", "# either. See:", "#", "# https://github.com/pypa/wheel/issues/294", "#...
[ 452, 4 ]
[ 466, 53 ]
python
en
['en', 'error', 'th']
False
Wheel.install
(self, paths, maker, **kwargs)
Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a discrepancy in the versions. This can be used to...
Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a discrepancy in the versions. This can be used to...
def install(self, paths, maker, **kwargs): """ Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a di...
[ "def", "install", "(", "self", ",", "paths", ",", "maker", ",", "*", "*", "kwargs", ")", ":", "dry_run", "=", "maker", ".", "dry_run", "warner", "=", "kwargs", ".", "get", "(", "'warner'", ")", "lib_only", "=", "kwargs", ".", "get", "(", "'lib_only'"...
[ 468, 4 ]
[ 703, 38 ]
python
en
['en', 'error', 'th']
False
Wheel.is_compatible
(self)
Determine if a wheel is compatible with the running system.
Determine if a wheel is compatible with the running system.
def is_compatible(self): """ Determine if a wheel is compatible with the running system. """ return is_compatible(self)
[ "def", "is_compatible", "(", "self", ")", ":", "return", "is_compatible", "(", "self", ")" ]
[ 748, 4 ]
[ 752, 34 ]
python
en
['en', 'error', 'th']
False
Wheel.is_mountable
(self)
Determine if a wheel is asserted as mountable by its metadata.
Determine if a wheel is asserted as mountable by its metadata.
def is_mountable(self): """ Determine if a wheel is asserted as mountable by its metadata. """ return True
[ "def", "is_mountable", "(", "self", ")", ":", "return", "True" ]
[ 754, 4 ]
[ 758, 19 ]
python
en
['en', 'error', 'th']
False
Wheel.update
(self, modifier, dest_dir=None, **kwargs)
Update the contents of a wheel in a generic way. The modifier should be a callable which expects a dictionary argument: its keys are archive-entry paths, and its values are absolute filesystem paths where the contents the corresponding archive entries can be found. The modifier ...
Update the contents of a wheel in a generic way. The modifier should be a callable which expects a dictionary argument: its keys are archive-entry paths, and its values are absolute filesystem paths where the contents the corresponding archive entries can be found. The modifier ...
def update(self, modifier, dest_dir=None, **kwargs): """ Update the contents of a wheel in a generic way. The modifier should be a callable which expects a dictionary argument: its keys are archive-entry paths, and its values are absolute filesystem paths where the contents the c...
[ "def", "update", "(", "self", ",", "modifier", ",", "dest_dir", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "get_version", "(", "path_map", ",", "info_dir", ")", ":", "version", "=", "path", "=", "None", "key", "=", "'%s/%s'", "%", "(", ...
[ 849, 4 ]
[ 948, 23 ]
python
en
['en', 'error', 'th']
False
logout_then_login
(request, login_url=None)
Log out the user if they are logged in. Then redirect to the login page.
Log out the user if they are logged in. Then redirect to the login page.
def logout_then_login(request, login_url=None): """ Log out the user if they are logged in. Then redirect to the login page. """ login_url = resolve_url(login_url or settings.LOGIN_URL) return LogoutView.as_view(next_page=login_url)(request)
[ "def", "logout_then_login", "(", "request", ",", "login_url", "=", "None", ")", ":", "login_url", "=", "resolve_url", "(", "login_url", "or", "settings", ".", "LOGIN_URL", ")", "return", "LogoutView", ".", "as_view", "(", "next_page", "=", "login_url", ")", ...
[ 165, 0 ]
[ 170, 59 ]
python
en
['en', 'error', 'th']
False
redirect_to_login
(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME)
Redirect the user to the login page, passing the given 'next' page.
Redirect the user to the login page, passing the given 'next' page.
def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Redirect the user to the login page, passing the given 'next' page. """ resolved_url = resolve_url(login_url or settings.LOGIN_URL) login_url_parts = list(urlparse(resolved_url)) if redirect_field_name: ...
[ "def", "redirect_to_login", "(", "next", ",", "login_url", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "resolved_url", "=", "resolve_url", "(", "login_url", "or", "settings", ".", "LOGIN_URL", ")", "login_url_parts", "=", "list",...
[ 173, 0 ]
[ 185, 60 ]
python
en
['en', 'error', 'th']
False
LoginView.get_redirect_url
(self)
Return the user-originating redirect URL if it's safe.
Return the user-originating redirect URL if it's safe.
def get_redirect_url(self): """Return the user-originating redirect URL if it's safe.""" redirect_to = self.request.POST.get( self.redirect_field_name, self.request.GET.get(self.redirect_field_name, '') ) url_is_safe = url_has_allowed_host_and_scheme( ...
[ "def", "get_redirect_url", "(", "self", ")", ":", "redirect_to", "=", "self", ".", "request", ".", "POST", ".", "get", "(", "self", ".", "redirect_field_name", ",", "self", ".", "request", ".", "GET", ".", "get", "(", "self", ".", "redirect_field_name", ...
[ 68, 4 ]
[ 79, 49 ]
python
en
['en', 'en', 'en']
True
LoginView.form_valid
(self, form)
Security check complete. Log the user in.
Security check complete. Log the user in.
def form_valid(self, form): """Security check complete. Log the user in.""" auth_login(self.request, form.get_user()) return HttpResponseRedirect(self.get_success_url())
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "auth_login", "(", "self", ".", "request", ",", "form", ".", "get_user", "(", ")", ")", "return", "HttpResponseRedirect", "(", "self", ".", "get_success_url", "(", ")", ")" ]
[ 89, 4 ]
[ 92, 59 ]
python
en
['en', 'en', 'en']
True
LogoutView.post
(self, request, *args, **kwargs)
Logout may be done via POST.
Logout may be done via POST.
def post(self, request, *args, **kwargs): """Logout may be done via POST.""" return self.get(request, *args, **kwargs)
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 124, 4 ]
[ 126, 49 ]
python
en
['en', 'fil', '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" ]
[ 145, 4 ]
[ 154, 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 t...
[ "def", "get_requires_for_build_wheel", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_wheel'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 156, 4 ]
[ 169, 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 tha...
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 n...
[ "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_...
[ 171, 4 ]
[ 187, 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",...
[ 189, 4 ]
[ 207, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.get_requires_for_build_editable
(self, config_settings=None)
Identify packages required for building an editable 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 s...
Identify packages required for building an editable wheel
def get_requires_for_build_editable(self, config_settings=None): """Identify packages required for building an editable wheel Returns a list of dependency specifications, e.g.:: ["wheel >= 0.25", "setuptools"] This does not include requirements specified in pyproject.toml. ...
[ "def", "get_requires_for_build_editable", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_editable'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 209, 4 ]
[ 222, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.prepare_metadata_for_build_editable
( 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 an editable wheel, and the dist-info extracte...
Prepare a ``*.dist-info`` folder with metadata for this project.
def prepare_metadata_for_build_editable( 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 thi...
[ "def", "prepare_metadata_for_build_editable", "(", "self", ",", "metadata_directory", ",", "config_settings", "=", "None", ",", "_allow_fallback", "=", "True", ")", ":", "return", "self", ".", "_call_hook", "(", "'prepare_metadata_for_build_editable'", ",", "{", "'met...
[ 224, 4 ]
[ 240, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.build_editable
( self, wheel_directory, config_settings=None, metadata_directory=None)
Build an editable wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_editable' hook in the backend. However, if that was previously called by 'prepare_metadata_for_build_editable', and the same metadata_directory is used, ...
Build an editable wheel from this project.
def build_editable( self, wheel_directory, config_settings=None, metadata_directory=None): """Build an editable wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_editable' hook in the backend. However, if ...
[ "def", "build_editable", "(", "self", ",", "wheel_directory", ",", "config_settings", "=", "None", ",", "metadata_directory", "=", "None", ")", ":", "if", "metadata_directory", "is", "not", "None", ":", "metadata_directory", "=", "abspath", "(", "metadata_director...
[ 242, 4 ]
[ 260, 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 o...
[ "def", "get_requires_for_build_sdist", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_sdist'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 262, 4 ]
[ 275, 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...
[ 277, 4 ]
[ 287, 10 ]
python
en
['en', 'en', 'en']
True
UpdateOwnProfile.has_object_permission
(self, request, view, obj)
Check user is trying to edit their own profile
Check user is trying to edit their own profile
def has_object_permission(self, request, view, obj): """Check user is trying to edit their own profile""" if request.method in permissions.SAFE_METHODS: return True return obj.id == request.user.id
[ "def", "has_object_permission", "(", "self", ",", "request", ",", "view", ",", "obj", ")", ":", "if", "request", ".", "method", "in", "permissions", ".", "SAFE_METHODS", ":", "return", "True", "return", "obj", ".", "id", "==", "request", ".", "user", "."...
[ 6, 4 ]
[ 11, 40 ]
python
en
['en', 'en', 'en']
True
UpdateOwnStatus.has_object_permission
(self, request, view, obj)
Check the user is trying to update their own status
Check the user is trying to update their own status
def has_object_permission(self, request, view, obj): """Check the user is trying to update their own status""" if request.method in permissions.SAFE_METHODS: return True return obj.id == request.user.id
[ "def", "has_object_permission", "(", "self", ",", "request", ",", "view", ",", "obj", ")", ":", "if", "request", ".", "method", "in", "permissions", ".", "SAFE_METHODS", ":", "return", "True", "return", "obj", ".", "id", "==", "request", ".", "user", "."...
[ 17, 4 ]
[ 22, 40 ]
python
en
['en', 'en', 'en']
True
ModificationTrackingDict.copy
(self)
Create a flat copy of the dict.
Create a flat copy of the dict.
def copy(self): """Create a flat copy of the dict.""" missing = object() result = object.__new__(self.__class__) for name in self.__slots__: val = getattr(self, name, missing) if val is not missing: setattr(result, name, val) return result
[ "def", "copy", "(", "self", ")", ":", "missing", "=", "object", "(", ")", "result", "=", "object", ".", "__new__", "(", "self", ".", "__class__", ")", "for", "name", "in", "self", ".", "__slots__", ":", "val", "=", "getattr", "(", "self", ",", "nam...
[ 108, 4 ]
[ 116, 21 ]
python
en
['en', 'en', 'en']
True
Session.should_save
(self)
True if the session should be saved. .. versionchanged:: 0.6 By default the session is now only saved if the session is modified, not if it is new like it was before.
True if the session should be saved.
def should_save(self): """True if the session should be saved. .. versionchanged:: 0.6 By default the session is now only saved if the session is modified, not if it is new like it was before. """ return self.modified
[ "def", "should_save", "(", "self", ")", ":", "return", "self", ".", "modified" ]
[ 143, 4 ]
[ 150, 28 ]
python
en
['en', 'en', 'en']
True
SessionStore.is_valid_key
(self, key)
Check if a key has the correct format.
Check if a key has the correct format.
def is_valid_key(self, key): """Check if a key has the correct format.""" return _sha1_re.match(key) is not None
[ "def", "is_valid_key", "(", "self", ",", "key", ")", ":", "return", "_sha1_re", ".", "match", "(", "key", ")", "is", "not", "None" ]
[ 167, 4 ]
[ 169, 46 ]
python
en
['en', 'en', 'en']
True
SessionStore.generate_key
(self, salt=None)
Simple function that generates a new session key.
Simple function that generates a new session key.
def generate_key(self, salt=None): """Simple function that generates a new session key.""" return generate_key(salt)
[ "def", "generate_key", "(", "self", ",", "salt", "=", "None", ")", ":", "return", "generate_key", "(", "salt", ")" ]
[ 171, 4 ]
[ 173, 33 ]
python
en
['en', 'en', 'en']
True
SessionStore.new
(self)
Generate a new session.
Generate a new session.
def new(self): """Generate a new session.""" return self.session_class({}, self.generate_key(), True)
[ "def", "new", "(", "self", ")", ":", "return", "self", ".", "session_class", "(", "{", "}", ",", "self", ".", "generate_key", "(", ")", ",", "True", ")" ]
[ 175, 4 ]
[ 177, 64 ]
python
en
['en', 'en', 'en']
True
SessionStore.save
(self, session)
Save a session.
Save a session.
def save(self, session): """Save a session."""
[ "def", "save", "(", "self", ",", "session", ")", ":" ]
[ 179, 4 ]
[ 180, 29 ]
python
en
['en', 'en', 'en']
True
SessionStore.save_if_modified
(self, session)
Save if a session class wants an update.
Save if a session class wants an update.
def save_if_modified(self, session): """Save if a session class wants an update.""" if session.should_save: self.save(session)
[ "def", "save_if_modified", "(", "self", ",", "session", ")", ":", "if", "session", ".", "should_save", ":", "self", ".", "save", "(", "session", ")" ]
[ 182, 4 ]
[ 185, 30 ]
python
en
['en', 'en', 'en']
True
SessionStore.delete
(self, session)
Delete a session.
Delete a session.
def delete(self, session): """Delete a session."""
[ "def", "delete", "(", "self", ",", "session", ")", ":" ]
[ 187, 4 ]
[ 188, 31 ]
python
en
['en', 'it', 'en']
True
SessionStore.get
(self, sid)
Get a session for this sid or a new session object. This method has to check if the session key is valid and create a new session if that wasn't the case.
Get a session for this sid or a new session object. This method has to check if the session key is valid and create a new session if that wasn't the case.
def get(self, sid): """Get a session for this sid or a new session object. This method has to check if the session key is valid and create a new session if that wasn't the case. """ return self.session_class({}, sid, True)
[ "def", "get", "(", "self", ",", "sid", ")", ":", "return", "self", ".", "session_class", "(", "{", "}", ",", "sid", ",", "True", ")" ]
[ 190, 4 ]
[ 195, 48 ]
python
en
['en', 'en', 'en']
True
FilesystemSessionStore.list
(self)
Lists all sessions in the store. .. versionadded:: 0.6
Lists all sessions in the store.
def list(self): """Lists all sessions in the store. .. versionadded:: 0.6 """ before, after = self.filename_template.split("%s", 1) filename_re = re.compile( r"%s(.{5,})%s$" % (re.escape(before), re.escape(after)) ) result = [] for filename in...
[ "def", "list", "(", "self", ")", ":", "before", ",", "after", "=", "self", ".", "filename_template", ".", "split", "(", "\"%s\"", ",", "1", ")", "filename_re", "=", "re", ".", "compile", "(", "r\"%s(.{5,})%s$\"", "%", "(", "re", ".", "escape", "(", "...
[ 293, 4 ]
[ 310, 21 ]
python
en
['en', 'en', 'en']
True
DashboardsServiceTransport.__init__
( self, *, host: str = DEFAULT_HOST, credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFA...
Instantiate the transport. Args: host (Optional[str]): The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the applicatio...
Instantiate the transport.
def __init__( self, *, host: str = DEFAULT_HOST, credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.Clien...
[ "def", "__init__", "(", "self", ",", "*", ",", "host", ":", "str", "=", "DEFAULT_HOST", ",", "credentials", ":", "ga_credentials", ".", "Credentials", "=", "None", ",", "credentials_file", ":", "Optional", "[", "str", "]", "=", "None", ",", "scopes", ":"...
[ 53, 4 ]
[ 125, 39 ]
python
en
['en', 'en', 'en']
True
DashboardsServiceTransport.close
(self)
Closes resources associated with the transport. .. warning:: Only call this method if the transport is NOT shared with other clients - this may cause errors in other clients!
Closes resources associated with the transport.
def close(self): """Closes resources associated with the transport. .. warning:: Only call this method if the transport is NOT shared with other clients - this may cause errors in other clients! """ raise NotImplementedError()
[ "def", "close", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 147, 4 ]
[ 154, 35 ]
python
en
['en', 'en', 'en']
True
pega_salada_sobremesa_suco
(items)
Funcao auxiliar que popula os atributos salada, sobremesa e suco do cardapio da refeicao fornecida.
Funcao auxiliar que popula os atributos salada, sobremesa e suco do cardapio da refeicao fornecida.
def pega_salada_sobremesa_suco(items): """ Funcao auxiliar que popula os atributos salada, sobremesa e suco do cardapio da refeicao fornecida.""" alimentos = ["salada", "suco", "sobremesa"] cardapio = {} for alim in alimentos: tag = alim.upper() + ":" # tag para procurar o cardapio dos alimento...
[ "def", "pega_salada_sobremesa_suco", "(", "items", ")", ":", "alimentos", "=", "[", "\"salada\"", ",", "\"suco\"", ",", "\"sobremesa\"", "]", "cardapio", "=", "{", "}", "for", "alim", "in", "alimentos", ":", "tag", "=", "alim", ".", "upper", "(", ")", "+...
[ 20, 0 ]
[ 32, 26 ]
python
pt
['pt', 'pt', 'pt']
True
get_refeicao
(tipo, soup)
Faz o parsing do cardapio de uma refeicao (e.g. almoco, jantar), dado o elemento em HTML contendo as informacoes. :param tipo: string que representa qual refeicao é (e.g. "Almoço", "Jantar") :param soup: objeto do BeatifulSoup que contem o HTML e sera utilizado para fazer o parsing. :return: dict com ...
Faz o parsing do cardapio de uma refeicao (e.g. almoco, jantar), dado o elemento em HTML contendo as informacoes.
def get_refeicao(tipo, soup): """ Faz o parsing do cardapio de uma refeicao (e.g. almoco, jantar), dado o elemento em HTML contendo as informacoes. :param tipo: string que representa qual refeicao é (e.g. "Almoço", "Jantar") :param soup: objeto do BeatifulSoup que contem o HTML e sera utilizado para fa...
[ "def", "get_refeicao", "(", "tipo", ",", "soup", ")", ":", "items", "=", "[", "s", "for", "s", "in", "soup", ".", "get_text", "(", ")", ".", "split", "(", "\"\\n\"", ")", "if", "s", "]", "# retira todas as tags de HTML, e armazena todos os elementos (strings n...
[ 37, 0 ]
[ 120, 42 ]
python
en
['en', 'error', 'th']
False
cardapio_por_data
(data_string)
Dada a string de uma data, fornece o objeto da classe Cardapio correspondente ao cardapio dessa data. :param data_string: string da data do cardapio desejado. :return: objeto da classe Cardapio que contem o cardapio requisitado.
Dada a string de uma data, fornece o objeto da classe Cardapio correspondente ao cardapio dessa data.
def cardapio_por_data(data_string): """ Dada a string de uma data, fornece o objeto da classe Cardapio correspondente ao cardapio dessa data. :param data_string: string da data do cardapio desejado. :return: objeto da classe Cardapio que contem o cardapio requisitado. """ res = requests.get(URL...
[ "def", "cardapio_por_data", "(", "data_string", ")", ":", "res", "=", "requests", ".", "get", "(", "URL_TEMPLATE", "+", "data_string", ")", "# faz o request para a pagina da prefeitura", "html_doc", "=", "res", ".", "content", "# pega a pagina HTML", "soup", "=", "B...
[ 124, 0 ]
[ 161, 50 ]
python
en
['en', 'error', 'th']
False
cardapio_para_datas
(data_strings)
Dada uma lista com strings das datas, essa funcao retorna os objetos Cardapio desses cardapios em uma lista. :param data_strings: lista com strings das datas dos cardapios desejados. :return: lista com objetos da classe Cardapio que contem os cardapios das datas fornecidas.
Dada uma lista com strings das datas, essa funcao retorna os objetos Cardapio desses cardapios em uma lista.
def cardapio_para_datas(data_strings): """ Dada uma lista com strings das datas, essa funcao retorna os objetos Cardapio desses cardapios em uma lista. :param data_strings: lista com strings das datas dos cardapios desejados. :return: lista com objetos da classe Cardapio que contem os cardapios das dat...
[ "def", "cardapio_para_datas", "(", "data_strings", ")", ":", "cardapios", "=", "[", "]", "for", "data", "in", "data_strings", ":", "c", "=", "cardapio_por_data", "(", "data", ")", "if", "c", "is", "not", "None", "and", "len", "(", "c", ".", "__dict__", ...
[ 168, 0 ]
[ 185, 20 ]
python
en
['en', 'error', 'th']
False
get_next_cardapios
(date_string, next)
Fornece os cardapios dos *next* dias a partir da data fornecida em *date_string*. Ponto de entrada principal. A view que sera chamada no app sera essa. :param date_string: data inicial. :param next: inteiro que representa a quantidade de cardapios desejados a partir da data inicial. :return: lis...
Fornece os cardapios dos *next* dias a partir da data fornecida em *date_string*.
def get_next_cardapios(date_string, next): """ Fornece os cardapios dos *next* dias a partir da data fornecida em *date_string*. Ponto de entrada principal. A view que sera chamada no app sera essa. :param date_string: data inicial. :param next: inteiro que representa a quantidade de cardapios de...
[ "def", "get_next_cardapios", "(", "date_string", ",", "next", ")", ":", "date_strings", "=", "date_services", ".", "next_weekdays", "(", "next", ",", "start_date_string", "=", "date_string", ")", "# print(\"EXECUTOU get_next_cardapio\")", "return", "cardapio_para_datas", ...
[ 189, 0 ]
[ 204, 44 ]
python
en
['en', 'error', 'th']
False
check_error_file
(file_check)
Function to check if file exist :param file_check: File to check :type file_check: str
Function to check if file exist
def check_error_file(file_check): """ Function to check if file exist :param file_check: File to check :type file_check: str """ try: open(file_check) except TypeError: raise TypeError("File cannot be empty or file is invalid: " + str(file_check))
[ "def", "check_error_file", "(", "file_check", ")", ":", "try", ":", "open", "(", "file_check", ")", "except", "TypeError", ":", "raise", "TypeError", "(", "\"File cannot be empty or file is invalid: \"", "+", "str", "(", "file_check", ")", ")" ]
[ 18, 0 ]
[ 30, 86 ]
python
en
['en', 'error', 'th']
False
check_len_lists
(list1, list2)
Function to check if 2 have the same length :param list1: First list :type list1: list :param list2: Second list :type list2: list
Function to check if 2 have the same length
def check_len_lists(list1, list2): """ Function to check if 2 have the same length :param list1: First list :type list1: list :param list2: Second list :type list2: list """ if len(list1) != len(list2): print("Error: Number of files in train list and rank list must be equal!"...
[ "def", "check_len_lists", "(", "list1", ",", "list2", ")", ":", "if", "len", "(", "list1", ")", "!=", "len", "(", "list2", ")", ":", "print", "(", "\"Error: Number of files in train list and rank list must be equal!\"", ")", "sys", ".", "exit", "(", ")" ]
[ 33, 0 ]
[ 47, 18 ]
python
en
['en', 'error', 'th']
False
timed
(f)
Function to calculate the time of execution :param f: Function name without () :type f: function name :return: Time of execution :rtype: float
Function to calculate the time of execution
def timed(f): """ Function to calculate the time of execution :param f: Function name without () :type f: function name :return: Time of execution :rtype: float """ start = time.time() f() elapsed = time.time() - start return elapsed
[ "def", "timed", "(", "f", ")", ":", "start", "=", "time", ".", "time", "(", ")", "f", "(", ")", "elapsed", "=", "time", ".", "time", "(", ")", "-", "start", "return", "elapsed" ]
[ 50, 0 ]
[ 64, 18 ]
python
en
['en', 'error', 'th']
False
print_header
(header_info, test_info=None)
Function to print the header with information of the files :param header_info: Dictionary with information about dataset or train file :type header_info: dict :param test_info: Dictionary with information about test file :type test_info: dict
Function to print the header with information of the files
def print_header(header_info, test_info=None): """ Function to print the header with information of the files :param header_info: Dictionary with information about dataset or train file :type header_info: dict :param test_info: Dictionary with information about test file :type test_info: dict ...
[ "def", "print_header", "(", "header_info", ",", "test_info", "=", "None", ")", ":", "print", "(", "\"[Case Recommender: %s]\\n\"", "%", "header_info", "[", "'title'", "]", ")", "print", "(", "\"train data:: %d users and %d items (%d interactions) | sparsity:: %.2f%%\"", "...
[ 67, 0 ]
[ 85, 111 ]
python
en
['en', 'error', 'th']
False
user_passes_test
(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME)
Decorator for views that checks that the user passes the given test, redirecting to the log-in page if necessary. The test should be a callable that takes the user object and returns True if the user passes.
Decorator for views that checks that the user passes the given test, redirecting to the log-in page if necessary. The test should be a callable that takes the user object and returns True if the user passes.
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Decorator for views that checks that the user passes the given test, redirecting to the log-in page if necessary. The test should be a callable that takes the user object and returns True if the user passes. ...
[ "def", "user_passes_test", "(", "test_func", ",", "login_url", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "def", "decorator", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "_wrapped_view", "(", "req...
[ 9, 0 ]
[ 34, 20 ]
python
en
['en', 'error', 'th']
False
login_required
(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None)
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.
def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ actual_decorator = user_passes_test( lambda u: u.is_authenticated, login_url=lo...
[ "def", "login_required", "(", "function", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "login_url", "=", "None", ")", ":", "actual_decorator", "=", "user_passes_test", "(", "lambda", "u", ":", "u", ".", "is_authenticated", ",", "logi...
[ 37, 0 ]
[ 49, 27 ]
python
en
['en', 'error', 'th']
False
permission_required
(perm, login_url=None, raise_exception=False)
Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. If the raise_exception parameter is given the PermissionDenied exception is raised.
Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. If the raise_exception parameter is given the PermissionDenied exception is raised.
def permission_required(perm, login_url=None, raise_exception=False): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. If the raise_exception parameter is given the PermissionDenied exception is raised. """ d...
[ "def", "permission_required", "(", "perm", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "def", "check_perms", "(", "user", ")", ":", "if", "isinstance", "(", "perm", ",", "str", ")", ":", "perms", "=", "(", "perm", ","...
[ 52, 0 ]
[ 72, 61 ]
python
en
['en', 'error', 'th']
False
ServiceAccountCredentials._to_json
(self, strip, to_serialize=None)
Utility function that creates JSON repr. of a credentials object. Over-ride is needed since PKCS#12 keys will not in general be JSON serializable. Args: strip: array, An array of names of members to exclude from the JSON. to_serialize: dict, (Optional...
Utility function that creates JSON repr. of a credentials object.
def _to_json(self, strip, to_serialize=None): """Utility function that creates JSON repr. of a credentials object. Over-ride is needed since PKCS#12 keys will not in general be JSON serializable. Args: strip: array, An array of names of members to exclude from the ...
[ "def", "_to_json", "(", "self", ",", "strip", ",", "to_serialize", "=", "None", ")", ":", "if", "to_serialize", "is", "None", ":", "to_serialize", "=", "copy", ".", "copy", "(", "self", ".", "__dict__", ")", "pkcs12_val", "=", "to_serialize", ".", "get",...
[ 117, 4 ]
[ 140, 45 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials._from_parsed_json_keyfile
(cls, keyfile_dict, scopes, token_uri=None, revoke_uri=None)
Helper for factory constructors from JSON keyfile. Args: keyfile_dict: dict-like object, The parsed dictionary-like object containing the contents of the JSON keyfile. scopes: List or string, Scopes to use when acquiring an access token. ...
Helper for factory constructors from JSON keyfile.
def _from_parsed_json_keyfile(cls, keyfile_dict, scopes, token_uri=None, revoke_uri=None): """Helper for factory constructors from JSON keyfile. Args: keyfile_dict: dict-like object, The parsed dictionary-like object containing the...
[ "def", "_from_parsed_json_keyfile", "(", "cls", ",", "keyfile_dict", ",", "scopes", ",", "token_uri", "=", "None", ",", "revoke_uri", "=", "None", ")", ":", "creds_type", "=", "keyfile_dict", ".", "get", "(", "'type'", ")", "if", "creds_type", "!=", "client"...
[ 143, 4 ]
[ 190, 26 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.from_json_keyfile_name
(cls, filename, scopes='', token_uri=None, revoke_uri=None)
Factory constructor from JSON keyfile by name. Args: filename: string, The location of the keyfile. scopes: List or string, (Optional) Scopes to use when acquiring an access token. token_uri: string, URI for OAuth 2.0 provider token endpoint. ...
Factory constructor from JSON keyfile by name.
def from_json_keyfile_name(cls, filename, scopes='', token_uri=None, revoke_uri=None): """Factory constructor from JSON keyfile by name. Args: filename: string, The location of the keyfile. scopes: List or string, (Optional) Scopes to use when acq...
[ "def", "from_json_keyfile_name", "(", "cls", ",", "filename", ",", "scopes", "=", "''", ",", "token_uri", "=", "None", ",", "revoke_uri", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "file_obj", ":", "client_credentials", ...
[ 193, 4 ]
[ 222, 67 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.from_json_keyfile_dict
(cls, keyfile_dict, scopes='', token_uri=None, revoke_uri=None)
Factory constructor from parsed JSON keyfile. Args: keyfile_dict: dict-like object, The parsed dictionary-like object containing the contents of the JSON keyfile. scopes: List or string, (Optional) Scopes to use when acquiring an access toke...
Factory constructor from parsed JSON keyfile.
def from_json_keyfile_dict(cls, keyfile_dict, scopes='', token_uri=None, revoke_uri=None): """Factory constructor from parsed JSON keyfile. Args: keyfile_dict: dict-like object, The parsed dictionary-like object containing the content...
[ "def", "from_json_keyfile_dict", "(", "cls", ",", "keyfile_dict", ",", "scopes", "=", "''", ",", "token_uri", "=", "None", ",", "revoke_uri", "=", "None", ")", ":", "return", "cls", ".", "_from_parsed_json_keyfile", "(", "keyfile_dict", ",", "scopes", ",", "...
[ 225, 4 ]
[ 252, 67 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials._from_p12_keyfile_contents
(cls, service_account_email, private_key_pkcs12, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2client.GOOGLE_REVOKE_URI)
Factory constructor from JSON keyfile. Args: service_account_email: string, The email associated with the service account. private_key_pkcs12: string, The contents of a PKCS#12 keyfile. private_key_password: string, (Optional) Password for ...
Factory constructor from JSON keyfile.
def _from_p12_keyfile_contents(cls, service_account_email, private_key_pkcs12, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2clien...
[ "def", "_from_p12_keyfile_contents", "(", "cls", ",", "service_account_email", ",", "private_key_pkcs12", ",", "private_key_password", "=", "None", ",", "scopes", "=", "''", ",", "token_uri", "=", "oauth2client", ".", "GOOGLE_TOKEN_URI", ",", "revoke_uri", "=", "oau...
[ 255, 4 ]
[ 295, 26 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.from_p12_keyfile
(cls, service_account_email, filename, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2client.GOOGLE_REVOKE_URI)
Factory constructor from JSON keyfile. Args: service_account_email: string, The email associated with the service account. filename: string, The location of the PKCS#12 keyfile. private_key_password: string, (Optional) Password for PKCS#12 ...
Factory constructor from JSON keyfile.
def from_p12_keyfile(cls, service_account_email, filename, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2client.GOOGLE_REVOKE_URI): """Factory constructor from JSON keyfile. Arg...
[ "def", "from_p12_keyfile", "(", "cls", ",", "service_account_email", ",", "filename", ",", "private_key_password", "=", "None", ",", "scopes", "=", "''", ",", "token_uri", "=", "oauth2client", ".", "GOOGLE_TOKEN_URI", ",", "revoke_uri", "=", "oauth2client", ".", ...
[ 298, 4 ]
[ 333, 55 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.from_p12_keyfile_buffer
(cls, service_account_email, file_buffer, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2client.GOOGLE_REVOKE_URI)
Factory constructor from JSON keyfile. Args: service_account_email: string, The email associated with the service account. file_buffer: stream, A buffer that implements ``read()`` and contains the PKCS#12 key contents. ...
Factory constructor from JSON keyfile.
def from_p12_keyfile_buffer(cls, service_account_email, file_buffer, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2client.GOOGLE_REVOKE_URI): """Factory constructor f...
[ "def", "from_p12_keyfile_buffer", "(", "cls", ",", "service_account_email", ",", "file_buffer", ",", "private_key_password", "=", "None", ",", "scopes", "=", "''", ",", "token_uri", "=", "oauth2client", ".", "GOOGLE_TOKEN_URI", ",", "revoke_uri", "=", "oauth2client"...
[ 336, 4 ]
[ 370, 55 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials._generate_assertion
(self)
Generate the assertion that will be used in the request.
Generate the assertion that will be used in the request.
def _generate_assertion(self): """Generate the assertion that will be used in the request.""" now = int(time.time()) payload = { 'aud': self.token_uri, 'scope': self._scopes, 'iat': now, 'exp': now + self.MAX_TOKEN_LIFETIME_SECS, 'iss':...
[ "def", "_generate_assertion", "(", "self", ")", ":", "now", "=", "int", "(", "time", ".", "time", "(", ")", ")", "payload", "=", "{", "'aud'", ":", "self", ".", "token_uri", ",", "'scope'", ":", "self", ".", "_scopes", ",", "'iat'", ":", "now", ","...
[ 372, 4 ]
[ 384, 65 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.sign_blob
(self, blob)
Cryptographically sign a blob (of bytes). Implements abstract method :meth:`oauth2client.client.AssertionCredentials.sign_blob`. Args: blob: bytes, Message to be signed. Returns: tuple, A pair of the private key ID used to sign the blob and the sign...
Cryptographically sign a blob (of bytes).
def sign_blob(self, blob): """Cryptographically sign a blob (of bytes). Implements abstract method :meth:`oauth2client.client.AssertionCredentials.sign_blob`. Args: blob: bytes, Message to be signed. Returns: tuple, A pair of the private key ID used to ...
[ "def", "sign_blob", "(", "self", ",", "blob", ")", ":", "return", "self", ".", "_private_key_id", ",", "self", ".", "_signer", ".", "sign", "(", "blob", ")" ]
[ 386, 4 ]
[ 399, 60 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.service_account_email
(self)
Get the email for the current service account. Returns: string, The email associated with the service account.
Get the email for the current service account.
def service_account_email(self): """Get the email for the current service account. Returns: string, The email associated with the service account. """ return self._service_account_email
[ "def", "service_account_email", "(", "self", ")", ":", "return", "self", ".", "_service_account_email" ]
[ 402, 4 ]
[ 408, 42 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.from_json
(cls, json_data)
Deserialize a JSON-serialized instance. Inverse to :meth:`to_json`. Args: json_data: dict or string, Serialized JSON (as a string or an already parsed dictionary) representing a credential. Returns: ServiceAccountCredentials from the serialized d...
Deserialize a JSON-serialized instance.
def from_json(cls, json_data): """Deserialize a JSON-serialized instance. Inverse to :meth:`to_json`. Args: json_data: dict or string, Serialized JSON (as a string or an already parsed dictionary) representing a credential. Returns: Servi...
[ "def", "from_json", "(", "cls", ",", "json_data", ")", ":", "if", "not", "isinstance", "(", "json_data", ",", "dict", ")", ":", "json_data", "=", "json", ".", "loads", "(", "_helpers", ".", "_from_bytes", "(", "json_data", ")", ")", "private_key_pkcs8_pem"...
[ 422, 4 ]
[ 474, 26 ]
python
en
['en', 'cs', 'en']
True
ServiceAccountCredentials.create_with_claims
(self, claims)
Create credentials that specify additional claims. Args: claims: dict, key-value pairs for claims. Returns: ServiceAccountCredentials, a copy of the current service account credentials with updated claims to use when obtaining access tokens.
Create credentials that specify additional claims.
def create_with_claims(self, claims): """Create credentials that specify additional claims. Args: claims: dict, key-value pairs for claims. Returns: ServiceAccountCredentials, a copy of the current service account credentials with updated claims to use when ...
[ "def", "create_with_claims", "(", "self", ",", "claims", ")", ":", "new_kwargs", "=", "dict", "(", "self", ".", "_kwargs", ")", "new_kwargs", ".", "update", "(", "claims", ")", "result", "=", "self", ".", "__class__", "(", "self", ".", "_service_account_em...
[ 494, 4 ]
[ 519, 21 ]
python
en
['en', 'en', 'en']
True
ServiceAccountCredentials.create_delegated
(self, sub)
Create credentials that act as domain-wide delegation of authority. Use the ``sub`` parameter as the subject to delegate on behalf of that user. For example:: >>> account_sub = 'foo@email.com' >>> delegate_creds = creds.create_delegated(account_sub) Args: ...
Create credentials that act as domain-wide delegation of authority.
def create_delegated(self, sub): """Create credentials that act as domain-wide delegation of authority. Use the ``sub`` parameter as the subject to delegate on behalf of that user. For example:: >>> account_sub = 'foo@email.com' >>> delegate_creds = creds.create_de...
[ "def", "create_delegated", "(", "self", ",", "sub", ")", ":", "return", "self", ".", "create_with_claims", "(", "{", "'sub'", ":", "sub", "}", ")" ]
[ 521, 4 ]
[ 540, 52 ]
python
en
['en', 'en', 'en']
True
_JWTAccessCredentials.authorize
(self, http)
Authorize an httplib2.Http instance with a JWT assertion. Unless specified, the 'aud' of the assertion will be the base uri of the request. Args: http: An instance of ``httplib2.Http`` or something that acts like it. Returns: A modified instanc...
Authorize an httplib2.Http instance with a JWT assertion.
def authorize(self, http): """Authorize an httplib2.Http instance with a JWT assertion. Unless specified, the 'aud' of the assertion will be the base uri of the request. Args: http: An instance of ``httplib2.Http`` or something that acts like it. R...
[ "def", "authorize", "(", "self", ",", "http", ")", ":", "transport", ".", "wrap_http_for_jwt_access", "(", "self", ",", "http", ")", "return", "http" ]
[ 583, 4 ]
[ 599, 19 ]
python
en
['en', 'lb', 'en']
True
_JWTAccessCredentials.get_access_token
(self, http=None, additional_claims=None)
Create a signed jwt. Args: http: unused additional_claims: dict, additional claims to add to the payload of the JWT. Returns: An AccessTokenInfo with the signed jwt
Create a signed jwt.
def get_access_token(self, http=None, additional_claims=None): """Create a signed jwt. Args: http: unused additional_claims: dict, additional claims to add to the payload of the JWT. Returns: An AccessTokenInfo with the signed jwt """ ...
[ "def", "get_access_token", "(", "self", ",", "http", "=", "None", ",", "additional_claims", "=", "None", ")", ":", "if", "additional_claims", "is", "None", ":", "if", "self", ".", "access_token", "is", "None", "or", "self", ".", "access_token_expired", ":", ...
[ 601, 4 ]
[ 620, 75 ]
python
en
['en', 'en', 'en']
True
_JWTAccessCredentials.revoke
(self, http)
Cannot revoke JWTAccessCredentials tokens.
Cannot revoke JWTAccessCredentials tokens.
def revoke(self, http): """Cannot revoke JWTAccessCredentials tokens.""" pass
[ "def", "revoke", "(", "self", ",", "http", ")", ":", "pass" ]
[ 622, 4 ]
[ 624, 12 ]
python
en
['en', 'ca', 'en']
True
_JWTAccessCredentials.refresh
(self, http)
Refreshes the access_token. The HTTP object is unused since no request needs to be made to get a new token, it can just be generated locally. Args: http: unused HTTP object
Refreshes the access_token.
def refresh(self, http): """Refreshes the access_token. The HTTP object is unused since no request needs to be made to get a new token, it can just be generated locally. Args: http: unused HTTP object """ self._refresh(None)
[ "def", "refresh", "(", "self", ",", "http", ")", ":", "self", ".", "_refresh", "(", "None", ")" ]
[ 650, 4 ]
[ 659, 27 ]
python
en
['en', 'en', 'en']
True
_JWTAccessCredentials._refresh
(self, http)
Refreshes the access_token. Args: http: unused HTTP object
Refreshes the access_token.
def _refresh(self, http): """Refreshes the access_token. Args: http: unused HTTP object """ self.access_token, self.token_expiry = self._create_token()
[ "def", "_refresh", "(", "self", ",", "http", ")", ":", "self", ".", "access_token", ",", "self", ".", "token_expiry", "=", "self", ".", "_create_token", "(", ")" ]
[ 661, 4 ]
[ 667, 67 ]
python
en
['en', 'en', 'en']
True
Marker.evaluate
(self, environment: Optional[Dict[str, str]] = None)
Evaluate a marker. Return the boolean from evaluating the given marker against the environment. environment is an optional argument to override all or part of the determined environment. The environment is determined from the current Python process.
Evaluate a marker.
def evaluate(self, environment: Optional[Dict[str, str]] = None) -> bool: """Evaluate a marker. Return the boolean from evaluating the given marker against the environment. environment is an optional argument to override all or part of the determined environment. The environmen...
[ "def", "evaluate", "(", "self", ",", "environment", ":", "Optional", "[", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ")", "->", "bool", ":", "current_environment", "=", "default_environment", "(", ")", "if", "environment", "is", "not", "None"...
[ 290, 4 ]
[ 303, 68 ]
python
en
['en', 'en', 'en']
True
lint
(session)
Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues.
Run linters.
def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ session.install("flake8", BLACK_VERSION) session.run( "black", "--check", *BLACK_PATHS, ) session.run("flake8", "google", "tests")
[ "def", "lint", "(", "session", ")", ":", "session", ".", "install", "(", "\"flake8\"", ",", "BLACK_VERSION", ")", "session", ".", "run", "(", "\"black\"", ",", "\"--check\"", ",", "*", "BLACK_PATHS", ",", ")", "session", ".", "run", "(", "\"flake8\"", ",...
[ 51, 0 ]
[ 61, 44 ]
python
en
['es', 'ms', 'en']
False
blacken
(session)
Run black. Format code to uniform standard.
Run black. Format code to uniform standard.
def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( "black", *BLACK_PATHS, )
[ "def", "blacken", "(", "session", ")", ":", "session", ".", "install", "(", "BLACK_VERSION", ")", "session", ".", "run", "(", "\"black\"", ",", "*", "BLACK_PATHS", ",", ")" ]
[ 65, 0 ]
[ 70, 5 ]
python
en
['en', 'lb', 'en']
True
lint_setup_py
(session)
Verify that setup.py is valid (including RST check).
Verify that setup.py is valid (including RST check).
def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" session.install("docutils", "pygments") session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
[ "def", "lint_setup_py", "(", "session", ")", ":", "session", ".", "install", "(", "\"docutils\"", ",", "\"pygments\"", ")", "session", ".", "run", "(", "\"python\"", ",", "\"setup.py\"", ",", "\"check\"", ",", "\"--restructuredtext\"", ",", "\"--strict\"", ")" ]
[ 74, 0 ]
[ 77, 80 ]
python
en
['en', 'en', 'en']
True
unit
(session)
Run the unit test suite.
Run the unit test suite.
def unit(session): """Run the unit test suite.""" default(session)
[ "def", "unit", "(", "session", ")", ":", "default", "(", "session", ")" ]
[ 115, 0 ]
[ 117, 20 ]
python
en
['en', 'fr', 'en']
True
system
(session)
Run the system test suite.
Run the system test suite.
def system(session): """Run the system test suite.""" constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") # Check the value of `RUN_S...
[ "def", "system", "(", "session", ")", ":", "constraints_path", "=", "str", "(", "CURRENT_DIRECTORY", "/", "\"testing\"", "/", "f\"constraints-{session.python}.txt\"", ")", "system_test_path", "=", "os", ".", "path", ".", "join", "(", "\"tests\"", ",", "\"system.py...
[ 121, 0 ]
[ 166, 9 ]
python
en
['en', 'en', 'en']
True
cover
(session)
Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data.
Run the final coverage report.
def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") session.run("coverage", "report", "--show-missing", "--fail-un...
[ "def", "cover", "(", "session", ")", ":", "session", ".", "install", "(", "\"coverage\"", ",", "\"pytest-cov\"", ")", "session", ".", "run", "(", "\"coverage\"", ",", "\"report\"", ",", "\"--show-missing\"", ",", "\"--fail-under=96\"", ")", "session", ".", "ru...
[ 170, 0 ]
[ 179, 36 ]
python
en
['en', 'it', 'en']
True
docs
(session)
Build the docs for this library.
Build the docs for this library.
def docs(session): """Build the docs for this library.""" session.install("-e", ".") session.install("sphinx==4.0.1", "alabaster", "recommonmark") shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( "sphinx-build", # "-W", # warnings as errors "-...
[ "def", "docs", "(", "session", ")", ":", "session", ".", "install", "(", "\"-e\"", ",", "\".\"", ")", "session", ".", "install", "(", "\"sphinx==4.0.1\"", ",", "\"alabaster\"", ",", "\"recommonmark\"", ")", "shutil", ".", "rmtree", "(", "os", ".", "path", ...
[ 183, 0 ]
[ 201, 5 ]
python
en
['en', 'en', 'en']
True
docfx
(session)
Build the docfx yaml files for this library.
Build the docfx yaml files for this library.
def docfx(session): """Build the docfx yaml files for this library.""" session.install("-e", ".") session.install( "sphinx==4.0.1", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml" ) shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( "sphinx-buil...
[ "def", "docfx", "(", "session", ")", ":", "session", ".", "install", "(", "\"-e\"", ",", "\".\"", ")", "session", ".", "install", "(", "\"sphinx==4.0.1\"", ",", "\"alabaster\"", ",", "\"recommonmark\"", ",", "\"gcp-sphinx-docfx-yaml\"", ")", "shutil", ".", "rm...
[ 205, 0 ]
[ 236, 5 ]
python
en
['en', 'en', 'en']
True
get_spontaneous_environment
(*args)
Return a new spontaneous environment. A spontaneous environment is an unnamed and unaccessible (in theory) environment that is used for templates generated from a string and not from the file system.
Return a new spontaneous environment. A spontaneous environment is an unnamed and unaccessible (in theory) environment that is used for templates generated from a string and not from the file system.
def get_spontaneous_environment(*args): """Return a new spontaneous environment. A spontaneous environment is an unnamed and unaccessible (in theory) environment that is used for templates generated from a string and not from the file system. """ try: env = _spontaneous_environments.get(arg...
[ "def", "get_spontaneous_environment", "(", "*", "args", ")", ":", "try", ":", "env", "=", "_spontaneous_environments", ".", "get", "(", "args", ")", "except", "TypeError", ":", "return", "Environment", "(", "*", "args", ")", "if", "env", "is", "not", "None...
[ 43, 0 ]
[ 56, 14 ]
python
en
['en', 'ht', 'en']
True
create_cache
(size)
Return the cache class for the given size.
Return the cache class for the given size.
def create_cache(size): """Return the cache class for the given size.""" if size == 0: return None if size < 0: return {} return LRUCache(size)
[ "def", "create_cache", "(", "size", ")", ":", "if", "size", "==", "0", ":", "return", "None", "if", "size", "<", "0", ":", "return", "{", "}", "return", "LRUCache", "(", "size", ")" ]
[ 59, 0 ]
[ 65, 25 ]
python
en
['en', 'en', 'en']
True
copy_cache
(cache)
Create an empty copy of the given cache.
Create an empty copy of the given cache.
def copy_cache(cache): """Create an empty copy of the given cache.""" if cache is None: return None elif type(cache) is dict: return {} return LRUCache(cache.capacity)
[ "def", "copy_cache", "(", "cache", ")", ":", "if", "cache", "is", "None", ":", "return", "None", "elif", "type", "(", "cache", ")", "is", "dict", ":", "return", "{", "}", "return", "LRUCache", "(", "cache", ".", "capacity", ")" ]
[ 68, 0 ]
[ 74, 35 ]
python
en
['en', 'en', 'en']
True
load_extensions
(environment, extensions)
Load the extensions from the list and bind it to the environment. Returns a dict of instantiated environments.
Load the extensions from the list and bind it to the environment. Returns a dict of instantiated environments.
def load_extensions(environment, extensions): """Load the extensions from the list and bind it to the environment. Returns a dict of instantiated environments. """ result = {} for extension in extensions: if isinstance(extension, string_types): extension = import_string(extension...
[ "def", "load_extensions", "(", "environment", ",", "extensions", ")", ":", "result", "=", "{", "}", "for", "extension", "in", "extensions", ":", "if", "isinstance", "(", "extension", ",", "string_types", ")", ":", "extension", "=", "import_string", "(", "ext...
[ 77, 0 ]
[ 86, 17 ]
python
en
['en', 'en', 'en']
True
_environment_sanity_check
(environment)
Perform a sanity check on the environment.
Perform a sanity check on the environment.
def _environment_sanity_check(environment): """Perform a sanity check on the environment.""" assert issubclass(environment.undefined, Undefined), 'undefined must ' \ 'be a subclass of undefined because filters depend on it.' assert environment.block_start_string != \ environment.variable_sta...
[ "def", "_environment_sanity_check", "(", "environment", ")", ":", "assert", "issubclass", "(", "environment", ".", "undefined", ",", "Undefined", ")", ",", "'undefined must '", "'be a subclass of undefined because filters depend on it.'", "assert", "environment", ".", "bloc...
[ 99, 0 ]
[ 109, 22 ]
python
en
['en', 'en', 'en']
True
Environment.add_extension
(self, extension)
Adds an extension after the environment was created. .. versionadded:: 2.5
Adds an extension after the environment was created.
def add_extension(self, extension): """Adds an extension after the environment was created. .. versionadded:: 2.5 """ self.extensions.update(load_extensions(self, [extension]))
[ "def", "add_extension", "(", "self", ",", "extension", ")", ":", "self", ".", "extensions", ".", "update", "(", "load_extensions", "(", "self", ",", "[", "extension", "]", ")", ")" ]
[ 339, 4 ]
[ 344, 66 ]
python
en
['en', 'en', 'en']
True
Environment.extend
(self, **attributes)
Add the items to the instance of the environment if they do not exist yet. This is used by :ref:`extensions <writing-extensions>` to register callbacks and configuration values without breaking inheritance.
Add the items to the instance of the environment if they do not exist yet. This is used by :ref:`extensions <writing-extensions>` to register callbacks and configuration values without breaking inheritance.
def extend(self, **attributes): """Add the items to the instance of the environment if they do not exist yet. This is used by :ref:`extensions <writing-extensions>` to register callbacks and configuration values without breaking inheritance. """ for key, value in iteritems(attri...
[ "def", "extend", "(", "self", ",", "*", "*", "attributes", ")", ":", "for", "key", ",", "value", "in", "iteritems", "(", "attributes", ")", ":", "if", "not", "hasattr", "(", "self", ",", "key", ")", ":", "setattr", "(", "self", ",", "key", ",", "...
[ 346, 4 ]
[ 353, 41 ]
python
en
['en', 'en', 'en']
True
Environment.overlay
(self, block_start_string=missing, block_end_string=missing, variable_start_string=missing, variable_end_string=missing, comment_start_string=missing, comment_end_string=missing, line_statement_prefix=missing, line_comment_prefix=missing, trim_blocks=missi...
Create a new overlay environment that shares all the data with the current environment except for cache and the overridden attributes. Extensions cannot be removed for an overlayed environment. An overlayed environment automatically gets all the extensions of the environment it is linke...
Create a new overlay environment that shares all the data with the current environment except for cache and the overridden attributes. Extensions cannot be removed for an overlayed environment. An overlayed environment automatically gets all the extensions of the environment it is linke...
def overlay(self, block_start_string=missing, block_end_string=missing, variable_start_string=missing, variable_end_string=missing, comment_start_string=missing, comment_end_string=missing, line_statement_prefix=missing, line_comment_prefix=missing, trim_b...
[ "def", "overlay", "(", "self", ",", "block_start_string", "=", "missing", ",", "block_end_string", "=", "missing", ",", "variable_start_string", "=", "missing", ",", "variable_end_string", "=", "missing", ",", "comment_start_string", "=", "missing", ",", "comment_en...
[ 355, 4 ]
[ 398, 44 ]
python
en
['en', 'en', 'en']
True
Environment.iter_extensions
(self)
Iterates over the extensions by priority.
Iterates over the extensions by priority.
def iter_extensions(self): """Iterates over the extensions by priority.""" return iter(sorted(self.extensions.values(), key=lambda x: x.priority))
[ "def", "iter_extensions", "(", "self", ")", ":", "return", "iter", "(", "sorted", "(", "self", ".", "extensions", ".", "values", "(", ")", ",", "key", "=", "lambda", "x", ":", "x", ".", "priority", ")", ")" ]
[ 402, 4 ]
[ 405, 53 ]
python
en
['en', 'en', 'en']
True
Environment.getitem
(self, obj, argument)
Get an item or attribute of an object but prefer the item.
Get an item or attribute of an object but prefer the item.
def getitem(self, obj, argument): """Get an item or attribute of an object but prefer the item.""" try: return obj[argument] except (AttributeError, TypeError, LookupError): if isinstance(argument, string_types): try: attr = str(argumen...
[ "def", "getitem", "(", "self", ",", "obj", ",", "argument", ")", ":", "try", ":", "return", "obj", "[", "argument", "]", "except", "(", "AttributeError", ",", "TypeError", ",", "LookupError", ")", ":", "if", "isinstance", "(", "argument", ",", "string_ty...
[ 407, 4 ]
[ 422, 57 ]
python
en
['en', 'en', 'en']
True
Environment.getattr
(self, obj, attribute)
Get an item or attribute of an object but prefer the attribute. Unlike :meth:`getitem` the attribute *must* be a bytestring.
Get an item or attribute of an object but prefer the attribute. Unlike :meth:`getitem` the attribute *must* be a bytestring.
def getattr(self, obj, attribute): """Get an item or attribute of an object but prefer the attribute. Unlike :meth:`getitem` the attribute *must* be a bytestring. """ try: return getattr(obj, attribute) except AttributeError: pass try: ...
[ "def", "getattr", "(", "self", ",", "obj", ",", "attribute", ")", ":", "try", ":", "return", "getattr", "(", "obj", ",", "attribute", ")", "except", "AttributeError", ":", "pass", "try", ":", "return", "obj", "[", "attribute", "]", "except", "(", "Type...
[ 424, 4 ]
[ 435, 58 ]
python
en
['en', 'en', 'en']
True
Environment.call_filter
(self, name, value, args=None, kwargs=None, context=None, eval_ctx=None)
Invokes a filter on a value the same way the compiler does it. Note that on Python 3 this might return a coroutine in case the filter is running from an environment in async mode and the filter supports async execution. It's your responsibility to await this if needed. .. vers...
Invokes a filter on a value the same way the compiler does it.
def call_filter(self, name, value, args=None, kwargs=None, context=None, eval_ctx=None): """Invokes a filter on a value the same way the compiler does it. Note that on Python 3 this might return a coroutine in case the filter is running from an environment in async mode and ...
[ "def", "call_filter", "(", "self", ",", "name", ",", "value", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "context", "=", "None", ",", "eval_ctx", "=", "None", ")", ":", "func", "=", "self", ".", "filters", ".", "get", "(", "name", ...
[ 437, 4 ]
[ 466, 44 ]
python
en
['en', 'en', 'en']
True
Environment.call_test
(self, name, value, args=None, kwargs=None)
Invokes a test on a value the same way the compiler does it. .. versionadded:: 2.7
Invokes a test on a value the same way the compiler does it.
def call_test(self, name, value, args=None, kwargs=None): """Invokes a test on a value the same way the compiler does it. .. versionadded:: 2.7 """ func = self.tests.get(name) if func is None: fail_for_missing_callable('no test named %r', name) return func(va...
[ "def", "call_test", "(", "self", ",", "name", ",", "value", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "func", "=", "self", ".", "tests", ".", "get", "(", "name", ")", "if", "func", "is", "None", ":", "fail_for_missing_callable",...
[ 468, 4 ]
[ 476, 59 ]
python
en
['en', 'en', 'en']
True
Environment.parse
(self, source, name=None, filename=None)
Parse the sourcecode and return the abstract syntax tree. This tree of nodes is used by the compiler to convert the template into executable source- or bytecode. This is useful for debugging or to extract information from templates. If you are :ref:`developing Jinja2 extensions <writi...
Parse the sourcecode and return the abstract syntax tree. This tree of nodes is used by the compiler to convert the template into executable source- or bytecode. This is useful for debugging or to extract information from templates.
def parse(self, source, name=None, filename=None): """Parse the sourcecode and return the abstract syntax tree. This tree of nodes is used by the compiler to convert the template into executable source- or bytecode. This is useful for debugging or to extract information from templates....
[ "def", "parse", "(", "self", ",", "source", ",", "name", "=", "None", ",", "filename", "=", "None", ")", ":", "try", ":", "return", "self", ".", "_parse", "(", "source", ",", "name", ",", "filename", ")", "except", "TemplateSyntaxError", ":", "exc_info...
[ 479, 4 ]
[ 492, 59 ]
python
en
['en', 'en', 'en']
True
Environment._parse
(self, source, name, filename)
Internal parsing function used by `parse` and `compile`.
Internal parsing function used by `parse` and `compile`.
def _parse(self, source, name, filename): """Internal parsing function used by `parse` and `compile`.""" return Parser(self, source, name, encode_filename(filename)).parse()
[ "def", "_parse", "(", "self", ",", "source", ",", "name", ",", "filename", ")", ":", "return", "Parser", "(", "self", ",", "source", ",", "name", ",", "encode_filename", "(", "filename", ")", ")", ".", "parse", "(", ")" ]
[ 494, 4 ]
[ 496, 76 ]
python
en
['en', 'en', 'en']
True
Environment.lex
(self, source, name=None, filename=None)
Lex the given sourcecode and return a generator that yields tokens as tuples in the form ``(lineno, token_type, value)``. This can be useful for :ref:`extension development <writing-extensions>` and debugging templates. This does not perform preprocessing. If you want the preprocessing...
Lex the given sourcecode and return a generator that yields tokens as tuples in the form ``(lineno, token_type, value)``. This can be useful for :ref:`extension development <writing-extensions>` and debugging templates.
def lex(self, source, name=None, filename=None): """Lex the given sourcecode and return a generator that yields tokens as tuples in the form ``(lineno, token_type, value)``. This can be useful for :ref:`extension development <writing-extensions>` and debugging templates. This do...
[ "def", "lex", "(", "self", ",", "source", ",", "name", "=", "None", ",", "filename", "=", "None", ")", ":", "source", "=", "text_type", "(", "source", ")", "try", ":", "return", "self", ".", "lexer", ".", "tokeniter", "(", "source", ",", "name", ",...
[ 498, 4 ]
[ 513, 59 ]
python
en
['en', 'en', 'en']
True
Environment.preprocess
(self, source, name=None, filename=None)
Preprocesses the source with all extensions. This is automatically called for all parsing and compiling methods but *not* for :meth:`lex` because there you usually only want the actual source tokenized.
Preprocesses the source with all extensions. This is automatically called for all parsing and compiling methods but *not* for :meth:`lex` because there you usually only want the actual source tokenized.
def preprocess(self, source, name=None, filename=None): """Preprocesses the source with all extensions. This is automatically called for all parsing and compiling methods but *not* for :meth:`lex` because there you usually only want the actual source tokenized. """ return reduce...
[ "def", "preprocess", "(", "self", ",", "source", ",", "name", "=", "None", ",", "filename", "=", "None", ")", ":", "return", "reduce", "(", "lambda", "s", ",", "e", ":", "e", ".", "preprocess", "(", "s", ",", "name", ",", "filename", ")", ",", "s...
[ 515, 4 ]
[ 521, 64 ]
python
en
['en', 'en', 'en']
True
Environment._tokenize
(self, source, name, filename=None, state=None)
Called by the parser to do the preprocessing and filtering for all the extensions. Returns a :class:`~jinja2.lexer.TokenStream`.
Called by the parser to do the preprocessing and filtering for all the extensions. Returns a :class:`~jinja2.lexer.TokenStream`.
def _tokenize(self, source, name, filename=None, state=None): """Called by the parser to do the preprocessing and filtering for all the extensions. Returns a :class:`~jinja2.lexer.TokenStream`. """ source = self.preprocess(source, name, filename) stream = self.lexer.tokenize(sou...
[ "def", "_tokenize", "(", "self", ",", "source", ",", "name", ",", "filename", "=", "None", ",", "state", "=", "None", ")", ":", "source", "=", "self", ".", "preprocess", "(", "source", ",", "name", ",", "filename", ")", "stream", "=", "self", ".", ...
[ 523, 4 ]
[ 533, 21 ]
python
en
['en', 'en', 'en']
True
Environment._generate
(self, source, name, filename, defer_init=False)
Internal hook that can be overridden to hook a different generate method in. .. versionadded:: 2.5
Internal hook that can be overridden to hook a different generate method in.
def _generate(self, source, name, filename, defer_init=False): """Internal hook that can be overridden to hook a different generate method in. .. versionadded:: 2.5 """ return generate(source, self, name, filename, defer_init=defer_init, optimized=self.op...
[ "def", "_generate", "(", "self", ",", "source", ",", "name", ",", "filename", ",", "defer_init", "=", "False", ")", ":", "return", "generate", "(", "source", ",", "self", ",", "name", ",", "filename", ",", "defer_init", "=", "defer_init", ",", "optimized...
[ 535, 4 ]
[ 542, 49 ]
python
en
['en', 'en', 'en']
True
Environment._compile
(self, source, filename)
Internal hook that can be overridden to hook a different compile method in. .. versionadded:: 2.5
Internal hook that can be overridden to hook a different compile method in.
def _compile(self, source, filename): """Internal hook that can be overridden to hook a different compile method in. .. versionadded:: 2.5 """ return compile(source, filename, 'exec')
[ "def", "_compile", "(", "self", ",", "source", ",", "filename", ")", ":", "return", "compile", "(", "source", ",", "filename", ",", "'exec'", ")" ]
[ 544, 4 ]
[ 550, 48 ]
python
en
['en', 'en', 'en']
True
Environment.compile
(self, source, name=None, filename=None, raw=False, defer_init=False)
Compile a node or template source code. The `name` parameter is the load name of the template after it was joined using :meth:`join_path` if necessary, not the filename on the file system. the `filename` parameter is the estimated filename of the template on the file system. If the tem...
Compile a node or template source code. The `name` parameter is the load name of the template after it was joined using :meth:`join_path` if necessary, not the filename on the file system. the `filename` parameter is the estimated filename of the template on the file system. If the tem...
def compile(self, source, name=None, filename=None, raw=False, defer_init=False): """Compile a node or template source code. The `name` parameter is the load name of the template after it was joined using :meth:`join_path` if necessary, not the filename on the file system. ...
[ "def", "compile", "(", "self", ",", "source", ",", "name", "=", "None", ",", "filename", "=", "None", ",", "raw", "=", "False", ",", "defer_init", "=", "False", ")", ":", "source_hint", "=", "None", "try", ":", "if", "isinstance", "(", "source", ",",...
[ 553, 4 ]
[ 590, 64 ]
python
en
['en', 'en', 'en']
True