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
StubManager.load_from
(self, directory, *args, **kwargs)
Recursively loads stubs from a directory. Args: directory (str): Path to load from Returns: [DeviceStub]: List of loaded Stubs
Recursively loads stubs from a directory.
def load_from(self, directory, *args, **kwargs): """Recursively loads stubs from a directory. Args: directory (str): Path to load from Returns: [DeviceStub]: List of loaded Stubs """ dir_path = Path(str(directory)).resolve() dirs = dir_path.iter...
[ "def", "load_from", "(", "self", ",", "directory", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dir_path", "=", "Path", "(", "str", "(", "directory", ")", ")", ".", "resolve", "(", ")", "dirs", "=", "dir_path", ".", "iterdir", "(", ")", ...
[ 234, 4 ]
[ 255, 20 ]
python
en
['en', 'en', 'en']
True
StubManager._should_recurse
(self, location)
Checks for multiple stubs in a location. Args: location (str): location of potential stub Raises: StubError: No info files could be found Returns: bool: True if multiple stubs are found
Checks for multiple stubs in a location.
def _should_recurse(self, location): """Checks for multiple stubs in a location. Args: location (str): location of potential stub Raises: StubError: No info files could be found Returns: bool: True if multiple stubs are found """ if...
[ "def", "_should_recurse", "(", "self", ",", "location", ")", ":", "if", "not", "Path", "(", "location", ")", ".", "exists", "(", ")", ":", "return", "False", "path", "=", "Path", "(", "location", ")", ".", "resolve", "(", ")", "info_glob", "=", "list...
[ 257, 4 ]
[ 278, 20 ]
python
en
['en', 'en', 'en']
True
StubManager.add
(self, location, dest=None, force=False)
Add stub(s) from source. Args: source (str): path to stub(s) dest (str, optional): path to copy stubs to. Defaults to self.resource force (bool, optional): overwrite existing stubs. Defaults to False. Raises: TypeError: No...
Add stub(s) from source.
def add(self, location, dest=None, force=False): """Add stub(s) from source. Args: source (str): path to stub(s) dest (str, optional): path to copy stubs to. Defaults to self.resource force (bool, optional): overwrite existing stubs. D...
[ "def", "add", "(", "self", ",", "location", ",", "dest", "=", "None", ",", "force", "=", "False", ")", ":", "_dest", "=", "dest", "or", "self", ".", "resource", "if", "not", "_dest", ":", "raise", "TypeError", "(", "\"No Stub Destination Provided!\"", ")...
[ 280, 4 ]
[ 310, 52 ]
python
en
['en', 'en', 'en']
True
StubManager.from_stubber
(self, path, dest)
Formats stubs generated by createstubs.py. Creates a stub package from the stubs generated by createstubs.py. Also attempts to auto-resolve the stubs firmware name. Args: path (str): path to generated stubs dest (str): path to output Returns: ...
Formats stubs generated by createstubs.py.
def from_stubber(self, path, dest): """Formats stubs generated by createstubs.py. Creates a stub package from the stubs generated by createstubs.py. Also attempts to auto-resolve the stubs firmware name. Args: path (str): path to generated stubs dest (st...
[ "def", "from_stubber", "(", "self", ",", "path", ",", "dest", ")", ":", "_path", "=", "Path", "(", "path", ")", ".", "resolve", "(", ")", "dest", "=", "Path", "(", "dest", ")", ".", "resolve", "(", ")", "mod_file", "=", "next", "(", "_path", ".",...
[ 312, 4 ]
[ 345, 23 ]
python
en
['en', 'en', 'en']
True
StubManager.search_remote
(self, query)
Search all repositories for query. Args: query (str): query to search for Returns: [tuple]: List of result tuples. The first item is the package name, and the second is a bool based on whether the package is installed or not
Search all repositories for query.
def search_remote(self, query): """Search all repositories for query. Args: query (str): query to search for Returns: [tuple]: List of result tuples. The first item is the package name, and the second is a bool based on whether the packag...
[ "def", "search_remote", "(", "self", ",", "query", ")", ":", "results", "=", "[", "]", "installed", "=", "[", "str", "(", "s", ")", "for", "s", "in", "self", ".", "_loaded", ".", "union", "(", "self", ".", "_firmware", ")", "]", "for", "repo", "i...
[ 347, 4 ]
[ 364, 30 ]
python
en
['en', 'en', 'en']
True
StubManager.resolve_subresource
(self, stubs, subresource)
Resolve or Create StubManager from list of stubs. Args: stubs ([Stub]): List of stubs to use in subresource subresource (str): path to subresource Returns: StubManager: StubManager with subresource stubs
Resolve or Create StubManager from list of stubs.
def resolve_subresource(self, stubs, subresource): """Resolve or Create StubManager from list of stubs. Args: stubs ([Stub]): List of stubs to use in subresource subresource (str): path to subresource Returns: StubManager: StubManager with subresource stubs ...
[ "def", "resolve_subresource", "(", "self", ",", "stubs", ",", "subresource", ")", ":", "for", "stub", "in", "stubs", ":", "fware", "=", "stub", ".", "firmware", "if", "fware", ":", "link", "=", "subresource", "/", "fware", ".", "path", ".", "name", "fw...
[ 366, 4 ]
[ 385, 22 ]
python
en
['en', 'en', 'en']
True
Stub.copy_to
(self, dest, name=None)
Copy stub to a directory.
Copy stub to a directory.
def copy_to(self, dest, name=None): """Copy stub to a directory.""" if not name: dest = Path(dest) / self.path.name shutil.copytree(self.path, dest) self.path = dest.resolve() return self
[ "def", "copy_to", "(", "self", ",", "dest", ",", "name", "=", "None", ")", ":", "if", "not", "name", ":", "dest", "=", "Path", "(", "dest", ")", "/", "self", ".", "path", ".", "name", "shutil", ".", "copytree", "(", "self", ".", "path", ",", "d...
[ 409, 4 ]
[ 415, 19 ]
python
en
['en', 'en', 'en']
True
Stub.resolve_link
(cls, stub, link_path)
Resolve or Create Stub Symlink. Args: stub (Stub): stub to resolve link_path (str): path to link Returns: Stub: Stub from symlink
Resolve or Create Stub Symlink.
def resolve_link(cls, stub, link_path): """Resolve or Create Stub Symlink. Args: stub (Stub): stub to resolve link_path (str): path to link Returns: Stub: Stub from symlink """ fware = stub.firmware if utils.is_dir_link(link_path): ...
[ "def", "resolve_link", "(", "cls", ",", "stub", ",", "link_path", ")", ":", "fware", "=", "stub", ".", "firmware", "if", "utils", ".", "is_dir_link", "(", "link_path", ")", ":", "return", "cls", "(", "link_path", ",", "firmware", "=", "fware", ")", "ut...
[ 418, 4 ]
[ 433, 45 ]
python
en
['en', 'da', 'en']
True
Stub.name
(self)
Human friendly stub name.
Human friendly stub name.
def name(self): """Human friendly stub name.""" raise NotImplementedError
[ "def", "name", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 436, 4 ]
[ 438, 33 ]
python
en
['en', 'ht', 'en']
True
DeviceStub.firmware_name
(self)
Return an appropriate firmware name. Returns: str: Name of Firmware
Return an appropriate firmware name.
def firmware_name(self): """Return an appropriate firmware name. Returns: str: Name of Firmware """ if isinstance(self.firmware, FirmwareStub): return self.firmware.firmware fware = self.firm_info.get("name", None) if not fware: fware...
[ "def", "firmware_name", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "firmware", ",", "FirmwareStub", ")", ":", "return", "self", ".", "firmware", ".", "firmware", "fware", "=", "self", ".", "firm_info", ".", "get", "(", "\"name\"", ",", ...
[ 476, 4 ]
[ 489, 20 ]
python
en
['en', 'en', 'en']
True
render_value_in_context
(value, context)
Convert any value to a string to become part of a rendered template. This means escaping, if required, and conversion to a string. If value is a string, it's expected to already be translated.
Convert any value to a string to become part of a rendered template. This means escaping, if required, and conversion to a string. If value is a string, it's expected to already be translated.
def render_value_in_context(value, context): """ Convert any value to a string to become part of a rendered template. This means escaping, if required, and conversion to a string. If value is a string, it's expected to already be translated. """ value = template_localtime(value, use_tz=context.u...
[ "def", "render_value_in_context", "(", "value", ",", "context", ")", ":", "value", "=", "template_localtime", "(", "value", ",", "use_tz", "=", "context", ".", "use_tz", ")", "value", "=", "localize", "(", "value", ",", "use_l10n", "=", "context", ".", "us...
[ 960, 0 ]
[ 973, 25 ]
python
en
['en', 'error', 'th']
False
token_kwargs
(bits, parser, support_legacy=False)
Parse token keyword arguments and return a dictionary of the arguments retrieved from the ``bits`` token list. `bits` is a list containing the remainder of the token (split by spaces) that is to be checked for arguments. Valid arguments are removed from this list. `support_legacy` - if True, ...
Parse token keyword arguments and return a dictionary of the arguments retrieved from the ``bits`` token list.
def token_kwargs(bits, parser, support_legacy=False): """ Parse token keyword arguments and return a dictionary of the arguments retrieved from the ``bits`` token list. `bits` is a list containing the remainder of the token (split by spaces) that is to be checked for arguments. Valid arguments are ...
[ "def", "token_kwargs", "(", "bits", ",", "parser", ",", "support_legacy", "=", "False", ")", ":", "if", "not", "bits", ":", "return", "{", "}", "match", "=", "kwarg_re", ".", "match", "(", "bits", "[", "0", "]", ")", "kwarg_format", "=", "match", "an...
[ 998, 0 ]
[ 1042, 17 ]
python
en
['en', 'error', 'th']
False
Template.render
(self, context)
Display stage -- can be called many times
Display stage -- can be called many times
def render(self, context): "Display stage -- can be called many times" with context.render_context.push_state(self): if context.template is None: with context.bind_template(self): context.template_name = self.name return self._render(co...
[ "def", "render", "(", "self", ",", "context", ")", ":", "with", "context", ".", "render_context", ".", "push_state", "(", "self", ")", ":", "if", "context", ".", "template", "is", "None", ":", "with", "context", ".", "bind_template", "(", "self", ")", ...
[ 164, 4 ]
[ 172, 44 ]
python
en
['en', 'en', 'en']
True
Template.compile_nodelist
(self)
Parse and compile the template source into a nodelist. If debug is True and an exception occurs during parsing, the exception is is annotated with contextual line information where it occurred in the template source.
Parse and compile the template source into a nodelist. If debug is True and an exception occurs during parsing, the exception is is annotated with contextual line information where it occurred in the template source.
def compile_nodelist(self): """ Parse and compile the template source into a nodelist. If debug is True and an exception occurs during parsing, the exception is is annotated with contextual line information where it occurred in the template source. """ if self.eng...
[ "def", "compile_nodelist", "(", "self", ")", ":", "if", "self", ".", "engine", ".", "debug", ":", "lexer", "=", "DebugLexer", "(", "self", ".", "source", ")", "else", ":", "lexer", "=", "Lexer", "(", "self", ".", "source", ")", "tokens", "=", "lexer"...
[ 174, 4 ]
[ 197, 17 ]
python
en
['en', 'error', 'th']
False
Template.get_exception_info
(self, exception, token)
Return a dictionary containing contextual line information of where the exception occurred in the template. The following information is provided: message The message of the exception raised. source_lines The lines before, after, and including the line ...
Return a dictionary containing contextual line information of where the exception occurred in the template. The following information is provided:
def get_exception_info(self, exception, token): """ Return a dictionary containing contextual line information of where the exception occurred in the template. The following information is provided: message The message of the exception raised. source_lines ...
[ "def", "get_exception_info", "(", "self", ",", "exception", ",", "token", ")", ":", "start", ",", "end", "=", "token", ".", "position", "context_lines", "=", "10", "line", "=", "0", "upto", "=", "0", "source_lines", "=", "[", "]", "before", "=", "durin...
[ 199, 4 ]
[ 275, 9 ]
python
en
['en', 'error', 'th']
False
Token.__init__
(self, token_type, contents, position=None, lineno=None)
A token representing a string from the template. token_type A TokenType, either .TEXT, .VAR, .BLOCK, or .COMMENT. contents The token source string. position An optional tuple containing the start and end index of the token in the templa...
A token representing a string from the template.
def __init__(self, token_type, contents, position=None, lineno=None): """ A token representing a string from the template. token_type A TokenType, either .TEXT, .VAR, .BLOCK, or .COMMENT. contents The token source string. position An optiona...
[ "def", "__init__", "(", "self", ",", "token_type", ",", "contents", ",", "position", "=", "None", ",", "lineno", "=", "None", ")", ":", "self", ".", "token_type", ",", "self", ".", "contents", "=", "token_type", ",", "contents", "self", ".", "lineno", ...
[ 288, 4 ]
[ 309, 32 ]
python
en
['en', 'error', 'th']
False
Lexer.tokenize
(self)
Return a list of tokens from a given template_string.
Return a list of tokens from a given template_string.
def tokenize(self): """ Return a list of tokens from a given template_string. """ in_tag = False lineno = 1 result = [] for bit in tag_re.split(self.template_string): if bit: result.append(self.create_token(bit, None, lineno, in_tag)) ...
[ "def", "tokenize", "(", "self", ")", ":", "in_tag", "=", "False", "lineno", "=", "1", "result", "=", "[", "]", "for", "bit", "in", "tag_re", ".", "split", "(", "self", ".", "template_string", ")", ":", "if", "bit", ":", "result", ".", "append", "("...
[ 337, 4 ]
[ 349, 21 ]
python
en
['en', 'error', 'th']
False
Lexer.create_token
(self, token_string, position, lineno, in_tag)
Convert the given token string into a new Token object and return it. If in_tag is True, we are processing something that matched a tag, otherwise it should be treated as a literal string.
Convert the given token string into a new Token object and return it. If in_tag is True, we are processing something that matched a tag, otherwise it should be treated as a literal string.
def create_token(self, token_string, position, lineno, in_tag): """ Convert the given token string into a new Token object and return it. If in_tag is True, we are processing something that matched a tag, otherwise it should be treated as a literal string. """ if in_tag a...
[ "def", "create_token", "(", "self", ",", "token_string", ",", "position", ",", "lineno", ",", "in_tag", ")", ":", "if", "in_tag", "and", "token_string", ".", "startswith", "(", "BLOCK_TAG_START", ")", ":", "# The [2:-2] ranges below strip off *_TAG_START and *_TAG_END...
[ 351, 4 ]
[ 378, 72 ]
python
en
['en', 'error', 'th']
False
DebugLexer.tokenize
(self)
Split a template string into tokens and annotates each token with its start and end position in the source. This is slower than the default lexer so only use it when debug is True.
Split a template string into tokens and annotates each token with its start and end position in the source. This is slower than the default lexer so only use it when debug is True.
def tokenize(self): """ Split a template string into tokens and annotates each token with its start and end position in the source. This is slower than the default lexer so only use it when debug is True. """ lineno = 1 result = [] upto = 0 for mat...
[ "def", "tokenize", "(", "self", ")", ":", "lineno", "=", "1", "result", "=", "[", "]", "upto", "=", "0", "for", "match", "in", "tag_re", ".", "finditer", "(", "self", ".", "template_string", ")", ":", "start", ",", "end", "=", "match", ".", "span",...
[ 382, 4 ]
[ 404, 21 ]
python
en
['en', 'error', 'th']
False
Parser.parse
(self, parse_until=None)
Iterate through the parser tokens and compiles each one into a node. If parse_until is provided, parsing will stop once one of the specified tokens has been reached. This is formatted as a list of tokens, e.g. ['elif', 'else', 'endif']. If no matching token is reached, raise an...
Iterate through the parser tokens and compiles each one into a node.
def parse(self, parse_until=None): """ Iterate through the parser tokens and compiles each one into a node. If parse_until is provided, parsing will stop once one of the specified tokens has been reached. This is formatted as a list of tokens, e.g. ['elif', 'else', 'endif']. If ...
[ "def", "parse", "(", "self", ",", "parse_until", "=", "None", ")", ":", "if", "parse_until", "is", "None", ":", "parse_until", "=", "[", "]", "nodelist", "=", "NodeList", "(", ")", "while", "self", ".", "tokens", ":", "token", "=", "self", ".", "next...
[ 424, 4 ]
[ 482, 23 ]
python
en
['en', 'error', 'th']
False
Parser.error
(self, token, e)
Return an exception annotated with the originating token. Since the parser can be called recursively, check if a token is already set. This ensures the innermost token is highlighted if an exception occurs, e.g. a compile error within the body of an if statement.
Return an exception annotated with the originating token. Since the parser can be called recursively, check if a token is already set. This ensures the innermost token is highlighted if an exception occurs, e.g. a compile error within the body of an if statement.
def error(self, token, e): """ Return an exception annotated with the originating token. Since the parser can be called recursively, check if a token is already set. This ensures the innermost token is highlighted if an exception occurs, e.g. a compile error within the body of an...
[ "def", "error", "(", "self", ",", "token", ",", "e", ")", ":", "if", "not", "isinstance", "(", "e", ",", "Exception", ")", ":", "e", "=", "TemplateSyntaxError", "(", "e", ")", "if", "not", "hasattr", "(", "e", ",", "'token'", ")", ":", "e", ".", ...
[ 505, 4 ]
[ 516, 16 ]
python
en
['en', 'error', 'th']
False
Parser.compile_filter
(self, token)
Convenient wrapper for FilterExpression
Convenient wrapper for FilterExpression
def compile_filter(self, token): """ Convenient wrapper for FilterExpression """ return FilterExpression(token, self)
[ "def", "compile_filter", "(", "self", ",", "token", ")", ":", "return", "FilterExpression", "(", "token", ",", "self", ")" ]
[ 557, 4 ]
[ 561, 44 ]
python
en
['en', 'error', 'th']
False
Variable.resolve
(self, context)
Resolve this variable against a given context.
Resolve this variable against a given context.
def resolve(self, context): """Resolve this variable against a given context.""" if self.lookups is not None: # We're dealing with a variable that needs to be resolved value = self._resolve_lookup(context) else: # We're dealing with a literal, so it's already ...
[ "def", "resolve", "(", "self", ",", "context", ")", ":", "if", "self", ".", "lookups", "is", "not", "None", ":", "# We're dealing with a variable that needs to be resolved", "value", "=", "self", ".", "_resolve_lookup", "(", "context", ")", "else", ":", "# We're...
[ 790, 4 ]
[ 806, 20 ]
python
en
['en', 'en', 'en']
True
Variable._resolve_lookup
(self, context)
Perform resolution of a real variable (i.e. not a literal) against the given context. As indicated by the method's name, this method is an implementation detail and shouldn't be called by external code. Use Variable.resolve() instead.
Perform resolution of a real variable (i.e. not a literal) against the given context.
def _resolve_lookup(self, context): """ Perform resolution of a real variable (i.e. not a literal) against the given context. As indicated by the method's name, this method is an implementation detail and shouldn't be called by external code. Use Variable.resolve() inste...
[ "def", "_resolve_lookup", "(", "self", ",", "context", ")", ":", "current", "=", "context", "try", ":", "# catch-all for silent variable failures", "for", "bit", "in", "self", ".", "lookups", ":", "try", ":", "# dictionary lookup", "current", "=", "current", "["...
[ 814, 4 ]
[ 878, 22 ]
python
en
['en', 'error', 'th']
False
Node.render
(self, context)
Return the node rendered as a string.
Return the node rendered as a string.
def render(self, context): """ Return the node rendered as a string. """ pass
[ "def", "render", "(", "self", ",", "context", ")", ":", "pass" ]
[ 888, 4 ]
[ 892, 12 ]
python
en
['en', 'error', 'th']
False
Node.render_annotated
(self, context)
Render the node. If debug is True and an exception occurs during rendering, the exception is annotated with contextual line information where it occurred in the template. For internal usage this method is preferred over using the render method directly.
Render the node. If debug is True and an exception occurs during rendering, the exception is annotated with contextual line information where it occurred in the template. For internal usage this method is preferred over using the render method directly.
def render_annotated(self, context): """ Render the node. If debug is True and an exception occurs during rendering, the exception is annotated with contextual line information where it occurred in the template. For internal usage this method is preferred over using the render me...
[ "def", "render_annotated", "(", "self", ",", "context", ")", ":", "try", ":", "return", "self", ".", "render", "(", "context", ")", "except", "Exception", "as", "e", ":", "if", "context", ".", "template", ".", "engine", ".", "debug", "and", "not", "has...
[ 894, 4 ]
[ 906, 17 ]
python
en
['en', 'error', 'th']
False
Node.get_nodes_by_type
(self, nodetype)
Return a list of all nodes (within this node and its nodelist) of the given type
Return a list of all nodes (within this node and its nodelist) of the given type
def get_nodes_by_type(self, nodetype): """ Return a list of all nodes (within this node and its nodelist) of the given type """ nodes = [] if isinstance(self, nodetype): nodes.append(self) for attr in self.child_nodelists: nodelist = getatt...
[ "def", "get_nodes_by_type", "(", "self", ",", "nodetype", ")", ":", "nodes", "=", "[", "]", "if", "isinstance", "(", "self", ",", "nodetype", ")", ":", "nodes", ".", "append", "(", "self", ")", "for", "attr", "in", "self", ".", "child_nodelists", ":", ...
[ 911, 4 ]
[ 923, 20 ]
python
en
['en', 'error', 'th']
False
NodeList.get_nodes_by_type
(self, nodetype)
Return a list of all nodes of the given type
Return a list of all nodes of the given type
def get_nodes_by_type(self, nodetype): "Return a list of all nodes of the given type" nodes = [] for node in self: nodes.extend(node.get_nodes_by_type(nodetype)) return nodes
[ "def", "get_nodes_by_type", "(", "self", ",", "nodetype", ")", ":", "nodes", "=", "[", "]", "for", "node", "in", "self", ":", "nodes", ".", "extend", "(", "node", ".", "get_nodes_by_type", "(", "nodetype", ")", ")", "return", "nodes" ]
[ 941, 4 ]
[ 946, 20 ]
python
en
['en', 'en', 'en']
True
RemoteUserMiddleware.clean_username
(self, username, request)
Allow the backend to clean the username, if the backend defines a clean_username method.
Allow the backend to clean the username, if the backend defines a clean_username method.
def clean_username(self, username, request): """ Allow the backend to clean the username, if the backend defines a clean_username method. """ backend_str = request.session[auth.BACKEND_SESSION_KEY] backend = auth.load_backend(backend_str) try: username...
[ "def", "clean_username", "(", "self", ",", "username", ",", "request", ")", ":", "backend_str", "=", "request", ".", "session", "[", "auth", ".", "BACKEND_SESSION_KEY", "]", "backend", "=", "auth", ".", "load_backend", "(", "backend_str", ")", "try", ":", ...
[ 84, 4 ]
[ 95, 23 ]
python
en
['en', 'error', 'th']
False
RemoteUserMiddleware._remove_invalid_user
(self, request)
Remove the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend.
Remove the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend.
def _remove_invalid_user(self, request): """ Remove the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend. """ try: stored_backend = load_backend(request.session.get(auth.BACKEND_SESSION_KEY, '')...
[ "def", "_remove_invalid_user", "(", "self", ",", "request", ")", ":", "try", ":", "stored_backend", "=", "load_backend", "(", "request", ".", "session", ".", "get", "(", "auth", ".", "BACKEND_SESSION_KEY", ",", "''", ")", ")", "except", "ImportError", ":", ...
[ 97, 4 ]
[ 109, 36 ]
python
en
['en', 'error', 'th']
False
bagnet32
(regularization = 0, pretrained=True, strides=[2, 2, 2, 1], **kwargs)
Constructs a Bagnet-32 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
Constructs a Bagnet-32 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
def bagnet32(regularization = 0, pretrained=True, strides=[2, 2, 2, 1], **kwargs): """Constructs a Bagnet-32 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = BagNet(regularization, Bottleneck, [3, 4, 6, 3], strides=strides, kernel3=[1,1,1,1], **kwargs)...
[ "def", "bagnet32", "(", "regularization", "=", "0", ",", "pretrained", "=", "True", ",", "strides", "=", "[", "2", ",", "2", ",", "2", ",", "1", "]", ",", "*", "*", "kwargs", ")", ":", "model", "=", "BagNet", "(", "regularization", ",", "Bottleneck...
[ 134, 0 ]
[ 142, 16 ]
python
en
['en', 'en', 'en']
True
bagnet16
(regularization = 0, pretrained=True, strides=[2, 2, 2, 1], **kwargs)
Constructs a Bagnet-16 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
Constructs a Bagnet-16 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
def bagnet16(regularization = 0, pretrained=True, strides=[2, 2, 2, 1], **kwargs): """Constructs a Bagnet-16 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = BagNet(regularization, Bottleneck, [ 3, 4, 6, 3], strides=strides, kernel3=[1,1,1,0], **kwargs...
[ "def", "bagnet16", "(", "regularization", "=", "0", ",", "pretrained", "=", "True", ",", "strides", "=", "[", "2", ",", "2", ",", "2", ",", "1", "]", ",", "*", "*", "kwargs", ")", ":", "model", "=", "BagNet", "(", "regularization", ",", "Bottleneck...
[ 144, 0 ]
[ 152, 16 ]
python
en
['en', 'en', 'en']
True
bagnet8
(regularization = 0, pretrained=True, strides=[2, 2, 2, 1], **kwargs)
Constructs a Bagnet-8 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
Constructs a Bagnet-8 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
def bagnet8(regularization = 0, pretrained=True, strides=[2, 2, 2, 1], **kwargs): """Constructs a Bagnet-8 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = BagNet(regularization, Bottleneck, [3, 4, 6, 3], strides=strides, kernel3=[1,1,0,0], **kwargs) ...
[ "def", "bagnet8", "(", "regularization", "=", "0", ",", "pretrained", "=", "True", ",", "strides", "=", "[", "2", ",", "2", ",", "2", ",", "1", "]", ",", "*", "*", "kwargs", ")", ":", "model", "=", "BagNet", "(", "regularization", ",", "Bottleneck"...
[ 154, 0 ]
[ 162, 16 ]
python
en
['en', 'en', 'en']
True
ModWsgiHandlerTestCase.test_check_password
(self)
Verify that check_password returns the correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider
Verify that check_password returns the correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider
def test_check_password(self): """ Verify that check_password returns the correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider """ User.objects.create_user('test', 'test@example.com', 'test') # User not in dat...
[ "def", "test_check_password", "(", "self", ")", ":", "User", ".", "objects", ".", "create_user", "(", "'test'", ",", "'test@example.com'", ",", "'test'", ")", "# User not in database", "self", ".", "assertTrue", "(", "check_password", "(", "{", "}", ",", "'unk...
[ 23, 4 ]
[ 41, 65 ]
python
en
['en', 'error', 'th']
False
ModWsgiHandlerTestCase.test_check_password_custom_user
(self)
Verify that check_password returns the correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider with custom user installed
Verify that check_password returns the correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider
def test_check_password_custom_user(self): """ Verify that check_password returns the correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider with custom user installed """ CustomUser._default_manager.create_use...
[ "def", "test_check_password_custom_user", "(", "self", ")", ":", "CustomUser", ".", "_default_manager", ".", "create_user", "(", "'test@example.com'", ",", "'1990-01-01'", ",", "'test'", ")", "# User not in database", "self", ".", "assertTrue", "(", "check_password", ...
[ 44, 4 ]
[ 61, 77 ]
python
en
['en', 'error', 'th']
False
ModWsgiHandlerTestCase.test_groups_for_user
(self)
Check that groups_for_user returns correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Group_Authorisation
Check that groups_for_user returns correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Group_Authorisation
def test_groups_for_user(self): """ Check that groups_for_user returns correct values as per http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Group_Authorisation """ user1 = User.objects.create_user('test', 'test@example.com', 'test') User.objects.crea...
[ "def", "test_groups_for_user", "(", "self", ")", ":", "user1", "=", "User", ".", "objects", ".", "create_user", "(", "'test'", ",", "'test@example.com'", ",", "'test'", ")", "User", ".", "objects", ".", "create_user", "(", "'test1'", ",", "'test1@example.com'"...
[ 64, 4 ]
[ 78, 58 ]
python
en
['en', 'error', 'th']
False
_resolve_name
(name, package, level)
Return the absolute name of the module to be imported.
Return the absolute name of the module to be imported.
def _resolve_name(name, package, level): """Return the absolute name of the module to be imported.""" if not hasattr(package, 'rindex'): raise ValueError("'package' not set to a string") dot = len(package) for x in range(level, 1, -1): try: dot = package.rindex('.', 0, dot) ...
[ "def", "_resolve_name", "(", "name", ",", "package", ",", "level", ")", ":", "if", "not", "hasattr", "(", "package", ",", "'rindex'", ")", ":", "raise", "ValueError", "(", "\"'package' not set to a string\"", ")", "dot", "=", "len", "(", "package", ")", "f...
[ 12, 0 ]
[ 22, 42 ]
python
en
['en', 'en', 'en']
True
get_tag_uri
(url, date)
Create a TagURI. See https://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id
Create a TagURI.
def get_tag_uri(url, date): """ Create a TagURI. See https://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id """ bits = urlparse(url) d = '' if date is not None: d = ',%s' % date.strftime('%Y-%m-%d') return 'tag:%s%s:%s/%s' % (bits.ho...
[ "def", "get_tag_uri", "(", "url", ",", "date", ")", ":", "bits", "=", "urlparse", "(", "url", ")", "d", "=", "''", "if", "date", "is", "not", "None", ":", "d", "=", "',%s'", "%", "date", ".", "strftime", "(", "'%Y-%m-%d'", ")", "return", "'tag:%s%s...
[ 45, 0 ]
[ 55, 74 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.add_item
(self, title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, unique_id_is_permalink=None, categories=(), item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs)
Add an item to the feed. All args are expected to be strings except pubdate and updateddate, which are datetime.datetime objects, and enclosures, which is an iterable of instances of the Enclosure class.
Add an item to the feed. All args are expected to be strings except pubdate and updateddate, which are datetime.datetime objects, and enclosures, which is an iterable of instances of the Enclosure class.
def add_item(self, title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, unique_id_is_permalink=None, categories=(), item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs): ...
[ "def", "add_item", "(", "self", ",", "title", ",", "link", ",", "description", ",", "author_email", "=", "None", ",", "author_name", "=", "None", ",", "author_link", "=", "None", ",", "pubdate", "=", "None", ",", "comments", "=", "None", ",", "unique_id"...
[ 84, 4 ]
[ 113, 10 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.root_attributes
(self)
Return extra attributes to place on the root (i.e. feed/channel) element. Called from write().
Return extra attributes to place on the root (i.e. feed/channel) element. Called from write().
def root_attributes(self): """ Return extra attributes to place on the root (i.e. feed/channel) element. Called from write(). """ return {}
[ "def", "root_attributes", "(", "self", ")", ":", "return", "{", "}" ]
[ 118, 4 ]
[ 123, 17 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.add_root_elements
(self, handler)
Add elements in the root (i.e. feed/channel) element. Called from write().
Add elements in the root (i.e. feed/channel) element. Called from write().
def add_root_elements(self, handler): """ Add elements in the root (i.e. feed/channel) element. Called from write(). """ pass
[ "def", "add_root_elements", "(", "self", ",", "handler", ")", ":", "pass" ]
[ 125, 4 ]
[ 130, 12 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.item_attributes
(self, item)
Return extra attributes to place on each item (i.e. item/entry) element.
Return extra attributes to place on each item (i.e. item/entry) element.
def item_attributes(self, item): """ Return extra attributes to place on each item (i.e. item/entry) element. """ return {}
[ "def", "item_attributes", "(", "self", ",", "item", ")", ":", "return", "{", "}" ]
[ 132, 4 ]
[ 136, 17 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.add_item_elements
(self, handler, item)
Add elements on each item (i.e. item/entry) element.
Add elements on each item (i.e. item/entry) element.
def add_item_elements(self, handler, item): """ Add elements on each item (i.e. item/entry) element. """ pass
[ "def", "add_item_elements", "(", "self", ",", "handler", ",", "item", ")", ":", "pass" ]
[ 138, 4 ]
[ 142, 12 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.write
(self, outfile, encoding)
Output the feed in the given encoding to outfile, which is a file-like object. Subclasses should override this.
Output the feed in the given encoding to outfile, which is a file-like object. Subclasses should override this.
def write(self, outfile, encoding): """ Output the feed in the given encoding to outfile, which is a file-like object. Subclasses should override this. """ raise NotImplementedError('subclasses of SyndicationFeed must provide a write() method')
[ "def", "write", "(", "self", ",", "outfile", ",", "encoding", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of SyndicationFeed must provide a write() method'", ")" ]
[ 144, 4 ]
[ 149, 96 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.writeString
(self, encoding)
Return the feed in the given encoding as a string.
Return the feed in the given encoding as a string.
def writeString(self, encoding): """ Return the feed in the given encoding as a string. """ s = StringIO() self.write(s, encoding) return s.getvalue()
[ "def", "writeString", "(", "self", ",", "encoding", ")", ":", "s", "=", "StringIO", "(", ")", "self", ".", "write", "(", "s", ",", "encoding", ")", "return", "s", ".", "getvalue", "(", ")" ]
[ 151, 4 ]
[ 157, 27 ]
python
en
['en', 'error', 'th']
False
SyndicationFeed.latest_post_date
(self)
Return the latest item's pubdate or updateddate. If no items have either of these attributes this return the current UTC date/time.
Return the latest item's pubdate or updateddate. If no items have either of these attributes this return the current UTC date/time.
def latest_post_date(self): """ Return the latest item's pubdate or updateddate. If no items have either of these attributes this return the current UTC date/time. """ latest_date = None date_keys = ('updateddate', 'pubdate') for item in self.items: f...
[ "def", "latest_post_date", "(", "self", ")", ":", "latest_date", "=", "None", "date_keys", "=", "(", "'updateddate'", ",", "'pubdate'", ")", "for", "item", "in", "self", ".", "items", ":", "for", "date_key", "in", "date_keys", ":", "item_date", "=", "item"...
[ 159, 4 ]
[ 175, 76 ]
python
en
['en', 'error', 'th']
False
Enclosure.__init__
(self, url, length, mime_type)
All args are expected to be strings
All args are expected to be strings
def __init__(self, url, length, mime_type): "All args are expected to be strings" self.length, self.mime_type = length, mime_type self.url = iri_to_uri(url)
[ "def", "__init__", "(", "self", ",", "url", ",", "length", ",", "mime_type", ")", ":", "self", ".", "length", ",", "self", ".", "mime_type", "=", "length", ",", "mime_type", "self", ".", "url", "=", "iri_to_uri", "(", "url", ")" ]
[ 180, 4 ]
[ 183, 34 ]
python
en
['en', 'en', 'en']
True
description_of
(lines, name='stdin')
Return a string describing the probable encoding of a file or list of strings. :param lines: The lines to get the encoding of. :type lines: Iterable of bytes :param name: Name of file or collection of lines :type name: str
Return a string describing the probable encoding of a file or list of strings.
def description_of(lines, name='stdin'): """ Return a string describing the probable encoding of a file or list of strings. :param lines: The lines to get the encoding of. :type lines: Iterable of bytes :param name: Name of file or collection of lines :type name: str """ u = Univers...
[ "def", "description_of", "(", "lines", ",", "name", "=", "'stdin'", ")", ":", "u", "=", "UniversalDetector", "(", ")", "for", "line", "in", "lines", ":", "line", "=", "bytearray", "(", "line", ")", "u", ".", "feed", "(", "line", ")", "# shortcut out of...
[ 25, 0 ]
[ 50, 44 ]
python
en
['en', 'error', 'th']
False
main
(argv=None)
Handles command line arguments and gets things started. :param argv: List of arguments, as if specified on the command-line. If None, ``sys.argv[1:]`` is used instead. :type argv: list of str
Handles command line arguments and gets things started.
def main(argv=None): """ Handles command line arguments and gets things started. :param argv: List of arguments, as if specified on the command-line. If None, ``sys.argv[1:]`` is used instead. :type argv: list of str """ # Get command line arguments parser = argparse.Argume...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "# Get command line arguments", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Takes one or more file paths and reports their detected \\\n encodings\"", ")", "parser", ".", ...
[ 53, 0 ]
[ 80, 40 ]
python
en
['en', 'error', 'th']
False
add_message
(request, level, message, extra_tags='', fail_silently=False)
Attempt to add a message to the request using the 'messages' app.
Attempt to add a message to the request using the 'messages' app.
def add_message(request, level, message, extra_tags='', fail_silently=False): """ Attempt to add a message to the request using the 'messages' app. """ try: messages = request._messages except AttributeError: if not hasattr(request, 'META'): raise TypeError( ...
[ "def", "add_message", "(", "request", ",", "level", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "try", ":", "messages", "=", "request", ".", "_messages", "except", "AttributeError", ":", "if", "not", "hasattr...
[ 15, 0 ]
[ 33, 55 ]
python
en
['en', 'error', 'th']
False
get_messages
(request)
Return the message storage on the request if it exists, otherwise return an empty list.
Return the message storage on the request if it exists, otherwise return an empty list.
def get_messages(request): """ Return the message storage on the request if it exists, otherwise return an empty list. """ return getattr(request, '_messages', [])
[ "def", "get_messages", "(", "request", ")", ":", "return", "getattr", "(", "request", ",", "'_messages'", ",", "[", "]", ")" ]
[ 36, 0 ]
[ 41, 44 ]
python
en
['en', 'error', 'th']
False
get_level
(request)
Return the minimum level of messages to be recorded. The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, use the ``INFO`` level.
Return the minimum level of messages to be recorded.
def get_level(request): """ Return the minimum level of messages to be recorded. The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, use the ``INFO`` level. """ storage = getattr(request, '_messages', default_storage(request)) return storage.level
[ "def", "get_level", "(", "request", ")", ":", "storage", "=", "getattr", "(", "request", ",", "'_messages'", ",", "default_storage", "(", "request", ")", ")", "return", "storage", ".", "level" ]
[ 44, 0 ]
[ 52, 24 ]
python
en
['en', 'error', 'th']
False
set_level
(request, level)
Set the minimum level of messages to be recorded, and return ``True`` if the level was recorded successfully. If set to ``None``, use the default level (see the get_level() function).
Set the minimum level of messages to be recorded, and return ``True`` if the level was recorded successfully.
def set_level(request, level): """ Set the minimum level of messages to be recorded, and return ``True`` if the level was recorded successfully. If set to ``None``, use the default level (see the get_level() function). """ if not hasattr(request, '_messages'): return False request._...
[ "def", "set_level", "(", "request", ",", "level", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_messages'", ")", ":", "return", "False", "request", ".", "_messages", ".", "level", "=", "level", "return", "True" ]
[ 55, 0 ]
[ 65, 15 ]
python
en
['en', 'error', 'th']
False
debug
(request, message, extra_tags='', fail_silently=False)
Add a message with the ``DEBUG`` level.
Add a message with the ``DEBUG`` level.
def debug(request, message, extra_tags='', fail_silently=False): """Add a message with the ``DEBUG`` level.""" add_message(request, constants.DEBUG, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "debug", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "DEBUG", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_sile...
[ 68, 0 ]
[ 71, 44 ]
python
en
['en', 'en', 'en']
True
info
(request, message, extra_tags='', fail_silently=False)
Add a message with the ``INFO`` level.
Add a message with the ``INFO`` level.
def info(request, message, extra_tags='', fail_silently=False): """Add a message with the ``INFO`` level.""" add_message(request, constants.INFO, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "info", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "INFO", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_silent...
[ 74, 0 ]
[ 77, 44 ]
python
en
['en', 'en', 'en']
True
success
(request, message, extra_tags='', fail_silently=False)
Add a message with the ``SUCCESS`` level.
Add a message with the ``SUCCESS`` level.
def success(request, message, extra_tags='', fail_silently=False): """Add a message with the ``SUCCESS`` level.""" add_message(request, constants.SUCCESS, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "success", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "SUCCESS", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_...
[ 80, 0 ]
[ 83, 44 ]
python
en
['en', 'en', 'en']
True
warning
(request, message, extra_tags='', fail_silently=False)
Add a message with the ``WARNING`` level.
Add a message with the ``WARNING`` level.
def warning(request, message, extra_tags='', fail_silently=False): """Add a message with the ``WARNING`` level.""" add_message(request, constants.WARNING, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "warning", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "WARNING", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_...
[ 86, 0 ]
[ 89, 44 ]
python
en
['en', 'en', 'en']
True
error
(request, message, extra_tags='', fail_silently=False)
Add a message with the ``ERROR`` level.
Add a message with the ``ERROR`` level.
def error(request, message, extra_tags='', fail_silently=False): """Add a message with the ``ERROR`` level.""" add_message(request, constants.ERROR, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "error", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "ERROR", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_sile...
[ 92, 0 ]
[ 95, 44 ]
python
en
['en', 'en', 'en']
True
RateLimiterBackendBase.api_calls_left_from_history
( self, history: List[float], max_window: int, max_calls: int, now: float )
This depends on the algorithm used in the backend, and should be defined by the test class.
This depends on the algorithm used in the backend, and should be defined by the test class.
def api_calls_left_from_history( self, history: List[float], max_window: int, max_calls: int, now: float ) -> Tuple[int, float]: """ This depends on the algorithm used in the backend, and should be defined by the test class. """ raise NotImplementedError()
[ "def", "api_calls_left_from_history", "(", "self", ",", "history", ":", "List", "[", "float", "]", ",", "max_window", ":", "int", ",", "max_calls", ":", "int", ",", "now", ":", "float", ")", "->", "Tuple", "[", "int", ",", "float", "]", ":", "raise", ...
[ 85, 4 ]
[ 91, 35 ]
python
en
['en', 'error', 'th']
False
RedisRateLimiterBackendTest.test_block_access
(self)
This test cannot verify that the user will get unblocked after the correct amount of time, because that event happens inside Redis, so we're not able to mock the timer. Making the test sleep for 1s is also too costly to be worth it.
This test cannot verify that the user will get unblocked after the correct amount of time, because that event happens inside Redis, so we're not able to mock the timer. Making the test sleep for 1s is also too costly to be worth it.
def test_block_access(self) -> None: """ This test cannot verify that the user will get unblocked after the correct amount of time, because that event happens inside Redis, so we're not able to mock the timer. Making the test sleep for 1s is also too costly to be worth it. ...
[ "def", "test_block_access", "(", "self", ")", "->", "None", ":", "obj", "=", "self", ".", "create_object", "(", "\"test\"", ",", "[", "(", "2", ",", "5", ")", "]", ")", "obj", ".", "block_access", "(", "1", ")", "self", ".", "make_request", "(", "o...
[ 164, 4 ]
[ 174, 84 ]
python
en
['en', 'error', 'th']
False
GISLookup.process_band_indices
(self, only_lhs=False)
Extract the lhs band index from the band transform class and the rhs band index from the input tuple.
Extract the lhs band index from the band transform class and the rhs band index from the input tuple.
def process_band_indices(self, only_lhs=False): """ Extract the lhs band index from the band transform class and the rhs band index from the input tuple. """ # PostGIS band indices are 1-based, so the band index needs to be # increased to be consistent with the GDALRaster...
[ "def", "process_band_indices", "(", "self", ",", "only_lhs", "=", "False", ")", ":", "# PostGIS band indices are 1-based, so the band index needs to be", "# increased to be consistent with the GDALRaster band indices.", "if", "only_lhs", ":", "self", ".", "band_rhs", "=", "1", ...
[ 38, 4 ]
[ 55, 57 ]
python
en
['en', 'error', 'th']
False
InlineFormsetTests.test_formset_over_to_field
(self)
A formset over a ForeignKey with a to_field can be saved. Regression for #10243
A formset over a ForeignKey with a to_field can be saved. Regression for #10243
def test_formset_over_to_field(self): "A formset over a ForeignKey with a to_field can be saved. Regression for #10243" Form = modelform_factory(User, fields="__all__") FormSet = inlineformset_factory(User, UserSite, fields="__all__") # Instantiate the Form and FormSet to prove ...
[ "def", "test_formset_over_to_field", "(", "self", ")", ":", "Form", "=", "modelform_factory", "(", "User", ",", "fields", "=", "\"__all__\"", ")", "FormSet", "=", "inlineformset_factory", "(", "User", ",", "UserSite", ",", "fields", "=", "\"__all__\"", ")", "#...
[ 16, 4 ]
[ 90, 69 ]
python
en
['en', 'en', 'en']
True
InlineFormsetTests.test_formset_over_inherited_model
(self)
A formset over a ForeignKey with a to_field can be saved. Regression for #11120
A formset over a ForeignKey with a to_field can be saved. Regression for #11120
def test_formset_over_inherited_model(self): "A formset over a ForeignKey with a to_field can be saved. Regression for #11120" Form = modelform_factory(Restaurant, fields="__all__") FormSet = inlineformset_factory(Restaurant, Manager, fields="__all__") # Instantiate the Form and FormSet...
[ "def", "test_formset_over_inherited_model", "(", "self", ")", ":", "Form", "=", "modelform_factory", "(", "Restaurant", ",", "fields", "=", "\"__all__\"", ")", "FormSet", "=", "inlineformset_factory", "(", "Restaurant", ",", "Manager", ",", "fields", "=", "\"__all...
[ 92, 4 ]
[ 157, 69 ]
python
en
['en', 'en', 'en']
True
InlineFormsetTests.test_inline_model_with_to_field
(self)
#13794 --- An inline model with a to_field of a formset with instance has working relations.
#13794 --- An inline model with a to_field of a formset with instance has working relations.
def test_inline_model_with_to_field(self): """ #13794 --- An inline model with a to_field of a formset with instance has working relations. """ FormSet = inlineformset_factory(User, UserSite, exclude=('is_superuser',)) user = User.objects.create(username="guido", serial=...
[ "def", "test_inline_model_with_to_field", "(", "self", ")", ":", "FormSet", "=", "inlineformset_factory", "(", "User", ",", "UserSite", ",", "exclude", "=", "(", "'is_superuser'", ",", ")", ")", "user", "=", "User", ".", "objects", ".", "create", "(", "usern...
[ 159, 4 ]
[ 171, 62 ]
python
en
['en', 'error', 'th']
False
InlineFormsetTests.test_inline_model_with_to_field_to_rel
(self)
#13794 --- An inline model with a to_field to a related field of a formset with instance has working relations.
#13794 --- An inline model with a to_field to a related field of a formset with instance has working relations.
def test_inline_model_with_to_field_to_rel(self): """ #13794 --- An inline model with a to_field to a related field of a formset with instance has working relations. """ FormSet = inlineformset_factory(UserProfile, ProfileNetwork, exclude=[]) user = User.objects.create(u...
[ "def", "test_inline_model_with_to_field_to_rel", "(", "self", ")", ":", "FormSet", "=", "inlineformset_factory", "(", "UserProfile", ",", "ProfileNetwork", ",", "exclude", "=", "[", "]", ")", "user", "=", "User", ".", "objects", ".", "create", "(", "username", ...
[ 173, 4 ]
[ 188, 59 ]
python
en
['en', 'error', 'th']
False
InlineFormsetTests.test_formset_with_none_instance
(self)
A formset with instance=None can be created. Regression for #11872
A formset with instance=None can be created. Regression for #11872
def test_formset_with_none_instance(self): "A formset with instance=None can be created. Regression for #11872" Form = modelform_factory(User, fields="__all__") FormSet = inlineformset_factory(User, UserSite, fields="__all__") # Instantiate the Form and FormSet to prove # you ca...
[ "def", "test_formset_with_none_instance", "(", "self", ")", ":", "Form", "=", "modelform_factory", "(", "User", ",", "fields", "=", "\"__all__\"", ")", "FormSet", "=", "inlineformset_factory", "(", "User", ",", "UserSite", ",", "fields", "=", "\"__all__\"", ")",...
[ 190, 4 ]
[ 198, 30 ]
python
en
['en', 'en', 'en']
True
InlineFormsetTests.test_empty_fields_on_modelformset
(self)
No fields passed to modelformset_factory should result in no fields on returned forms except for the id. See #14119.
No fields passed to modelformset_factory should result in no fields on returned forms except for the id. See #14119.
def test_empty_fields_on_modelformset(self): "No fields passed to modelformset_factory should result in no fields on returned forms except for the id. See #14119." UserFormSet = modelformset_factory(User, fields=()) formset = UserFormSet() for form in formset.forms: self.asse...
[ "def", "test_empty_fields_on_modelformset", "(", "self", ")", ":", "UserFormSet", "=", "modelformset_factory", "(", "User", ",", "fields", "=", "(", ")", ")", "formset", "=", "UserFormSet", "(", ")", "for", "form", "in", "formset", ".", "forms", ":", "self",...
[ 200, 4 ]
[ 206, 49 ]
python
en
['en', 'en', 'en']
True
InlineFormsetTests.test_save_as_new_with_new_inlines
(self)
Existing and new inlines are saved with save_as_new. Regression for #14938.
Existing and new inlines are saved with save_as_new.
def test_save_as_new_with_new_inlines(self): """ Existing and new inlines are saved with save_as_new. Regression for #14938. """ efnet = Network.objects.create(name="EFNet") host1 = Host.objects.create(hostname="irc.he.net", network=efnet) HostFormSet = inlinef...
[ "def", "test_save_as_new_with_new_inlines", "(", "self", ")", ":", "efnet", "=", "Network", ".", "objects", ".", "create", "(", "name", "=", "\"EFNet\"", ")", "host1", "=", "Host", ".", "objects", ".", "create", "(", "hostname", "=", "\"irc.he.net\"", ",", ...
[ 208, 4 ]
[ 239, 9 ]
python
en
['en', 'error', 'th']
False
FormsetTests.test_error_class
(self)
Test the type of Formset and Form error attributes
Test the type of Formset and Form error attributes
def test_error_class(self): ''' Test the type of Formset and Form error attributes ''' Formset = modelformset_factory(User, fields="__all__") data = { 'form-TOTAL_FORMS': '2', 'form-INITIAL_FORMS': '0', 'form-MAX_NUM_FORMS': '0', 'f...
[ "def", "test_error_class", "(", "self", ")", ":", "Formset", "=", "modelformset_factory", "(", "User", ",", "fields", "=", "\"__all__\"", ")", "data", "=", "{", "'form-TOTAL_FORMS'", ":", "'2'", ",", "'form-INITIAL_FORMS'", ":", "'0'", ",", "'form-MAX_NUM_FORMS'...
[ 253, 4 ]
[ 276, 69 ]
python
en
['en', 'error', 'th']
False
FormfieldShouldDeleteFormTests.test_init_database
(self)
Add test data to database via formset
Add test data to database via formset
def test_init_database(self): """ Add test data to database via formset """ formset = self.NormalFormset(self.data) self.assertTrue(formset.is_valid()) self.assertEqual(len(formset.save()), 4)
[ "def", "test_init_database", "(", "self", ")", ":", "formset", "=", "self", ".", "NormalFormset", "(", "self", ".", "data", ")", "self", ".", "assertTrue", "(", "formset", ".", "is_valid", "(", ")", ")", "self", ".", "assertEqual", "(", "len", "(", "fo...
[ 426, 4 ]
[ 430, 48 ]
python
en
['en', 'en', 'en']
True
FormfieldShouldDeleteFormTests.test_no_delete
(self)
Verify base formset doesn't modify database
Verify base formset doesn't modify database
def test_no_delete(self): """ Verify base formset doesn't modify database """ # reload database self.test_init_database() # pass standard data dict & see none updated data = dict(self.data) data['form-INITIAL_FORMS'] = 4 data.update(dict( ('form-%d-id...
[ "def", "test_no_delete", "(", "self", ")", ":", "# reload database", "self", ".", "test_init_database", "(", ")", "# pass standard data dict & see none updated", "data", "=", "dict", "(", "self", ".", "data", ")", "data", "[", "'form-INITIAL_FORMS'", "]", "=", "4"...
[ 432, 4 ]
[ 447, 52 ]
python
cs
['nl', 'cs', 'en']
False
FormfieldShouldDeleteFormTests.test_all_delete
(self)
Verify base formset honors DELETE field
Verify base formset honors DELETE field
def test_all_delete(self): """ Verify base formset honors DELETE field """ # reload database self.test_init_database() # create data dict with all fields marked for deletion data = dict(self.data) data['form-INITIAL_FORMS'] = 4 data.update(dict( ('for...
[ "def", "test_all_delete", "(", "self", ")", ":", "# reload database", "self", ".", "test_init_database", "(", ")", "# create data dict with all fields marked for deletion", "data", "=", "dict", "(", "self", ".", "data", ")", "data", "[", "'form-INITIAL_FORMS'", "]", ...
[ 449, 4 ]
[ 465, 52 ]
python
en
['en', 'en', 'en']
True
FormfieldShouldDeleteFormTests.test_custom_delete
(self)
Verify DeleteFormset ignores DELETE field and uses form method
Verify DeleteFormset ignores DELETE field and uses form method
def test_custom_delete(self): """ Verify DeleteFormset ignores DELETE field and uses form method """ # reload database self.test_init_database() # Create formset with custom Delete function # create data dict with all fields marked for deletion data = dict(self.data) ...
[ "def", "test_custom_delete", "(", "self", ")", ":", "# reload database", "self", ".", "test_init_database", "(", ")", "# Create formset with custom Delete function", "# create data dict with all fields marked for deletion", "data", "=", "dict", "(", "self", ".", "data", ")"...
[ 467, 4 ]
[ 490, 41 ]
python
en
['en', 'sr', 'en']
True
OptimizationTest.test_init
(self)
Function to test initialization of OptimizationTest.
Function to test initialization of OptimizationTest.
def test_init(self): """ Function to test initialization of OptimizationTest. """ sess, dual_formulation_object = self.prepare_dual_object() dual_formulation_object.set_differentiable_objective() sess.run(tf.global_variables_initializer()) optimization_params = { "ini...
[ "def", "test_init", "(", "self", ")", ":", "sess", ",", "dual_formulation_object", "=", "self", ".", "prepare_dual_object", "(", ")", "dual_formulation_object", ".", "set_differentiable_objective", "(", ")", "sess", ".", "run", "(", "tf", ".", "global_variables_in...
[ 99, 4 ]
[ 119, 49 ]
python
en
['en', 'en', 'en']
True
OptimizationTest.test_get_min_eig_vec_proxy
(self)
Function test computing min eigen value using matrix vector products.
Function test computing min eigen value using matrix vector products.
def test_get_min_eig_vec_proxy(self): """ Function test computing min eigen value using matrix vector products.""" sess, dual_formulation_object = self.prepare_dual_object() _, matrix_m = dual_formulation_object.get_full_psd_matrix() optimization_params = { "init_learning_rat...
[ "def", "test_get_min_eig_vec_proxy", "(", "self", ")", ":", "sess", ",", "dual_formulation_object", "=", "self", ".", "prepare_dual_object", "(", ")", "_", ",", "matrix_m", "=", "dual_formulation_object", ".", "get_full_psd_matrix", "(", ")", "optimization_params", ...
[ 121, 4 ]
[ 195, 73 ]
python
de
['de', 'en', 'nl']
False
OptimizationTest.test_optimization
(self)
Function to test optimization.
Function to test optimization.
def test_optimization(self): """Function to test optimization.""" sess, dual_formulation_object = self.prepare_dual_object() optimization_params = { "init_penalty": 10000, "large_eig_num_steps": 1000, "small_eig_num_steps": 500, "inner_num_steps": ...
[ "def", "test_optimization", "(", "self", ")", ":", "sess", ",", "dual_formulation_object", "=", "self", ".", "prepare_dual_object", "(", ")", "optimization_params", "=", "{", "\"init_penalty\"", ":", "10000", ",", "\"large_eig_num_steps\"", ":", "1000", ",", "\"sm...
[ 197, 4 ]
[ 223, 39 ]
python
en
['en', 'en', 'en']
True
WKBReader.read
(self, wkb)
Returns a GEOSGeometry for the given WKB buffer.
Returns a GEOSGeometry for the given WKB buffer.
def read(self, wkb): "Returns a GEOSGeometry for the given WKB buffer." return GEOSGeometry(super(WKBReader, self).read(wkb))
[ "def", "read", "(", "self", ",", "wkb", ")", ":", "return", "GEOSGeometry", "(", "super", "(", "WKBReader", ",", "self", ")", ".", "read", "(", "wkb", ")", ")" ]
[ 13, 4 ]
[ 15, 61 ]
python
en
['en', 'en', 'en']
True
WKTReader.read
(self, wkt)
Returns a GEOSGeometry for the given WKT string.
Returns a GEOSGeometry for the given WKT string.
def read(self, wkt): "Returns a GEOSGeometry for the given WKT string." return GEOSGeometry(super(WKTReader, self).read(wkt))
[ "def", "read", "(", "self", ",", "wkt", ")", ":", "return", "GEOSGeometry", "(", "super", "(", "WKTReader", ",", "self", ")", ".", "read", "(", "wkt", ")", ")" ]
[ 19, 4 ]
[ 21, 61 ]
python
en
['en', 'en', 'en']
True
staff_member_required
(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='admin:login')
Decorator for views that checks that the user is logged in and is a staff member, redirecting to the login page if necessary.
Decorator for views that checks that the user is logged in and is a staff member, redirecting to the login page if necessary.
def staff_member_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='admin:login'): """ Decorator for views that checks that the user is logged in and is a staff member, redirecting to the login page if necessary. """ actual_decorator = user_passes_...
[ "def", "staff_member_required", "(", "view_func", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "login_url", "=", "'admin:login'", ")", ":", "actual_decorator", "=", "user_passes_test", "(", "lambda", "u", ":", "u", ".", "is_active", "a...
[ 4, 0 ]
[ 17, 27 ]
python
en
['en', 'error', 'th']
False
load_images
(input_dir, batch_shape)
Read png images from input directory in batches. Args: input_dir: input directory batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3] Yields: filenames: list file names without path of each image Lenght of this list could be less than batch_size, in this case o...
Read png images from input directory in batches.
def load_images(input_dir, batch_shape): """Read png images from input directory in batches. Args: input_dir: input directory batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3] Yields: filenames: list file names without path of each image Lenght of this li...
[ "def", "load_images", "(", "input_dir", ",", "batch_shape", ")", ":", "images", "=", "np", ".", "zeros", "(", "batch_shape", ")", "filenames", "=", "[", "]", "idx", "=", "0", "batch_size", "=", "batch_shape", "[", "0", "]", "for", "filepath", "in", "tf...
[ 40, 0 ]
[ 70, 31 ]
python
en
['en', 'en', 'en']
True
save_images
(images, filenames, output_dir)
Saves images to the output directory. Args: images: array with minibatch of images filenames: list of filenames without path If number of file names in this list less than number of images in the minibatch then only first len(filenames) images will be saved. output_dir: directory ...
Saves images to the output directory.
def save_images(images, filenames, output_dir): """Saves images to the output directory. Args: images: array with minibatch of images filenames: list of filenames without path If number of file names in this list less than number of images in the minibatch then only first len(filena...
[ "def", "save_images", "(", "images", ",", "filenames", ",", "output_dir", ")", ":", "for", "i", ",", "filename", "in", "enumerate", "(", "filenames", ")", ":", "# Images for inception classifier are normalized to be in [-1, 1] interval,", "# so rescale them back to [0, 1]."...
[ 73, 0 ]
[ 88, 54 ]
python
en
['en', 'en', 'en']
True
main
(_)
Run the sample attack
Run the sample attack
def main(_): """Run the sample attack""" # Images for inception classifier are normalized to be in [-1, 1] interval, # eps is a difference between pixels so it should be in [0, 2] interval. # Renormalizing epsilon from [0, 255] to [0, 2]. eps = 2.0 * FLAGS.max_epsilon / 255.0 batch_shape = [FLAG...
[ "def", "main", "(", "_", ")", ":", "# Images for inception classifier are normalized to be in [-1, 1] interval,", "# eps is a difference between pixels so it should be in [0, 2] interval.", "# Renormalizing epsilon from [0, 255] to [0, 2].", "eps", "=", "2.0", "*", "FLAGS", ".", "max_e...
[ 124, 0 ]
[ 155, 68 ]
python
en
['en', 'it', 'en']
True
InceptionModel.__call__
(self, x_input)
Constructs model and return probabilities for given input.
Constructs model and return probabilities for given input.
def __call__(self, x_input): """Constructs model and return probabilities for given input.""" reuse = True if self.built else None with slim.arg_scope(inception.inception_v3_arg_scope()): _, end_points = inception.inception_v3( x_input, num_classes=self.nb_classes, is...
[ "def", "__call__", "(", "self", ",", "x_input", ")", ":", "reuse", "=", "True", "if", "self", ".", "built", "else", "None", "with", "slim", ".", "arg_scope", "(", "inception", ".", "inception_v3_arg_scope", "(", ")", ")", ":", "_", ",", "end_points", "...
[ 110, 4 ]
[ 121, 20 ]
python
en
['en', 'en', 'en']
True
RequirementSet.__init__
(self, check_supported_wheels=True)
Create a RequirementSet.
Create a RequirementSet.
def __init__(self, check_supported_wheels=True): # type: (bool) -> None """Create a RequirementSet. """ self.requirements = OrderedDict() # type: Dict[str, InstallRequirement] # noqa: E501 self.check_supported_wheels = check_supported_wheels self.unnamed_requirements ...
[ "def", "__init__", "(", "self", ",", "check_supported_wheels", "=", "True", ")", ":", "# type: (bool) -> None", "self", ".", "requirements", "=", "OrderedDict", "(", ")", "# type: Dict[str, InstallRequirement] # noqa: E501", "self", ".", "check_supported_wheels", "=", ...
[ 25, 4 ]
[ 33, 38 ]
python
en
['en', 'en', 'en']
True
RequirementSet.add_requirement
( self, install_req, # type: InstallRequirement parent_req_name=None, # type: Optional[str] extras_requested=None # type: Optional[Iterable[str]] )
Add install_req as a requirement to install. :param parent_req_name: The name of the requirement that needed this added. The name is used because when multiple unnamed requirements resolve to the same name, we could otherwise end up with dependency links that point outside t...
Add install_req as a requirement to install.
def add_requirement( self, install_req, # type: InstallRequirement parent_req_name=None, # type: Optional[str] extras_requested=None # type: Optional[Iterable[str]] ): # type: (...) -> Tuple[List[InstallRequirement], Optional[InstallRequirement]] # noqa: E501 """A...
[ "def", "add_requirement", "(", "self", ",", "install_req", ",", "# type: InstallRequirement", "parent_req_name", "=", "None", ",", "# type: Optional[str]", "extras_requested", "=", "None", "# type: Optional[Iterable[str]]", ")", ":", "# type: (...) -> Tuple[List[InstallRequirem...
[ 69, 4 ]
[ 178, 43 ]
python
en
['en', 'en', 'en']
True
TrelloHookTests.test_ignored_card_actions
(self)
Certain card-related actions are now ignored solely based on the action type, and we don't need to do any other parsing to ignore them as invalid.
Certain card-related actions are now ignored solely based on the action type, and we don't need to do any other parsing to ignore them as invalid.
def test_ignored_card_actions(self) -> None: """ Certain card-related actions are now ignored solely based on the action type, and we don't need to do any other parsing to ignore them as invalid. """ actions = [ "copyCard", "createCheckItem", ...
[ "def", "test_ignored_card_actions", "(", "self", ")", "->", "None", ":", "actions", "=", "[", "\"copyCard\"", ",", "\"createCheckItem\"", ",", "\"updateCheckItem\"", ",", "\"updateList\"", ",", "]", "for", "action", "in", "actions", ":", "data", "=", "dict", "...
[ 127, 4 ]
[ 147, 48 ]
python
en
['en', 'error', 'th']
False
Style.parse_styles
(self)
Parses the style string and returns a tuple of style codes in correct order.
Parses the style string and returns a tuple of style codes in correct order.
def parse_styles(self) -> tuple: """ Parses the style string and returns a tuple of style codes in correct order. """ if not self.style: return () codes = [] # List of control codes for s in self.style.split(" "): if s in STYLE_TO_CODE: ...
[ "def", "parse_styles", "(", "self", ")", "->", "tuple", ":", "if", "not", "self", ".", "style", ":", "return", "(", ")", "codes", "=", "[", "]", "# List of control codes", "for", "s", "in", "self", ".", "style", ".", "split", "(", "\" \"", ")", ":", ...
[ 28, 4 ]
[ 49, 27 ]
python
en
['en', 'error', 'th']
False
DatabaseErrorWrapper.__init__
(self, wrapper)
wrapper is a database wrapper. It must have a Database attribute defining PEP-249 exceptions.
wrapper is a database wrapper.
def __init__(self, wrapper): """ wrapper is a database wrapper. It must have a Database attribute defining PEP-249 exceptions. """ self.wrapper = wrapper
[ "def", "__init__", "(", "self", ",", "wrapper", ")", ":", "self", ".", "wrapper", "=", "wrapper" ]
[ 61, 4 ]
[ 67, 30 ]
python
en
['en', 'error', 'th']
False
ConnectionHandler.__init__
(self, databases=None)
databases is an optional dictionary of database definitions (structured like settings.DATABASES).
databases is an optional dictionary of database definitions (structured like settings.DATABASES).
def __init__(self, databases=None): """ databases is an optional dictionary of database definitions (structured like settings.DATABASES). """ self._databases = databases self._connections = local()
[ "def", "__init__", "(", "self", ",", "databases", "=", "None", ")", ":", "self", ".", "_databases", "=", "databases", "self", ".", "_connections", "=", "local", "(", ")" ]
[ 137, 4 ]
[ 143, 35 ]
python
en
['en', 'error', 'th']
False
ConnectionHandler.ensure_defaults
(self, alias)
Puts the defaults into the settings dictionary for a given connection where no settings is provided.
Puts the defaults into the settings dictionary for a given connection where no settings is provided.
def ensure_defaults(self, alias): """ Puts the defaults into the settings dictionary for a given connection where no settings is provided. """ try: conn = self.databases[alias] except KeyError: raise ConnectionDoesNotExist("The connection %s doesn'...
[ "def", "ensure_defaults", "(", "self", ",", "alias", ")", ":", "try", ":", "conn", "=", "self", ".", "databases", "[", "alias", "]", "except", "KeyError", ":", "raise", "ConnectionDoesNotExist", "(", "\"The connection %s doesn't exist\"", "%", "alias", ")", "c...
[ 159, 4 ]
[ 178, 40 ]
python
en
['en', 'error', 'th']
False
ConnectionHandler.prepare_test_settings
(self, alias)
Makes sure the test settings are available in the 'TEST' sub-dictionary.
Makes sure the test settings are available in the 'TEST' sub-dictionary.
def prepare_test_settings(self, alias): """ Makes sure the test settings are available in the 'TEST' sub-dictionary. """ try: conn = self.databases[alias] except KeyError: raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias) tes...
[ "def", "prepare_test_settings", "(", "self", ",", "alias", ")", ":", "try", ":", "conn", "=", "self", ".", "databases", "[", "alias", "]", "except", "KeyError", ":", "raise", "ConnectionDoesNotExist", "(", "\"The connection %s doesn't exist\"", "%", "alias", ")"...
[ 187, 4 ]
[ 228, 47 ]
python
en
['en', 'error', 'th']
False
ConnectionRouter.__init__
(self, routers=None)
If routers is not specified, will default to settings.DATABASE_ROUTERS.
If routers is not specified, will default to settings.DATABASE_ROUTERS.
def __init__(self, routers=None): """ If routers is not specified, will default to settings.DATABASE_ROUTERS. """ self._routers = routers
[ "def", "__init__", "(", "self", ",", "routers", "=", "None", ")", ":", "self", ".", "_routers", "=", "routers" ]
[ 256, 4 ]
[ 260, 31 ]
python
en
['en', 'error', 'th']
False
ConnectionRouter.get_migratable_models
(self, app_config, db, include_auto_created=False)
Return app models allowed to be synchronized on provided db.
Return app models allowed to be synchronized on provided db.
def get_migratable_models(self, app_config, db, include_auto_created=False): """ Return app models allowed to be synchronized on provided db. """ models = app_config.get_models(include_auto_created=include_auto_created) return [model for model in models if self.allow_migrate(db, ...
[ "def", "get_migratable_models", "(", "self", ",", "app_config", ",", "db", ",", "include_auto_created", "=", "False", ")", ":", "models", "=", "app_config", ".", "get_models", "(", "include_auto_created", "=", "include_auto_created", ")", "return", "[", "model", ...
[ 330, 4 ]
[ 335, 75 ]
python
en
['en', 'error', 'th']
False
add_new_user_history
(user_profile: UserProfile, streams: Iterable[Stream])
Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public streams, so you have something to look at in your home view once you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES are marked unread.
Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public streams, so you have something to look at in your home view once you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES are marked unread.
def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -> None: """Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public streams, so you have something to look at in your home view once you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES are marked ...
[ "def", "add_new_user_history", "(", "user_profile", ":", "UserProfile", ",", "streams", ":", "Iterable", "[", "Stream", "]", ")", "->", "None", ":", "one_week_ago", "=", "timezone_now", "(", ")", "-", "datetime", ".", "timedelta", "(", "weeks", "=", "1", "...
[ 412, 0 ]
[ 452, 60 ]
python
en
['en', 'en', 'en']
True
do_set_realm_property
( realm: Realm, name: str, value: Any, *, acting_user: Optional[UserProfile] )
Takes in a realm object, the name of an attribute to update, the value to update and and the user who initiated the update.
Takes in a realm object, the name of an attribute to update, the value to update and and the user who initiated the update.
def do_set_realm_property( realm: Realm, name: str, value: Any, *, acting_user: Optional[UserProfile] ) -> None: """Takes in a realm object, the name of an attribute to update, the value to update and and the user who initiated the update. """ property_type = Realm.property_types[name] assert is...
[ "def", "do_set_realm_property", "(", "realm", ":", "Realm", ",", "name", ":", "str", ",", "value", ":", "Any", ",", "*", ",", "acting_user", ":", "Optional", "[", "UserProfile", "]", ")", "->", "None", ":", "property_type", "=", "Realm", ".", "property_t...
[ 778, 0 ]
[ 832, 73 ]
python
en
['en', 'en', 'en']
True
do_deactivate_realm
(realm: Realm, *, acting_user: Optional[UserProfile])
Deactivate this realm. Do NOT deactivate the users -- we need to be able to tell the difference between users that were intentionally deactivated, e.g. by a realm admin, and users who can't currently use Zulip because their realm has been deactivated.
Deactivate this realm. Do NOT deactivate the users -- we need to be able to tell the difference between users that were intentionally deactivated, e.g. by a realm admin, and users who can't currently use Zulip because their realm has been deactivated.
def do_deactivate_realm(realm: Realm, *, acting_user: Optional[UserProfile]) -> None: """ Deactivate this realm. Do NOT deactivate the users -- we need to be able to tell the difference between users that were intentionally deactivated, e.g. by a realm admin, and users who can't currently use Zulip beca...
[ "def", "do_deactivate_realm", "(", "realm", ":", "Realm", ",", "*", ",", "acting_user", ":", "Optional", "[", "UserProfile", "]", ")", "->", "None", ":", "if", "realm", ".", "deactivated", ":", "return", "realm", ".", "deactivated", "=", "True", "realm", ...
[ 979, 0 ]
[ 1022, 55 ]
python
en
['en', 'error', 'th']
False
change_user_is_active
(user_profile: UserProfile, value: bool)
Helper function for changing the .is_active field. Not meant as a standalone function in production code as properly activating/deactivating users requires more steps. This changes the is_active value and saves it, while ensuring Subscription.is_user_active values are updated in the same db transaction...
Helper function for changing the .is_active field. Not meant as a standalone function in production code as properly activating/deactivating users requires more steps. This changes the is_active value and saves it, while ensuring Subscription.is_user_active values are updated in the same db transaction...
def change_user_is_active(user_profile: UserProfile, value: bool) -> None: """ Helper function for changing the .is_active field. Not meant as a standalone function in production code as properly activating/deactivating users requires more steps. This changes the is_active value and saves it, while ensu...
[ "def", "change_user_is_active", "(", "user_profile", ":", "UserProfile", ",", "value", ":", "bool", ")", "->", "None", ":", "with", "transaction", ".", "atomic", "(", "savepoint", "=", "False", ")", ":", "user_profile", ".", "is_active", "=", "value", "user_...
[ 1141, 0 ]
[ 1151, 91 ]
python
en
['en', 'error', 'th']
False
build_message_send_dict
( message_dict: Dict[str, Any], email_gateway: bool = False )
Returns a dictionary that can be passed into do_send_messages. In production, this is always called by check_message, but some testing code paths call it directly.
Returns a dictionary that can be passed into do_send_messages. In production, this is always called by check_message, but some testing code paths call it directly.
def build_message_send_dict( message_dict: Dict[str, Any], email_gateway: bool = False ) -> SendMessageRequest: """Returns a dictionary that can be passed into do_send_messages. In production, this is always called by check_message, but some testing code paths call it directly. """ realm = mess...
[ "def", "build_message_send_dict", "(", "message_dict", ":", "Dict", "[", "str", ",", "Any", "]", ",", "email_gateway", ":", "bool", "=", "False", ")", "->", "SendMessageRequest", ":", "realm", "=", "message_dict", ".", "get", "(", "\"realm\"", ",", "message_...
[ 1721, 0 ]
[ 1812, 28 ]
python
en
['en', 'en', 'en']
True
do_send_messages
( send_message_requests_maybe_none: Sequence[Optional[SendMessageRequest]], email_gateway: bool = False, mark_as_read: Sequence[int] = [], )
See https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html for high-level documentation on this subsystem.
See https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html for high-level documentation on this subsystem.
def do_send_messages( send_message_requests_maybe_none: Sequence[Optional[SendMessageRequest]], email_gateway: bool = False, mark_as_read: Sequence[int] = [], ) -> List[int]: """See https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html for high-level documentation on this subsy...
[ "def", "do_send_messages", "(", "send_message_requests_maybe_none", ":", "Sequence", "[", "Optional", "[", "SendMessageRequest", "]", "]", ",", "email_gateway", ":", "bool", "=", "False", ",", "mark_as_read", ":", "Sequence", "[", "int", "]", "=", "[", "]", ",...
[ 1815, 0 ]
[ 2006, 78 ]
python
en
['en', 'en', 'ur']
False
bulk_insert_ums
(ums: List[UserMessageLite])
Doing bulk inserts this way is much faster than using Django, since we don't have any ORM overhead. Profiling with 1000 users shows a speedup of 0.436 -> 0.027 seconds, so we're talking about a 15x speedup.
Doing bulk inserts this way is much faster than using Django, since we don't have any ORM overhead. Profiling with 1000 users shows a speedup of 0.436 -> 0.027 seconds, so we're talking about a 15x speedup.
def bulk_insert_ums(ums: List[UserMessageLite]) -> None: """ Doing bulk inserts this way is much faster than using Django, since we don't have any ORM overhead. Profiling with 1000 users shows a speedup of 0.436 -> 0.027 seconds, so we're talking about a 15x speedup. """ if not ums: ...
[ "def", "bulk_insert_ums", "(", "ums", ":", "List", "[", "UserMessageLite", "]", ")", "->", "None", ":", "if", "not", "ums", ":", "return", "vals", "=", "[", "(", "um", ".", "user_profile_id", ",", "um", ".", "message_id", ",", "um", ".", "flags", ")"...
[ 2096, 0 ]
[ 2116, 50 ]
python
en
['en', 'error', 'th']
False