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
Chatters.__iter__
(self)
Iterate over all chatters :return: Yield chatter
Iterate over all chatters :return: Yield chatter
def __iter__(self) -> Generator['tmi.Chatter', None, None]: """ Iterate over all chatters :return: Yield chatter """ for chatter in self.all(): yield chatter
[ "def", "__iter__", "(", "self", ")", "->", "Generator", "[", "'tmi.Chatter'", ",", "None", ",", "None", "]", ":", "for", "chatter", "in", "self", ".", "all", "(", ")", ":", "yield", "chatter" ]
[ 49, 4 ]
[ 55, 25 ]
python
en
['en', 'error', 'th']
False
Chatters.__getitem__
(self, index: int)
Get chatter by index :param index: Index :return: Chatter
Get chatter by index :param index: Index :return: Chatter
def __getitem__(self, index: int) -> 'tmi.Chatter': """ Get chatter by index :param index: Index :return: Chatter """ return self.all()[index]
[ "def", "__getitem__", "(", "self", ",", "index", ":", "int", ")", "->", "'tmi.Chatter'", ":", "return", "self", ".", "all", "(", ")", "[", "index", "]" ]
[ 57, 4 ]
[ 63, 32 ]
python
en
['en', 'error', 'th']
False
Command.__init__
(self, dist)
Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated.
Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated.
def __init__(self, dist): """Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated. """ # late import because of mutual dependence betwee...
[ "def", "__init__", "(", "self", ",", "dist", ")", ":", "# late import because of mutual dependence between these classes", "from", "distutils", ".", "dist", "import", "Distribution", "if", "not", "isinstance", "(", "dist", ",", "Distribution", ")", ":", "raise", "Ty...
[ 46, 4 ]
[ 91, 26 ]
python
en
['en', 'en', 'en']
True
Command.initialize_options
(self)
Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, 'initialize_option...
Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, 'initialize_option...
def initialize_options(self): """Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies betwe...
[ "def", "initialize_options", "(", "self", ")", ":", "raise", "RuntimeError", "(", "\"abstract method -- subclass %s must override\"", "%", "self", ".", "__class__", ")" ]
[ 122, 4 ]
[ 133, 44 ]
python
en
['en', 'en', 'en']
True
Command.finalize_options
(self)
Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if 'foo' depends on 'bar', then...
Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if 'foo' depends on 'bar', then...
def finalize_options(self): """Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: ...
[ "def", "finalize_options", "(", "self", ")", ":", "raise", "RuntimeError", "(", "\"abstract method -- subclass %s must override\"", "%", "self", ".", "__class__", ")" ]
[ 135, 4 ]
[ 147, 44 ]
python
en
['en', 'en', 'en']
True
Command.run
(self)
A command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files, and finalized in 'finalize_options()'. All terminal output and files...
A command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files, and finalized in 'finalize_options()'. All terminal output and files...
def run(self): """A command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files, and finalized in 'finalize_options()'. All...
[ "def", "run", "(", "self", ")", ":", "raise", "RuntimeError", "(", "\"abstract method -- subclass %s must override\"", "%", "self", ".", "__class__", ")" ]
[ 164, 4 ]
[ 175, 44 ]
python
en
['en', 'fr', 'en']
True
Command.announce
(self, msg, level=1)
If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout.
If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout.
def announce(self, msg, level=1): """If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout. """ log.log(level, msg)
[ "def", "announce", "(", "self", ",", "msg", ",", "level", "=", "1", ")", ":", "log", ".", "log", "(", "level", ",", "msg", ")" ]
[ 177, 4 ]
[ 181, 27 ]
python
en
['en', 'en', 'en']
True
Command.debug_print
(self, msg)
Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true.
Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true.
def debug_print(self, msg): """Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. """ from distutils.debug import DEBUG if DEBUG: print(msg) sys.stdout.flush()
[ "def", "debug_print", "(", "self", ",", "msg", ")", ":", "from", "distutils", ".", "debug", "import", "DEBUG", "if", "DEBUG", ":", "print", "(", "msg", ")", "sys", ".", "stdout", ".", "flush", "(", ")" ]
[ 183, 4 ]
[ 190, 30 ]
python
en
['en', 'en', 'en']
True
Command.ensure_string
(self, option, default=None)
Ensure that 'option' is a string; if not defined, set it to 'default'.
Ensure that 'option' is a string; if not defined, set it to 'default'.
def ensure_string(self, option, default=None): """Ensure that 'option' is a string; if not defined, set it to 'default'. """ self._ensure_stringlike(option, "string", default)
[ "def", "ensure_string", "(", "self", ",", "option", ",", "default", "=", "None", ")", ":", "self", ".", "_ensure_stringlike", "(", "option", ",", "\"string\"", ",", "default", ")" ]
[ 216, 4 ]
[ 220, 58 ]
python
en
['en', 'en', 'en']
True
Command.ensure_string_list
(self, option)
r"""Ensure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"].
r"""Ensure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"].
def ensure_string_list(self, option): r"""Ensure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"]. """ val = getattr(self, ...
[ "def", "ensure_string_list", "(", "self", ",", "option", ")", ":", "val", "=", "getattr", "(", "self", ",", "option", ")", "if", "val", "is", "None", ":", "return", "elif", "isinstance", "(", "val", ",", "str", ")", ":", "setattr", "(", "self", ",", ...
[ 222, 4 ]
[ 241, 38 ]
python
en
['en', 'en', 'en']
True
Command.ensure_filename
(self, option)
Ensure that 'option' is the name of an existing file.
Ensure that 'option' is the name of an existing file.
def ensure_filename(self, option): """Ensure that 'option' is the name of an existing file.""" self._ensure_tested_string(option, os.path.isfile, "filename", "'%s' does not exist or is not a file")
[ "def", "ensure_filename", "(", "self", ",", "option", ")", ":", "self", ".", "_ensure_tested_string", "(", "option", ",", "os", ".", "path", ".", "isfile", ",", "\"filename\"", ",", "\"'%s' does not exist or is not a file\"", ")" ]
[ 250, 4 ]
[ 254, 74 ]
python
en
['en', 'en', 'en']
True
Command.set_undefined_options
(self, src_cmd, *option_pairs)
Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'initialize_options()' and 'finalize_options()'. Usually calle...
Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'initialize_options()' and 'finalize_options()'. Usually calle...
def set_undefined_options(self, src_cmd, *option_pairs): """Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'in...
[ "def", "set_undefined_options", "(", "self", ",", "src_cmd", ",", "*", "option_pairs", ")", ":", "# Option_pairs: list of (src_option, dst_option) tuples", "src_cmd_obj", "=", "self", ".", "distribution", ".", "get_command_obj", "(", "src_cmd", ")", "src_cmd_obj", ".", ...
[ 270, 4 ]
[ 289, 75 ]
python
en
['en', 'en', 'en']
True
Command.get_finalized_command
(self, command, create=1)
Wrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object.
Wrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object.
def get_finalized_command(self, command, create=1): """Wrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object. """ ...
[ "def", "get_finalized_command", "(", "self", ",", "command", ",", "create", "=", "1", ")", ":", "cmd_obj", "=", "self", ".", "distribution", ".", "get_command_obj", "(", "command", ",", "create", ")", "cmd_obj", ".", "ensure_finalized", "(", ")", "return", ...
[ 291, 4 ]
[ 299, 22 ]
python
en
['en', 'de', 'en']
True
Command.run_command
(self, command)
Run some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method.
Run some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method.
def run_command(self, command): """Run some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method. """ self.distribution.run_command(command)
[ "def", "run_command", "(", "self", ",", "command", ")", ":", "self", ".", "distribution", ".", "run_command", "(", "command", ")" ]
[ 307, 4 ]
[ 312, 46 ]
python
en
['en', 'en', 'en']
True
Command.get_sub_commands
(self)
Determine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be run for the current distribution...
Determine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be run for the current distribution...
def get_sub_commands(self): """Determine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be ...
[ "def", "get_sub_commands", "(", "self", ")", ":", "commands", "=", "[", "]", "for", "(", "cmd_name", ",", "method", ")", "in", "self", ".", "sub_commands", ":", "if", "method", "is", "None", "or", "method", "(", "self", ")", ":", "commands", ".", "ap...
[ 314, 4 ]
[ 325, 23 ]
python
en
['en', 'en', 'en']
True
Command.copy_file
(self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1)
Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)
Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)
def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1): """Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't ...
[ "def", "copy_file", "(", "self", ",", "infile", ",", "outfile", ",", "preserve_mode", "=", "1", ",", "preserve_times", "=", "1", ",", "link", "=", "None", ",", "level", "=", "1", ")", ":", "return", "file_util", ".", "copy_file", "(", "infile", ",", ...
[ 339, 4 ]
[ 346, 56 ]
python
en
['en', 'en', 'en']
True
Command.copy_tree
(self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1)
Copy an entire directory tree respecting verbose, dry-run, and force flags.
Copy an entire directory tree respecting verbose, dry-run, and force flags.
def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1): """Copy an entire directory tree respecting verbose, dry-run, and force flags. """ return dir_util.copy_tree(infile, outfile, preserve_mode, ...
[ "def", "copy_tree", "(", "self", ",", "infile", ",", "outfile", ",", "preserve_mode", "=", "1", ",", "preserve_times", "=", "1", ",", "preserve_symlinks", "=", "0", ",", "level", "=", "1", ")", ":", "return", "dir_util", ".", "copy_tree", "(", "infile", ...
[ 348, 4 ]
[ 355, 71 ]
python
en
['en', 'en', 'en']
True
Command.move_file
(self, src, dst, level=1)
Move a file respecting dry-run flag.
Move a file respecting dry-run flag.
def move_file (self, src, dst, level=1): """Move a file respecting dry-run flag.""" return file_util.move_file(src, dst, dry_run=self.dry_run)
[ "def", "move_file", "(", "self", ",", "src", ",", "dst", ",", "level", "=", "1", ")", ":", "return", "file_util", ".", "move_file", "(", "src", ",", "dst", ",", "dry_run", "=", "self", ".", "dry_run", ")" ]
[ 357, 4 ]
[ 359, 66 ]
python
en
['id', 'en', 'en']
True
Command.spawn
(self, cmd, search_path=1, level=1)
Spawn an external command respecting dry-run flag.
Spawn an external command respecting dry-run flag.
def spawn(self, cmd, search_path=1, level=1): """Spawn an external command respecting dry-run flag.""" from distutils.spawn import spawn spawn(cmd, search_path, dry_run=self.dry_run)
[ "def", "spawn", "(", "self", ",", "cmd", ",", "search_path", "=", "1", ",", "level", "=", "1", ")", ":", "from", "distutils", ".", "spawn", "import", "spawn", "spawn", "(", "cmd", ",", "search_path", ",", "dry_run", "=", "self", ".", "dry_run", ")" ]
[ 361, 4 ]
[ 364, 53 ]
python
en
['en', 'lb', 'en']
True
Command.make_file
(self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1)
Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the...
Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the...
def make_file(self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): """Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a differe...
[ "def", "make_file", "(", "self", ",", "infiles", ",", "outfile", ",", "func", ",", "args", ",", "exec_msg", "=", "None", ",", "skip_msg", "=", "None", ",", "level", "=", "1", ")", ":", "if", "skip_msg", "is", "None", ":", "skip_msg", "=", "\"skipping...
[ 372, 4 ]
[ 402, 31 ]
python
en
['en', 'en', 'en']
True
AbstractDocument.clean
(self)
Checks for WAGTAILDOCS_EXTENSIONS and validates the uploaded file based on allowed extensions that were specified. Warning : This doesn't always ensure that the uploaded file is valid as files can be renamed to have an extension no matter what data they contain. More in...
Checks for WAGTAILDOCS_EXTENSIONS and validates the uploaded file based on allowed extensions that were specified. Warning : This doesn't always ensure that the uploaded file is valid as files can be renamed to have an extension no matter what data they contain.
def clean(self): """ Checks for WAGTAILDOCS_EXTENSIONS and validates the uploaded file based on allowed extensions that were specified. Warning : This doesn't always ensure that the uploaded file is valid as files can be renamed to have an extension no matter what data th...
[ "def", "clean", "(", "self", ")", ":", "allowed_extensions", "=", "getattr", "(", "settings", ",", "\"WAGTAILDOCS_EXTENSIONS\"", ",", "None", ")", "if", "allowed_extensions", ":", "validate", "=", "FileExtensionValidator", "(", "allowed_extensions", ")", "validate",...
[ 57, 4 ]
[ 70, 31 ]
python
en
['en', 'error', 'th']
False
AbstractDocument.is_stored_locally
(self)
Returns True if the image is hosted on the local filesystem
Returns True if the image is hosted on the local filesystem
def is_stored_locally(self): """ Returns True if the image is hosted on the local filesystem """ try: self.file.path return True except NotImplementedError: return False
[ "def", "is_stored_locally", "(", "self", ")", ":", "try", ":", "self", ".", "file", ".", "path", "return", "True", "except", "NotImplementedError", ":", "return", "False" ]
[ 72, 4 ]
[ 81, 24 ]
python
en
['en', 'error', 'th']
False
get_boot_diagnostics_storage_account
(self, limited=False, vm_dict=None)
Get the boot diagnostics storage account. Arguments: - limited - if true, limit the logic to the boot_diagnostics storage account this is used if initial creation of the VM has a stanza with boot_diagnostics disabled, so we only create a storage ac...
Get the boot diagnostics storage account.
def get_boot_diagnostics_storage_account(self, limited=False, vm_dict=None): """ Get the boot diagnostics storage account. Arguments: - limited - if true, limit the logic to the boot_diagnostics storage account this is used if initial creation of the VM has a sta...
[ "def", "get_boot_diagnostics_storage_account", "(", "self", ",", "limited", "=", "False", ",", "vm_dict", "=", "None", ")", ":", "bsa", "=", "None", "if", "'storage_account'", "in", "self", ".", "boot_diagnostics", ":", "bsa", "=", "self", ".", "get_storage_ac...
[ 906, 4 ]
[ 939, 18 ]
python
en
['en', 'error', 'th']
False
get_vm
(self)
Get the VM with expanded instanceView :return: VirtualMachine object
Get the VM with expanded instanceView
def get_vm(self): ''' Get the VM with expanded instanceView :return: VirtualMachine object ''' try: vm = self.compute_client.virtual_machines.get(self.resource_group, self.name, expand='instanceview') return vm except Exception as exc: ...
[ "def", "get_vm", "(", "self", ")", ":", "try", ":", "vm", "=", "self", ".", "compute_client", ".", "virtual_machines", ".", "get", "(", "self", ".", "resource_group", ",", "self", ".", "name", ",", "expand", "=", "'instanceview'", ")", "return", "vm", ...
[ 1614, 4 ]
[ 1624, 92 ]
python
en
['en', 'error', 'th']
False
serialize_vm
(self, vm)
Convert a VirtualMachine object to dict. :param vm: VirtualMachine object :return: dict
Convert a VirtualMachine object to dict.
def serialize_vm(self, vm): ''' Convert a VirtualMachine object to dict. :param vm: VirtualMachine object :return: dict ''' result = self.serialize_obj(vm, AZURE_OBJECT_CLASS, enum_modules=AZURE_ENUM_MODULES) result['id'] = vm.id result['name'] = vm.name...
[ "def", "serialize_vm", "(", "self", ",", "vm", ")", ":", "result", "=", "self", ".", "serialize_obj", "(", "vm", ",", "AZURE_OBJECT_CLASS", ",", "enum_modules", "=", "AZURE_ENUM_MODULES", ")", "result", "[", "'id'", "]", "=", "vm", ".", "id", "result", "...
[ 1626, 4 ]
[ 1676, 21 ]
python
en
['en', 'error', 'th']
False
vm_size_is_valid
(self)
Validate self.vm_size against the list of virtual machine sizes available for the account and location. :return: boolean
Validate self.vm_size against the list of virtual machine sizes available for the account and location.
def vm_size_is_valid(self): ''' Validate self.vm_size against the list of virtual machine sizes available for the account and location. :return: boolean ''' try: sizes = self.compute_client.virtual_machine_sizes.list(self.location) except Exception as exc: ...
[ "def", "vm_size_is_valid", "(", "self", ")", ":", "try", ":", "sizes", "=", "self", ".", "compute_client", ".", "virtual_machine_sizes", ".", "list", "(", "self", ".", "location", ")", "except", "Exception", "as", "exc", ":", "self", ".", "fail", "(", "\...
[ 1970, 4 ]
[ 1983, 20 ]
python
en
['en', 'error', 'th']
False
create_default_storage_account
(self, vm_dict=None)
Create (once) a default storage account <vm name>XXXX, where XXXX is a random number. NOTE: If <vm name>XXXX exists, use it instead of failing. Highly unlikely. If this method is called multiple times across executions it will return the same storage account created with the random nam...
Create (once) a default storage account <vm name>XXXX, where XXXX is a random number. NOTE: If <vm name>XXXX exists, use it instead of failing. Highly unlikely. If this method is called multiple times across executions it will return the same storage account created with the random nam...
def create_default_storage_account(self, vm_dict=None): ''' Create (once) a default storage account <vm name>XXXX, where XXXX is a random number. NOTE: If <vm name>XXXX exists, use it instead of failing. Highly unlikely. If this method is called multiple times across executions it will ...
[ "def", "create_default_storage_account", "(", "self", ",", "vm_dict", "=", "None", ")", ":", "account", "=", "None", "valid_name", "=", "False", "if", "self", ".", "tags", "is", "None", ":", "self", ".", "tags", "=", "{", "}", "if", "self", ".", "tags"...
[ 1985, 4 ]
[ 2045, 61 ]
python
en
['en', 'error', 'th']
False
sha256_treehash
(sexp: CLVMObject, precalculated: Optional[Set[bytes32]] = None)
Hash values in `precalculated` are presumed to have been hashed already.
Hash values in `precalculated` are presumed to have been hashed already.
def sha256_treehash(sexp: CLVMObject, precalculated: Optional[Set[bytes32]] = None) -> bytes32: """ Hash values in `precalculated` are presumed to have been hashed already. """ if precalculated is None: precalculated = set() def handle_sexp(sexp_stack, op_stack, precalculated: Set[bytes32]...
[ "def", "sha256_treehash", "(", "sexp", ":", "CLVMObject", ",", "precalculated", ":", "Optional", "[", "Set", "[", "bytes32", "]", "]", "=", "None", ")", "->", "bytes32", ":", "if", "precalculated", "is", "None", ":", "precalculated", "=", "set", "(", ")"...
[ 16, 0 ]
[ 57, 33 ]
python
en
['en', 'error', 'th']
False
user_can_edit_snippet_type
(user, model)
true if user has 'add', 'change' or 'delete' permission on this model
true if user has 'add', 'change' or 'delete' permission on this model
def user_can_edit_snippet_type(user, model): """ true if user has 'add', 'change' or 'delete' permission on this model """ for action in ('add', 'change', 'delete'): if user.has_perm(get_permission_name(action, model)): return True return False
[ "def", "user_can_edit_snippet_type", "(", "user", ",", "model", ")", ":", "for", "action", "in", "(", "'add'", ",", "'change'", ",", "'delete'", ")", ":", "if", "user", ".", "has_perm", "(", "get_permission_name", "(", "action", ",", "model", ")", ")", "...
[ 9, 0 ]
[ 15, 16 ]
python
en
['en', 'en', 'en']
True
user_can_edit_snippets
(user)
true if user has 'add', 'change' or 'delete' permission on any model registered as a snippet type
true if user has 'add', 'change' or 'delete' permission on any model registered as a snippet type
def user_can_edit_snippets(user): """ true if user has 'add', 'change' or 'delete' permission on any model registered as a snippet type """ snippet_models = get_snippet_models() for model in snippet_models: if user_can_edit_snippet_type(user, model): return True return ...
[ "def", "user_can_edit_snippets", "(", "user", ")", ":", "snippet_models", "=", "get_snippet_models", "(", ")", "for", "model", "in", "snippet_models", ":", "if", "user_can_edit_snippet_type", "(", "user", ",", "model", ")", ":", "return", "True", "return", "Fals...
[ 18, 0 ]
[ 29, 16 ]
python
en
['en', 'error', 'th']
False
EmailBackend.open
(self)
Ensure an open connection to the email server. Return whether or not a new connection was required (True or False) or None if an exception passed silently.
Ensure an open connection to the email server. Return whether or not a new connection was required (True or False) or None if an exception passed silently.
def open(self): """ Ensure an open connection to the email server. Return whether or not a new connection was required (True or False) or None if an exception passed silently. """ if self.connection: # Nothing to do if the connection is already open. ...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "connection", ":", "# Nothing to do if the connection is already open.", "return", "False", "# If local_hostname is not specified, socket.getfqdn() gets used.", "# For performance, we use the cached FQDN for local_hostname.", "...
[ 42, 4 ]
[ 74, 21 ]
python
en
['en', 'error', 'th']
False
EmailBackend.close
(self)
Closes the connection to the email server.
Closes the connection to the email server.
def close(self): """Closes the connection to the email server.""" if self.connection is None: return try: try: self.connection.quit() except (ssl.SSLError, smtplib.SMTPServerDisconnected): # This happens when calling quit() on a...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "connection", "is", "None", ":", "return", "try", ":", "try", ":", "self", ".", "connection", ".", "quit", "(", ")", "except", "(", "ssl", ".", "SSLError", ",", "smtplib", ".", "SMTPServerDisc...
[ 76, 4 ]
[ 93, 34 ]
python
en
['en', 'en', 'en']
True
EmailBackend.send_messages
(self, email_messages)
Sends one or more EmailMessage objects and returns the number of email messages sent.
Sends one or more EmailMessage objects and returns the number of email messages sent.
def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return with self._lock: new_conn_created = self.open() if not self.connection ...
[ "def", "send_messages", "(", "self", ",", "email_messages", ")", ":", "if", "not", "email_messages", ":", "return", "with", "self", ".", "_lock", ":", "new_conn_created", "=", "self", ".", "open", "(", ")", "if", "not", "self", ".", "connection", "or", "...
[ 95, 4 ]
[ 115, 23 ]
python
en
['en', 'error', 'th']
False
EmailBackend._send
(self, email_message)
A helper method that does the actual sending.
A helper method that does the actual sending.
def _send(self, email_message): """A helper method that does the actual sending.""" if not email_message.recipients(): return False encoding = email_message.encoding or settings.DEFAULT_CHARSET from_email = sanitize_address(email_message.from_email, encoding) recipien...
[ "def", "_send", "(", "self", ",", "email_message", ")", ":", "if", "not", "email_message", ".", "recipients", "(", ")", ":", "return", "False", "encoding", "=", "email_message", ".", "encoding", "or", "settings", ".", "DEFAULT_CHARSET", "from_email", "=", "s...
[ 117, 4 ]
[ 131, 19 ]
python
en
['en', 'en', 'en']
True
Command._get_instance_id
(self, variables, default='')
Retrieve the instance ID from the given dict of host variables. The instance ID variable may be specified as 'foo.bar', in which case the lookup will traverse into nested dicts, equivalent to: from_dict.get('foo', {}).get('bar', default) Multiple ID variables may be specified...
Retrieve the instance ID from the given dict of host variables.
def _get_instance_id(self, variables, default=''): """ Retrieve the instance ID from the given dict of host variables. The instance ID variable may be specified as 'foo.bar', in which case the lookup will traverse into nested dicts, equivalent to: from_dict.get('foo', {}).get('...
[ "def", "_get_instance_id", "(", "self", ",", "variables", ",", "default", "=", "''", ")", ":", "instance_id", "=", "default", "if", "getattr", "(", "self", ",", "'instance_id_var'", ",", "None", ")", ":", "for", "single_instance_id", "in", "self", ".", "in...
[ 185, 4 ]
[ 210, 38 ]
python
en
['en', 'error', 'th']
False
Command._get_enabled
(self, from_dict, default=None)
Retrieve the enabled state from the given dict of host variables. The enabled variable may be specified as 'foo.bar', in which case the lookup will traverse into nested dicts, equivalent to: from_dict.get('foo', {}).get('bar', default)
Retrieve the enabled state from the given dict of host variables.
def _get_enabled(self, from_dict, default=None): """ Retrieve the enabled state from the given dict of host variables. The enabled variable may be specified as 'foo.bar', in which case the lookup will traverse into nested dicts, equivalent to: from_dict.get('foo', {}).get('bar'...
[ "def", "_get_enabled", "(", "self", ",", "from_dict", ",", "default", "=", "None", ")", ":", "enabled", "=", "default", "if", "getattr", "(", "self", ",", "'enabled_var'", ",", "None", ")", ":", "default", "=", "object", "(", ")", "for", "key", "in", ...
[ 212, 4 ]
[ 241, 92 ]
python
en
['en', 'error', 'th']
False
Command._build_db_instance_id_map
(self)
Find any hosts in the database without an instance_id set that may still have one available via host variables.
Find any hosts in the database without an instance_id set that may still have one available via host variables.
def _build_db_instance_id_map(self): """ Find any hosts in the database without an instance_id set that may still have one available via host variables. """ self.db_instance_id_map = {} if self.instance_id_var: host_qs = self.inventory_source.hosts.all() ...
[ "def", "_build_db_instance_id_map", "(", "self", ")", ":", "self", ".", "db_instance_id_map", "=", "{", "}", "if", "self", ".", "instance_id_var", ":", "host_qs", "=", "self", ".", "inventory_source", ".", "hosts", ".", "all", "(", ")", "host_qs", "=", "ho...
[ 263, 4 ]
[ 276, 62 ]
python
en
['en', 'error', 'th']
False
Command._build_mem_instance_id_map
(self)
Update instance ID for each imported host and define a mapping of instance IDs to MemHost instances.
Update instance ID for each imported host and define a mapping of instance IDs to MemHost instances.
def _build_mem_instance_id_map(self): """ Update instance ID for each imported host and define a mapping of instance IDs to MemHost instances. """ self.mem_instance_id_map = {} if self.instance_id_var: for mem_host in self.all_group.all_hosts.values(): ...
[ "def", "_build_mem_instance_id_map", "(", "self", ")", ":", "self", ".", "mem_instance_id_map", "=", "{", "}", "if", "self", ".", "instance_id_var", ":", "for", "mem_host", "in", "self", ".", "all_group", ".", "all_hosts", ".", "values", "(", ")", ":", "in...
[ 278, 4 ]
[ 291, 69 ]
python
en
['en', 'error', 'th']
False
Command._existing_host_pks
(self)
Returns cached set of existing / previous host primary key values this is the starting set, meaning that it is pre-modification by deletions and other things done in the course of this import
Returns cached set of existing / previous host primary key values this is the starting set, meaning that it is pre-modification by deletions and other things done in the course of this import
def _existing_host_pks(self): """Returns cached set of existing / previous host primary key values this is the starting set, meaning that it is pre-modification by deletions and other things done in the course of this import """ if not hasattr(self, '_cached_host_pk_set'): ...
[ "def", "_existing_host_pks", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_cached_host_pk_set'", ")", ":", "self", ".", "_cached_host_pk_set", "=", "frozenset", "(", "self", ".", "inventory_source", ".", "hosts", ".", "values_list", "(", ...
[ 293, 4 ]
[ 300, 39 ]
python
en
['en', 'en', 'en']
True
Command._delete_hosts
(self)
For each host in the database that is NOT in the local list, delete it. When importing from a cloud inventory source attached to a specific group, only delete hosts beneath that group. Delete each host individually so signal handlers will run.
For each host in the database that is NOT in the local list, delete it. When importing from a cloud inventory source attached to a specific group, only delete hosts beneath that group. Delete each host individually so signal handlers will run.
def _delete_hosts(self): """ For each host in the database that is NOT in the local list, delete it. When importing from a cloud inventory source attached to a specific group, only delete hosts beneath that group. Delete each host individually so signal handlers will run. ...
[ "def", "_delete_hosts", "(", "self", ")", ":", "if", "settings", ".", "SQL_DEBUG", ":", "queries_before", "=", "len", "(", "connection", ".", "queries", ")", "hosts_qs", "=", "self", ".", "inventory_source", ".", "hosts", "# Build list of all host pks, remove all ...
[ 302, 4 ]
[ 339, 133 ]
python
en
['en', 'error', 'th']
False
Command._delete_groups
(self)
# If overwrite is set, for each group in the database that is NOT in # the local list, delete it. When importing from a cloud inventory # source attached to a specific group, only delete children of that # group. Delete each group individually so signal handlers will run.
# If overwrite is set, for each group in the database that is NOT in # the local list, delete it. When importing from a cloud inventory # source attached to a specific group, only delete children of that # group. Delete each group individually so signal handlers will run.
def _delete_groups(self): """ # If overwrite is set, for each group in the database that is NOT in # the local list, delete it. When importing from a cloud inventory # source attached to a specific group, only delete children of that # group. Delete each group individually so si...
[ "def", "_delete_groups", "(", "self", ")", ":", "if", "settings", ".", "SQL_DEBUG", ":", "queries_before", "=", "len", "(", "connection", ".", "queries", ")", "groups_qs", "=", "self", ".", "inventory_source", ".", "groups", ".", "all", "(", ")", "# Build ...
[ 341, 4 ]
[ 368, 135 ]
python
en
['en', 'error', 'th']
False
Command._delete_group_children_and_hosts
(self)
Clear all invalid child relationships for groups and all invalid host memberships. When importing from a cloud inventory source attached to a specific group, only clear relationships for hosts and groups that are beneath the inventory source group.
Clear all invalid child relationships for groups and all invalid host memberships. When importing from a cloud inventory source attached to a specific group, only clear relationships for hosts and groups that are beneath the inventory source group.
def _delete_group_children_and_hosts(self): """ Clear all invalid child relationships for groups and all invalid host memberships. When importing from a cloud inventory source attached to a specific group, only clear relationships for hosts and groups that are beneath the invent...
[ "def", "_delete_group_children_and_hosts", "(", "self", ")", ":", "# FIXME: Optimize performance!", "if", "settings", ".", "SQL_DEBUG", ":", "queries_before", "=", "len", "(", "connection", ".", "queries", ")", "group_group_count", "=", "0", "group_host_count", "=", ...
[ 370, 4 ]
[ 449, 13 ]
python
en
['en', 'error', 'th']
False
Command._update_inventory
(self)
Update inventory variables from "all" group.
Update inventory variables from "all" group.
def _update_inventory(self): """ Update inventory variables from "all" group. """ # TODO: We disable variable overwrite here in case user-defined inventory variables get # mangled. But we still need to figure out a better way of processing multiple inventory # update vari...
[ "def", "_update_inventory", "(", "self", ")", ":", "# TODO: We disable variable overwrite here in case user-defined inventory variables get", "# mangled. But we still need to figure out a better way of processing multiple inventory", "# update variables mixing with each other.", "all_obj", "=", ...
[ 451, 4 ]
[ 466, 58 ]
python
en
['en', 'error', 'th']
False
Command._create_update_groups
(self)
For each group in the local list, create it if it doesn't exist in the database. Otherwise, update/replace database variables from the imported data. Associate with the inventory source group if importing from cloud inventory source.
For each group in the local list, create it if it doesn't exist in the database. Otherwise, update/replace database variables from the imported data. Associate with the inventory source group if importing from cloud inventory source.
def _create_update_groups(self): """ For each group in the local list, create it if it doesn't exist in the database. Otherwise, update/replace database variables from the imported data. Associate with the inventory source group if importing from cloud inventory source. ...
[ "def", "_create_update_groups", "(", "self", ")", ":", "if", "settings", ".", "SQL_DEBUG", ":", "queries_before", "=", "len", "(", "connection", ".", "queries", ")", "all_group_names", "=", "sorted", "(", "self", ".", "all_group", ".", "all_groups", ".", "ke...
[ 468, 4 ]
[ 517, 147 ]
python
en
['en', 'error', 'th']
False
Command._create_update_hosts
(self)
For each host in the local list, create it if it doesn't exist in the database. Otherwise, update/replace database variables from the imported data. Associate with the inventory source group if importing from cloud inventory source.
For each host in the local list, create it if it doesn't exist in the database. Otherwise, update/replace database variables from the imported data. Associate with the inventory source group if importing from cloud inventory source.
def _create_update_hosts(self): """ For each host in the local list, create it if it doesn't exist in the database. Otherwise, update/replace database variables from the imported data. Associate with the inventory source group if importing from cloud inventory source. "...
[ "def", "_create_update_hosts", "(", "self", ")", ":", "if", "settings", ".", "SQL_DEBUG", ":", "queries_before", "=", "len", "(", "connection", ".", "queries", ")", "host_pks_updated", "=", "set", "(", ")", "mem_host_pk_map", "=", "{", "}", "mem_host_instance_...
[ 570, 4 ]
[ 654, 144 ]
python
en
['en', 'error', 'th']
False
Command._create_update_group_children
(self)
For each imported group, create all parent-child group relationships.
For each imported group, create all parent-child group relationships.
def _create_update_group_children(self): """ For each imported group, create all parent-child group relationships. """ if settings.SQL_DEBUG: queries_before = len(connection.queries) all_group_names = sorted([k for k, v in self.all_group.all_groups.items() if v.childr...
[ "def", "_create_update_group_children", "(", "self", ")", ":", "if", "settings", ".", "SQL_DEBUG", ":", "queries_before", "=", "len", "(", "connection", ".", "queries", ")", "all_group_names", "=", "sorted", "(", "[", "k", "for", "k", ",", "v", "in", "self...
[ 657, 4 ]
[ 681, 159 ]
python
en
['en', 'error', 'th']
False
Command.load_into_database
(self)
Load inventory from in-memory groups to the database, overwriting or merging as appropriate.
Load inventory from in-memory groups to the database, overwriting or merging as appropriate.
def load_into_database(self): """ Load inventory from in-memory groups to the database, overwriting or merging as appropriate. """ # FIXME: Attribute changes to superuser? # Perform __in queries in batches (mainly for unit tests using SQLite). self._batch_size = 5...
[ "def", "load_into_database", "(", "self", ")", ":", "# FIXME: Attribute changes to superuser?", "# Perform __in queries in batches (mainly for unit tests using SQLite).", "self", ".", "_batch_size", "=", "500", "self", ".", "_build_db_instance_id_map", "(", ")", "self", ".", ...
[ 718, 4 ]
[ 736, 41 ]
python
en
['en', 'error', 'th']
False
Command.perform_update
(self, options, data, inventory_update)
Shared method for both awx-manage CLI updates and inventory updates from the tasks system. This saves the inventory data to the database, calling load_into_database but also wraps that method in a host of options processing
Shared method for both awx-manage CLI updates and inventory updates from the tasks system.
def perform_update(self, options, data, inventory_update): """Shared method for both awx-manage CLI updates and inventory updates from the tasks system. This saves the inventory data to the database, calling load_into_database but also wraps that method in a host of options processing ...
[ "def", "perform_update", "(", "self", ",", "options", ",", "data", ",", "inventory_update", ")", ":", "# outside of normal options, these are needed as part of programatic interface", "self", ".", "inventory", "=", "inventory_update", ".", "inventory", "self", ".", "inven...
[ 874, 4 ]
[ 1010, 122 ]
python
en
['en', 'en', 'en']
True
test_save_survey_passwords_to_job
(job_template_with_survey_passwords)
Test that when a new job is created, the survey_passwords field is given all of the passwords that exist in the JT survey
Test that when a new job is created, the survey_passwords field is given all of the passwords that exist in the JT survey
def test_save_survey_passwords_to_job(job_template_with_survey_passwords): """Test that when a new job is created, the survey_passwords field is given all of the passwords that exist in the JT survey""" job = job_template_with_survey_passwords.create_unified_job() assert job.survey_passwords == {'SSN': ...
[ "def", "test_save_survey_passwords_to_job", "(", "job_template_with_survey_passwords", ")", ":", "job", "=", "job_template_with_survey_passwords", ".", "create_unified_job", "(", ")", "assert", "job", ".", "survey_passwords", "==", "{", "'SSN'", ":", "'$encrypted$'", ",",...
[ 266, 0 ]
[ 270, 86 ]
python
en
['en', 'en', 'en']
True
test_save_survey_passwords_on_migration
(job_template_with_survey_passwords)
Test that when upgrading to 3.0.2, the jobs connected to a JT that has a survey with passwords in it, the survey passwords get saved to the job survey_passwords field.
Test that when upgrading to 3.0.2, the jobs connected to a JT that has a survey with passwords in it, the survey passwords get saved to the job survey_passwords field.
def test_save_survey_passwords_on_migration(job_template_with_survey_passwords): """Test that when upgrading to 3.0.2, the jobs connected to a JT that has a survey with passwords in it, the survey passwords get saved to the job survey_passwords field.""" Job.objects.create(job_template=job_template_with...
[ "def", "test_save_survey_passwords_on_migration", "(", "job_template_with_survey_passwords", ")", ":", "Job", ".", "objects", ".", "create", "(", "job_template", "=", "job_template_with_survey_passwords", ")", "save_password_keys", ".", "migrate_survey_passwords", "(", "apps"...
[ 274, 0 ]
[ 281, 86 ]
python
en
['en', 'en', 'en']
True
tx_removals_and_additions
(npc_list: List[NPC])
Doesn't return farmer and pool reward.
Doesn't return farmer and pool reward.
def tx_removals_and_additions(npc_list: List[NPC]) -> Tuple[List[bytes32], List[Coin]]: """ Doesn't return farmer and pool reward. """ removals: List[bytes32] = [] additions: List[Coin] = [] # build removals list if npc_list is None: return [], [] for npc in npc_list: r...
[ "def", "tx_removals_and_additions", "(", "npc_list", ":", "List", "[", "NPC", "]", ")", "->", "Tuple", "[", "List", "[", "bytes32", "]", ",", "List", "[", "Coin", "]", "]", ":", "removals", ":", "List", "[", "bytes32", "]", "=", "[", "]", "additions"...
[ 49, 0 ]
[ 65, 30 ]
python
en
['en', 'error', 'th']
False
Schedule.rrulestr
(cls, rrule, fast_forward=True, **kwargs)
Apply our own custom rrule parsing requirements
Apply our own custom rrule parsing requirements
def rrulestr(cls, rrule, fast_forward=True, **kwargs): """ Apply our own custom rrule parsing requirements """ rrule = Schedule.coerce_naive_until(rrule) kwargs['forceset'] = True x = dateutil.rrule.rrulestr(rrule, tzinfos=UTC_TIMEZONES, **kwargs) for r in x._rru...
[ "def", "rrulestr", "(", "cls", ",", "rrule", ",", "fast_forward", "=", "True", ",", "*", "*", "kwargs", ")", ":", "rrule", "=", "Schedule", ".", "coerce_naive_until", "(", "rrule", ")", "kwargs", "[", "'forceset'", "]", "=", "True", "x", "=", "dateutil...
[ 166, 4 ]
[ 192, 16 ]
python
en
['en', 'error', 'th']
False
_escape_pgpass
(txt)
Escape a fragment of a PostgreSQL .pgpass file.
Escape a fragment of a PostgreSQL .pgpass file.
def _escape_pgpass(txt): """ Escape a fragment of a PostgreSQL .pgpass file. """ return txt.replace('\\', '\\\\').replace(':', '\\:')
[ "def", "_escape_pgpass", "(", "txt", ")", ":", "return", "txt", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", ".", "replace", "(", "':'", ",", "'\\\\:'", ")" ]
[ 8, 0 ]
[ 12, 56 ]
python
en
['en', 'error', 'th']
False
test_organization_access_admin
(cl, organization, user)
can_change because I am an admin of that org
can_change because I am an admin of that org
def test_organization_access_admin(cl, organization, user): '''can_change because I am an admin of that org''' a = user('admin', False) organization.admin_role.members.add(a) organization.member_role.members.add(user('user', False)) access = OrganizationAccess(a) assert access.can_change(organi...
[ "def", "test_organization_access_admin", "(", "cl", ",", "organization", ",", "user", ")", ":", "a", "=", "user", "(", "'admin'", ",", "False", ")", "organization", ".", "admin_role", ".", "members", ".", "add", "(", "a", ")", "organization", ".", "member_...
[ 11, 0 ]
[ 23, 50 ]
python
en
['en', 'en', 'en']
True
FileUploadTest.test_rest_endpoint
(self)
Tests the /api/v1/user_uploads API endpoint. Here a single file is uploaded and downloaded using a username and api_key
Tests the /api/v1/user_uploads API endpoint. Here a single file is uploaded and downloaded using a username and api_key
def test_rest_endpoint(self) -> None: """ Tests the /api/v1/user_uploads API endpoint. Here a single file is uploaded and downloaded using a username and api_key """ fp = StringIO("zulip!") fp.name = "zulip.txt" # Upload file via API result = self.api_pos...
[ "def", "test_rest_endpoint", "(", "self", ")", "->", "None", ":", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "# Upload file via API", "result", "=", "self", ".", "api_post", "(", "self", ".", "example_user", "(", ...
[ 83, 4 ]
[ 107, 63 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_mobile_api_endpoint
(self)
Tests the /api/v1/user_uploads API endpoint with ?api_key auth. Here a single file is uploaded and downloaded using a username and api_key
Tests the /api/v1/user_uploads API endpoint with ?api_key auth. Here a single file is uploaded and downloaded using a username and api_key
def test_mobile_api_endpoint(self) -> None: """ Tests the /api/v1/user_uploads API endpoint with ?api_key auth. Here a single file is uploaded and downloaded using a username and api_key """ fp = StringIO("zulip!") fp.name = "zulip.txt" # Upload file via ...
[ "def", "test_mobile_api_endpoint", "(", "self", ")", "->", "None", ":", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "# Upload file via API", "result", "=", "self", ".", "api_post", "(", "self", ".", "example_user", ...
[ 109, 4 ]
[ 136, 41 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_upload_file_with_supplied_mimetype
(self)
When files are copied into the system clipboard and pasted for upload the filename may not be supplied so the extension is determined from a query string parameter.
When files are copied into the system clipboard and pasted for upload the filename may not be supplied so the extension is determined from a query string parameter.
def test_upload_file_with_supplied_mimetype(self) -> None: """ When files are copied into the system clipboard and pasted for upload the filename may not be supplied so the extension is determined from a query string parameter. """ fp = StringIO("zulip!") fp.name ...
[ "def", "test_upload_file_with_supplied_mimetype", "(", "self", ")", "->", "None", ":", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"pasted_file\"", "result", "=", "self", ".", "api_post", "(", "self", ".", "example_user", "(", "\...
[ 138, 4 ]
[ 151, 56 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_file_too_big_failure
(self)
Attempting to upload big files should fail.
Attempting to upload big files should fail.
def test_file_too_big_failure(self) -> None: """ Attempting to upload big files should fail. """ self.login("hamlet") fp = StringIO("bah!") fp.name = "a.txt" # Use MAX_FILE_UPLOAD_SIZE of 0, because the next increment # would be 1MB. with self.set...
[ "def", "test_file_too_big_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"bah!\"", ")", "fp", ".", "name", "=", "\"a.txt\"", "# Use MAX_FILE_UPLOAD_SIZE of 0, because the next increment", ...
[ 153, 4 ]
[ 165, 97 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ self.login("hamlet") fp = StringIO("bah!") fp.name = "a.txt" fp2 = StringIO("pshaw!") fp2.name = "b.txt" result = self.client_post("/json/user_uplo...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"bah!\"", ")", "fp", ".", "name", "=", "\"a.txt\"", "fp2", "=", "StringIO", "(", "\"pshaw!\"", ")", "f...
[ 167, 4 ]
[ 178, 80 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("hamlet") result = self.client_post("/json/user_uploads") self.assert_json_error(result, "You must specify a file to upload")
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/user_uploads\"", ")", "self", ".", "assert_json_error", "(", "result", ",", "\"You...
[ 180, 4 ]
[ 187, 75 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_file_upload_authed
(self)
A call to /json/user_uploads should return a uri and actually create an entry in the database. This entry will be marked unclaimed till a message refers it.
A call to /json/user_uploads should return a uri and actually create an entry in the database. This entry will be marked unclaimed till a message refers it.
def test_file_upload_authed(self) -> None: """ A call to /json/user_uploads should return a uri and actually create an entry in the database. This entry will be marked unclaimed till a message refers it. """ self.login("hamlet") fp = StringIO("zulip!") fp....
[ "def", "test_file_upload_authed", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "result", "=", "self", ".", "client_post", "(", "...
[ 191, 4 ]
[ 236, 49 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_removed_file_download
(self)
Trying to download deleted files should return 404 error
Trying to download deleted files should return 404 error
def test_removed_file_download(self) -> None: """ Trying to download deleted files should return 404 error """ self.login("hamlet") fp = StringIO("zulip!") fp.name = "zulip.txt" result = self.client_post("/json/user_uploads", {"file": fp}) destroy_uploads...
[ "def", "test_removed_file_download", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "result", "=", "self", ".", "client_post", "(", ...
[ 294, 4 ]
[ 306, 51 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_non_existing_file_download
(self)
Trying to download a file that was never uploaded will return a json_error
Trying to download a file that was never uploaded will return a json_error
def test_non_existing_file_download(self) -> None: """ Trying to download a file that was never uploaded will return a json_error """ hamlet = self.example_user("hamlet") self.login_user(hamlet) response = self.client_get( f"http://localhost:9991/user_uploads/...
[ "def", "test_non_existing_file_download", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "hamlet", ")", "response", "=", "self", ".", "client_get", "(", "f\"http://localh...
[ 308, 4 ]
[ 318, 60 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_multiple_claim_attachments
(self)
This test tries to claim the same attachment twice. The messages field in the Attachment model should have both the messages in its entry.
This test tries to claim the same attachment twice. The messages field in the Attachment model should have both the messages in its entry.
def test_multiple_claim_attachments(self) -> None: """ This test tries to claim the same attachment twice. The messages field in the Attachment model should have both the messages in its entry. """ self.login("hamlet") d1 = StringIO("zulip!") d1.name = "dummy_1.tx...
[ "def", "test_multiple_claim_attachments", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "d1", "=", "StringIO", "(", "\"zulip!\"", ")", "d1", ".", "name", "=", "\"dummy_1.txt\"", "result", "=", "self", ".", "client_post", ...
[ 366, 4 ]
[ 384, 88 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_multiple_claim_attachments_different_owners
(self)
This test tries to claim the same attachment more than once, first with a private stream and then with different recipients.
This test tries to claim the same attachment more than once, first with a private stream and then with different recipients.
def test_multiple_claim_attachments_different_owners(self) -> None: """This test tries to claim the same attachment more than once, first with a private stream and then with different recipients.""" self.login("hamlet") d1 = StringIO("zulip!") d1.name = "dummy_1.txt" resu...
[ "def", "test_multiple_claim_attachments_different_owners", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "d1", "=", "StringIO", "(", "\"zulip!\"", ")", "d1", ".", "name", "=", "\"dummy_1.txt\"", "result", "=", "self", ".", ...
[ 386, 4 ]
[ 436, 81 ]
python
en
['en', 'en', 'en']
True
FileUploadTest.test_file_name
(self)
Unicode filenames should be processed correctly.
Unicode filenames should be processed correctly.
def test_file_name(self) -> None: """ Unicode filenames should be processed correctly. """ self.login("hamlet") for expected in ["Здравейте.txt", "test"]: fp = StringIO("bah!") fp.name = urllib.parse.quote(expected) result = self.client_post(...
[ "def", "test_file_name", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "for", "expected", "in", "[", "\"Здравейте.txt\", \"test\"]:", "", "", "", "", "fp", "=", "StringIO", "(", "\"bah!\"", ")", "fp", ".", "name", ...
[ 506, 4 ]
[ 516, 66 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_realm_quota
(self)
Realm quota for uploading should not be exceeded.
Realm quota for uploading should not be exceeded.
def test_realm_quota(self) -> None: """ Realm quota for uploading should not be exceeded. """ self.login("hamlet") d1 = StringIO("zulip!") d1.name = "dummy_1.txt" result = self.client_post("/json/user_uploads", {"file": d1}) d1_path_id = re.sub("/user_upl...
[ "def", "test_realm_quota", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "d1", "=", "StringIO", "(", "\"zulip!\"", ")", "d1", ".", "name", "=", "\"dummy_1.txt\"", "result", "=", "self", ".", "client_post", "(", "\"/js...
[ 518, 4 ]
[ 556, 40 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_avatar_url
(self)
Verifies URL schemes for avatars and realm icons.
Verifies URL schemes for avatars and realm icons.
def test_avatar_url(self) -> None: """Verifies URL schemes for avatars and realm icons.""" backend: ZulipUploadBackend = LocalUploadBackend() self.assertEqual(backend.get_public_upload_root_url(), "/user_avatars/") self.assertEqual(backend.get_avatar_url("hash", False), "/user_avatars/ha...
[ "def", "test_avatar_url", "(", "self", ")", "->", "None", ":", "backend", ":", "ZulipUploadBackend", "=", "LocalUploadBackend", "(", ")", "self", ".", "assertEqual", "(", "backend", ".", "get_public_upload_root_url", "(", ")", ",", "\"/user_avatars/\"", ")", "se...
[ 911, 4 ]
[ 948, 13 ]
python
en
['en', 'en', 'en']
True
AvatarTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ self.login("hamlet") with get_test_image_file("img.png") as fp1, get_test_image_file("img.png") as fp2: result = self.client_post("/json/users/me/avatar", {"f1": fp1, "...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "with", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp1", ",", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp2", ":"...
[ 950, 4 ]
[ 957, 77 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("hamlet") result = self.client_post("/json/users/me/avatar") self.assert_json_error(result, "You must upload exactly one avatar.")
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/users/me/avatar\"", ")", "self", ".", "assert_json_error", "(", "result", ",", "\"...
[ 959, 4 ]
[ 966, 77 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_avatar_changes_disabled_failure
(self)
Attempting to upload avatar on a realm with avatar changes disabled should fail.
Attempting to upload avatar on a realm with avatar changes disabled should fail.
def test_avatar_changes_disabled_failure(self) -> None: """ Attempting to upload avatar on a realm with avatar changes disabled should fail. """ self.login("cordelia") do_set_realm_property( self.example_user("cordelia").realm, "avatar_changes_disabled", ...
[ "def", "test_avatar_changes_disabled_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"cordelia\"", ")", "do_set_realm_property", "(", "self", ".", "example_user", "(", "\"cordelia\"", ")", ".", "realm", ",", "\"avatar_changes_disabled\"",...
[ 968, 4 ]
[ 982, 91 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_valid_avatars
(self)
A PUT request to /json/users/me/avatar with a valid file should return a URL and actually create an avatar.
A PUT request to /json/users/me/avatar with a valid file should return a URL and actually create an avatar.
def test_valid_avatars(self) -> None: """ A PUT request to /json/users/me/avatar with a valid file should return a URL and actually create an avatar. """ version = 2 for fname, rfname in self.correct_files: # TODO: use self.subTest once we're exclusively on python 3 b...
[ "def", "test_valid_avatars", "(", "self", ")", "->", "None", ":", "version", "=", "2", "for", "fname", ",", "rfname", "in", "self", ".", "correct_files", ":", "# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.", "# with self.subTest...
[ 1103, 4 ]
[ 1145, 24 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_invalid_avatars
(self)
A PUT request to /json/users/me/avatar with an invalid file should fail.
A PUT request to /json/users/me/avatar with an invalid file should fail.
def test_invalid_avatars(self) -> None: """ A PUT request to /json/users/me/avatar with an invalid file should fail. """ for fname in self.corrupt_files: # with self.subTest(fname=fname): self.login("hamlet") with get_test_image_file(fname) as fp: ...
[ "def", "test_invalid_avatars", "(", "self", ")", "->", "None", ":", "for", "fname", "in", "self", ".", "corrupt_files", ":", "# with self.subTest(fname=fname):", "self", ".", "login", "(", "\"hamlet\"", ")", "with", "get_test_image_file", "(", "fname", ")", "as"...
[ 1200, 4 ]
[ 1212, 60 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_delete_avatar
(self)
A DELETE request to /json/users/me/avatar should delete the profile picture and return gravatar URL
A DELETE request to /json/users/me/avatar should delete the profile picture and return gravatar URL
def test_delete_avatar(self) -> None: """ A DELETE request to /json/users/me/avatar should delete the profile picture and return gravatar URL """ self.login("cordelia") cordelia = self.example_user("cordelia") cordelia.avatar_source = UserProfile.AVATAR_FROM_USER ...
[ "def", "test_delete_avatar", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"cordelia\"", ")", "cordelia", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "cordelia", ".", "avatar_source", "=", "UserProfile", ".", "AVATAR_FROM_US...
[ 1214, 4 ]
[ 1236, 56 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ # Log in as admin self.login("iago") with get_test_image_file("img.png") as fp1, get_test_image_file("img.png") as fp2: result = self.client_post("/json/realm/i...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "# Log in as admin", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp1", ",", "get_test_image_file", "(", "\"img.png\"", ")", ...
[ 1298, 4 ]
[ 1306, 75 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("iago") result = self.client_post("/json/realm/icon") self.assert_json_error(result, "You must upload exactly one icon.")
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"iago\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/realm/icon\"", ")", "self", ".", "assert_json_error", "(", "result", ",", "\"You mus...
[ 1308, 4 ]
[ 1315, 75 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_valid_icons
(self)
A PUT request to /json/realm/icon with a valid file should return a URL and actually create an realm icon.
A PUT request to /json/realm/icon with a valid file should return a URL and actually create an realm icon.
def test_valid_icons(self) -> None: """ A PUT request to /json/realm/icon with a valid file should return a URL and actually create an realm icon. """ for fname, rfname in self.correct_files: # TODO: use self.subTest once we're exclusively on python 3 by uncommenting ...
[ "def", "test_valid_icons", "(", "self", ")", "->", "None", ":", "for", "fname", ",", "rfname", "in", "self", ".", "correct_files", ":", "# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.", "# with self.subTest(fname=fname):", "self", ...
[ 1355, 4 ]
[ 1376, 79 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_invalid_icons
(self)
A PUT request to /json/realm/icon with an invalid file should fail.
A PUT request to /json/realm/icon with an invalid file should fail.
def test_invalid_icons(self) -> None: """ A PUT request to /json/realm/icon with an invalid file should fail. """ for fname in self.corrupt_files: # with self.subTest(fname=fname): self.login("iago") with get_test_image_file(fname) as fp: ...
[ "def", "test_invalid_icons", "(", "self", ")", "->", "None", ":", "for", "fname", "in", "self", ".", "corrupt_files", ":", "# with self.subTest(fname=fname):", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "fname", ")", "as", ...
[ 1378, 4 ]
[ 1388, 99 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_delete_icon
(self)
A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL
A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL
def test_delete_icon(self) -> None: """ A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL """ self.login("iago") realm = get_realm("zulip") do_change_icon_source(realm, Realm.ICON_UPLOADED, acting_user=None) result = self.c...
[ "def", "test_delete_icon", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"iago\"", ")", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "do_change_icon_source", "(", "realm", ",", "Realm", ".", "ICON_UPLOADED", ",", "acting_user", "=", ...
[ 1390, 4 ]
[ 1404, 69 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ # Log in as admin self.login("iago") with get_test_image_file("img.png") as fp1, get_test_image_file("img.png") as fp2: result = self.client_post( ...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "# Log in as admin", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp1", ",", "get_test_image_file", "(", "\"img.png\"", ")", ...
[ 1431, 4 ]
[ 1442, 75 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("iago") result = self.client_post("/json/realm/logo", {"night": orjson.dumps(self.night).decode()}) self.assert_json_error(result, "You must upload exactly ...
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"iago\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/realm/logo\"", ",", "{", "\"night\"", ":", "orjson", ".", "dumps", "(", "self", ...
[ 1444, 4 ]
[ 1451, 75 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_valid_logos
(self)
A PUT request to /json/realm/logo with a valid file should return a URL and actually create an realm logo.
A PUT request to /json/realm/logo with a valid file should return a URL and actually create an realm logo.
def test_valid_logos(self) -> None: """ A PUT request to /json/realm/logo with a valid file should return a URL and actually create an realm logo. """ for fname, rfname in self.correct_files: # TODO: use self.subTest once we're exclusively on python 3 by uncommenting ...
[ "def", "test_valid_logos", "(", "self", ")", "->", "None", ":", "for", "fname", ",", "rfname", "in", "self", ".", "correct_files", ":", "# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.", "# with self.subTest(fname=fname):", "self", ...
[ 1527, 4 ]
[ 1549, 79 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_invalid_logo_upload
(self)
A PUT request to /json/realm/logo with an invalid file should fail.
A PUT request to /json/realm/logo with an invalid file should fail.
def test_invalid_logo_upload(self) -> None: """ A PUT request to /json/realm/logo with an invalid file should fail. """ for fname in self.corrupt_files: # with self.subTest(fname=fname): self.login("iago") with get_test_image_file(fname) as fp: ...
[ "def", "test_invalid_logo_upload", "(", "self", ")", "->", "None", ":", "for", "fname", "in", "self", ".", "corrupt_files", ":", "# with self.subTest(fname=fname):", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "fname", ")", "a...
[ 1551, 4 ]
[ 1563, 99 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_delete_logo
(self)
A DELETE request to /json/realm/logo should delete the realm logo and return gravatar URL
A DELETE request to /json/realm/logo should delete the realm logo and return gravatar URL
def test_delete_logo(self) -> None: """ A DELETE request to /json/realm/logo should delete the realm logo and return gravatar URL """ user_profile = self.example_user("iago") self.login_user(user_profile) realm = user_profile.realm do_change_logo_source(realm, Rea...
[ "def", "test_delete_logo", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "self", ".", "login_user", "(", "user_profile", ")", "realm", "=", "user_profile", ".", "realm", "do_change_logo_source", "(...
[ 1565, 4 ]
[ 1581, 67 ]
python
en
['en', 'error', 'th']
False
S3Test.test_file_upload_authed
(self)
A call to /json/user_uploads should return a uri and actually create an object.
A call to /json/user_uploads should return a uri and actually create an object.
def test_file_upload_authed(self) -> None: """ A call to /json/user_uploads should return a uri and actually create an object. """ bucket = create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET)[0] self.login("hamlet") fp = StringIO("zulip!") fp.name = "zulip.txt" ...
[ "def", "test_file_upload_authed", "(", "self", ")", "->", "None", ":", "bucket", "=", "create_s3_buckets", "(", "settings", ".", "S3_AUTH_UPLOADS_BUCKET", ")", "[", "0", "]", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"zulip!...
[ 1798, 4 ]
[ 1839, 86 ]
python
en
['en', 'error', 'th']
False
set_script_prefix
(prefix)
Set the script prefix for the current thread.
Set the script prefix for the current thread.
def set_script_prefix(prefix): """ Set the script prefix for the current thread. """ if not prefix.endswith('/'): prefix += '/' _prefixes.value = prefix
[ "def", "set_script_prefix", "(", "prefix", ")", ":", "if", "not", "prefix", ".", "endswith", "(", "'/'", ")", ":", "prefix", "+=", "'/'", "_prefixes", ".", "value", "=", "prefix" ]
[ 102, 0 ]
[ 108, 28 ]
python
en
['en', 'error', 'th']
False
get_script_prefix
()
Return the currently active script prefix. Useful for client code that wishes to construct their own URLs manually (although accessing the request instance is normally going to be a lot cleaner).
Return the currently active script prefix. Useful for client code that wishes to construct their own URLs manually (although accessing the request instance is normally going to be a lot cleaner).
def get_script_prefix(): """ Return the currently active script prefix. Useful for client code that wishes to construct their own URLs manually (although accessing the request instance is normally going to be a lot cleaner). """ return getattr(_prefixes, "value", '/')
[ "def", "get_script_prefix", "(", ")", ":", "return", "getattr", "(", "_prefixes", ",", "\"value\"", ",", "'/'", ")" ]
[ 111, 0 ]
[ 117, 43 ]
python
en
['en', 'error', 'th']
False
clear_script_prefix
()
Unset the script prefix for the current thread.
Unset the script prefix for the current thread.
def clear_script_prefix(): """ Unset the script prefix for the current thread. """ try: del _prefixes.value except AttributeError: pass
[ "def", "clear_script_prefix", "(", ")", ":", "try", ":", "del", "_prefixes", ".", "value", "except", "AttributeError", ":", "pass" ]
[ 120, 0 ]
[ 127, 12 ]
python
en
['en', 'error', 'th']
False
set_urlconf
(urlconf_name)
Set the URLconf for the current thread (overriding the default one in settings). If urlconf_name is None, revert back to the default.
Set the URLconf for the current thread (overriding the default one in settings). If urlconf_name is None, revert back to the default.
def set_urlconf(urlconf_name): """ Set the URLconf for the current thread (overriding the default one in settings). If urlconf_name is None, revert back to the default. """ if urlconf_name: _urlconfs.value = urlconf_name else: if hasattr(_urlconfs, "value"): del _urlc...
[ "def", "set_urlconf", "(", "urlconf_name", ")", ":", "if", "urlconf_name", ":", "_urlconfs", ".", "value", "=", "urlconf_name", "else", ":", "if", "hasattr", "(", "_urlconfs", ",", "\"value\"", ")", ":", "del", "_urlconfs", ".", "value" ]
[ 130, 0 ]
[ 139, 31 ]
python
en
['en', 'error', 'th']
False
get_urlconf
(default=None)
Return the root URLconf to use for the current thread if it has been changed from the default one.
Return the root URLconf to use for the current thread if it has been changed from the default one.
def get_urlconf(default=None): """ Return the root URLconf to use for the current thread if it has been changed from the default one. """ return getattr(_urlconfs, "value", default)
[ "def", "get_urlconf", "(", "default", "=", "None", ")", ":", "return", "getattr", "(", "_urlconfs", ",", "\"value\"", ",", "default", ")" ]
[ 142, 0 ]
[ 147, 47 ]
python
en
['en', 'error', 'th']
False
is_valid_path
(path, urlconf=None)
Return True if the given path resolves against the default URL resolver, False otherwise. This is a convenience method to make working with "is this a match?" cases easier, avoiding try...except blocks.
Return True if the given path resolves against the default URL resolver, False otherwise. This is a convenience method to make working with "is this a match?" cases easier, avoiding try...except blocks.
def is_valid_path(path, urlconf=None): """ Return True if the given path resolves against the default URL resolver, False otherwise. This is a convenience method to make working with "is this a match?" cases easier, avoiding try...except blocks. """ try: resolve(path, urlconf) re...
[ "def", "is_valid_path", "(", "path", ",", "urlconf", "=", "None", ")", ":", "try", ":", "resolve", "(", "path", ",", "urlconf", ")", "return", "True", "except", "Resolver404", ":", "return", "False" ]
[ 150, 0 ]
[ 160, 20 ]
python
en
['en', 'error', 'th']
False
translate_url
(url, lang_code)
Given a URL (absolute or relative), try to get its translated version in the `lang_code` language (either by i18n_patterns or by translated regex). Return the original URL if no translated version is found.
Given a URL (absolute or relative), try to get its translated version in the `lang_code` language (either by i18n_patterns or by translated regex). Return the original URL if no translated version is found.
def translate_url(url, lang_code): """ Given a URL (absolute or relative), try to get its translated version in the `lang_code` language (either by i18n_patterns or by translated regex). Return the original URL if no translated version is found. """ parsed = urlsplit(url) try: match ...
[ "def", "translate_url", "(", "url", ",", "lang_code", ")", ":", "parsed", "=", "urlsplit", "(", "url", ")", "try", ":", "match", "=", "resolve", "(", "parsed", ".", "path", ")", "except", "Resolver404", ":", "pass", "else", ":", "to_be_reversed", "=", ...
[ 163, 0 ]
[ 183, 14 ]
python
en
['en', 'error', 'th']
False
DistanceThresholdFilter.__init__
(self, distance_threshold)
Keeps the distance threshold
Keeps the distance threshold
def __init__(self, distance_threshold): """ Keeps the distance threshold """ self.distance_threshold = distance_threshold
[ "def", "__init__", "(", "self", ",", "distance_threshold", ")", ":", "self", ".", "distance_threshold", "=", "distance_threshold" ]
[ 30, 4 ]
[ 34, 52 ]
python
en
['en', 'error', 'th']
False
DistanceThresholdFilter.filter_vectors
(self, input_list)
Returns subset of specified input list.
Returns subset of specified input list.
def filter_vectors(self, input_list): """ Returns subset of specified input list. """ try: # Return filtered (vector, data, distance )tuple list. Will fail # if input is list of (vector, data) tuples. return [x for x in input_list if x[2] < self.distan...
[ "def", "filter_vectors", "(", "self", ",", "input_list", ")", ":", "try", ":", "# Return filtered (vector, data, distance )tuple list. Will fail", "# if input is list of (vector, data) tuples.", "return", "[", "x", "for", "x", "in", "input_list", "if", "x", "[", "2", "]...
[ 36, 4 ]
[ 46, 29 ]
python
en
['en', 'error', 'th']
False
_FindCommandInPath
(command)
If there are no slashes in the command given, this function searches the PATH env to find the given command, and converts it to an absolute path. We have to do this because MSVS is looking for an actual file to launch a debugger on, not just a command line. Note that this happens at GYP time, so a...
If there are no slashes in the command given, this function searches the PATH env to find the given command, and converts it to an absolute path. We have to do this because MSVS is looking for an actual file to launch a debugger on, not just a command line. Note that this happens at GYP time, so a...
def _FindCommandInPath(command): """If there are no slashes in the command given, this function searches the PATH env to find the given command, and converts it to an absolute path. We have to do this because MSVS is looking for an actual file to launch a debugger on, not just a command line. ...
[ "def", "_FindCommandInPath", "(", "command", ")", ":", "if", "\"/\"", "in", "command", "or", "\"\\\\\"", "in", "command", ":", "# If the command already has path elements (either relative or", "# absolute), then assume it is constructed properly.", "return", "command", "else", ...
[ 16, 0 ]
[ 35, 18 ]
python
en
['en', 'en', 'en']
True
Writer.__init__
(self, user_file_path, version, name)
Initializes the user file. Args: user_file_path: Path to the user file. version: Version info. name: Name of the user file.
Initializes the user file.
def __init__(self, user_file_path, version, name): """Initializes the user file. Args: user_file_path: Path to the user file. version: Version info. name: Name of the user file. """ self.user_file_path = user_file_path self.version = version self.name = name ...
[ "def", "__init__", "(", "self", ",", "user_file_path", ",", "version", ",", "name", ")", ":", "self", ".", "user_file_path", "=", "user_file_path", "self", ".", "version", "=", "version", "self", ".", "name", "=", "name", "self", ".", "configurations", "="...
[ 58, 4 ]
[ 69, 32 ]
python
en
['en', 'en', 'en']
True
Writer.AddConfig
(self, name)
Adds a configuration to the project. Args: name: Configuration name.
Adds a configuration to the project.
def AddConfig(self, name): """Adds a configuration to the project. Args: name: Configuration name. """ self.configurations[name] = ["Configuration", {"Name": name}]
[ "def", "AddConfig", "(", "self", ",", "name", ")", ":", "self", ".", "configurations", "[", "name", "]", "=", "[", "\"Configuration\"", ",", "{", "\"Name\"", ":", "name", "}", "]" ]
[ 71, 4 ]
[ 77, 69 ]
python
en
['en', 'en', 'en']
True
Writer.AddDebugSettings
( self, config_name, command, environment={}, working_directory="" )
Adds a DebugSettings node to the user file for a particular config. Args: command: command line to run. First element in the list is the executable. All elements of the command will be quoted if necessary. working_directory: other files which may trigger the rule. (optional)
Adds a DebugSettings node to the user file for a particular config.
def AddDebugSettings( self, config_name, command, environment={}, working_directory="" ): """Adds a DebugSettings node to the user file for a particular config. Args: command: command line to run. First element in the list is the executable. All elements of the command will be q...
[ "def", "AddDebugSettings", "(", "self", ",", "config_name", ",", "command", ",", "environment", "=", "{", "}", ",", "working_directory", "=", "\"\"", ")", ":", "command", "=", "_QuoteWin32CommandLineArgs", "(", "command", ")", "abs_command", "=", "_FindCommandIn...
[ 79, 4 ]
[ 137, 54 ]
python
en
['en', 'en', 'en']
True
Writer.WriteIfChanged
(self)
Writes the user file.
Writes the user file.
def WriteIfChanged(self): """Writes the user file.""" configs = ["Configurations"] for config, spec in sorted(self.configurations.items()): configs.append(spec) content = [ "VisualStudioUserFile", {"Version": self.version.ProjectVersion(), "Name": sel...
[ "def", "WriteIfChanged", "(", "self", ")", ":", "configs", "=", "[", "\"Configurations\"", "]", "for", "config", ",", "spec", "in", "sorted", "(", "self", ".", "configurations", ".", "items", "(", ")", ")", ":", "configs", ".", "append", "(", "spec", "...
[ 139, 4 ]
[ 152, 9 ]
python
en
['en', 'en', 'en']
True
_compile_regex
(regex: str)
Compile the regex for the module constants :param regex: :return:
Compile the regex for the module constants :param regex: :return:
def _compile_regex(regex: str): """ Compile the regex for the module constants :param regex: :return: """ r = re.compile(regex) def match(string): if not re.match(r, string): raise LookupError("%s not valid as expected" % regex) return string return match
[ "def", "_compile_regex", "(", "regex", ":", "str", ")", ":", "r", "=", "re", ".", "compile", "(", "regex", ")", "def", "match", "(", "string", ")", ":", "if", "not", "re", ".", "match", "(", "r", ",", "string", ")", ":", "raise", "LookupError", "...
[ 23, 0 ]
[ 36, 16 ]
python
en
['en', 'error', 'th']
False