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
Environment.compile_expression
(self, source, undefined_to_none=True)
A handy helper method that returns a callable that accepts keyword arguments that appear as variables in the expression. If called it returns the result of the expression. This is useful if applications want to use the same rules as Jinja in template "configuration files" or similar si...
A handy helper method that returns a callable that accepts keyword arguments that appear as variables in the expression. If called it returns the result of the expression.
def compile_expression(self, source, undefined_to_none=True): """A handy helper method that returns a callable that accepts keyword arguments that appear as variables in the expression. If called it returns the result of the expression. This is useful if applications want to use the sa...
[ "def", "compile_expression", "(", "self", ",", "source", ",", "undefined_to_none", "=", "True", ")", ":", "parser", "=", "Parser", "(", "self", ",", "source", ",", "state", "=", "'variable'", ")", "exc_info", "=", "None", "try", ":", "expr", "=", "parser...
[ 592, 4 ]
[ 635, 62 ]
python
en
['en', 'en', 'en']
True
Environment.compile_templates
(self, target, extensions=None, filter_func=None, zip='deflated', log_function=None, ignore_errors=True, py_compile=False)
Finds all the templates the loader can find, compiles them and stores them in `target`. If `zip` is `None`, instead of in a zipfile, the templates will be stored in a directory. By default a deflate zip algorithm is used. To switch to the stored algorithm, `zip` can be set to ``'stored'...
Finds all the templates the loader can find, compiles them and stores them in `target`. If `zip` is `None`, instead of in a zipfile, the templates will be stored in a directory. By default a deflate zip algorithm is used. To switch to the stored algorithm, `zip` can be set to ``'stored'...
def compile_templates(self, target, extensions=None, filter_func=None, zip='deflated', log_function=None, ignore_errors=True, py_compile=False): """Finds all the templates the loader can find, compiles them and stores them in `target`. If `zip` is `No...
[ "def", "compile_templates", "(", "self", ",", "target", ",", "extensions", "=", "None", ",", "filter_func", "=", "None", ",", "zip", "=", "'deflated'", ",", "log_function", "=", "None", ",", "ignore_errors", "=", "True", ",", "py_compile", "=", "False", ")...
[ 637, 4 ]
[ 730, 52 ]
python
en
['en', 'en', 'en']
True
Environment.list_templates
(self, extensions=None, filter_func=None)
Returns a list of templates for this environment. This requires that the loader supports the loader's :meth:`~BaseLoader.list_templates` method. If there are other files in the template folder besides the actual templates, the returned list can be filtered. There are two ways:...
Returns a list of templates for this environment. This requires that the loader supports the loader's :meth:`~BaseLoader.list_templates` method.
def list_templates(self, extensions=None, filter_func=None): """Returns a list of templates for this environment. This requires that the loader supports the loader's :meth:`~BaseLoader.list_templates` method. If there are other files in the template folder besides the actual te...
[ "def", "list_templates", "(", "self", ",", "extensions", "=", "None", ",", "filter_func", "=", "None", ")", ":", "x", "=", "self", ".", "loader", ".", "list_templates", "(", ")", "if", "extensions", "is", "not", "None", ":", "if", "filter_func", "is", ...
[ 732, 4 ]
[ 757, 16 ]
python
en
['en', 'en', 'en']
True
Environment.handle_exception
(self, exc_info=None, rendered=False, source_hint=None)
Exception handling helper. This is used internally to either raise rewritten exceptions or return a rendered traceback for the template.
Exception handling helper. This is used internally to either raise rewritten exceptions or return a rendered traceback for the template.
def handle_exception(self, exc_info=None, rendered=False, source_hint=None): """Exception handling helper. This is used internally to either raise rewritten exceptions or return a rendered traceback for the template. """ global _make_traceback if exc_info is None: ex...
[ "def", "handle_exception", "(", "self", ",", "exc_info", "=", "None", ",", "rendered", "=", "False", ",", "source_hint", "=", "None", ")", ":", "global", "_make_traceback", "if", "exc_info", "is", "None", ":", "exc_info", "=", "sys", ".", "exc_info", "(", ...
[ 759, 4 ]
[ 779, 40 ]
python
en
['en', 'en', 'en']
True
Environment.join_path
(self, template, parent)
Join a template with the parent. By default all the lookups are relative to the loader root so this method returns the `template` parameter unchanged, but if the paths should be relative to the parent template, this function can be used to calculate the real template name. Subc...
Join a template with the parent. By default all the lookups are relative to the loader root so this method returns the `template` parameter unchanged, but if the paths should be relative to the parent template, this function can be used to calculate the real template name.
def join_path(self, template, parent): """Join a template with the parent. By default all the lookups are relative to the loader root so this method returns the `template` parameter unchanged, but if the paths should be relative to the parent template, this function can be used to calcu...
[ "def", "join_path", "(", "self", ",", "template", ",", "parent", ")", ":", "return", "template" ]
[ 781, 4 ]
[ 791, 23 ]
python
en
['en', 'en', 'en']
True
Environment.get_template
(self, name, parent=None, globals=None)
Load a template from the loader. If a loader is configured this method asks the loader for the template and returns a :class:`Template`. If the `parent` parameter is not `None`, :meth:`join_path` is called to get the real template name before loading. The `globals` parameter can be use...
Load a template from the loader. If a loader is configured this method asks the loader for the template and returns a :class:`Template`. If the `parent` parameter is not `None`, :meth:`join_path` is called to get the real template name before loading.
def get_template(self, name, parent=None, globals=None): """Load a template from the loader. If a loader is configured this method asks the loader for the template and returns a :class:`Template`. If the `parent` parameter is not `None`, :meth:`join_path` is called to get the real templ...
[ "def", "get_template", "(", "self", ",", "name", ",", "parent", "=", "None", ",", "globals", "=", "None", ")", ":", "if", "isinstance", "(", "name", ",", "Template", ")", ":", "return", "name", "if", "parent", "is", "not", "None", ":", "name", "=", ...
[ 809, 4 ]
[ 829, 68 ]
python
en
['en', 'en', 'en']
True
Environment.select_template
(self, names, parent=None, globals=None)
Works like :meth:`get_template` but tries a number of templates before it fails. If it cannot find any of the templates, it will raise a :exc:`TemplatesNotFound` exception. .. versionadded:: 2.3 .. versionchanged:: 2.4 If `names` contains a :class:`Template` object it is re...
Works like :meth:`get_template` but tries a number of templates before it fails. If it cannot find any of the templates, it will raise a :exc:`TemplatesNotFound` exception.
def select_template(self, names, parent=None, globals=None): """Works like :meth:`get_template` but tries a number of templates before it fails. If it cannot find any of the templates, it will raise a :exc:`TemplatesNotFound` exception. .. versionadded:: 2.3 .. versionchanged:...
[ "def", "select_template", "(", "self", ",", "names", ",", "parent", "=", "None", ",", "globals", "=", "None", ")", ":", "if", "not", "names", ":", "raise", "TemplatesNotFound", "(", "message", "=", "u'Tried to select from an empty list '", "u'of templates.'", ")...
[ 832, 4 ]
[ 856, 38 ]
python
en
['en', 'en', 'en']
True
Environment.get_or_select_template
(self, template_name_or_list, parent=None, globals=None)
Does a typecheck and dispatches to :meth:`select_template` if an iterable of template names is given, otherwise to :meth:`get_template`. .. versionadded:: 2.3
Does a typecheck and dispatches to :meth:`select_template` if an iterable of template names is given, otherwise to :meth:`get_template`.
def get_or_select_template(self, template_name_or_list, parent=None, globals=None): """Does a typecheck and dispatches to :meth:`select_template` if an iterable of template names is given, otherwise to :meth:`get_template`. .. versionadded:: 2.3 ""...
[ "def", "get_or_select_template", "(", "self", ",", "template_name_or_list", ",", "parent", "=", "None", ",", "globals", "=", "None", ")", ":", "if", "isinstance", "(", "template_name_or_list", ",", "string_types", ")", ":", "return", "self", ".", "get_template",...
[ 859, 4 ]
[ 871, 75 ]
python
en
['en', 'en', 'en']
True
Environment.from_string
(self, source, globals=None, template_class=None)
Load a template from a string. This parses the source given and returns a :class:`Template` object.
Load a template from a string. This parses the source given and returns a :class:`Template` object.
def from_string(self, source, globals=None, template_class=None): """Load a template from a string. This parses the source given and returns a :class:`Template` object. """ globals = self.make_globals(globals) cls = template_class or self.template_class return cls.from_c...
[ "def", "from_string", "(", "self", ",", "source", ",", "globals", "=", "None", ",", "template_class", "=", "None", ")", ":", "globals", "=", "self", ".", "make_globals", "(", "globals", ")", "cls", "=", "template_class", "or", "self", ".", "template_class"...
[ 873, 4 ]
[ 879, 71 ]
python
en
['en', 'en', 'en']
True
Environment.make_globals
(self, d)
Return a dict for the globals.
Return a dict for the globals.
def make_globals(self, d): """Return a dict for the globals.""" if not d: return self.globals return dict(self.globals, **d)
[ "def", "make_globals", "(", "self", ",", "d", ")", ":", "if", "not", "d", ":", "return", "self", ".", "globals", "return", "dict", "(", "self", ".", "globals", ",", "*", "*", "d", ")" ]
[ 881, 4 ]
[ 885, 38 ]
python
en
['en', 'en', 'en']
True
Template.from_code
(cls, environment, code, globals, uptodate=None)
Creates a template object from compiled code and the globals. This is used by the loaders and environment to create a template object.
Creates a template object from compiled code and the globals. This is used by the loaders and environment to create a template object.
def from_code(cls, environment, code, globals, uptodate=None): """Creates a template object from compiled code and the globals. This is used by the loaders and environment to create a template object. """ namespace = { 'environment': environment, '__file__': ...
[ "def", "from_code", "(", "cls", ",", "environment", ",", "code", ",", "globals", ",", "uptodate", "=", "None", ")", ":", "namespace", "=", "{", "'environment'", ":", "environment", ",", "'__file__'", ":", "code", ".", "co_filename", "}", "exec", "(", "co...
[ 947, 4 ]
[ 958, 17 ]
python
en
['en', 'en', 'en']
True
Template.from_module_dict
(cls, environment, module_dict, globals)
Creates a template object from a module. This is used by the module loader to create a template object. .. versionadded:: 2.4
Creates a template object from a module. This is used by the module loader to create a template object.
def from_module_dict(cls, environment, module_dict, globals): """Creates a template object from a module. This is used by the module loader to create a template object. .. versionadded:: 2.4 """ return cls._from_namespace(environment, module_dict, globals)
[ "def", "from_module_dict", "(", "cls", ",", "environment", ",", "module_dict", ",", "globals", ")", ":", "return", "cls", ".", "_from_namespace", "(", "environment", ",", "module_dict", ",", "globals", ")" ]
[ 961, 4 ]
[ 967, 69 ]
python
en
['en', 'en', 'en']
True
Template.render
(self, *args, **kwargs)
This method accepts the same arguments as the `dict` constructor: A dict, a dict subclass or some keyword arguments. If no arguments are given the context will be empty. These two calls do the same:: template.render(knights='that say nih') template.render({'knights': 'that say...
This method accepts the same arguments as the `dict` constructor: A dict, a dict subclass or some keyword arguments. If no arguments are given the context will be empty. These two calls do the same::
def render(self, *args, **kwargs): """This method accepts the same arguments as the `dict` constructor: A dict, a dict subclass or some keyword arguments. If no arguments are given the context will be empty. These two calls do the same:: template.render(knights='that say nih') ...
[ "def", "render", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "vars", "=", "dict", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "return", "concat", "(", "self", ".", "root_render_func", "(", "self", ".", "new_c...
[ 992, 4 ]
[ 1007, 64 ]
python
en
['en', 'en', 'en']
True
Template.render_async
(self, *args, **kwargs)
This works similar to :meth:`render` but returns a coroutine that when awaited returns the entire rendered template string. This requires the async feature to be enabled. Example usage:: await template.render_async(knights='that say nih; asynchronously')
This works similar to :meth:`render` but returns a coroutine that when awaited returns the entire rendered template string. This requires the async feature to be enabled.
def render_async(self, *args, **kwargs): """This works similar to :meth:`render` but returns a coroutine that when awaited returns the entire rendered template string. This requires the async feature to be enabled. Example usage:: await template.render_async(knights='that ...
[ "def", "render_async", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# see asyncsupport for the actual implementation", "raise", "NotImplementedError", "(", "'This feature is not available for this '", "'version of Python'", ")" ]
[ 1009, 4 ]
[ 1020, 54 ]
python
en
['en', 'en', 'en']
True
Template.stream
(self, *args, **kwargs)
Works exactly like :meth:`generate` but returns a :class:`TemplateStream`.
Works exactly like :meth:`generate` but returns a :class:`TemplateStream`.
def stream(self, *args, **kwargs): """Works exactly like :meth:`generate` but returns a :class:`TemplateStream`. """ return TemplateStream(self.generate(*args, **kwargs))
[ "def", "stream", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "TemplateStream", "(", "self", ".", "generate", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
[ 1022, 4 ]
[ 1026, 61 ]
python
en
['en', 'en', 'en']
True
Template.generate
(self, *args, **kwargs)
For very large templates it can be useful to not render the whole template at once but evaluate each statement after another and yield piece for piece. This method basically does exactly that and returns a generator that yields one item after another as unicode strings. It accepts the ...
For very large templates it can be useful to not render the whole template at once but evaluate each statement after another and yield piece for piece. This method basically does exactly that and returns a generator that yields one item after another as unicode strings.
def generate(self, *args, **kwargs): """For very large templates it can be useful to not render the whole template at once but evaluate each statement after another and yield piece for piece. This method basically does exactly that and returns a generator that yields one item after anot...
[ "def", "generate", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "vars", "=", "dict", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "for", "event", "in", "self", ".", "root_render_func", "(", "self", ".", "new_co...
[ 1028, 4 ]
[ 1044, 63 ]
python
en
['en', 'en', 'en']
True
Template.generate_async
(self, *args, **kwargs)
An async version of :meth:`generate`. Works very similarly but returns an async iterator instead.
An async version of :meth:`generate`. Works very similarly but returns an async iterator instead.
def generate_async(self, *args, **kwargs): """An async version of :meth:`generate`. Works very similarly but returns an async iterator instead. """ # see asyncsupport for the actual implementation raise NotImplementedError('This feature is not available for this ' ...
[ "def", "generate_async", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# see asyncsupport for the actual implementation", "raise", "NotImplementedError", "(", "'This feature is not available for this '", "'version of Python'", ")" ]
[ 1046, 4 ]
[ 1052, 54 ]
python
en
['en', 'en', 'en']
True
Template.new_context
(self, vars=None, shared=False, locals=None)
Create a new :class:`Context` for this template. The vars provided will be passed to the template. Per default the globals are added to the context. If shared is set to `True` the data is passed as it to the context without adding the globals. `locals` can be a dict of local variable...
Create a new :class:`Context` for this template. The vars provided will be passed to the template. Per default the globals are added to the context. If shared is set to `True` the data is passed as it to the context without adding the globals.
def new_context(self, vars=None, shared=False, locals=None): """Create a new :class:`Context` for this template. The vars provided will be passed to the template. Per default the globals are added to the context. If shared is set to `True` the data is passed as it to the context witho...
[ "def", "new_context", "(", "self", ",", "vars", "=", "None", ",", "shared", "=", "False", ",", "locals", "=", "None", ")", ":", "return", "new_context", "(", "self", ".", "environment", ",", "self", ".", "name", ",", "self", ".", "blocks", ",", "vars...
[ 1054, 4 ]
[ 1063, 62 ]
python
en
['en', 'en', 'en']
True
Template.make_module
(self, vars=None, shared=False, locals=None)
This method works like the :attr:`module` attribute when called without arguments but it will evaluate the template on every call rather than caching it. It's also possible to provide a dict which is then used as context. The arguments are the same as for the :meth:`new_context` method...
This method works like the :attr:`module` attribute when called without arguments but it will evaluate the template on every call rather than caching it. It's also possible to provide a dict which is then used as context. The arguments are the same as for the :meth:`new_context` method...
def make_module(self, vars=None, shared=False, locals=None): """This method works like the :attr:`module` attribute when called without arguments but it will evaluate the template on every call rather than caching it. It's also possible to provide a dict which is then used as context. ...
[ "def", "make_module", "(", "self", ",", "vars", "=", "None", ",", "shared", "=", "False", ",", "locals", "=", "None", ")", ":", "return", "TemplateModule", "(", "self", ",", "self", ".", "new_context", "(", "vars", ",", "shared", ",", "locals", ")", ...
[ 1065, 4 ]
[ 1072, 75 ]
python
en
['en', 'en', 'en']
True
Template.make_module_async
(self, vars=None, shared=False, locals=None)
As template module creation can invoke template code for asynchronous exections this method must be used instead of the normal :meth:`make_module` one. Likewise the module attribute becomes unavailable in async mode.
As template module creation can invoke template code for asynchronous exections this method must be used instead of the normal :meth:`make_module` one. Likewise the module attribute becomes unavailable in async mode.
def make_module_async(self, vars=None, shared=False, locals=None): """As template module creation can invoke template code for asynchronous exections this method must be used instead of the normal :meth:`make_module` one. Likewise the module attribute becomes unavailable in async mode. ...
[ "def", "make_module_async", "(", "self", ",", "vars", "=", "None", ",", "shared", "=", "False", ",", "locals", "=", "None", ")", ":", "# see asyncsupport for the actual implementation", "raise", "NotImplementedError", "(", "'This feature is not available for this '", "'...
[ 1074, 4 ]
[ 1082, 54 ]
python
en
['ro', 'en', 'en']
True
Template.module
(self)
The template as module. This is used for imports in the template runtime but is also useful if one wants to access exported template variables from the Python layer: >>> t = Template('{% macro foo() %}42{% endmacro %}23') >>> str(t.module) '23' >>> t.module.foo() == u'4...
The template as module. This is used for imports in the template runtime but is also useful if one wants to access exported template variables from the Python layer:
def module(self): """The template as module. This is used for imports in the template runtime but is also useful if one wants to access exported template variables from the Python layer: >>> t = Template('{% macro foo() %}42{% endmacro %}23') >>> str(t.module) '23' ...
[ "def", "module", "(", "self", ")", ":", "return", "self", ".", "_get_default_module", "(", ")" ]
[ 1092, 4 ]
[ 1105, 41 ]
python
en
['en', 'en', 'en']
True
Template.get_corresponding_lineno
(self, lineno)
Return the source line number of a line number in the generated bytecode as they are not in sync.
Return the source line number of a line number in the generated bytecode as they are not in sync.
def get_corresponding_lineno(self, lineno): """Return the source line number of a line number in the generated bytecode as they are not in sync. """ for template_line, code_line in reversed(self.debug_info): if code_line <= lineno: return template_line ...
[ "def", "get_corresponding_lineno", "(", "self", ",", "lineno", ")", ":", "for", "template_line", ",", "code_line", "in", "reversed", "(", "self", ".", "debug_info", ")", ":", "if", "code_line", "<=", "lineno", ":", "return", "template_line", "return", "1" ]
[ 1107, 4 ]
[ 1114, 16 ]
python
en
['en', 'en', 'en']
True
Template.is_up_to_date
(self)
If this variable is `False` there is a newer version available.
If this variable is `False` there is a newer version available.
def is_up_to_date(self): """If this variable is `False` there is a newer version available.""" if self._uptodate is None: return True return self._uptodate()
[ "def", "is_up_to_date", "(", "self", ")", ":", "if", "self", ".", "_uptodate", "is", "None", ":", "return", "True", "return", "self", ".", "_uptodate", "(", ")" ]
[ 1117, 4 ]
[ 1121, 31 ]
python
en
['en', 'en', 'en']
True
Template.debug_info
(self)
The debug info mapping.
The debug info mapping.
def debug_info(self): """The debug info mapping.""" return [tuple(imap(int, x.split('='))) for x in self._debug_info.split('&')]
[ "def", "debug_info", "(", "self", ")", ":", "return", "[", "tuple", "(", "imap", "(", "int", ",", "x", ".", "split", "(", "'='", ")", ")", ")", "for", "x", "in", "self", ".", "_debug_info", ".", "split", "(", "'&'", ")", "]" ]
[ 1124, 4 ]
[ 1127, 44 ]
python
en
['en', 'en', 'en']
True
Index.clone
(self)
Create a copy of this Index.
Create a copy of this Index.
def clone(self): """Create a copy of this Index.""" _, args, kwargs = self.deconstruct() return self.__class__(*args, **kwargs)
[ "def", "clone", "(", "self", ")", ":", "_", ",", "args", ",", "kwargs", "=", "self", ".", "deconstruct", "(", ")", "return", "self", ".", "__class__", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 136, 4 ]
[ 139, 46 ]
python
en
['en', 'en', 'en']
True
Index.set_name_with_model
(self, model)
Generate a unique name for the index. The name is divided into 3 parts - table name (12 chars), field name (8 chars) and unique hash + suffix (10 chars). Each part is made to fit its size by truncating the excess length.
Generate a unique name for the index.
def set_name_with_model(self, model): """ Generate a unique name for the index. The name is divided into 3 parts - table name (12 chars), field name (8 chars) and unique hash + suffix (10 chars). Each part is made to fit its size by truncating the excess length. """ ...
[ "def", "set_name_with_model", "(", "self", ",", "model", ")", ":", "_", ",", "table_name", "=", "split_identifier", "(", "model", ".", "_meta", ".", "db_table", ")", "column_names", "=", "[", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")",...
[ 141, 4 ]
[ 168, 45 ]
python
en
['en', 'error', 'th']
False
inject_into_urllib3
()
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
def inject_into_urllib3(): """ Monkey-patch urllib3 with SecureTransport-backed SSL-support. """ util.SSLContext = SecureTransportContext util.ssl_.SSLContext = SecureTransportContext util.HAS_SNI = HAS_SNI util.ssl_.HAS_SNI = HAS_SNI util.IS_SECURETRANSPORT = True util.ssl_.IS_SECUR...
[ "def", "inject_into_urllib3", "(", ")", ":", "util", ".", "SSLContext", "=", "SecureTransportContext", "util", ".", "ssl_", ".", "SSLContext", "=", "SecureTransportContext", "util", ".", "HAS_SNI", "=", "HAS_SNI", "util", ".", "ssl_", ".", "HAS_SNI", "=", "HAS...
[ 188, 0 ]
[ 197, 39 ]
python
en
['en', 'error', 'th']
False
extract_from_urllib3
()
Undo monkey-patching by :func:`inject_into_urllib3`.
Undo monkey-patching by :func:`inject_into_urllib3`.
def extract_from_urllib3(): """ Undo monkey-patching by :func:`inject_into_urllib3`. """ util.SSLContext = orig_util_SSLContext util.ssl_.SSLContext = orig_util_SSLContext util.HAS_SNI = orig_util_HAS_SNI util.ssl_.HAS_SNI = orig_util_HAS_SNI util.IS_SECURETRANSPORT = False util.ssl_...
[ "def", "extract_from_urllib3", "(", ")", ":", "util", ".", "SSLContext", "=", "orig_util_SSLContext", "util", ".", "ssl_", ".", "SSLContext", "=", "orig_util_SSLContext", "util", ".", "HAS_SNI", "=", "orig_util_HAS_SNI", "util", ".", "ssl_", ".", "HAS_SNI", "=",...
[ 200, 0 ]
[ 209, 40 ]
python
en
['en', 'error', 'th']
False
_read_callback
(connection_id, data_buffer, data_length_pointer)
SecureTransport read callback. This is called by ST to request that data be returned from the socket.
SecureTransport read callback. This is called by ST to request that data be returned from the socket.
def _read_callback(connection_id, data_buffer, data_length_pointer): """ SecureTransport read callback. This is called by ST to request that data be returned from the socket. """ wrapped_socket = None try: wrapped_socket = _connection_refs.get(connection_id) if wrapped_socket is ...
[ "def", "_read_callback", "(", "connection_id", ",", "data_buffer", ",", "data_length_pointer", ")", ":", "wrapped_socket", "=", "None", "try", ":", "wrapped_socket", "=", "_connection_refs", ".", "get", "(", "connection_id", ")", "if", "wrapped_socket", "is", "Non...
[ 212, 0 ]
[ 264, 43 ]
python
en
['en', 'error', 'th']
False
_write_callback
(connection_id, data_buffer, data_length_pointer)
SecureTransport write callback. This is called by ST to request that data actually be sent on the network.
SecureTransport write callback. This is called by ST to request that data actually be sent on the network.
def _write_callback(connection_id, data_buffer, data_length_pointer): """ SecureTransport write callback. This is called by ST to request that data actually be sent on the network. """ wrapped_socket = None try: wrapped_socket = _connection_refs.get(connection_id) if wrapped_sock...
[ "def", "_write_callback", "(", "connection_id", ",", "data_buffer", ",", "data_length_pointer", ")", ":", "wrapped_socket", "=", "None", "try", ":", "wrapped_socket", "=", "_connection_refs", ".", "get", "(", "connection_id", ")", "if", "wrapped_socket", "is", "No...
[ 267, 0 ]
[ 315, 43 ]
python
en
['en', 'error', 'th']
False
WrappedSocket._raise_on_error
(self)
A context manager that can be used to wrap calls that do I/O from SecureTransport. If any of the I/O callbacks hit an exception, this context manager will correctly propagate the exception after the fact. This avoids silently swallowing those exceptions. It also correctly force...
A context manager that can be used to wrap calls that do I/O from SecureTransport. If any of the I/O callbacks hit an exception, this context manager will correctly propagate the exception after the fact. This avoids silently swallowing those exceptions.
def _raise_on_error(self): """ A context manager that can be used to wrap calls that do I/O from SecureTransport. If any of the I/O callbacks hit an exception, this context manager will correctly propagate the exception after the fact. This avoids silently swallowing those except...
[ "def", "_raise_on_error", "(", "self", ")", ":", "self", ".", "_exception", "=", "None", "# We explicitly don't catch around this yield because in the unlikely", "# event that an exception was hit in the block we don't want to swallow", "# it.", "yield", "if", "self", ".", "_exce...
[ 352, 4 ]
[ 370, 27 ]
python
en
['en', 'error', 'th']
False
WrappedSocket._set_ciphers
(self)
Sets up the allowed ciphers. By default this matches the set in util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done custom and doesn't allow changing at this time, mostly because parsing OpenSSL cipher strings is going to be a freaking nightmare.
Sets up the allowed ciphers. By default this matches the set in util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done custom and doesn't allow changing at this time, mostly because parsing OpenSSL cipher strings is going to be a freaking nightmare.
def _set_ciphers(self): """ Sets up the allowed ciphers. By default this matches the set in util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done custom and doesn't allow changing at this time, mostly because parsing OpenSSL cipher strings is going to be a freak...
[ "def", "_set_ciphers", "(", "self", ")", ":", "ciphers", "=", "(", "Security", ".", "SSLCipherSuite", "*", "len", "(", "CIPHER_SUITES", ")", ")", "(", "*", "CIPHER_SUITES", ")", "result", "=", "Security", ".", "SSLSetEnabledCiphers", "(", "self", ".", "con...
[ 372, 4 ]
[ 383, 32 ]
python
en
['en', 'error', 'th']
False
WrappedSocket._set_alpn_protocols
(self, protocols)
Sets up the ALPN protocols on the context.
Sets up the ALPN protocols on the context.
def _set_alpn_protocols(self, protocols): """ Sets up the ALPN protocols on the context. """ if not protocols: return protocols_arr = _create_cfstring_array(protocols) try: result = Security.SSLSetALPNProtocols(self.context, protocols_arr) ...
[ "def", "_set_alpn_protocols", "(", "self", ",", "protocols", ")", ":", "if", "not", "protocols", ":", "return", "protocols_arr", "=", "_create_cfstring_array", "(", "protocols", ")", "try", ":", "result", "=", "Security", ".", "SSLSetALPNProtocols", "(", "self",...
[ 385, 4 ]
[ 396, 51 ]
python
en
['en', 'error', 'th']
False
WrappedSocket._custom_validate
(self, verify, trust_bundle)
Called when we have set custom validation. We do this in two cases: first, when cert validation is entirely disabled; and second, when using a custom trust DB. Raises an SSLError if the connection is not trusted.
Called when we have set custom validation. We do this in two cases: first, when cert validation is entirely disabled; and second, when using a custom trust DB. Raises an SSLError if the connection is not trusted.
def _custom_validate(self, verify, trust_bundle): """ Called when we have set custom validation. We do this in two cases: first, when cert validation is entirely disabled; and second, when using a custom trust DB. Raises an SSLError if the connection is not trusted. """ ...
[ "def", "_custom_validate", "(", "self", ",", "verify", ",", "trust_bundle", ")", ":", "# If we disabled cert validation, just say: cool.", "if", "not", "verify", ":", "return", "successes", "=", "(", "SecurityConst", ".", "kSecTrustResultUnspecified", ",", "SecurityCons...
[ 398, 4 ]
[ 431, 68 ]
python
en
['en', 'error', 'th']
False
WrappedSocket.handshake
( self, server_hostname, verify, trust_bundle, min_version, max_version, client_cert, client_key, client_key_passphrase, alpn_protocols, )
Actually performs the TLS handshake. This is run automatically by wrapped socket, and shouldn't be needed in user code.
Actually performs the TLS handshake. This is run automatically by wrapped socket, and shouldn't be needed in user code.
def handshake( self, server_hostname, verify, trust_bundle, min_version, max_version, client_cert, client_key, client_key_passphrase, alpn_protocols, ): """ Actually performs the TLS handshake. This is run automatically ...
[ "def", "handshake", "(", "self", ",", "server_hostname", ",", "verify", ",", "trust_bundle", ",", "min_version", ",", "max_version", ",", "client_cert", ",", "client_key", ",", "client_key_passphrase", ",", "alpn_protocols", ",", ")", ":", "# First, we do the initia...
[ 473, 4 ]
[ 564, 25 ]
python
en
['en', 'error', 'th']
False
SecureTransportContext.check_hostname
(self)
SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file.
SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file.
def check_hostname(self): """ SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file. """ return True
[ "def", "check_hostname", "(", "self", ")", ":", "return", "True" ]
[ 803, 4 ]
[ 808, 19 ]
python
en
['en', 'error', 'th']
False
SecureTransportContext.check_hostname
(self, value)
SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file.
SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file.
def check_hostname(self, value): """ SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file. """ pass
[ "def", "check_hostname", "(", "self", ",", "value", ")", ":", "pass" ]
[ 811, 4 ]
[ 816, 12 ]
python
en
['en', 'error', 'th']
False
SecureTransportContext.set_alpn_protocols
(self, protocols)
Sets the ALPN protocols that will later be set on the context. Raises a NotImplementedError if ALPN is not supported.
Sets the ALPN protocols that will later be set on the context.
def set_alpn_protocols(self, protocols): """ Sets the ALPN protocols that will later be set on the context. Raises a NotImplementedError if ALPN is not supported. """ if not hasattr(Security, "SSLSetALPNProtocols"): raise NotImplementedError( "SecureT...
[ "def", "set_alpn_protocols", "(", "self", ",", "protocols", ")", ":", "if", "not", "hasattr", "(", "Security", ",", "\"SSLSetALPNProtocols\"", ")", ":", "raise", "NotImplementedError", "(", "\"SecureTransport supports ALPN only in macOS 10.12+\"", ")", "self", ".", "_...
[ 878, 4 ]
[ 888, 72 ]
python
en
['en', 'error', 'th']
False
i16le
(c, o=0)
Converts a 2-bytes (16 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 2-bytes (16 bits) string to an unsigned integer.
def i16le(c, o=0): """ Converts a 2-bytes (16 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<H", c, o)[0]
[ "def", "i16le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<H\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 29, 0 ]
[ 36, 37 ]
python
en
['en', 'error', 'th']
False
si16le
(c, o=0)
Converts a 2-bytes (16 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 2-bytes (16 bits) string to a signed integer.
def si16le(c, o=0): """ Converts a 2-bytes (16 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<h", c, o)[0]
[ "def", "si16le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<h\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 39, 0 ]
[ 46, 37 ]
python
en
['en', 'error', 'th']
False
i32le
(c, o=0)
Converts a 4-bytes (32 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 4-bytes (32 bits) string to an unsigned integer.
def i32le(c, o=0): """ Converts a 4-bytes (32 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<I", c, o)[0]
[ "def", "i32le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<I\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 49, 0 ]
[ 56, 37 ]
python
en
['en', 'error', 'th']
False
si32le
(c, o=0)
Converts a 4-bytes (32 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 4-bytes (32 bits) string to a signed integer.
def si32le(c, o=0): """ Converts a 4-bytes (32 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<i", c, o)[0]
[ "def", "si32le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<i\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 59, 0 ]
[ 66, 37 ]
python
en
['en', 'error', 'th']
False
anomaly_detection
(features, labels, mode, params)
Custom Estimator model function for anomaly detection. Given dictionary of feature tensors, labels tensor, Estimator mode, and dictionary for parameters, return EstimatorSpec object for custom Estimator. Args: features: Dictionary of feature tensors. labels: Labels tensor or None. mode: Estimator Mo...
Custom Estimator model function for anomaly detection.
def anomaly_detection(features, labels, mode, params): """Custom Estimator model function for anomaly detection. Given dictionary of feature tensors, labels tensor, Estimator mode, and dictionary for parameters, return EstimatorSpec object for custom Estimator. Args: features: Dictionary of feature tensor...
[ "def", "anomaly_detection", "(", "features", ",", "labels", ",", "mode", ",", "params", ")", ":", "print", "(", "\"\\nanomaly_detection: features = \\n{}\"", ".", "format", "(", "features", ")", ")", "print", "(", "\"anomaly_detection: labels = \\n{}\"", ".", "forma...
[ 19, 0 ]
[ 283, 36 ]
python
en
['es', 'no', 'en']
False
BprMF.__init__
(self, train_file=None, test_file=None, output_file=None, factors=10, learn_rate=0.05, epochs=30, batch_size=0, rank_length=10, init_mean=0, init_stdev=0.1, reg_u=0.0025, reg_i=0.0025, reg_j=0.00025, reg_bias=0, sep='\t', output_sep='\t', random_seed=None, items_test=False)
BPRMF for Item Recommendation BPR reduces ranking to pairwise classification. The different variants (settings) of this recommender roughly optimize the area under the ROC curve (AUC). Usage:: >> BprMF(train, test).compute() >> BprMF(train, test, batch_size=...
BPRMF for Item Recommendation
def __init__(self, train_file=None, test_file=None, output_file=None, factors=10, learn_rate=0.05, epochs=30, batch_size=0, rank_length=10, init_mean=0, init_stdev=0.1, reg_u=0.0025, reg_i=0.0025, reg_j=0.00025, reg_bias=0, sep='\t', output_sep='\t', random_seed=None, items_test=False)...
[ "def", "__init__", "(", "self", ",", "train_file", "=", "None", ",", "test_file", "=", "None", ",", "output_file", "=", "None", ",", "factors", "=", "10", ",", "learn_rate", "=", "0.05", ",", "epochs", "=", "30", ",", "batch_size", "=", "0", ",", "ra...
[ 25, 4 ]
[ 123, 36 ]
python
en
['en', 'error', 'th']
False
BprMF.init_model
(self)
Method to treat and initialize the model
Method to treat and initialize the model
def init_model(self): """ Method to treat and initialize the model """ # Upgrade unobserved items with test set samples if self.items_test: for u, user in enumerate(self.users): self.train_set['items_unobserved'][user] = list(set(self.items) - ...
[ "def", "init_model", "(", "self", ")", ":", "# Upgrade unobserved items with test set samples", "if", "self", ".", "items_test", ":", "for", "u", ",", "user", "in", "enumerate", "(", "self", ".", "users", ")", ":", "self", ".", "train_set", "[", "'items_unobse...
[ 125, 4 ]
[ 144, 100 ]
python
en
['en', 'error', 'th']
False
BprMF.fit
(self)
This method performs iterations of stochastic gradient ascent over the training data. One iteration is samples number of positive entries in the training matrix times, if batch size is 0, else we divide the number of positive entries per batch size (see in the init_model).
This method performs iterations of stochastic gradient ascent over the training data. One iteration is samples number of positive entries in the training matrix times, if batch size is 0, else we divide the number of positive entries per batch size (see in the init_model).
def fit(self): """ This method performs iterations of stochastic gradient ascent over the training data. One iteration is samples number of positive entries in the training matrix times, if batch size is 0, else we divide the number of positive entries per batch size (see in the init_mod...
[ "def", "fit", "(", "self", ")", ":", "for", "n", "in", "range", "(", "self", ".", "epochs", ")", ":", "random_users", "=", "random", ".", "choices", "(", "self", ".", "train_set", "[", "'users'", "]", ",", "k", "=", "self", ".", "num_interactions", ...
[ 146, 4 ]
[ 158, 113 ]
python
en
['en', 'error', 'th']
False
BprMF.create_factors
(self)
This method create factors for users, items and bias
This method create factors for users, items and bias
def create_factors(self): """ This method create factors for users, items and bias """ self.p = np.random.normal(self.init_mean, self.init_stdev, (len(self.users), self.factors)) self.q = np.random.normal(self.init_mean, self.init_stdev, (len(self.items), self.factors)) ...
[ "def", "create_factors", "(", "self", ")", ":", "self", ".", "p", "=", "np", ".", "random", ".", "normal", "(", "self", ".", "init_mean", ",", "self", ".", "init_stdev", ",", "(", "len", "(", "self", ".", "users", ")", ",", "self", ".", "factors", ...
[ 160, 4 ]
[ 168, 56 ]
python
en
['en', 'error', 'th']
False
BprMF.sample_pair
(self, user)
Randomly selects a known and unknown item to a particular user. :param user: User to generate pairs :type user: int :return: known item, unknown item
Randomly selects a known and unknown item to a particular user.
def sample_pair(self, user): """ Randomly selects a known and unknown item to a particular user. :param user: User to generate pairs :type user: int :return: known item, unknown item """ return random.choice(list(self.train_set['items_seen_by_user'][user])), ra...
[ "def", "sample_pair", "(", "self", ",", "user", ")", ":", "return", "random", ".", "choice", "(", "list", "(", "self", ".", "train_set", "[", "'items_seen_by_user'", "]", "[", "user", "]", ")", ")", ",", "random", ".", "choice", "(", "self", ".", "tr...
[ 170, 4 ]
[ 181, 53 ]
python
en
['en', 'error', 'th']
False
BprMF.predict_score
(self, user, item)
Method to predict a single score for a pair (user, item) :param user: User ID :type user: int :param item: Item ID :type item: int :return: Score generate for pair (user, item) :rtype: float
Method to predict a single score for a pair (user, item)
def predict_score(self, user, item): """ Method to predict a single score for a pair (user, item) :param user: User ID :type user: int :param item: Item ID :type item: int :return: Score generate for pair (user, item) :rtype: float """ ...
[ "def", "predict_score", "(", "self", ",", "user", ",", "item", ")", ":", "return", "np", ".", "dot", "(", "self", ".", "p", "[", "user", "]", ",", "self", ".", "q", "[", "item", "]", ")" ]
[ 183, 4 ]
[ 198, 49 ]
python
en
['en', 'error', 'th']
False
BprMF.update_factors
(self, u, i, j)
Update latent factors according to the stochastic gradient descent update rule :param u: User ID for update :type u: int :param i: Known Item ID :type i: int :param j: Unknown Item ID :type j: int
Update latent factors according to the stochastic gradient descent update rule
def update_factors(self, u, i, j): """ Update latent factors according to the stochastic gradient descent update rule :param u: User ID for update :type u: int :param i: Known Item ID :type i: int :param j: Unknown Item ID :type j: int """ ...
[ "def", "update_factors", "(", "self", ",", "u", ",", "i", ",", "j", ")", ":", "# Compute Difference", "x_uij", "=", "self", ".", "bias", "[", "i", "]", "-", "self", ".", "bias", "[", "j", "]", "+", "(", "self", ".", "predict_score", "(", "u", ","...
[ 200, 4 ]
[ 229, 70 ]
python
en
['en', 'error', 'th']
False
BprMF.predict
(self)
This method predict final result, building an rank of each user of the train set.
This method predict final result, building an rank of each user of the train set.
def predict(self): """ This method predict final result, building an rank of each user of the train set. """ w = self.bias.T + np.dot(self.p, self.q.T) for u, user in enumerate(self.users): partial_ranking = list() candidate_items = sorted(range(len(w[u...
[ "def", "predict", "(", "self", ")", ":", "w", "=", "self", ".", "bias", ".", "T", "+", "np", ".", "dot", "(", "self", ".", "p", ",", "self", ".", "q", ".", "T", ")", "for", "u", ",", "user", "in", "enumerate", "(", "self", ".", "users", ")"...
[ 231, 4 ]
[ 252, 43 ]
python
en
['en', 'error', 'th']
False
BprMF.compute
(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t')
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default True :param metrics: List of evaluation measures :type metrics: list, default None :param ve...
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm
def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t'): """ Extends compute method from BaseItemRecommendation. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default Tru...
[ "def", "compute", "(", "self", ",", "verbose", "=", "True", ",", "metrics", "=", "None", ",", "verbose_evaluation", "=", "True", ",", "as_table", "=", "False", ",", "table_sep", "=", "'\\t'", ")", ":", "super", "(", "BprMF", ",", "self", ")", ".", "c...
[ 254, 4 ]
[ 296, 94 ]
python
en
['en', 'error', 'th']
False
BaseReporter.starting
(self)
Called before the resolution actually starts.
Called before the resolution actually starts.
def starting(self): """Called before the resolution actually starts."""
[ "def", "starting", "(", "self", ")", ":" ]
[ 3, 4 ]
[ 4, 59 ]
python
en
['en', 'en', 'en']
True
BaseReporter.starting_round
(self, index)
Called before each round of resolution starts. The index is zero-based.
Called before each round of resolution starts.
def starting_round(self, index): """Called before each round of resolution starts. The index is zero-based. """
[ "def", "starting_round", "(", "self", ",", "index", ")", ":" ]
[ 6, 4 ]
[ 10, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.ending_round
(self, index, state)
Called before each round of resolution ends. This is NOT called if the resolution ends at this round. Use `ending` if you want to report finalization. The index is zero-based.
Called before each round of resolution ends.
def ending_round(self, index, state): """Called before each round of resolution ends. This is NOT called if the resolution ends at this round. Use `ending` if you want to report finalization. The index is zero-based. """
[ "def", "ending_round", "(", "self", ",", "index", ",", "state", ")", ":" ]
[ 12, 4 ]
[ 17, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.ending
(self, state)
Called before the resolution ends successfully.
Called before the resolution ends successfully.
def ending(self, state): """Called before the resolution ends successfully."""
[ "def", "ending", "(", "self", ",", "state", ")", ":" ]
[ 19, 4 ]
[ 20, 61 ]
python
en
['en', 'en', 'en']
True
BaseReporter.adding_requirement
(self, requirement, parent)
Called when adding a new requirement into the resolve criteria. :param requirement: The additional requirement to be applied to filter the available candidaites. :param parent: The candidate that requires ``requirement`` as a dependency, or None if ``requirement`` is one of the ...
Called when adding a new requirement into the resolve criteria.
def adding_requirement(self, requirement, parent): """Called when adding a new requirement into the resolve criteria. :param requirement: The additional requirement to be applied to filter the available candidaites. :param parent: The candidate that requires ``requirement`` as a ...
[ "def", "adding_requirement", "(", "self", ",", "requirement", ",", "parent", ")", ":" ]
[ 22, 4 ]
[ 30, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.backtracking
(self, candidate)
Called when rejecting a candidate during backtracking.
Called when rejecting a candidate during backtracking.
def backtracking(self, candidate): """Called when rejecting a candidate during backtracking."""
[ "def", "backtracking", "(", "self", ",", "candidate", ")", ":" ]
[ 32, 4 ]
[ 33, 68 ]
python
en
['en', 'en', 'en']
True
BaseReporter.pinning
(self, candidate)
Called when adding a candidate to the potential solution.
Called when adding a candidate to the potential solution.
def pinning(self, candidate): """Called when adding a candidate to the potential solution."""
[ "def", "pinning", "(", "self", ",", "candidate", ")", ":" ]
[ 35, 4 ]
[ 36, 71 ]
python
en
['en', 'en', 'en']
True
Clawler.save_img
(self, rtn_folpath=False)
フォルダを作成し画像を収集する :return: 作成したフォルダの相対パス
フォルダを作成し画像を収集する :return: 作成したフォルダの相対パス
def save_img(self, rtn_folpath=False): """ フォルダを作成し画像を収集する :return: 作成したフォルダの相対パス """ if self.urls: super().save_img(self.urls) rtn = self.made_imgdir if rtn_folpath else None return rtn else: raise ex.CrawlingError
[ "def", "save_img", "(", "self", ",", "rtn_folpath", "=", "False", ")", ":", "if", "self", ".", "urls", ":", "super", "(", ")", ".", "save_img", "(", "self", ".", "urls", ")", "rtn", "=", "self", ".", "made_imgdir", "if", "rtn_folpath", "else", "None"...
[ 23, 4 ]
[ 33, 34 ]
python
en
['en', 'error', 'th']
False
Clawler.delete_datas_dir
(self)
data/img配下を全削除 :return: なし
data/img配下を全削除 :return: なし
def delete_datas_dir(self): """ data/img配下を全削除 :return: なし """ data_path = os.path.join('/'.join(inspect.stack()[0][1].split('/')[:-2]), 'data', 'img') if os.path.exists(data_path): shutil.rmtree(data_path) os.makedirs(data_path, exist_ok=True) ...
[ "def", "delete_datas_dir", "(", "self", ")", ":", "data_path", "=", "os", ".", "path", ".", "join", "(", "'/'", ".", "join", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "1", "]", ".", "split", "(", "'/'", ")", "[", ":", "-", "...
[ 35, 4 ]
[ 44, 38 ]
python
en
['en', 'error', 'th']
False
Clawler.write_crawl_stat
(self, del_mode=False)
直近のクロール枚数を保持してファイルに書き込む del_mode(bool) Trueでログリフレッシュ :return: なし
直近のクロール枚数を保持してファイルに書き込む del_mode(bool) Trueでログリフレッシュ :return: なし
def write_crawl_stat(self, del_mode=False): """ 直近のクロール枚数を保持してファイルに書き込む del_mode(bool) Trueでログリフレッシュ :return: なし """ here = os.path.join('/'.join(inspect.stack()[0][1].split('/')[:-1])) crawler_logs_path = os.path.join(here, '.crawler_logs') mode =...
[ "def", "write_crawl_stat", "(", "self", ",", "del_mode", "=", "False", ")", ":", "here", "=", "os", ".", "path", ".", "join", "(", "'/'", ".", "join", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "1", "]", ".", "split", "(", "'/'...
[ 46, 4 ]
[ 58, 46 ]
python
en
['en', 'error', 'th']
False
Clawler.read_crawl_stat
(self, target)
write_crawl_statで書き込まれたログを読み込む :return: クロール枚数(int)
write_crawl_statで書き込まれたログを読み込む :return: クロール枚数(int)
def read_crawl_stat(self, target): """ write_crawl_statで書き込まれたログを読み込む :return: クロール枚数(int) """ import re here = os.path.join('/'.join(inspect.stack()[0][1].split('/')[:-1])) crawler_logs_path = os.path.join(here, '.crawler_logs') with open(crawler_logs_pat...
[ "def", "read_crawl_stat", "(", "self", ",", "target", ")", ":", "import", "re", "here", "=", "os", ".", "path", ".", "join", "(", "'/'", ".", "join", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "1", "]", ".", "split", "(", "'/'"...
[ 60, 4 ]
[ 71, 18 ]
python
en
['en', 'error', 'th']
False
get
(http, path, root=METADATA_ROOT, recursive=None)
Fetch a resource from the metadata server. Args: http: an object to be used to make HTTP requests. path: A string indicating the resource to retrieve. For example, 'instance/service-accounts/default' root: A string indicating the full path to the metadata server root. re...
Fetch a resource from the metadata server.
def get(http, path, root=METADATA_ROOT, recursive=None): """Fetch a resource from the metadata server. Args: http: an object to be used to make HTTP requests. path: A string indicating the resource to retrieve. For example, 'instance/service-accounts/default' root: A string ...
[ "def", "get", "(", "http", ",", "path", ",", "root", "=", "METADATA_ROOT", ",", "recursive", "=", "None", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "root", ",", "path", ")", "url", "=", "_helpers", ".", "_add_query_parameter", "(", "url", ...
[ 36, 0 ]
[ 70, 69 ]
python
en
['en', 'en', 'en']
True
get_service_account_info
(http, service_account='default')
Get information about a service account from the metadata server. Args: http: an object to be used to make HTTP requests. service_account: An email specifying the service account for which to look up information. Default will be information for the "default" service account ...
Get information about a service account from the metadata server.
def get_service_account_info(http, service_account='default'): """Get information about a service account from the metadata server. Args: http: an object to be used to make HTTP requests. service_account: An email specifying the service account for which to look up information. Defa...
[ "def", "get_service_account_info", "(", "http", ",", "service_account", "=", "'default'", ")", ":", "return", "get", "(", "http", ",", "'instance/service-accounts/{0}/'", ".", "format", "(", "service_account", ")", ",", "recursive", "=", "True", ")" ]
[ 73, 0 ]
[ 95, 23 ]
python
en
['en', 'en', 'en']
True
get_token
(http, service_account='default')
Fetch an oauth token for the Args: http: an object to be used to make HTTP requests. service_account: An email specifying the service account this token should represent. Default will be a token for the "default" service account of the current compute engine instance. R...
Fetch an oauth token for the
def get_token(http, service_account='default'): """Fetch an oauth token for the Args: http: an object to be used to make HTTP requests. service_account: An email specifying the service account this token should represent. Default will be a token for the "default" service ...
[ "def", "get_token", "(", "http", ",", "service_account", "=", "'default'", ")", ":", "token_json", "=", "get", "(", "http", ",", "'instance/service-accounts/{0}/token'", ".", "format", "(", "service_account", ")", ")", "token_expiry", "=", "client", ".", "_UTCNO...
[ 98, 0 ]
[ 117, 51 ]
python
en
['en', 'en', 'en']
True
url_parse
(url, scheme=None, allow_fragments=True)
Parses a URL from a string into a :class:`URL` tuple. If the URL is lacking a scheme it can be provided as second argument. Otherwise, it is ignored. Optionally fragments can be stripped from the URL by setting `allow_fragments` to `False`. The inverse of this function is :func:`url_unparse`. :p...
Parses a URL from a string into a :class:`URL` tuple. If the URL is lacking a scheme it can be provided as second argument. Otherwise, it is ignored. Optionally fragments can be stripped from the URL by setting `allow_fragments` to `False`.
def url_parse(url, scheme=None, allow_fragments=True): """Parses a URL from a string into a :class:`URL` tuple. If the URL is lacking a scheme it can be provided as second argument. Otherwise, it is ignored. Optionally fragments can be stripped from the URL by setting `allow_fragments` to `False`. ...
[ "def", "url_parse", "(", "url", ",", "scheme", "=", "None", ",", "allow_fragments", "=", "True", ")", ":", "s", "=", "make_literal_wrapper", "(", "url", ")", "is_text_based", "=", "isinstance", "(", "url", ",", "text_type", ")", "if", "scheme", "is", "No...
[ 437, 0 ]
[ 483, 60 ]
python
en
['en', 'en', 'en']
True
_make_fast_url_quote
(charset="utf-8", errors="strict", safe="/:", unsafe="")
Precompile the translation table for a URL encoding function. Unlike :func:`url_quote`, the generated function only takes the string to quote. :param charset: The charset to encode the result with. :param errors: How to handle encoding errors. :param safe: An optional sequence of safe characters t...
Precompile the translation table for a URL encoding function.
def _make_fast_url_quote(charset="utf-8", errors="strict", safe="/:", unsafe=""): """Precompile the translation table for a URL encoding function. Unlike :func:`url_quote`, the generated function only takes the string to quote. :param charset: The charset to encode the result with. :param errors: ...
[ "def", "_make_fast_url_quote", "(", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ",", "safe", "=", "\"/:\"", ",", "unsafe", "=", "\"\"", ")", ":", "if", "isinstance", "(", "safe", ",", "text_type", ")", ":", "safe", "=", "safe", ".", ...
[ 486, 0 ]
[ 516, 16 ]
python
en
['en', 'en', 'en']
True
url_quote
(string, charset="utf-8", errors="strict", safe="/:", unsafe="")
URL encode a single string with a given encoding. :param s: the string to quote. :param charset: the charset to be used. :param safe: an optional sequence of safe characters. :param unsafe: an optional sequence of unsafe characters. .. versionadded:: 0.9.2 The `unsafe` parameter was added. ...
URL encode a single string with a given encoding.
def url_quote(string, charset="utf-8", errors="strict", safe="/:", unsafe=""): """URL encode a single string with a given encoding. :param s: the string to quote. :param charset: the charset to be used. :param safe: an optional sequence of safe characters. :param unsafe: an optional sequence of uns...
[ "def", "url_quote", "(", "string", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ",", "safe", "=", "\"/:\"", ",", "unsafe", "=", "\"\"", ")", ":", "if", "not", "isinstance", "(", "string", ",", "(", "text_type", ",", "bytes", ",",...
[ 527, 0 ]
[ 553, 31 ]
python
en
['en', 'en', 'en']
True
url_quote_plus
(string, charset="utf-8", errors="strict", safe="")
URL encode a single string with the given encoding and convert whitespace to "+". :param s: The string to quote. :param charset: The charset to be used. :param safe: An optional sequence of safe characters.
URL encode a single string with the given encoding and convert whitespace to "+".
def url_quote_plus(string, charset="utf-8", errors="strict", safe=""): """URL encode a single string with the given encoding and convert whitespace to "+". :param s: The string to quote. :param charset: The charset to be used. :param safe: An optional sequence of safe characters. """ return...
[ "def", "url_quote_plus", "(", "string", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ",", "safe", "=", "\"\"", ")", ":", "return", "url_quote", "(", "string", ",", "charset", ",", "errors", ",", "safe", "+", "\" \"", ",", "\"+\"", ...
[ 556, 0 ]
[ 564, 80 ]
python
en
['en', 'en', 'en']
True
url_unparse
(components)
The reverse operation to :meth:`url_parse`. This accepts arbitrary as well as :class:`URL` tuples and returns a URL as a string. :param components: the parsed URL as tuple which should be converted into a URL string.
The reverse operation to :meth:`url_parse`. This accepts arbitrary as well as :class:`URL` tuples and returns a URL as a string.
def url_unparse(components): """The reverse operation to :meth:`url_parse`. This accepts arbitrary as well as :class:`URL` tuples and returns a URL as a string. :param components: the parsed URL as tuple which should be converted into a URL string. """ scheme, netloc, path, ...
[ "def", "url_unparse", "(", "components", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "normalize_string_tuple", "(", "components", ")", "s", "=", "make_literal_wrapper", "(", "scheme", ")", "url", "=", "s", "(", "\"\"...
[ 567, 0 ]
[ 594, 14 ]
python
en
['en', 'en', 'en']
True
url_unquote
(string, charset="utf-8", errors="replace", unsafe="")
URL decode a single string with a given encoding. If the charset is set to `None` no unicode decoding is performed and raw bytes are returned. :param s: the string to unquote. :param charset: the charset of the query string. If set to `None` no unicode decoding will take place. ...
URL decode a single string with a given encoding. If the charset is set to `None` no unicode decoding is performed and raw bytes are returned.
def url_unquote(string, charset="utf-8", errors="replace", unsafe=""): """URL decode a single string with a given encoding. If the charset is set to `None` no unicode decoding is performed and raw bytes are returned. :param s: the string to unquote. :param charset: the charset of the query string....
[ "def", "url_unquote", "(", "string", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"replace\"", ",", "unsafe", "=", "\"\"", ")", ":", "rv", "=", "_unquote_to_bytes", "(", "string", ",", "unsafe", ")", "if", "charset", "is", "not", "None", ":", ...
[ 597, 0 ]
[ 610, 13 ]
python
en
['en', 'en', 'en']
True
url_unquote_plus
(s, charset="utf-8", errors="replace")
URL decode a single string with the given `charset` and decode "+" to whitespace. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a :exc:`HTTPUnicodeError` is raised. :param s: The string to unquote. ...
URL decode a single string with the given `charset` and decode "+" to whitespace.
def url_unquote_plus(s, charset="utf-8", errors="replace"): """URL decode a single string with the given `charset` and decode "+" to whitespace. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a :exc:`...
[ "def", "url_unquote_plus", "(", "s", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"replace\"", ")", ":", "if", "isinstance", "(", "s", ",", "text_type", ")", ":", "s", "=", "s", ".", "replace", "(", "u\"+\"", ",", "u\" \"", ")", "else", ":...
[ 613, 0 ]
[ 630, 42 ]
python
en
['en', 'en', 'en']
True
url_fix
(s, charset="utf-8")
r"""Sometimes you get an URL by a user that just isn't a real URL because it contains unsafe characters like ' ' and so on. This function can fix some of the problems in a similar way browsers handle data entered by the user: >>> url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)') 'ht...
r"""Sometimes you get an URL by a user that just isn't a real URL because it contains unsafe characters like ' ' and so on. This function can fix some of the problems in a similar way browsers handle data entered by the user:
def url_fix(s, charset="utf-8"): r"""Sometimes you get an URL by a user that just isn't a real URL because it contains unsafe characters like ' ' and so on. This function can fix some of the problems in a similar way browsers handle data entered by the user: >>> url_fix(u'http://de.wikipedia.org/wi...
[ "def", "url_fix", "(", "s", ",", "charset", "=", "\"utf-8\"", ")", ":", "# First step is to switch to unicode processing and to convert", "# backslashes (which are invalid in URLs anyways) to slashes. This is", "# consistent with what Chrome does.", "s", "=", "to_unicode", "(", "s...
[ 633, 0 ]
[ 660, 86 ]
python
en
['en', 'en', 'en']
True
_codec_error_url_quote
(e)
Used in :func:`uri_to_iri` after unquoting to re-quote any invalid bytes.
Used in :func:`uri_to_iri` after unquoting to re-quote any invalid bytes.
def _codec_error_url_quote(e): """Used in :func:`uri_to_iri` after unquoting to re-quote any invalid bytes. """ out = _fast_url_quote(e.object[e.start : e.end]) if PY2: out = out.decode("utf-8") return out, e.end
[ "def", "_codec_error_url_quote", "(", "e", ")", ":", "out", "=", "_fast_url_quote", "(", "e", ".", "object", "[", "e", ".", "start", ":", "e", ".", "end", "]", ")", "if", "PY2", ":", "out", "=", "out", ".", "decode", "(", "\"utf-8\"", ")", "return"...
[ 667, 0 ]
[ 676, 21 ]
python
en
['en', 'en', 'en']
True
uri_to_iri
(uri, charset="utf-8", errors="werkzeug.url_quote")
Convert a URI to an IRI. All valid UTF-8 characters are unquoted, leaving all reserved and invalid characters quoted. If the URL has a domain, it is decoded from Punycode. >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF") 'http://\\u2603.net/p\\xe5th?q=\\xe8ry%DF' :param uri: The URI to...
Convert a URI to an IRI. All valid UTF-8 characters are unquoted, leaving all reserved and invalid characters quoted. If the URL has a domain, it is decoded from Punycode.
def uri_to_iri(uri, charset="utf-8", errors="werkzeug.url_quote"): """Convert a URI to an IRI. All valid UTF-8 characters are unquoted, leaving all reserved and invalid characters quoted. If the URL has a domain, it is decoded from Punycode. >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF") ...
[ "def", "uri_to_iri", "(", "uri", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"werkzeug.url_quote\"", ")", ":", "if", "isinstance", "(", "uri", ",", "tuple", ")", ":", "uri", "=", "url_unparse", "(", "uri", ")", "uri", "=", "url_parse", "(", ...
[ 682, 0 ]
[ 709, 80 ]
python
en
['en', 'en', 'en']
True
iri_to_uri
(iri, charset="utf-8", errors="strict", safe_conversion=False)
Convert an IRI to a URI. All non-ASCII and unsafe characters are quoted. If the URL has a domain, it is encoded to Punycode. >>> iri_to_uri('http://\\u2603.net/p\\xe5th?q=\\xe8ry%DF') 'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF' :param iri: The IRI to convert. :param charset: The encoding of the I...
Convert an IRI to a URI. All non-ASCII and unsafe characters are quoted. If the URL has a domain, it is encoded to Punycode.
def iri_to_uri(iri, charset="utf-8", errors="strict", safe_conversion=False): """Convert an IRI to a URI. All non-ASCII and unsafe characters are quoted. If the URL has a domain, it is encoded to Punycode. >>> iri_to_uri('http://\\u2603.net/p\\xe5th?q=\\xe8ry%DF') 'http://xn--n3h.net/p%C3%A5th?q=%C3%A8...
[ "def", "iri_to_uri", "(", "iri", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ",", "safe_conversion", "=", "False", ")", ":", "if", "isinstance", "(", "iri", ",", "tuple", ")", ":", "iri", "=", "url_unparse", "(", "iri", ")", "if...
[ 716, 0 ]
[ 776, 5 ]
python
en
['en', 'en', 'en']
True
url_decode
( s, charset="utf-8", decode_keys=False, include_empty=True, errors="replace", separator="&", cls=None, )
Parse a querystring and return it as :class:`MultiDict`. There is a difference in key decoding on different Python versions. On Python 3 keys will always be fully decoded whereas on Python 2, keys will remain bytestrings if they fit into ASCII. On 2.x keys can be forced to be unicode by setting ...
Parse a querystring and return it as :class:`MultiDict`. There is a difference in key decoding on different Python versions. On Python 3 keys will always be fully decoded whereas on Python 2, keys will remain bytestrings if they fit into ASCII. On 2.x keys can be forced to be unicode by setting ...
def url_decode( s, charset="utf-8", decode_keys=False, include_empty=True, errors="replace", separator="&", cls=None, ): """ Parse a querystring and return it as :class:`MultiDict`. There is a difference in key decoding on different Python versions. On Python 3 keys will al...
[ "def", "url_decode", "(", "s", ",", "charset", "=", "\"utf-8\"", ",", "decode_keys", "=", "False", ",", "include_empty", "=", "True", ",", "errors", "=", "\"replace\"", ",", "separator", "=", "\"&\"", ",", "cls", "=", "None", ",", ")", ":", "if", "cls"...
[ 779, 0 ]
[ 838, 5 ]
python
en
['en', 'error', 'th']
False
url_decode_stream
( stream, charset="utf-8", decode_keys=False, include_empty=True, errors="replace", separator="&", cls=None, limit=None, return_iterator=False, )
Works like :func:`url_decode` but decodes a stream. The behavior of stream and limit follows functions like :func:`~werkzeug.wsgi.make_line_iter`. The generator of pairs is directly fed to the `cls` so you can consume the data while it's parsed. .. versionadded:: 0.8 :param stream: a stream ...
Works like :func:`url_decode` but decodes a stream. The behavior of stream and limit follows functions like :func:`~werkzeug.wsgi.make_line_iter`. The generator of pairs is directly fed to the `cls` so you can consume the data while it's parsed.
def url_decode_stream( stream, charset="utf-8", decode_keys=False, include_empty=True, errors="replace", separator="&", cls=None, limit=None, return_iterator=False, ): """Works like :func:`url_decode` but decodes a stream. The behavior of stream and limit follows functions l...
[ "def", "url_decode_stream", "(", "stream", ",", "charset", "=", "\"utf-8\"", ",", "decode_keys", "=", "False", ",", "include_empty", "=", "True", ",", "errors", "=", "\"replace\"", ",", "separator", "=", "\"&\"", ",", "cls", "=", "None", ",", "limit", "=",...
[ 841, 0 ]
[ 892, 23 ]
python
en
['en', 'en', 'en']
True
url_encode
( obj, charset="utf-8", encode_keys=False, sort=False, key=None, separator=b"&" )
URL encode a dict/`MultiDict`. If a value is `None` it will not appear in the result string. Per default only values are encoded into the target charset strings. If `encode_keys` is set to ``True`` unicode keys are supported too. If `sort` is set to `True` the items are sorted by `key` or the defaul...
URL encode a dict/`MultiDict`. If a value is `None` it will not appear in the result string. Per default only values are encoded into the target charset strings. If `encode_keys` is set to ``True`` unicode keys are supported too.
def url_encode( obj, charset="utf-8", encode_keys=False, sort=False, key=None, separator=b"&" ): """URL encode a dict/`MultiDict`. If a value is `None` it will not appear in the result string. Per default only values are encoded into the target charset strings. If `encode_keys` is set to ``True`` uni...
[ "def", "url_encode", "(", "obj", ",", "charset", "=", "\"utf-8\"", ",", "encode_keys", "=", "False", ",", "sort", "=", "False", ",", "key", "=", "None", ",", "separator", "=", "b\"&\"", ")", ":", "separator", "=", "to_native", "(", "separator", ",", "\...
[ 914, 0 ]
[ 938, 81 ]
python
en
['en', 'en', 'en']
True
url_encode_stream
( obj, stream=None, charset="utf-8", encode_keys=False, sort=False, key=None, separator=b"&", )
Like :meth:`url_encode` but writes the results to a stream object. If the stream is `None` a generator over all encoded pairs is returned. .. versionadded:: 0.8 :param obj: the object to encode into a query string. :param stream: a stream to write the encoded object into or `None` if ...
Like :meth:`url_encode` but writes the results to a stream object. If the stream is `None` a generator over all encoded pairs is returned.
def url_encode_stream( obj, stream=None, charset="utf-8", encode_keys=False, sort=False, key=None, separator=b"&", ): """Like :meth:`url_encode` but writes the results to a stream object. If the stream is `None` a generator over all encoded pairs is returned. .. versionadde...
[ "def", "url_encode_stream", "(", "obj", ",", "stream", "=", "None", ",", "charset", "=", "\"utf-8\"", ",", "encode_keys", "=", "False", ",", "sort", "=", "False", ",", "key", "=", "None", ",", "separator", "=", "b\"&\"", ",", ")", ":", "separator", "="...
[ 941, 0 ]
[ 975, 27 ]
python
en
['en', 'en', 'en']
True
url_join
(base, url, allow_fragments=True)
Join a base URL and a possibly relative URL to form an absolute interpretation of the latter. :param base: the base URL for the join operation. :param url: the URL to join. :param allow_fragments: indicates whether fragments should be allowed.
Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.
def url_join(base, url, allow_fragments=True): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter. :param base: the base URL for the join operation. :param url: the URL to join. :param allow_fragments: indicates whether fragments should be allowed. "...
[ "def", "url_join", "(", "base", ",", "url", ",", "allow_fragments", "=", "True", ")", ":", "if", "isinstance", "(", "base", ",", "tuple", ")", ":", "base", "=", "url_unparse", "(", "base", ")", "if", "isinstance", "(", "url", ",", "tuple", ")", ":", ...
[ 978, 0 ]
[ 1042, 63 ]
python
en
['en', 'en', 'en']
True
BaseURL.replace
(self, **kwargs)
Return an URL with the same values, except for those parameters given new values by whichever keyword arguments are specified.
Return an URL with the same values, except for those parameters given new values by whichever keyword arguments are specified.
def replace(self, **kwargs): """Return an URL with the same values, except for those parameters given new values by whichever keyword arguments are specified.""" return self._replace(**kwargs)
[ "def", "replace", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_replace", "(", "*", "*", "kwargs", ")" ]
[ 64, 4 ]
[ 67, 38 ]
python
en
['en', 'en', 'en']
True
BaseURL.host
(self)
The host part of the URL if available, otherwise `None`. The host is either the hostname or the IP address mentioned in the URL. It will not contain the port.
The host part of the URL if available, otherwise `None`. The host is either the hostname or the IP address mentioned in the URL. It will not contain the port.
def host(self): """The host part of the URL if available, otherwise `None`. The host is either the hostname or the IP address mentioned in the URL. It will not contain the port. """ return self._split_host()[0]
[ "def", "host", "(", "self", ")", ":", "return", "self", ".", "_split_host", "(", ")", "[", "0", "]" ]
[ 70, 4 ]
[ 75, 36 ]
python
en
['en', 'en', 'en']
True
BaseURL.ascii_host
(self)
Works exactly like :attr:`host` but will return a result that is restricted to ASCII. If it finds a netloc that is not ASCII it will attempt to idna decode it. This is useful for socket operations when the URL might include internationalized characters.
Works exactly like :attr:`host` but will return a result that is restricted to ASCII. If it finds a netloc that is not ASCII it will attempt to idna decode it. This is useful for socket operations when the URL might include internationalized characters.
def ascii_host(self): """Works exactly like :attr:`host` but will return a result that is restricted to ASCII. If it finds a netloc that is not ASCII it will attempt to idna decode it. This is useful for socket operations when the URL might include internationalized characters. ...
[ "def", "ascii_host", "(", "self", ")", ":", "rv", "=", "self", ".", "host", "if", "rv", "is", "not", "None", "and", "isinstance", "(", "rv", ",", "text_type", ")", ":", "try", ":", "rv", "=", "_encode_idna", "(", "rv", ")", "except", "UnicodeError", ...
[ 78, 4 ]
[ 90, 47 ]
python
en
['en', 'en', 'en']
True
BaseURL.port
(self)
The port in the URL as an integer if it was present, `None` otherwise. This does not fill in default ports.
The port in the URL as an integer if it was present, `None` otherwise. This does not fill in default ports.
def port(self): """The port in the URL as an integer if it was present, `None` otherwise. This does not fill in default ports. """ try: rv = int(to_native(self._split_host()[1])) if 0 <= rv <= 65535: return rv except (ValueError, TypeError...
[ "def", "port", "(", "self", ")", ":", "try", ":", "rv", "=", "int", "(", "to_native", "(", "self", ".", "_split_host", "(", ")", "[", "1", "]", ")", ")", "if", "0", "<=", "rv", "<=", "65535", ":", "return", "rv", "except", "(", "ValueError", ",...
[ 93, 4 ]
[ 102, 16 ]
python
en
['en', 'en', 'en']
True
BaseURL.auth
(self)
The authentication part in the URL if available, `None` otherwise.
The authentication part in the URL if available, `None` otherwise.
def auth(self): """The authentication part in the URL if available, `None` otherwise. """ return self._split_netloc()[0]
[ "def", "auth", "(", "self", ")", ":", "return", "self", ".", "_split_netloc", "(", ")", "[", "0", "]" ]
[ 105, 4 ]
[ 109, 38 ]
python
en
['en', 'en', 'en']
True
BaseURL.username
(self)
The username if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a unicode string.
The username if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a unicode string.
def username(self): """The username if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a unicode string. """ rv = self._split_auth()[0] if rv is not None: return _url_unquote_legacy(rv)
[ "def", "username", "(", "self", ")", ":", "rv", "=", "self", ".", "_split_auth", "(", ")", "[", "0", "]", "if", "rv", "is", "not", "None", ":", "return", "_url_unquote_legacy", "(", "rv", ")" ]
[ 112, 4 ]
[ 118, 42 ]
python
en
['en', 'en', 'en']
True
BaseURL.raw_username
(self)
The username if it was part of the URL, `None` otherwise. Unlike :attr:`username` this one is not being decoded.
The username if it was part of the URL, `None` otherwise. Unlike :attr:`username` this one is not being decoded.
def raw_username(self): """The username if it was part of the URL, `None` otherwise. Unlike :attr:`username` this one is not being decoded. """ return self._split_auth()[0]
[ "def", "raw_username", "(", "self", ")", ":", "return", "self", ".", "_split_auth", "(", ")", "[", "0", "]" ]
[ 121, 4 ]
[ 125, 36 ]
python
en
['en', 'en', 'en']
True
BaseURL.password
(self)
The password if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a unicode string.
The password if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a unicode string.
def password(self): """The password if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a unicode string. """ rv = self._split_auth()[1] if rv is not None: return _url_unquote_legacy(rv)
[ "def", "password", "(", "self", ")", ":", "rv", "=", "self", ".", "_split_auth", "(", ")", "[", "1", "]", "if", "rv", "is", "not", "None", ":", "return", "_url_unquote_legacy", "(", "rv", ")" ]
[ 128, 4 ]
[ 134, 42 ]
python
en
['en', 'en', 'en']
True
BaseURL.raw_password
(self)
The password if it was part of the URL, `None` otherwise. Unlike :attr:`password` this one is not being decoded.
The password if it was part of the URL, `None` otherwise. Unlike :attr:`password` this one is not being decoded.
def raw_password(self): """The password if it was part of the URL, `None` otherwise. Unlike :attr:`password` this one is not being decoded. """ return self._split_auth()[1]
[ "def", "raw_password", "(", "self", ")", ":", "return", "self", ".", "_split_auth", "(", ")", "[", "1", "]" ]
[ 137, 4 ]
[ 141, 36 ]
python
en
['en', 'en', 'en']
True
BaseURL.decode_query
(self, *args, **kwargs)
Decodes the query part of the URL. Ths is a shortcut for calling :func:`url_decode` on the query argument. The arguments and keyword arguments are forwarded to :func:`url_decode` unchanged.
Decodes the query part of the URL. Ths is a shortcut for calling :func:`url_decode` on the query argument. The arguments and keyword arguments are forwarded to :func:`url_decode` unchanged.
def decode_query(self, *args, **kwargs): """Decodes the query part of the URL. Ths is a shortcut for calling :func:`url_decode` on the query argument. The arguments and keyword arguments are forwarded to :func:`url_decode` unchanged. """ return url_decode(self.query, *args, **k...
[ "def", "decode_query", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "url_decode", "(", "self", ".", "query", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 143, 4 ]
[ 148, 54 ]
python
en
['en', 'en', 'en']
True
BaseURL.join
(self, *args, **kwargs)
Joins this URL with another one. This is just a convenience function for calling into :meth:`url_join` and then parsing the return value again.
Joins this URL with another one. This is just a convenience function for calling into :meth:`url_join` and then parsing the return value again.
def join(self, *args, **kwargs): """Joins this URL with another one. This is just a convenience function for calling into :meth:`url_join` and then parsing the return value again. """ return url_parse(url_join(self, *args, **kwargs))
[ "def", "join", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "url_parse", "(", "url_join", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
[ 150, 4 ]
[ 155, 57 ]
python
en
['en', 'en', 'en']
True
BaseURL.to_url
(self)
Returns a URL string or bytes depending on the type of the information stored. This is just a convenience function for calling :meth:`url_unparse` for this URL.
Returns a URL string or bytes depending on the type of the information stored. This is just a convenience function for calling :meth:`url_unparse` for this URL.
def to_url(self): """Returns a URL string or bytes depending on the type of the information stored. This is just a convenience function for calling :meth:`url_unparse` for this URL. """ return url_unparse(self)
[ "def", "to_url", "(", "self", ")", ":", "return", "url_unparse", "(", "self", ")" ]
[ 157, 4 ]
[ 162, 32 ]
python
en
['en', 'en', 'en']
True
BaseURL.decode_netloc
(self)
Decodes the netloc part into a string.
Decodes the netloc part into a string.
def decode_netloc(self): """Decodes the netloc part into a string.""" rv = _decode_idna(self.host or "") if ":" in rv: rv = "[%s]" % rv port = self.port if port is not None: rv = "%s:%d" % (rv, port) auth = ":".join( filter( ...
[ "def", "decode_netloc", "(", "self", ")", ":", "rv", "=", "_decode_idna", "(", "self", ".", "host", "or", "\"\"", ")", "if", "\":\"", "in", "rv", ":", "rv", "=", "\"[%s]\"", "%", "rv", "port", "=", "self", ".", "port", "if", "port", "is", "not", ...
[ 164, 4 ]
[ 184, 17 ]
python
en
['en', 'en', 'en']
True
BaseURL.to_uri_tuple
(self)
Returns a :class:`BytesURL` tuple that holds a URI. This will encode all the information in the URL properly to ASCII using the rules a web browser would follow. It's usually more interesting to directly call :meth:`iri_to_uri` which will return a string.
Returns a :class:`BytesURL` tuple that holds a URI. This will encode all the information in the URL properly to ASCII using the rules a web browser would follow.
def to_uri_tuple(self): """Returns a :class:`BytesURL` tuple that holds a URI. This will encode all the information in the URL properly to ASCII using the rules a web browser would follow. It's usually more interesting to directly call :meth:`iri_to_uri` which will return a str...
[ "def", "to_uri_tuple", "(", "self", ")", ":", "return", "url_parse", "(", "iri_to_uri", "(", "self", ")", ".", "encode", "(", "\"ascii\"", ")", ")" ]
[ 186, 4 ]
[ 194, 58 ]
python
en
['en', 'en', 'en']
True
BaseURL.to_iri_tuple
(self)
Returns a :class:`URL` tuple that holds a IRI. This will try to decode as much information as possible in the URL without losing information similar to how a web browser does it for the URL bar. It's usually more interesting to directly call :meth:`uri_to_iri` which will return...
Returns a :class:`URL` tuple that holds a IRI. This will try to decode as much information as possible in the URL without losing information similar to how a web browser does it for the URL bar.
def to_iri_tuple(self): """Returns a :class:`URL` tuple that holds a IRI. This will try to decode as much information as possible in the URL without losing information similar to how a web browser does it for the URL bar. It's usually more interesting to directly call :meth:`ur...
[ "def", "to_iri_tuple", "(", "self", ")", ":", "return", "url_parse", "(", "uri_to_iri", "(", "self", ")", ")" ]
[ 196, 4 ]
[ 205, 42 ]
python
en
['en', 'en', 'en']
True
BaseURL.get_file_location
(self, pathformat=None)
Returns a tuple with the location of the file in the form ``(server, location)``. If the netloc is empty in the URL or points to localhost, it's represented as ``None``. The `pathformat` by default is autodetection but needs to be set when working with URLs of a specific system. The s...
Returns a tuple with the location of the file in the form ``(server, location)``. If the netloc is empty in the URL or points to localhost, it's represented as ``None``.
def get_file_location(self, pathformat=None): """Returns a tuple with the location of the file in the form ``(server, location)``. If the netloc is empty in the URL or points to localhost, it's represented as ``None``. The `pathformat` by default is autodetection but needs to be set ...
[ "def", "get_file_location", "(", "self", ",", "pathformat", "=", "None", ")", ":", "if", "self", ".", "scheme", "!=", "\"file\"", ":", "return", "None", ",", "None", "path", "=", "url_unquote", "(", "self", ".", "path", ")", "host", "=", "self", ".", ...
[ 207, 4 ]
[ 265, 25 ]
python
en
['en', 'en', 'en']
True
BytesURL.encode_netloc
(self)
Returns the netloc unchanged as bytes.
Returns the netloc unchanged as bytes.
def encode_netloc(self): """Returns the netloc unchanged as bytes.""" return self.netloc
[ "def", "encode_netloc", "(", "self", ")", ":", "return", "self", ".", "netloc" ]
[ 363, 4 ]
[ 365, 26 ]
python
en
['en', 'xh', 'en']
True
BytesURL.decode
(self, charset="utf-8", errors="replace")
Decodes the URL to a tuple made out of strings. The charset is only being used for the path, query and fragment.
Decodes the URL to a tuple made out of strings. The charset is only being used for the path, query and fragment.
def decode(self, charset="utf-8", errors="replace"): """Decodes the URL to a tuple made out of strings. The charset is only being used for the path, query and fragment. """ return URL( self.scheme.decode("ascii"), self.decode_netloc(), self.path.decod...
[ "def", "decode", "(", "self", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"replace\"", ")", ":", "return", "URL", "(", "self", ".", "scheme", ".", "decode", "(", "\"ascii\"", ")", ",", "self", ".", "decode_netloc", "(", ")", ",", "self", ...
[ 367, 4 ]
[ 377, 9 ]
python
en
['en', 'en', 'en']
True