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
Distribution._parse_command_opts
(self, parser, args)
Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse). Returns a new version of 'args' with the next command at the front of the list; wi...
Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse). Returns a new version of 'args' with the next command at the front of the list; wi...
def _parse_command_opts(self, parser, args): """Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse). Returns a new version of 'args' wi...
[ "def", "_parse_command_opts", "(", "self", ",", "parser", ",", "args", ")", ":", "# late import because of mutual dependence between these modules", "from", "distutils", ".", "cmd", "import", "Command", "# Pull the current command from the head of the command line", "command", ...
[ 517, 4 ]
[ 606, 19 ]
python
en
['en', 'en', 'en']
True
Distribution.finalize_options
(self)
Set final values for all the options on the Distribution instance, analogous to the .finalize_options() method of Command objects.
Set final values for all the options on the Distribution instance, analogous to the .finalize_options() method of Command objects.
def finalize_options(self): """Set final values for all the options on the Distribution instance, analogous to the .finalize_options() method of Command objects. """ for attr in ('keywords', 'platforms'): value = getattr(self.metadata, attr) if value is No...
[ "def", "finalize_options", "(", "self", ")", ":", "for", "attr", "in", "(", "'keywords'", ",", "'platforms'", ")", ":", "value", "=", "getattr", "(", "self", ".", "metadata", ",", "attr", ")", "if", "value", "is", "None", ":", "continue", "if", "isinst...
[ 608, 4 ]
[ 619, 51 ]
python
en
['en', 'en', 'en']
True
Distribution._show_help
(self, parser, global_options=1, display_options=1, commands=[])
Show help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same state, as its option table will be reset to make it generate the correct help text. If 'globa...
Show help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same state, as its option table will be reset to make it generate the correct help text.
def _show_help(self, parser, global_options=1, display_options=1, commands=[]): """Show help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same ...
[ "def", "_show_help", "(", "self", ",", "parser", ",", "global_options", "=", "1", ",", "display_options", "=", "1", ",", "commands", "=", "[", "]", ")", ":", "# late import because of mutual dependence between these modules", "from", "distutils", ".", "core", "imp...
[ 621, 4 ]
[ 669, 42 ]
python
en
['en', 'en', 'en']
True
Distribution.handle_display_options
(self, option_order)
If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false.
If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false.
def handle_display_options(self, option_order): """If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false. """ from distutils.core import gen_...
[ "def", "handle_display_options", "(", "self", ",", "option_order", ")", ":", "from", "distutils", ".", "core", "import", "gen_usage", "# User just wants a list of commands -- we'll print it out and stop", "# processing now (ie. if they ran \"setup --help-commands foo bar\",", "# we i...
[ 671, 4 ]
[ 709, 34 ]
python
en
['en', 'en', 'en']
True
Distribution.print_command_list
(self, commands, header, max_length)
Print a subset of the list of all commands -- used by 'print_commands()'.
Print a subset of the list of all commands -- used by 'print_commands()'.
def print_command_list(self, commands, header, max_length): """Print a subset of the list of all commands -- used by 'print_commands()'. """ print(header + ":") for cmd in commands: klass = self.cmdclass.get(cmd) if not klass: klass = self...
[ "def", "print_command_list", "(", "self", ",", "commands", ",", "header", ",", "max_length", ")", ":", "print", "(", "header", "+", "\":\"", ")", "for", "cmd", "in", "commands", ":", "klass", "=", "self", ".", "cmdclass", ".", "get", "(", "cmd", ")", ...
[ 711, 4 ]
[ 726, 64 ]
python
en
['en', 'en', 'en']
True
Distribution.print_commands
(self)
Print out a help message listing all available commands with a description of each. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command c...
Print out a help message listing all available commands with a description of each. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command c...
def print_commands(self): """Print out a help message listing all available commands with a description of each. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The ...
[ "def", "print_commands", "(", "self", ")", ":", "import", "distutils", ".", "command", "std_commands", "=", "distutils", ".", "command", ".", "__all__", "is_std", "=", "{", "}", "for", "cmd", "in", "std_commands", ":", "is_std", "[", "cmd", "]", "=", "1"...
[ 728, 4 ]
[ 759, 47 ]
python
en
['en', 'en', 'en']
True
Distribution.get_command_list
(self)
Get a list of (command, description) tuples. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command class attribute 'description'.
Get a list of (command, description) tuples. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command class attribute 'description'.
def get_command_list(self): """Get a list of (command, description) tuples. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command cl...
[ "def", "get_command_list", "(", "self", ")", ":", "# Currently this is only used on Mac OS, for the Mac-only GUI", "# Distutils interface (by Jack Jansen)", "import", "distutils", ".", "command", "std_commands", "=", "distutils", ".", "command", ".", "__all__", "is_std", "=",...
[ 761, 4 ]
[ 791, 17 ]
python
en
['en', 'fr', 'en']
True
Distribution.get_command_packages
(self)
Return a list of packages from which commands are loaded.
Return a list of packages from which commands are loaded.
def get_command_packages(self): """Return a list of packages from which commands are loaded.""" pkgs = self.command_packages if not isinstance(pkgs, list): if pkgs is None: pkgs = '' pkgs = [pkg.strip() for pkg in pkgs.split(',') if pkg != ''] ...
[ "def", "get_command_packages", "(", "self", ")", ":", "pkgs", "=", "self", ".", "command_packages", "if", "not", "isinstance", "(", "pkgs", ",", "list", ")", ":", "if", "pkgs", "is", "None", ":", "pkgs", "=", "''", "pkgs", "=", "[", "pkg", ".", "stri...
[ 795, 4 ]
[ 805, 19 ]
python
en
['en', 'en', 'en']
True
Distribution.get_command_class
(self, command)
Return the class that implements the Distutils command named by 'command'. First we check the 'cmdclass' dictionary; if the command is mentioned there, we fetch the class object from the dictionary and return it. Otherwise we load the command module ("distutils.command." + command) and...
Return the class that implements the Distutils command named by 'command'. First we check the 'cmdclass' dictionary; if the command is mentioned there, we fetch the class object from the dictionary and return it. Otherwise we load the command module ("distutils.command." + command) and...
def get_command_class(self, command): """Return the class that implements the Distutils command named by 'command'. First we check the 'cmdclass' dictionary; if the command is mentioned there, we fetch the class object from the dictionary and return it. Otherwise we load the command mo...
[ "def", "get_command_class", "(", "self", ",", "command", ")", ":", "klass", "=", "self", ".", "cmdclass", ".", "get", "(", "command", ")", "if", "klass", ":", "return", "klass", "for", "pkgname", "in", "self", ".", "get_command_packages", "(", ")", ":", ...
[ 807, 4 ]
[ 843, 68 ]
python
en
['en', 'en', 'en']
True
Distribution.get_command_obj
(self, command, create=1)
Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no command object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None.
Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no command object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None.
def get_command_obj(self, command, create=1): """Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no command object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return Non...
[ "def", "get_command_obj", "(", "self", ",", "command", ",", "create", "=", "1", ")", ":", "cmd_obj", "=", "self", ".", "command_obj", ".", "get", "(", "command", ")", "if", "not", "cmd_obj", "and", "create", ":", "if", "DEBUG", ":", "self", ".", "ann...
[ 845, 4 ]
[ 870, 22 ]
python
en
['en', 'en', 'en']
True
Distribution._set_command_options
(self, command_obj, option_dict=None)
Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). 'command_obj' must be a Command instance. If 'option_dict' is not supplied, uses the standard option dictionary for thi...
Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command').
def _set_command_options(self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). 'command_obj' must be a Command instance. If 'option_...
[ "def", "_set_command_options", "(", "self", ",", "command_obj", ",", "option_dict", "=", "None", ")", ":", "command_name", "=", "command_obj", ".", "get_command_name", "(", ")", "if", "option_dict", "is", "None", ":", "option_dict", "=", "self", ".", "get_opti...
[ 872, 4 ]
[ 914, 47 ]
python
en
['en', 'en', 'en']
True
Distribution.reinitialize_command
(self, command, reinit_subcommands=0)
Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command...
Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command...
def reinitialize_command(self, command, reinit_subcommands=0): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or su...
[ "def", "reinitialize_command", "(", "self", ",", "command", ",", "reinit_subcommands", "=", "0", ")", ":", "from", "distutils", ".", "cmd", "import", "Command", "if", "not", "isinstance", "(", "command", ",", "Command", ")", ":", "command_name", "=", "comman...
[ 916, 4 ]
[ 953, 22 ]
python
en
['en', 'en', 'en']
True
Distribution.run_commands
(self)
Run each command that was seen on the setup script command line. Uses the list of commands found and cache of command objects created by 'get_command_obj()'.
Run each command that was seen on the setup script command line. Uses the list of commands found and cache of command objects created by 'get_command_obj()'.
def run_commands(self): """Run each command that was seen on the setup script command line. Uses the list of commands found and cache of command objects created by 'get_command_obj()'. """ for cmd in self.commands: self.run_command(cmd)
[ "def", "run_commands", "(", "self", ")", ":", "for", "cmd", "in", "self", ".", "commands", ":", "self", ".", "run_command", "(", "cmd", ")" ]
[ 960, 4 ]
[ 966, 33 ]
python
en
['en', 'en', 'en']
True
Distribution.run_command
(self, command)
Do whatever it takes to run a command (including nothing at all, if the command has already been run). Specifically: if we have already created and run the command named by 'command', return silently without doing anything. If the command named by 'command' doesn't even have a command ...
Do whatever it takes to run a command (including nothing at all, if the command has already been run). Specifically: if we have already created and run the command named by 'command', return silently without doing anything. If the command named by 'command' doesn't even have a command ...
def run_command(self, command): """Do whatever it takes to run a command (including nothing at all, if the command has already been run). Specifically: if we have already created and run the command named by 'command', return silently without doing anything. If the command named by 'co...
[ "def", "run_command", "(", "self", ",", "command", ")", ":", "# Already been here, done that? then return silently.", "if", "self", ".", "have_run", ".", "get", "(", "command", ")", ":", "return", "log", ".", "info", "(", "\"running %s\"", ",", "command", ")", ...
[ 970, 4 ]
[ 986, 34 ]
python
en
['en', 'en', 'en']
True
DistributionMetadata.read_pkg_file
(self, file)
Reads the metadata values from a file object.
Reads the metadata values from a file object.
def read_pkg_file(self, file): """Reads the metadata values from a file object.""" msg = message_from_file(file) def _read_field(name): value = msg[name] if value == 'UNKNOWN': return None return value def _read_list(name): ...
[ "def", "read_pkg_file", "(", "self", ",", "file", ")", ":", "msg", "=", "message_from_file", "(", "file", ")", "def", "_read_field", "(", "name", ")", ":", "value", "=", "msg", "[", "name", "]", "if", "value", "==", "'UNKNOWN'", ":", "return", "None", ...
[ 1060, 4 ]
[ 1110, 33 ]
python
en
['en', 'en', 'en']
True
DistributionMetadata.write_pkg_info
(self, base_dir)
Write the PKG-INFO file into the release tree.
Write the PKG-INFO file into the release tree.
def write_pkg_info(self, base_dir): """Write the PKG-INFO file into the release tree. """ with open(os.path.join(base_dir, 'PKG-INFO'), 'w', encoding='UTF-8') as pkg_info: self.write_pkg_file(pkg_info)
[ "def", "write_pkg_info", "(", "self", ",", "base_dir", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "base_dir", ",", "'PKG-INFO'", ")", ",", "'w'", ",", "encoding", "=", "'UTF-8'", ")", "as", "pkg_info", ":", "self", ".", "writ...
[ 1112, 4 ]
[ 1117, 41 ]
python
en
['en', 'en', 'en']
True
DistributionMetadata.write_pkg_file
(self, file)
Write the PKG-INFO format data to a file object.
Write the PKG-INFO format data to a file object.
def write_pkg_file(self, file): """Write the PKG-INFO format data to a file object. """ version = '1.0' if (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): version = '1.1' file.write('Metadata-Version: %s\n'...
[ "def", "write_pkg_file", "(", "self", ",", "file", ")", ":", "version", "=", "'1.0'", "if", "(", "self", ".", "provides", "or", "self", ".", "requires", "or", "self", ".", "obsoletes", "or", "self", ".", "classifiers", "or", "self", ".", "download_url", ...
[ 1119, 4 ]
[ 1151, 65 ]
python
en
['en', 'en', 'en']
True
format_command_result
( command_args, # type: List[str] command_output, # type: Text )
Format command information for logging.
Format command information for logging.
def format_command_result( command_args, # type: List[str] command_output, # type: Text ): # type: (...) -> str """Format command information for logging.""" command_desc = format_command_args(command_args) text = 'Command arguments: {}\n'.format(command_desc) if not command_output: ...
[ "def", "format_command_result", "(", "command_args", ",", "# type: List[str]", "command_output", ",", "# type: Text", ")", ":", "# type: (...) -> str", "command_desc", "=", "format_command_args", "(", "command_args", ")", "text", "=", "'Command arguments: {}\\n'", ".", "f...
[ 20, 0 ]
[ 38, 15 ]
python
en
['en', 'da', 'en']
True
get_legacy_build_wheel_path
( names, # type: List[str] temp_dir, # type: str name, # type: str command_args, # type: List[str] command_output, # type: Text )
Return the path to the wheel in the temporary build directory.
Return the path to the wheel in the temporary build directory.
def get_legacy_build_wheel_path( names, # type: List[str] temp_dir, # type: str name, # type: str command_args, # type: List[str] command_output, # type: Text ): # type: (...) -> Optional[str] """Return the path to the wheel in the temporary build directory.""" # Sort for determinis...
[ "def", "get_legacy_build_wheel_path", "(", "names", ",", "# type: List[str]", "temp_dir", ",", "# type: str", "name", ",", "# type: str", "command_args", ",", "# type: List[str]", "command_output", ",", "# type: Text", ")", ":", "# type: (...) -> Optional[str]", "# Sort for...
[ 41, 0 ]
[ 68, 43 ]
python
en
['en', 'en', 'en']
True
build_wheel_legacy
( name, # type: str setup_py_path, # type: str source_dir, # type: str global_options, # type: List[str] build_options, # type: List[str] tempd, # type: str )
Build one unpacked package using the "legacy" build process. Returns path to wheel if successfully built. Otherwise, returns None.
Build one unpacked package using the "legacy" build process.
def build_wheel_legacy( name, # type: str setup_py_path, # type: str source_dir, # type: str global_options, # type: List[str] build_options, # type: List[str] tempd, # type: str ): # type: (...) -> Optional[str] """Build one unpacked package using the "legacy" build process. ...
[ "def", "build_wheel_legacy", "(", "name", ",", "# type: str", "setup_py_path", ",", "# type: str", "source_dir", ",", "# type: str", "global_options", ",", "# type: List[str]", "build_options", ",", "# type: List[str]", "tempd", ",", "# type: str", ")", ":", "# type: (....
[ 71, 0 ]
[ 114, 25 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_table_list
(self, cursor)
Returns a list of table and view names in the current database.
Returns a list of table and view names in the current database.
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ cursor.execute("SELECT TABLE_NAME, 't' FROM USER_TABLES UNION ALL " "SELECT VIEW_NAME, 'v' FROM USER_VIEWS") return [TableInfo(row[0].lower(), row[1]) ...
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "\"SELECT TABLE_NAME, 't' FROM USER_TABLES UNION ALL \"", "\"SELECT VIEW_NAME, 'v' FROM USER_VIEWS\"", ")", "return", "[", "TableInfo", "(", "row", "[", "0", "]", ".", "lower...
[ 49, 4 ]
[ 55, 79 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_table_description
(self, cursor, table_name)
Returns a description of the table, with the DB-API cursor.description interface.
Returns a description of the table, with the DB-API cursor.description interface.
def get_table_description(self, cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." cursor.execute("SELECT * FROM %s WHERE ROWNUM < 2" % self.connection.ops.quote_name(table_name)) description = [] for desc in cursor.description: ...
[ "def", "get_table_description", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "cursor", ".", "execute", "(", "\"SELECT * FROM %s WHERE ROWNUM < 2\"", "%", "self", ".", "connection", ".", "ops", ".", "quote_name", "(", "table_name", ")", ")", "descript...
[ 57, 4 ]
[ 65, 26 ]
python
en
['en', 'fr', 'en']
True
DatabaseIntrospection.table_name_converter
(self, name)
Table name comparison is case insensitive under Oracle
Table name comparison is case insensitive under Oracle
def table_name_converter(self, name): "Table name comparison is case insensitive under Oracle" return name.lower()
[ "def", "table_name_converter", "(", "self", ",", "name", ")", ":", "return", "name", ".", "lower", "(", ")" ]
[ 67, 4 ]
[ 69, 27 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection._name_to_index
(self, cursor, table_name)
Returns a dictionary of {field_name: field_index} for the given table. Indexes are 0-based.
Returns a dictionary of {field_name: field_index} for the given table. Indexes are 0-based.
def _name_to_index(self, cursor, table_name): """ Returns a dictionary of {field_name: field_index} for the given table. Indexes are 0-based. """ return dict((d[0], i) for i, d in enumerate(self.get_table_description(cursor, table_name)))
[ "def", "_name_to_index", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "return", "dict", "(", "(", "d", "[", "0", "]", ",", "i", ")", "for", "i", ",", "d", "in", "enumerate", "(", "self", ".", "get_table_description", "(", "cursor", ",", ...
[ 71, 4 ]
[ 76, 100 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_relations
(self, cursor, table_name)
Returns a dictionary of {field_index: (field_index_other_table, other_table)} representing all relationships to the given table. Indexes are 0-based.
Returns a dictionary of {field_index: (field_index_other_table, other_table)} representing all relationships to the given table. Indexes are 0-based.
def get_relations(self, cursor, table_name): """ Returns a dictionary of {field_index: (field_index_other_table, other_table)} representing all relationships to the given table. Indexes are 0-based. """ table_name = table_name.upper() cursor.execute(""" SELECT ta.colu...
[ "def", "get_relations", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "table_name", "=", "table_name", ".", "upper", "(", ")", "cursor", ".", "execute", "(", "\"\"\"\n SELECT ta.column_id - 1, tb.table_name, tb.column_id - 1\n FROM user_constraints, USER_...
[ 78, 4 ]
[ 101, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
def get_constraints(self, cursor, table_name): """ Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. """ constraints = {} # Loop over the constraints, getting PKs and uniques cursor.execute(""" SELECT ...
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "{", "}", "# Loop over the constraints, getting PKs and uniques", "cursor", ".", "execute", "(", "\"\"\"\n SELECT\n user_constraints.constraint_name,...
[ 145, 4 ]
[ 283, 26 ]
python
en
['en', 'error', 'th']
False
AccessControlGrant.cancel
(self)
Cancels a grant. The method checks if the grant was installed into the access control system already and asks for its revocation is it was. Otherwise the grant is just marked as removed.
Cancels a grant.
def cancel(self): """Cancels a grant. The method checks if the grant was installed into the access control system already and asks for its revocation is it was. Otherwise the grant is just marked as removed. """ logger.info('[%s] Canceling' % self) if self.state ...
[ "def", "cancel", "(", "self", ")", ":", "logger", ".", "info", "(", "'[%s] Canceling'", "%", "self", ")", "if", "self", ".", "state", "not", "in", "(", "self", ".", "REQUESTED", ",", "self", ".", "INSTALLED", ")", ":", "logger", ".", "warn", "(", "...
[ 142, 4 ]
[ 160, 59 ]
python
en
['en', 'ca', 'en']
True
AccessControlGrant.install
(self)
Installs the grant to the remote access control system.
Installs the grant to the remote access control system.
def install(self): """Installs the grant to the remote access control system. """ logger.info('[%s] Installing' % self) assert self.state == self.REQUESTED # Sanity check to make sure we don't try to install grants # for past reservations. if self.ends_at < timezo...
[ "def", "install", "(", "self", ")", ":", "logger", ".", "info", "(", "'[%s] Installing'", "%", "self", ")", "assert", "self", ".", "state", "==", "self", ".", "REQUESTED", "# Sanity check to make sure we don't try to install grants", "# for past reservations.", "if", ...
[ 162, 4 ]
[ 198, 79 ]
python
en
['en', 'en', 'en']
True
AccessControlGrant.remove
(self)
Removes the grant from the remote access control system.
Removes the grant from the remote access control system.
def remove(self): """Removes the grant from the remote access control system. """ logger.info('[%s] Removing' % self) assert self.state in (self.INSTALLED, self.CANCELLED) old_state = self.state with transaction.atomic(): db_self = AccessControlGrant.objects.s...
[ "def", "remove", "(", "self", ")", ":", "logger", ".", "info", "(", "'[%s] Removing'", "%", "self", ")", "assert", "self", ".", "state", "in", "(", "self", ".", "INSTALLED", ",", "self", ".", "CANCELLED", ")", "old_state", "=", "self", ".", "state", ...
[ 200, 4 ]
[ 227, 79 ]
python
en
['en', 'en', 'en']
True
AccessControlSystem.save_respa_resource
(self, resource: AccessControlResource, respa_resource: Resource)
Notify driver about saving a Respa resource Allows for driver-specific customization of the Respa resource or the corresponding access control resource. Called when the Respa resource object is saved. NOTE: The driver must not call `respa_resource.save()`. Saving the resource is handled...
Notify driver about saving a Respa resource
def save_respa_resource(self, resource: AccessControlResource, respa_resource: Resource): """Notify driver about saving a Respa resource Allows for driver-specific customization of the Respa resource or the corresponding access control resource. Called when the Respa resource object is saved. ...
[ "def", "save_respa_resource", "(", "self", ",", "resource", ":", "AccessControlResource", ",", "respa_resource", ":", "Resource", ")", ":", "self", ".", "_get_driver", "(", ")", ".", "save_respa_resource", "(", "resource", ",", "respa_resource", ")" ]
[ 387, 4 ]
[ 395, 72 ]
python
en
['en', 'en', 'en']
True
AccessControlSystem.save_resource
(self, resource: AccessControlResource)
Notify driver about saving an access control resource Allows for driver-specific customization of the access control resource or the corresponding Respa resource. Called when the access control resource is saved.
Notify driver about saving an access control resource
def save_resource(self, resource: AccessControlResource): """Notify driver about saving an access control resource Allows for driver-specific customization of the access control resource or the corresponding Respa resource. Called when the access control resource is saved. """ s...
[ "def", "save_resource", "(", "self", ",", "resource", ":", "AccessControlResource", ")", ":", "self", ".", "_get_driver", "(", ")", ".", "save_resource", "(", "resource", ")" ]
[ 397, 4 ]
[ 403, 50 ]
python
en
['en', 'en', 'en']
True
CustomManagersRegressTestCase.test_filtered_default_manager
(self)
Even though the default manager filters out some records, we must still be able to save (particularly, save by updating existing records) those filtered instances. This is a regression test for #8990, #9527
Even though the default manager filters out some records, we must still be able to save (particularly, save by updating existing records) those filtered instances. This is a regression test for #8990, #9527
def test_filtered_default_manager(self): """Even though the default manager filters out some records, we must still be able to save (particularly, save by updating existing records) those filtered instances. This is a regression test for #8990, #9527""" related = RelatedModel.obj...
[ "def", "test_filtered_default_manager", "(", "self", ")", ":", "related", "=", "RelatedModel", ".", "objects", ".", "create", "(", "name", "=", "\"xyzzy\"", ")", "obj", "=", "RestrictedModel", ".", "objects", ".", "create", "(", "name", "=", "\"hidden\"", ",...
[ 469, 4 ]
[ 481, 66 ]
python
en
['en', 'en', 'en']
True
CustomManagersRegressTestCase.test_delete_related_on_filtered_manager
(self)
Deleting related objects should also not be distracted by a restricted manager on the related object. This is a regression test for #2698.
Deleting related objects should also not be distracted by a restricted manager on the related object. This is a regression test for #2698.
def test_delete_related_on_filtered_manager(self): """Deleting related objects should also not be distracted by a restricted manager on the related object. This is a regression test for #2698.""" related = RelatedModel.objects.create(name="xyzzy") for name, public in (('one', Tr...
[ "def", "test_delete_related_on_filtered_manager", "(", "self", ")", ":", "related", "=", "RelatedModel", ".", "objects", ".", "create", "(", "name", "=", "\"xyzzy\"", ")", "for", "name", ",", "public", "in", "(", "(", "'one'", ",", "True", ")", ",", "(", ...
[ 483, 4 ]
[ 499, 69 ]
python
en
['en', 'en', 'en']
True
sha256
(s)
Return the SHA256 HEX digest related to the specified string.
Return the SHA256 HEX digest related to the specified string.
def sha256(s): """ Return the SHA256 HEX digest related to the specified string. """ m = hashlib.sha256() m.update(bytes(s,"utf-8")) return m.hexdigest()
[ "def", "sha256", "(", "s", ")", ":", "m", "=", "hashlib", ".", "sha256", "(", ")", "m", ".", "update", "(", "bytes", "(", "s", ",", "\"utf-8\"", ")", ")", "return", "m", ".", "hexdigest", "(", ")" ]
[ 122, 0 ]
[ 127, 24 ]
python
en
['en', 'en', 'en']
True
put_s3_object
(s3path, content)
s3path: Format must be s3://<bucketname>/<key>
s3path: Format must be s3://<bucketname>/<key>
def put_s3_object(s3path, content): """ s3path: Format must be s3://<bucketname>/<key> """ m = re.search("^s3://([-.\w]+)/(.*)", s3path) if len(m.groups()) != 2: return False bucket, key = [m.group(1), m.group(2)] key = "/".join([p for p in key.split("/") if p != ""]) # Remove extra '/' ...
[ "def", "put_s3_object", "(", "s3path", ",", "content", ")", ":", "m", "=", "re", ".", "search", "(", "\"^s3://([-.\\w]+)/(.*)\"", ",", "s3path", ")", "if", "len", "(", "m", ".", "groups", "(", ")", ")", "!=", "2", ":", "return", "False", "bucket", ",...
[ 240, 0 ]
[ 256, 20 ]
python
en
['en', 'en', 'sw']
True
discovery
(ctx)
Returns a discovery JSON dict of essential environment variables
Returns a discovery JSON dict of essential environment variables
def discovery(ctx): """ Returns a discovery JSON dict of essential environment variables """ context = ctx.copy() for k in ctx.keys(): if (k.startswith("AWS_") or k.startswith("_AWS_") or k.startswith("LAMBDA") or k.endswith("_SNSTopicArn") or k in ["_HANDLER", "...
[ "def", "discovery", "(", "ctx", ")", ":", "context", "=", "ctx", ".", "copy", "(", ")", "for", "k", "in", "ctx", ".", "keys", "(", ")", ":", "if", "(", "k", ".", "startswith", "(", "\"AWS_\"", ")", "or", "k", ".", "startswith", "(", "\"_AWS_\"", ...
[ 347, 0 ]
[ 357, 55 ]
python
en
['en', 'en', 'en']
True
supports_color
()
Returns True if the running system's terminal supports color, and False otherwise.
Returns True if the running system's terminal supports color, and False otherwise.
def supports_color(): """ Returns True if the running system's terminal supports color, and False otherwise. """ plat = sys.platform supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ) # isatty is not alw...
[ "def", "supports_color", "(", ")", ":", "plat", "=", "sys", ".", "platform", "supported_platform", "=", "plat", "!=", "'Pocket PC'", "and", "(", "plat", "!=", "'win32'", "or", "'ANSICON'", "in", "os", ".", "environ", ")", "# isatty is not always implemented, #62...
[ 10, 0 ]
[ 22, 15 ]
python
en
['en', 'error', 'th']
False
color_style
()
Returns a Style object with the Django color scheme.
Returns a Style object with the Django color scheme.
def color_style(): """Returns a Style object with the Django color scheme.""" if not supports_color(): style = no_style() else: DJANGO_COLORS = os.environ.get('DJANGO_COLORS', '') color_settings = termcolors.parse_color_setting(DJANGO_COLORS) if color_settings: cl...
[ "def", "color_style", "(", ")", ":", "if", "not", "supports_color", "(", ")", ":", "style", "=", "no_style", "(", ")", "else", ":", "DJANGO_COLORS", "=", "os", ".", "environ", ".", "get", "(", "'DJANGO_COLORS'", ",", "''", ")", "color_settings", "=", "...
[ 25, 0 ]
[ 47, 16 ]
python
en
['en', 'en', 'en']
True
no_style
()
Returns a Style object that has no colors.
Returns a Style object that has no colors.
def no_style(): """Returns a Style object that has no colors.""" class dummy: def __getattr__(self, attr): return lambda x: x return dummy()
[ "def", "no_style", "(", ")", ":", "class", "dummy", ":", "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "return", "lambda", "x", ":", "x", "return", "dummy", "(", ")" ]
[ 50, 0 ]
[ 55, 18 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.spatial_version
(self)
Determine the version of the PostGIS library.
Determine the version of the PostGIS library.
def spatial_version(self): """Determine the version of the PostGIS library.""" # Trying to get the PostGIS version because the function # signatures will depend on the version used. The cost # here is a database query to determine the version, which # can be mitigated by setting...
[ "def", "spatial_version", "(", "self", ")", ":", "# Trying to get the PostGIS version because the function", "# signatures will depend on the version used. The cost", "# here is a database query to determine the version, which", "# can be mitigated by setting `POSTGIS_VERSION` with a 3-tuple", ...
[ 158, 4 ]
[ 185, 22 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.convert_extent
(self, box)
Return a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)".
Return a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)".
def convert_extent(self, box): """ Return a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)". """ if box is None: return None ll, ur = box[4:-...
[ "def", "convert_extent", "(", "self", ",", "box", ")", ":", "if", "box", "is", "None", ":", "return", "None", "ll", ",", "ur", "=", "box", "[", "4", ":", "-", "1", "]", ".", "split", "(", "','", ")", "xmin", ",", "ymin", "=", "map", "(", "flo...
[ 187, 4 ]
[ 198, 39 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.convert_extent3d
(self, box3d)
Return a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)".
Return a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)".
def convert_extent3d(self, box3d): """ Return a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)". """ if box3d is None: return None ...
[ "def", "convert_extent3d", "(", "self", ",", "box3d", ")", ":", "if", "box3d", "is", "None", ":", "return", "None", "ll", ",", "ur", "=", "box3d", "[", "6", ":", "-", "1", "]", ".", "split", "(", "','", ")", "xmin", ",", "ymin", ",", "zmin", "=...
[ 200, 4 ]
[ 211, 51 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.geo_db_type
(self, f)
Return the database field type for the given spatial field.
Return the database field type for the given spatial field.
def geo_db_type(self, f): """ Return the database field type for the given spatial field. """ if f.geom_type == 'RASTER': return 'raster' # Type-based geometries. # TODO: Support 'M' extension. if f.dim == 3: geom_type = f.geom_type + 'Z' ...
[ "def", "geo_db_type", "(", "self", ",", "f", ")", ":", "if", "f", ".", "geom_type", "==", "'RASTER'", ":", "return", "'raster'", "# Type-based geometries.", "# TODO: Support 'M' extension.", "if", "f", ".", "dim", "==", "3", ":", "geom_type", "=", "f", ".", ...
[ 213, 4 ]
[ 232, 58 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.get_distance
(self, f, dist_val, lookup_type)
Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. This is the most complex implementation of the spatial backends due to what is supported on geodetic geometry columns vs. what's available on projected geometry c...
Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type.
def get_distance(self, f, dist_val, lookup_type): """ Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. This is the most complex implementation of the spatial backends due to what is supported on geodetic geometry...
[ "def", "get_distance", "(", "self", ",", "f", ",", "dist_val", ",", "lookup_type", ")", ":", "# Getting the distance parameter", "value", "=", "dist_val", "[", "0", "]", "# Shorthand boolean flags.", "geodetic", "=", "f", ".", "geodetic", "(", "self", ".", "co...
[ 234, 4 ]
[ 265, 27 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.get_geom_placeholder
(self, f, value, compiler)
Provide a proper substitution value for Geometries or rasters that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call.
Provide a proper substitution value for Geometries or rasters that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call.
def get_geom_placeholder(self, f, value, compiler): """ Provide a proper substitution value for Geometries or rasters that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call. """ transform_func = self.spatial_f...
[ "def", "get_geom_placeholder", "(", "self", ",", "f", ",", "value", ",", "compiler", ")", ":", "transform_func", "=", "self", ".", "spatial_function_name", "(", "'Transform'", ")", "if", "hasattr", "(", "value", ",", "'as_sql'", ")", ":", "if", "value", "....
[ 267, 4 ]
[ 294, 26 ]
python
en
['en', 'error', 'th']
False
PostGISOperations._get_postgis_func
(self, func)
Helper routine for calling PostGIS functions and returning their result.
Helper routine for calling PostGIS functions and returning their result.
def _get_postgis_func(self, func): """ Helper routine for calling PostGIS functions and returning their result. """ # Close out the connection. See #9437. with self.connection.temporary_connection() as cursor: cursor.execute('SELECT %s()' % func) return c...
[ "def", "_get_postgis_func", "(", "self", ",", "func", ")", ":", "# Close out the connection. See #9437.", "with", "self", ".", "connection", ".", "temporary_connection", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'SELECT %s()'", "%", "func", ...
[ 296, 4 ]
[ 303, 39 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.postgis_geos_version
(self)
Return the version of the GEOS library used with PostGIS.
Return the version of the GEOS library used with PostGIS.
def postgis_geos_version(self): "Return the version of the GEOS library used with PostGIS." return self._get_postgis_func('postgis_geos_version')
[ "def", "postgis_geos_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_geos_version'", ")" ]
[ 305, 4 ]
[ 307, 61 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_lib_version
(self)
Return the version number of the PostGIS library used with PostgreSQL.
Return the version number of the PostGIS library used with PostgreSQL.
def postgis_lib_version(self): "Return the version number of the PostGIS library used with PostgreSQL." return self._get_postgis_func('postgis_lib_version')
[ "def", "postgis_lib_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_lib_version'", ")" ]
[ 309, 4 ]
[ 311, 60 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_proj_version
(self)
Return the version of the PROJ.4 library used with PostGIS.
Return the version of the PROJ.4 library used with PostGIS.
def postgis_proj_version(self): "Return the version of the PROJ.4 library used with PostGIS." return self._get_postgis_func('postgis_proj_version')
[ "def", "postgis_proj_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_proj_version'", ")" ]
[ 313, 4 ]
[ 315, 61 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_version
(self)
Return PostGIS version number and compile-time options.
Return PostGIS version number and compile-time options.
def postgis_version(self): "Return PostGIS version number and compile-time options." return self._get_postgis_func('postgis_version')
[ "def", "postgis_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_version'", ")" ]
[ 317, 4 ]
[ 319, 56 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_full_version
(self)
Return PostGIS version number and compile-time options.
Return PostGIS version number and compile-time options.
def postgis_full_version(self): "Return PostGIS version number and compile-time options." return self._get_postgis_func('postgis_full_version')
[ "def", "postgis_full_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_full_version'", ")" ]
[ 321, 4 ]
[ 323, 61 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_version_tuple
(self)
Return the PostGIS version as a tuple (version string, major, minor, subminor).
Return the PostGIS version as a tuple (version string, major, minor, subminor).
def postgis_version_tuple(self): """ Return the PostGIS version as a tuple (version string, major, minor, subminor). """ version = self.postgis_lib_version() return (version,) + get_version_tuple(version)
[ "def", "postgis_version_tuple", "(", "self", ")", ":", "version", "=", "self", ".", "postgis_lib_version", "(", ")", "return", "(", "version", ",", ")", "+", "get_version_tuple", "(", "version", ")" ]
[ 325, 4 ]
[ 331, 54 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.proj_version_tuple
(self)
Return the version of PROJ.4 used by PostGIS as a tuple of the major, minor, and subminor release numbers.
Return the version of PROJ.4 used by PostGIS as a tuple of the major, minor, and subminor release numbers.
def proj_version_tuple(self): """ Return the version of PROJ.4 used by PostGIS as a tuple of the major, minor, and subminor release numbers. """ proj_regex = re.compile(r'(\d+)\.(\d+)\.(\d+)') proj_ver_str = self.postgis_proj_version() m = proj_regex.search(proj_v...
[ "def", "proj_version_tuple", "(", "self", ")", ":", "proj_regex", "=", "re", ".", "compile", "(", "r'(\\d+)\\.(\\d+)\\.(\\d+)'", ")", "proj_ver_str", "=", "self", ".", "postgis_proj_version", "(", ")", "m", "=", "proj_regex", ".", "search", "(", "proj_ver_str", ...
[ 333, 4 ]
[ 344, 79 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.parse_raster
(self, value)
Convert a PostGIS HEX String into a dict readable by GDALRaster.
Convert a PostGIS HEX String into a dict readable by GDALRaster.
def parse_raster(self, value): """Convert a PostGIS HEX String into a dict readable by GDALRaster.""" return from_pgraster(value)
[ "def", "parse_raster", "(", "self", ",", "value", ")", ":", "return", "from_pgraster", "(", "value", ")" ]
[ 359, 4 ]
[ 361, 35 ]
python
en
['en', 'en', 'en']
True
_populate_reservation
(reservation, ex_resource, item_props, ex_reservation=None)
Populate a Reservation instance based on Exchange data :type reservation: resources.models.Reservation :type ex_resource: respa_exchange.models.ExchangeResource :type item_props: dict :return:
Populate a Reservation instance based on Exchange data
def _populate_reservation(reservation, ex_resource, item_props, ex_reservation=None): """ Populate a Reservation instance based on Exchange data :type reservation: resources.models.Reservation :type ex_resource: respa_exchange.models.ExchangeResource :type item_props: dict :return: """ ...
[ "def", "_populate_reservation", "(", "reservation", ",", "ex_resource", ",", "item_props", ",", "ex_reservation", "=", "None", ")", ":", "reservation", ".", "begin", "=", "item_props", "[", "'start'", "]", "reservation", ".", "end", "=", "item_props", "[", "'e...
[ 28, 0 ]
[ 69, 39 ]
python
en
['en', 'error', 'th']
False
_find_exchange_user_by_mailbox
(ex_resource, mailbox, last_updated_at=None)
Try to find the ExchangeUser entry matching the organizer XML element Matching is attempted based on the organizer's email address and their X500 addresses. If a match can't be found, a ResolveNamesRequest is sent and the ExchangeUser model is updated based on the response.
Try to find the ExchangeUser entry matching the organizer XML element
def _find_exchange_user_by_mailbox(ex_resource, mailbox, last_updated_at=None): """Try to find the ExchangeUser entry matching the organizer XML element Matching is attempted based on the organizer's email address and their X500 addresses. If a match can't be found, a ResolveNamesRequest is sent and th...
[ "def", "_find_exchange_user_by_mailbox", "(", "ex_resource", ",", "mailbox", ",", "last_updated_at", "=", "None", ")", ":", "routing_type", "=", "mailbox", ".", "find", "(", "\"t:RoutingType\"", ",", "namespaces", "=", "NAMESPACES", ")", ".", "text", "user_identif...
[ 102, 0 ]
[ 222, 18 ]
python
en
['en', 'en', 'en']
True
sync_from_exchange
(ex_resource, future_days=365, no_op=False)
Synchronize from Exchange to Respa Synchronizes current and future events for the given Exchange resource into the relevant Respa resource as reservations. :param ex_resource: The Exchange resource to sync :type ex_resource: respa_exchange.models.ExchangeResource :param future_days: How many ...
Synchronize from Exchange to Respa
def sync_from_exchange(ex_resource, future_days=365, no_op=False): """ Synchronize from Exchange to Respa Synchronizes current and future events for the given Exchange resource into the relevant Respa resource as reservations. :param ex_resource: The Exchange resource to sync :type ex_resource...
[ "def", "sync_from_exchange", "(", "ex_resource", ",", "future_days", "=", "365", ",", "no_op", "=", "False", ")", ":", "# To avoid race conditions with the Respa API processes, we lock the", "# resource on database level before starting sync.", "ex_resource", "=", "ExchangeResour...
[ 306, 0 ]
[ 404, 77 ]
python
en
['en', 'error', 'th']
False
TestRuleList.test_paths_in_rules
(self)
Verifies that the paths mentioned in linter rules actually exist
Verifies that the paths mentioned in linter rules actually exist
def test_paths_in_rules(self) -> None: """Verifies that the paths mentioned in linter rules actually exist""" for rule in self.all_rules: for path in rule.get("exclude", {}): abs_path = os.path.abspath(os.path.join(ROOT_DIR, path)) self.assertTrue( ...
[ "def", "test_paths_in_rules", "(", "self", ")", "->", "None", ":", "for", "rule", "in", "self", ".", "all_rules", ":", "for", "path", "in", "rule", ".", "get", "(", "\"exclude\"", ",", "{", "}", ")", ":", "abs_path", "=", "os", ".", "path", ".", "a...
[ 19, 4 ]
[ 41, 21 ]
python
en
['en', 'en', 'en']
True
TestRuleList.test_rule_patterns
(self)
Verifies that the search regex specified in a custom rule actually matches the expectation and doesn't throw false positives.
Verifies that the search regex specified in a custom rule actually matches the expectation and doesn't throw false positives.
def test_rule_patterns(self) -> None: """Verifies that the search regex specified in a custom rule actually matches the expectation and doesn't throw false positives.""" for rule in self.all_rules: pattern = rule["pattern"] for line in rule.get("good_lines", []): ...
[ "def", "test_rule_patterns", "(", "self", ")", "->", "None", ":", "for", "rule", "in", "self", ".", "all_rules", ":", "pattern", "=", "rule", "[", "\"pattern\"", "]", "for", "line", "in", "rule", ".", "get", "(", "\"good_lines\"", ",", "[", "]", ")", ...
[ 43, 4 ]
[ 73, 21 ]
python
en
['en', 'en', 'en']
True
Hashes.__init__
(self, hashes=None)
:param hashes: A dict of algorithm names pointing to lists of allowed hex digests
:param hashes: A dict of algorithm names pointing to lists of allowed hex digests
def __init__(self, hashes=None): # type: (Dict[str, List[str]]) -> None """ :param hashes: A dict of algorithm names pointing to lists of allowed hex digests """ self._allowed = {} if hashes is None else hashes
[ "def", "__init__", "(", "self", ",", "hashes", "=", "None", ")", ":", "# type: (Dict[str, List[str]]) -> None", "self", ".", "_allowed", "=", "{", "}", "if", "hashes", "is", "None", "else", "hashes" ]
[ 40, 4 ]
[ 46, 56 ]
python
en
['en', 'error', 'th']
False
Hashes.is_hash_allowed
( self, hash_name, # type: str hex_digest, # type: str )
Return whether the given hex digest is allowed.
Return whether the given hex digest is allowed.
def is_hash_allowed( self, hash_name, # type: str hex_digest, # type: str ): # type: (...) -> bool """Return whether the given hex digest is allowed.""" return hex_digest in self._allowed.get(hash_name, [])
[ "def", "is_hash_allowed", "(", "self", ",", "hash_name", ",", "# type: str", "hex_digest", ",", "# type: str", ")", ":", "# type: (...) -> bool", "return", "hex_digest", "in", "self", ".", "_allowed", ".", "get", "(", "hash_name", ",", "[", "]", ")" ]
[ 53, 4 ]
[ 60, 61 ]
python
en
['en', 'en', 'en']
True
Hashes.check_against_chunks
(self, chunks)
Check good hashes against ones built from iterable of chunks of data. Raise HashMismatch if none match.
Check good hashes against ones built from iterable of chunks of data.
def check_against_chunks(self, chunks): # type: (Iterator[bytes]) -> None """Check good hashes against ones built from iterable of chunks of data. Raise HashMismatch if none match. """ gots = {} for hash_name in iterkeys(self._allowed): try: ...
[ "def", "check_against_chunks", "(", "self", ",", "chunks", ")", ":", "# type: (Iterator[bytes]) -> None", "gots", "=", "{", "}", "for", "hash_name", "in", "iterkeys", "(", "self", ".", "_allowed", ")", ":", "try", ":", "gots", "[", "hash_name", "]", "=", "...
[ 62, 4 ]
[ 86, 25 ]
python
en
['en', 'en', 'en']
True
Hashes.check_against_file
(self, file)
Check good hashes against a file-like object Raise HashMismatch if none match.
Check good hashes against a file-like object
def check_against_file(self, file): # type: (BinaryIO) -> None """Check good hashes against a file-like object Raise HashMismatch if none match. """ return self.check_against_chunks(read_chunks(file))
[ "def", "check_against_file", "(", "self", ",", "file", ")", ":", "# type: (BinaryIO) -> None", "return", "self", ".", "check_against_chunks", "(", "read_chunks", "(", "file", ")", ")" ]
[ 92, 4 ]
[ 99, 59 ]
python
en
['en', 'en', 'en']
True
Hashes.__nonzero__
(self)
Return whether I know any known-good hashes.
Return whether I know any known-good hashes.
def __nonzero__(self): # type: () -> bool """Return whether I know any known-good hashes.""" return bool(self._allowed)
[ "def", "__nonzero__", "(", "self", ")", ":", "# type: () -> bool", "return", "bool", "(", "self", ".", "_allowed", ")" ]
[ 106, 4 ]
[ 109, 34 ]
python
en
['en', 'en', 'en']
True
MissingHashes.__init__
(self)
Don't offer the ``hashes`` kwarg.
Don't offer the ``hashes`` kwarg.
def __init__(self): # type: () -> None """Don't offer the ``hashes`` kwarg.""" # Pass our favorite hash in to generate a "gotten hash". With the # empty list, it will never match, so an error will always raise. super(MissingHashes, self).__init__(hashes={FAVORITE_HASH: []})
[ "def", "__init__", "(", "self", ")", ":", "# type: () -> None", "# Pass our favorite hash in to generate a \"gotten hash\". With the", "# empty list, it will never match, so an error will always raise.", "super", "(", "MissingHashes", ",", "self", ")", ".", "__init__", "(", "hash...
[ 123, 4 ]
[ 128, 71 ]
python
en
['en', 'en', 'sw']
True
get_static_prefix
(parser, token)
Populate a template variable with the static prefix, ``settings.STATIC_URL``. Usage:: {% get_static_prefix [as varname] %} Examples:: {% get_static_prefix %} {% get_static_prefix as static_prefix %}
Populate a template variable with the static prefix, ``settings.STATIC_URL``.
def get_static_prefix(parser, token): """ Populate a template variable with the static prefix, ``settings.STATIC_URL``. Usage:: {% get_static_prefix [as varname] %} Examples:: {% get_static_prefix %} {% get_static_prefix as static_prefix %} """ return PrefixNode.h...
[ "def", "get_static_prefix", "(", "parser", ",", "token", ")", ":", "return", "PrefixNode", ".", "handle_token", "(", "parser", ",", "token", ",", "\"STATIC_URL\"", ")" ]
[ 57, 0 ]
[ 71, 63 ]
python
en
['en', 'error', 'th']
False
get_media_prefix
(parser, token)
Populate a template variable with the media prefix, ``settings.MEDIA_URL``. Usage:: {% get_media_prefix [as varname] %} Examples:: {% get_media_prefix %} {% get_media_prefix as media_prefix %}
Populate a template variable with the media prefix, ``settings.MEDIA_URL``.
def get_media_prefix(parser, token): """ Populate a template variable with the media prefix, ``settings.MEDIA_URL``. Usage:: {% get_media_prefix [as varname] %} Examples:: {% get_media_prefix %} {% get_media_prefix as media_prefix %} """ return PrefixNode.handle_t...
[ "def", "get_media_prefix", "(", "parser", ",", "token", ")", ":", "return", "PrefixNode", ".", "handle_token", "(", "parser", ",", "token", ",", "\"MEDIA_URL\"", ")" ]
[ 75, 0 ]
[ 89, 62 ]
python
en
['en', 'error', 'th']
False
do_static
(parser, token)
Join the given path with the STATIC_URL setting. Usage:: {% static path [as varname] %} Examples:: {% static "myapp/css/base.css" %} {% static variable_with_path %} {% static "myapp/css/base.css" as admin_base_css %} {% static variable_with_path as varname %} ...
Join the given path with the STATIC_URL setting.
def do_static(parser, token): """ Join the given path with the STATIC_URL setting. Usage:: {% static path [as varname] %} Examples:: {% static "myapp/css/base.css" %} {% static variable_with_path %} {% static "myapp/css/base.css" as admin_base_css %} {% static...
[ "def", "do_static", "(", "parser", ",", "token", ")", ":", "return", "StaticNode", ".", "handle_token", "(", "parser", ",", "token", ")" ]
[ 143, 0 ]
[ 158, 49 ]
python
en
['en', 'error', 'th']
False
static
(path)
Given a relative path to a static asset, return the absolute path to the asset.
Given a relative path to a static asset, return the absolute path to the asset.
def static(path): """ Given a relative path to a static asset, return the absolute path to the asset. """ return StaticNode.handle_simple(path)
[ "def", "static", "(", "path", ")", ":", "return", "StaticNode", ".", "handle_simple", "(", "path", ")" ]
[ 161, 0 ]
[ 166, 41 ]
python
en
['en', 'error', 'th']
False
PrefixNode.handle_token
(cls, parser, token, name)
Class method to parse prefix node and return a Node.
Class method to parse prefix node and return a Node.
def handle_token(cls, parser, token, name): """ Class method to parse prefix node and return a Node. """ # token.split_contents() isn't useful here because tags using this method don't accept variable as arguments tokens = token.contents.split() if len(tokens) > 1 and tok...
[ "def", "handle_token", "(", "cls", ",", "parser", ",", "token", ",", "name", ")", ":", "# token.split_contents() isn't useful here because tags using this method don't accept variable as arguments", "tokens", "=", "token", ".", "contents", ".", "split", "(", ")", "if", ...
[ 23, 4 ]
[ 36, 33 ]
python
en
['en', 'error', 'th']
False
StaticNode.handle_token
(cls, parser, token)
Class method to parse prefix node and return a Node.
Class method to parse prefix node and return a Node.
def handle_token(cls, parser, token): """ Class method to parse prefix node and return a Node. """ bits = token.split_contents() if len(bits) < 2: raise template.TemplateSyntaxError( "'%s' takes at least one argument (path to file)" % bits[0]) ...
[ "def", "handle_token", "(", "cls", ",", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "\"'%s' takes at least one ...
[ 122, 4 ]
[ 139, 33 ]
python
en
['en', 'error', 'th']
False
unify_device_name
(dname)
Converts TensorFlow device names in the format /Device:GPU0 to /gpu:0.
Converts TensorFlow device names in the format /Device:GPU0 to /gpu:0.
def unify_device_name(dname): """Converts TensorFlow device names in the format /Device:GPU0 to /gpu:0.""" if dname is None: return None return dname.lower().replace("device:", "")
[ "def", "unify_device_name", "(", "dname", ")", ":", "if", "dname", "is", "None", ":", "return", "None", "return", "dname", ".", "lower", "(", ")", ".", "replace", "(", "\"device:\"", ",", "\"\"", ")" ]
[ 20, 0 ]
[ 24, 47 ]
python
en
['en', 'en', 'en']
True
MLPnGPU.set_device
(self, device_name)
Set the device before the next fprop to create a new graph on the specified device.
Set the device before the next fprop to create a new graph on the specified device.
def set_device(self, device_name): """ Set the device before the next fprop to create a new graph on the specified device. """ device_name = unify_device_name(device_name) self.device_name = device_name for layer in self.layers: layer.device_name = dev...
[ "def", "set_device", "(", "self", ",", "device_name", ")", ":", "device_name", "=", "unify_device_name", "(", "device_name", ")", "self", ".", "device_name", "=", "device_name", "for", "layer", "in", "self", ".", "layers", ":", "layer", ".", "device_name", "...
[ 199, 4 ]
[ 207, 43 ]
python
en
['en', 'error', 'th']
False
MLPnGPU.create_sync_ops
(self, host_device)
Return a list of assignment operations that syncs the parameters of all model copies with the one on host_device. :param host_device: (required str) the name of the device with latest parameters
Return a list of assignment operations that syncs the parameters of all model copies with the one on host_device. :param host_device: (required str) the name of the device with latest parameters
def create_sync_ops(self, host_device): """ Return a list of assignment operations that syncs the parameters of all model copies with the one on host_device. :param host_device: (required str) the name of the device with latest parameters """ h...
[ "def", "create_sync_ops", "(", "self", ",", "host_device", ")", ":", "host_device", "=", "unify_device_name", "(", "host_device", ")", "sync_ops", "=", "[", "]", "for", "layer", "in", "self", ".", "layers", ":", "if", "isinstance", "(", "layer", ",", "Laye...
[ 209, 4 ]
[ 221, 23 ]
python
en
['en', 'error', 'th']
False
LayernGPU.__init__
(self)
:param input_shape: a tuple or list as the input shape to layer
:param input_shape: a tuple or list as the input shape to layer
def __init__(self): """ :param input_shape: a tuple or list as the input shape to layer """ self.input_shape = None self.params_device = {} self.params_names = None self.device_name = "/gpu:0" self.training = True
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "input_shape", "=", "None", "self", ".", "params_device", "=", "{", "}", "self", ".", "params_names", "=", "None", "self", ".", "device_name", "=", "\"/gpu:0\"", "self", ".", "training", "=", "True" ...
[ 234, 4 ]
[ 242, 28 ]
python
en
['en', 'error', 'th']
False
LayernGPU.get_variable
(self, name, initializer)
Create and initialize a variable using a numpy array and set trainable. :param name: (required str) name of the variable :param initializer: a numpy array or a tensor
Create and initialize a variable using a numpy array and set trainable. :param name: (required str) name of the variable :param initializer: a numpy array or a tensor
def get_variable(self, name, initializer): """ Create and initialize a variable using a numpy array and set trainable. :param name: (required str) name of the variable :param initializer: a numpy array or a tensor """ v = tf.get_variable( name, sha...
[ "def", "get_variable", "(", "self", ",", "name", ",", "initializer", ")", ":", "v", "=", "tf", ".", "get_variable", "(", "name", ",", "shape", "=", "initializer", ".", "shape", ",", "initializer", "=", "(", "lambda", "shape", ",", "dtype", ",", "partit...
[ 247, 4 ]
[ 259, 16 ]
python
en
['en', 'error', 'th']
False
LayernGPU.set_input_shape_ngpu
(self, new_input_shape)
Create and initialize layer parameters on the device previously set in self.device_name. :param new_input_shape: a list or tuple for the shape of the input.
Create and initialize layer parameters on the device previously set in self.device_name.
def set_input_shape_ngpu(self, new_input_shape): """ Create and initialize layer parameters on the device previously set in self.device_name. :param new_input_shape: a list or tuple for the shape of the input. """ assert self.device_name, "Device name has not been set." ...
[ "def", "set_input_shape_ngpu", "(", "self", ",", "new_input_shape", ")", ":", "assert", "self", ".", "device_name", ",", "\"Device name has not been set.\"", "device_name", "=", "self", ".", "device_name", "if", "self", ".", "input_shape", "is", "None", ":", "# Fi...
[ 261, 4 ]
[ 293, 52 ]
python
en
['en', 'error', 'th']
False
LayernGPU.create_sync_ops
(self, host_device)
Create an assignment operation for each weight on all devices. The weight is assigned the value of the copy on the `host_device'.
Create an assignment operation for each weight on all devices. The weight is assigned the value of the copy on the `host_device'.
def create_sync_ops(self, host_device): """Create an assignment operation for each weight on all devices. The weight is assigned the value of the copy on the `host_device'. """ sync_ops = [] host_params = self.params_device[host_device] for device, params in (self.params_...
[ "def", "create_sync_ops", "(", "self", ",", "host_device", ")", ":", "sync_ops", "=", "[", "]", "host_params", "=", "self", ".", "params_device", "[", "host_device", "]", "for", "device", ",", "params", "in", "(", "self", ".", "params_device", ")", ".", ...
[ 295, 4 ]
[ 307, 23 ]
python
en
['en', 'en', 'en']
True
looks_like_ci
()
Return whether it looks like pip is running under CI.
Return whether it looks like pip is running under CI.
def looks_like_ci(): # type: () -> bool """ Return whether it looks like pip is running under CI. """ # We don't use the method of checking for a tty (e.g. using isatty()) # because some CI systems mimic a tty (e.g. Travis CI). Thus that # method doesn't provide definitive information in ei...
[ "def", "looks_like_ci", "(", ")", ":", "# type: () -> bool", "# We don't use the method of checking for a tty (e.g. using isatty())", "# because some CI systems mimic a tty (e.g. Travis CI). Thus that", "# method doesn't provide definitive information in either direction.", "return", "any", "...
[ 87, 0 ]
[ 95, 71 ]
python
en
['en', 'error', 'th']
False
user_agent
()
Return a string representing the user agent.
Return a string representing the user agent.
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": __version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["impl...
[ "def", "user_agent", "(", ")", ":", "data", "=", "{", "\"installer\"", ":", "{", "\"name\"", ":", "\"pip\"", ",", "\"version\"", ":", "__version__", "}", ",", "\"python\"", ":", "platform", ".", "python_version", "(", ")", ",", "\"implementation\"", ":", "...
[ 98, 0 ]
[ 175, 5 ]
python
en
['en', 'error', 'th']
False
PipSession.__init__
(self, *args, **kwargs)
:param trusted_hosts: Domains not to emit warnings for when not using HTTPS.
:param trusted_hosts: Domains not to emit warnings for when not using HTTPS.
def __init__(self, *args, **kwargs): """ :param trusted_hosts: Domains not to emit warnings for when not using HTTPS. """ retries = kwargs.pop("retries", 0) cache = kwargs.pop("cache", None) trusted_hosts = kwargs.pop("trusted_hosts", []) # type: List[str] ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "retries", "=", "kwargs", ".", "pop", "(", "\"retries\"", ",", "0", ")", "cache", "=", "kwargs", ".", "pop", "(", "\"cache\"", ",", "None", ")", "trusted_hosts", "...
[ 231, 4 ]
[ 305, 62 ]
python
en
['en', 'error', 'th']
False
PipSession.add_trusted_host
(self, host, source=None, suppress_logging=False)
:param host: It is okay to provide a host that has previously been added. :param source: An optional source string, for logging where the host string came from.
:param host: It is okay to provide a host that has previously been added. :param source: An optional source string, for logging where the host string came from.
def add_trusted_host(self, host, source=None, suppress_logging=False): # type: (str, Optional[str], bool) -> None """ :param host: It is okay to provide a host that has previously been added. :param source: An optional source string, for logging where the host str...
[ "def", "add_trusted_host", "(", "self", ",", "host", ",", "source", "=", "None", ",", "suppress_logging", "=", "False", ")", ":", "# type: (str, Optional[str], bool) -> None", "if", "not", "suppress_logging", ":", "msg", "=", "'adding trusted host: {!r}'", ".", "for...
[ 307, 4 ]
[ 334, 13 ]
python
en
['en', 'error', 'th']
False
FallbackStorage._get
(self, *args, **kwargs)
Get a single list of messages from all storage backends.
Get a single list of messages from all storage backends.
def _get(self, *args, **kwargs): """ Get a single list of messages from all storage backends. """ all_messages = [] for storage in self.storages: messages, all_retrieved = storage._get() # If the backend hasn't been used, no more retrieval is necessary. ...
[ "def", "_get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "all_messages", "=", "[", "]", "for", "storage", "in", "self", ".", "storages", ":", "messages", ",", "all_retrieved", "=", "storage", ".", "_get", "(", ")", "# If the b...
[ 18, 4 ]
[ 35, 42 ]
python
en
['en', 'error', 'th']
False
FallbackStorage._store
(self, messages, response, *args, **kwargs)
Store the messages and return any unstored messages after trying all backends. For each storage backend, any messages not stored are passed on to the next backend.
Store the messages and return any unstored messages after trying all backends.
def _store(self, messages, response, *args, **kwargs): """ Store the messages and return any unstored messages after trying all backends. For each storage backend, any messages not stored are passed on to the next backend. """ for storage in self.storages: ...
[ "def", "_store", "(", "self", ",", "messages", ",", "response", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "storage", "in", "self", ".", "storages", ":", "if", "messages", ":", "messages", "=", "storage", ".", "_store", "(", "message...
[ 37, 4 ]
[ 53, 23 ]
python
en
['en', 'error', 'th']
False
no_backend
(test_func, backend)
Use this decorator to disable test on specified backend.
Use this decorator to disable test on specified backend.
def no_backend(test_func, backend): "Use this decorator to disable test on specified backend." if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend: @skip("This test is skipped on '%s' backend" % backend) def inner(): pass return inner else: ...
[ "def", "no_backend", "(", "test_func", ",", "backend", ")", ":", "if", "settings", ".", "DATABASES", "[", "DEFAULT_DB_ALIAS", "]", "[", "'ENGINE'", "]", ".", "rsplit", "(", "'.'", ")", "[", "-", "1", "]", "==", "backend", ":", "@", "skip", "(", "\"Th...
[ 6, 0 ]
[ 14, 24 ]
python
en
['en', 'en', 'en']
True
delete_selected
(modeladmin, request, queryset)
Default action which deletes the selected objects. This action first displays a confirmation page whichs shows all the deleteable objects, or, if the user has no permission one of the related childs (foreignkeys), a "permission denied" message. Next, it deletes all selected objects and redirects ...
Default action which deletes the selected objects.
def delete_selected(modeladmin, request, queryset): """ Default action which deletes the selected objects. This action first displays a confirmation page whichs shows all the deleteable objects, or, if the user has no permission one of the related childs (foreignkeys), a "permission denied" message...
[ "def", "delete_selected", "(", "modeladmin", ",", "request", ",", "queryset", ")", ":", "opts", "=", "modeladmin", ".", "model", ".", "_meta", "app_label", "=", "opts", ".", "app_label", "# Check that the user has delete permission for the actual model", "if", "not", ...
[ 14, 0 ]
[ 82, 55 ]
python
en
['en', 'error', 'th']
False
DatetimeTests.test_zero_padding
(self)
Regression for #12524 Check that pre-1000AD dates are padded with zeros if necessary
Regression for #12524
def test_zero_padding(self): """ Regression for #12524 Check that pre-1000AD dates are padded with zeros if necessary """ self.assertEqual(date(1, 1, 1).strftime("%Y/%m/%d was a %A"), '0001/01/01 was a Monday')
[ "def", "test_zero_padding", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "date", "(", "1", ",", "1", ",", "1", ")", ".", "strftime", "(", "\"%Y/%m/%d was a %A\"", ")", ",", "'0001/01/01 was a Monday'", ")" ]
[ 36, 4 ]
[ 42, 96 ]
python
en
['en', 'error', 'th']
False
contextmanager
(func)
@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <b...
@contextmanager decorator.
def contextmanager(func): """@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<argument...
[ "def", "contextmanager", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "helper", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "return", "_GeneratorContextManager", "(", "func", ",", "args", ",", "kwds", ")", "return", "helper" ]
[ 184, 0 ]
[ 215, 17 ]
python
da
['da', 'su', 'it']
False
AbstractContextManager.__enter__
(self)
Return `self` upon entering the runtime context.
Return `self` upon entering the runtime context.
def __enter__(self): """Return `self` upon entering the runtime context.""" return self
[ "def", "__enter__", "(", "self", ")", ":", "return", "self" ]
[ 55, 4 ]
[ 57, 19 ]
python
en
['en', 'en', 'en']
True
AbstractContextManager.__exit__
(self, exc_type, exc_value, traceback)
Raise any exception triggered within the runtime context.
Raise any exception triggered within the runtime context.
def __exit__(self, exc_type, exc_value, traceback): """Raise any exception triggered within the runtime context.""" return None
[ "def", "__exit__", "(", "self", ",", "exc_type", ",", "exc_value", ",", "traceback", ")", ":", "return", "None" ]
[ 60, 4 ]
[ 62, 19 ]
python
en
['en', 'en', 'en']
True
AbstractContextManager.__subclasshook__
(cls, C)
Check whether subclass is considered a subclass of this ABC.
Check whether subclass is considered a subclass of this ABC.
def __subclasshook__(cls, C): """Check whether subclass is considered a subclass of this ABC.""" if cls is AbstractContextManager: return _check_methods(C, "__enter__", "__exit__") return NotImplemented
[ "def", "__subclasshook__", "(", "cls", ",", "C", ")", ":", "if", "cls", "is", "AbstractContextManager", ":", "return", "_check_methods", "(", "C", ",", "\"__enter__\"", ",", "\"__exit__\"", ")", "return", "NotImplemented" ]
[ 65, 4 ]
[ 69, 29 ]
python
en
['en', 'en', 'en']
True
ContextDecorator.refresh_cm
(self)
Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decorators via implicit recrea...
Returns the context manager used to actually wrap the call to the decorated function.
def refresh_cm(self): """Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decor...
[ "def", "refresh_cm", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"refresh_cm was never added to the standard library\"", ",", "DeprecationWarning", ")", "return", "self", ".", "_recreate_cm", "(", ")" ]
[ 75, 4 ]
[ 90, 34 ]
python
en
['en', 'en', 'en']
True
ContextDecorator._recreate_cm
(self)
Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11647 for details.
Return a recreated instance of self.
def _recreate_cm(self): """Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11...
[ "def", "_recreate_cm", "(", "self", ")", ":", "return", "self" ]
[ 92, 4 ]
[ 102, 19 ]
python
en
['en', 'en', 'en']
True
ExitStack.pop_all
(self)
Preserve the context stack by transferring it to a new instance
Preserve the context stack by transferring it to a new instance
def pop_all(self): """Preserve the context stack by transferring it to a new instance""" new_stack = type(self)() new_stack._exit_callbacks = self._exit_callbacks self._exit_callbacks = deque() return new_stack
[ "def", "pop_all", "(", "self", ")", ":", "new_stack", "=", "type", "(", "self", ")", "(", ")", "new_stack", ".", "_exit_callbacks", "=", "self", ".", "_exit_callbacks", "self", ".", "_exit_callbacks", "=", "deque", "(", ")", "return", "new_stack" ]
[ 385, 4 ]
[ 390, 24 ]
python
en
['en', 'en', 'en']
True
ExitStack._push_cm_exit
(self, cm, cm_exit)
Helper to correctly register callbacks to __exit__ methods
Helper to correctly register callbacks to __exit__ methods
def _push_cm_exit(self, cm, cm_exit): """Helper to correctly register callbacks to __exit__ methods""" def _exit_wrapper(*exc_details): return cm_exit(cm, *exc_details) _exit_wrapper.__self__ = cm self.push(_exit_wrapper)
[ "def", "_push_cm_exit", "(", "self", ",", "cm", ",", "cm_exit", ")", ":", "def", "_exit_wrapper", "(", "*", "exc_details", ")", ":", "return", "cm_exit", "(", "cm", ",", "*", "exc_details", ")", "_exit_wrapper", ".", "__self__", "=", "cm", "self", ".", ...
[ 392, 4 ]
[ 397, 32 ]
python
en
['en', 'en', 'en']
True
ExitStack.push
(self, exit)
Registers a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself)
Registers a callback with the standard __exit__ method signature
def push(self, exit): """Registers a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself) """ # We ...
[ "def", "push", "(", "self", ",", "exit", ")", ":", "# We use an unbound method rather than a bound method to follow", "# the standard lookup behaviour for special methods", "_cb_type", "=", "_get_type", "(", "exit", ")", "try", ":", "exit_method", "=", "_cb_type", ".", "_...
[ 399, 4 ]
[ 417, 19 ]
python
en
['en', 'en', 'en']
True
ExitStack.callback
(self, callback, *args, **kwds)
Registers an arbitrary callback and arguments. Cannot suppress exceptions.
Registers an arbitrary callback and arguments.
def callback(self, callback, *args, **kwds): """Registers an arbitrary callback and arguments. Cannot suppress exceptions. """ def _exit_wrapper(exc_type, exc, tb): callback(*args, **kwds) # We changed the signature, so using @wraps is not appropriate, but # ...
[ "def", "callback", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "def", "_exit_wrapper", "(", "exc_type", ",", "exc", ",", "tb", ")", ":", "callback", "(", "*", "args", ",", "*", "*", "kwds", ")", "# We changed th...
[ 419, 4 ]
[ 430, 23 ]
python
en
['en', 'en', 'en']
True
ExitStack.enter_context
(self, cm)
Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method.
Enters the supplied context manager
def enter_context(self, cm): """Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method. """ # We look up the special methods on the type to match the with statement _cm_type = _get_t...
[ "def", "enter_context", "(", "self", ",", "cm", ")", ":", "# We look up the special methods on the type to match the with statement", "_cm_type", "=", "_get_type", "(", "cm", ")", "_exit", "=", "_cm_type", ".", "__exit__", "result", "=", "_cm_type", ".", "__enter__", ...
[ 432, 4 ]
[ 443, 21 ]
python
en
['en', 'en', 'en']
True
ExitStack.close
(self)
Immediately unwind the context stack
Immediately unwind the context stack
def close(self): """Immediately unwind the context stack""" self.__exit__(None, None, None)
[ "def", "close", "(", "self", ")", ":", "self", ".", "__exit__", "(", "None", ",", "None", ",", "None", ")" ]
[ 445, 4 ]
[ 447, 39 ]
python
en
['en', 'en', 'en']
True
urlsafe_b64encode
(data)
urlsafe_b64encode without padding
urlsafe_b64encode without padding
def urlsafe_b64encode(data): """urlsafe_b64encode without padding""" return base64.urlsafe_b64encode(data).rstrip(b'=')
[ "def", "urlsafe_b64encode", "(", "data", ")", ":", "return", "base64", ".", "urlsafe_b64encode", "(", "data", ")", ".", "rstrip", "(", "b'='", ")" ]
[ 25, 0 ]
[ 27, 54 ]
python
en
['en', 'zu', 'en']
True