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
EggInfoDistribution.list_distinfo_files
(self, absolute=False)
Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories. :parameter absolute: If *absolute* is ``True``, each returned path is trans...
Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories.
def list_distinfo_files(self, absolute=False): """ Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories. :parameter absolute: If *absolute* is ``Tru...
[ "def", "list_distinfo_files", "(", "self", ",", "absolute", "=", "False", ")", ":", "record_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "'installed-files.txt'", ")", "if", "os", ".", "path", ".", "exists", "(", "record_path...
[ 1040, 4 ]
[ 1067, 42 ]
python
en
['en', 'error', 'th']
False
DependencyGraph.add_distribution
(self, distribution)
Add the *distribution* to the graph. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution`
Add the *distribution* to the graph.
def add_distribution(self, distribution): """Add the *distribution* to the graph. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` """ self.adjacency_list[distribution] = [] sel...
[ "def", "add_distribution", "(", "self", ",", "distribution", ")", ":", "self", ".", "adjacency_list", "[", "distribution", "]", "=", "[", "]", "self", ".", "reverse_list", "[", "distribution", "]", "=", "[", "]" ]
[ 1101, 4 ]
[ 1108, 44 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.add_edge
(self, x, y, label=None)
Add an edge from distribution *x* to distribution *y* with the given *label*. :type x: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type y: :class:`distutils2.database.InstalledDistribution` or :class:`...
Add an edge from distribution *x* to distribution *y* with the given *label*.
def add_edge(self, x, y, label=None): """Add an edge from distribution *x* to distribution *y* with the given *label*. :type x: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type y: :class:`distutils2.database.In...
[ "def", "add_edge", "(", "self", ",", "x", ",", "y", ",", "label", "=", "None", ")", ":", "self", ".", "adjacency_list", "[", "x", "]", ".", "append", "(", "(", "y", ",", "label", ")", ")", "# multiple edges are allowed, so be careful", "if", "x", "not"...
[ 1111, 4 ]
[ 1124, 42 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.add_missing
(self, distribution, requirement)
Add a missing *requirement* for the given *distribution*. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type requirement: ``str``
Add a missing *requirement* for the given *distribution*.
def add_missing(self, distribution, requirement): """ Add a missing *requirement* for the given *distribution*. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type requirement: ``str...
[ "def", "add_missing", "(", "self", ",", "distribution", ",", "requirement", ")", ":", "logger", ".", "debug", "(", "'%s missing %r'", ",", "distribution", ",", "requirement", ")", "self", ".", "missing", ".", "setdefault", "(", "distribution", ",", "[", "]",...
[ 1126, 4 ]
[ 1135, 69 ]
python
en
['en', 'error', 'th']
False
DependencyGraph.repr_node
(self, dist, level=1)
Prints only a subgraph
Prints only a subgraph
def repr_node(self, dist, level=1): """Prints only a subgraph""" output = [self._repr_dist(dist)] for other, label in self.adjacency_list[dist]: dist = self._repr_dist(other) if label is not None: dist = '%s [%s]' % (dist, label) output.append(...
[ "def", "repr_node", "(", "self", ",", "dist", ",", "level", "=", "1", ")", ":", "output", "=", "[", "self", ".", "_repr_dist", "(", "dist", ")", "]", "for", "other", ",", "label", "in", "self", ".", "adjacency_list", "[", "dist", "]", ":", "dist", ...
[ 1140, 4 ]
[ 1151, 32 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.to_dot
(self, f, skip_disconnected=True)
Writes a DOT output for the graph to the provided file *f*. If *skip_disconnected* is set to ``True``, then all distributions that are not dependent on any other distribution are skipped. :type f: has to support ``file``-like operations :type skip_disconnected: ``bool``
Writes a DOT output for the graph to the provided file *f*.
def to_dot(self, f, skip_disconnected=True): """Writes a DOT output for the graph to the provided file *f*. If *skip_disconnected* is set to ``True``, then all distributions that are not dependent on any other distribution are skipped. :type f: has to support ``file``-like operations ...
[ "def", "to_dot", "(", "self", ",", "f", ",", "skip_disconnected", "=", "True", ")", ":", "disconnected", "=", "[", "]", "f", ".", "write", "(", "\"digraph dependencies {\\n\"", ")", "for", "dist", ",", "adjs", "in", "self", ".", "adjacency_list", ".", "i...
[ 1153, 4 ]
[ 1183, 22 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.topological_sort
(self)
Perform a topological sort of the graph. :return: A tuple, the first element of which is a topologically sorted list of distributions, and the second element of which is a list of distributions that cannot be sorted because they have circular dependenc...
Perform a topological sort of the graph. :return: A tuple, the first element of which is a topologically sorted list of distributions, and the second element of which is a list of distributions that cannot be sorted because they have circular dependenc...
def topological_sort(self): """ Perform a topological sort of the graph. :return: A tuple, the first element of which is a topologically sorted list of distributions, and the second element of which is a list of distributions that cannot be sorted because they h...
[ "def", "topological_sort", "(", "self", ")", ":", "result", "=", "[", "]", "# Make a shallow copy of the adjacency list", "alist", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "adjacency_list", ".", "items", "(", ")", ":", "alist", "[", "k", "...
[ 1185, 4 ]
[ 1214, 41 ]
python
en
['en', 'error', 'th']
False
DependencyGraph.__repr__
(self)
Representation of the graph
Representation of the graph
def __repr__(self): """Representation of the graph""" output = [] for dist, adjs in self.adjacency_list.items(): output.append(self.repr_node(dist)) return '\n'.join(output)
[ "def", "__repr__", "(", "self", ")", ":", "output", "=", "[", "]", "for", "dist", ",", "adjs", "in", "self", ".", "adjacency_list", ".", "items", "(", ")", ":", "output", ".", "append", "(", "self", ".", "repr_node", "(", "dist", ")", ")", "return"...
[ 1216, 4 ]
[ 1221, 32 ]
python
en
['en', 'en', 'en']
True
_Replacement_write_data
(writer, data, is_attrib=False)
Writes datachars to writer.
Writes datachars to writer.
def _Replacement_write_data(writer, data, is_attrib=False): """Writes datachars to writer.""" data = data.replace("&", "&amp;").replace("<", "&lt;") data = data.replace('"', "&quot;").replace(">", "&gt;") if is_attrib: data = data.replace("\r", "&#xD;").replace("\n", "&#xA;").replace("\t", "&#x9...
[ "def", "_Replacement_write_data", "(", "writer", ",", "data", ",", "is_attrib", "=", "False", ")", ":", "data", "=", "data", ".", "replace", "(", "\"&\"", ",", "\"&amp;\"", ")", ".", "replace", "(", "\"<\"", ",", "\"&lt;\"", ")", "data", "=", "data", "...
[ 15, 0 ]
[ 21, 22 ]
python
en
['en', 'sn', 'en']
True
PermutedIndex.get_neighbour_keys
(self, bucket_key, k)
The computing complexity is O( np*beam*log(np*beam) ) where, np = number of permutations beam = self.beam_size Make sure np*beam is much less than the number of bucket keys, otherwise we could use brute-force to get the neighbours
The computing complexity is O( np*beam*log(np*beam) ) where, np = number of permutations beam = self.beam_size
def get_neighbour_keys(self, bucket_key, k): """ The computing complexity is O( np*beam*log(np*beam) ) where, np = number of permutations beam = self.beam_size Make sure np*beam is much less than the number of bucket keys, otherwise we could use brute-force to ge...
[ "def", "get_neighbour_keys", "(", "self", ",", "bucket_key", ",", "k", ")", ":", "# convert query_key into bitarray", "query_key", "=", "bitarray", "(", "bucket_key", ")", "topk", "=", "set", "(", ")", "for", "i", "in", "xrange", "(", "len", "(", "self", "...
[ 122, 4 ]
[ 147, 23 ]
python
en
['en', 'error', 'th']
False
generate_and_print
()
Generates a seed for a private key, and prints the mnemonic to the terminal.
Generates a seed for a private key, and prints the mnemonic to the terminal.
def generate_and_print(): """ Generates a seed for a private key, and prints the mnemonic to the terminal. """ mnemonic = generate_mnemonic() print("Generating private key. Mnemonic (24 secret words):") print(mnemonic) print("Note that this key has not been added to the keychain. Run kale k...
[ "def", "generate_and_print", "(", ")", ":", "mnemonic", "=", "generate_mnemonic", "(", ")", "print", "(", "\"Generating private key. Mnemonic (24 secret words):\"", ")", "print", "(", "mnemonic", ")", "print", "(", "\"Note that this key has not been added to the keychain. Run...
[ 15, 0 ]
[ 24, 19 ]
python
en
['en', 'error', 'th']
False
generate_and_add
()
Generates a seed for a private key, prints the mnemonic to the terminal, and adds the key to the keyring.
Generates a seed for a private key, prints the mnemonic to the terminal, and adds the key to the keyring.
def generate_and_add(): """ Generates a seed for a private key, prints the mnemonic to the terminal, and adds the key to the keyring. """ mnemonic = generate_mnemonic() print("Generating private key") add_private_key_seed(mnemonic)
[ "def", "generate_and_add", "(", ")", ":", "mnemonic", "=", "generate_mnemonic", "(", ")", "print", "(", "\"Generating private key\"", ")", "add_private_key_seed", "(", "mnemonic", ")" ]
[ 27, 0 ]
[ 34, 34 ]
python
en
['en', 'error', 'th']
False
add_private_key_seed
(mnemonic: str)
Add a private key seed to the keyring, with the given mnemonic.
Add a private key seed to the keyring, with the given mnemonic.
def add_private_key_seed(mnemonic: str): """ Add a private key seed to the keyring, with the given mnemonic. """ try: passphrase = "" sk = keychain.add_private_key(mnemonic, passphrase) fingerprint = sk.get_g1().get_fingerprint() print(f"Added private key with public key...
[ "def", "add_private_key_seed", "(", "mnemonic", ":", "str", ")", ":", "try", ":", "passphrase", "=", "\"\"", "sk", "=", "keychain", ".", "add_private_key", "(", "mnemonic", ",", "passphrase", ")", "fingerprint", "=", "sk", ".", "get_g1", "(", ")", ".", "...
[ 42, 0 ]
[ 56, 19 ]
python
en
['en', 'error', 'th']
False
show_all_keys
(show_mnemonic: bool)
Prints all keys and mnemonics (if available).
Prints all keys and mnemonics (if available).
def show_all_keys(show_mnemonic: bool): """ Prints all keys and mnemonics (if available). """ root_path = DEFAULT_ROOT_PATH config = load_config(root_path, "config.yaml") private_keys = keychain.get_all_private_keys() selected = config["selected_network"] prefix = config["network_overrid...
[ "def", "show_all_keys", "(", "show_mnemonic", ":", "bool", ")", ":", "root_path", "=", "DEFAULT_ROOT_PATH", "config", "=", "load_config", "(", "root_path", ",", "\"config.yaml\"", ")", "private_keys", "=", "keychain", ".", "get_all_private_keys", "(", ")", "select...
[ 59, 0 ]
[ 97, 27 ]
python
en
['en', 'error', 'th']
False
delete
(fingerprint: int)
Delete a key by its public key fingerprint (which is an integer).
Delete a key by its public key fingerprint (which is an integer).
def delete(fingerprint: int): """ Delete a key by its public key fingerprint (which is an integer). """ print(f"Deleting private_key with fingerprint {fingerprint}") keychain.delete_key_by_fingerprint(fingerprint)
[ "def", "delete", "(", "fingerprint", ":", "int", ")", ":", "print", "(", "f\"Deleting private_key with fingerprint {fingerprint}\"", ")", "keychain", ".", "delete_key_by_fingerprint", "(", "fingerprint", ")" ]
[ 100, 0 ]
[ 105, 51 ]
python
en
['en', 'error', 'th']
False
DateField._check_fix_default_value
(self)
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up.
def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 1182, 4 ]
[ 1223, 17 ]
python
en
['en', 'error', 'th']
False
DateTimeField._check_fix_default_value
(self)
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up.
def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 1324, 4 ]
[ 1368, 17 ]
python
en
['en', 'error', 'th']
False
DecimalField.format_number
(self, value)
Formats a number into a string with the requisite number of digits and decimal places.
Formats a number into a string with the requisite number of digits and decimal places.
def format_number(self, value): """ Formats a number into a string with the requisite number of digits and decimal places. """ # Method moved to django.db.backends.utils. # # It is preserved because it is used by the oracle backend # (django.db.backends.or...
[ "def", "format_number", "(", "self", ",", "value", ")", ":", "# Method moved to django.db.backends.utils.", "#", "# It is preserved because it is used by the oracle backend", "# (django.db.backends.oracle.query), and also for", "# backwards-compatibility with any external code which may have...
[ 1584, 4 ]
[ 1596, 79 ]
python
en
['en', 'error', 'th']
False
PositiveIntegerRelDbTypeMixin.rel_db_type
(self, connection)
Return the data type that a related field pointing to this field should use. In most cases, a foreign key pointing to a positive integer primary key will have an integer column data type but some databases (e.g. MySQL) have an unsigned integer type. In that case (related_fields_...
Return the data type that a related field pointing to this field should use. In most cases, a foreign key pointing to a positive integer primary key will have an integer column data type but some databases (e.g. MySQL) have an unsigned integer type. In that case (related_fields_...
def rel_db_type(self, connection): """ Return the data type that a related field pointing to this field should use. In most cases, a foreign key pointing to a positive integer primary key will have an integer column data type but some databases (e.g. MySQL) have an unsigned integ...
[ "def", "rel_db_type", "(", "self", ",", "connection", ")", ":", "if", "connection", ".", "features", ".", "related_fields_match_type", ":", "return", "self", ".", "db_type", "(", "connection", ")", "else", ":", "return", "IntegerField", "(", ")", ".", "db_ty...
[ 2050, 4 ]
[ 2062, 64 ]
python
en
['en', 'error', 'th']
False
TimeField._check_fix_default_value
(self)
Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905
Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up.
def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 2173, 4 ]
[ 2217, 17 ]
python
en
['en', 'error', 'th']
False
BinaryField.value_to_string
(self, obj)
Binary data is serialized as base64
Binary data is serialized as base64
def value_to_string(self, obj): """Binary data is serialized as base64""" return b64encode(force_bytes(self.value_from_object(obj))).decode('ascii')
[ "def", "value_to_string", "(", "self", ",", "obj", ")", ":", "return", "b64encode", "(", "force_bytes", "(", "self", ".", "value_from_object", "(", "obj", ")", ")", ")", ".", "decode", "(", "'ascii'", ")" ]
[ 2348, 4 ]
[ 2350, 82 ]
python
en
['en', 'en', 'en']
True
parse_requirements
( filename, # type: str session, # type: PipSession finder=None, # type: Optional[PackageFinder] options=None, # type: Optional[optparse.Values] constraint=False, # type: bool )
Parse a requirements file and yield ParsedRequirement instances. :param filename: Path or url of requirements file. :param session: PipSession instance. :param finder: Instance of pip.index.PackageFinder. :param options: cli options. :param constraint: If true, parsing a constraint...
Parse a requirements file and yield ParsedRequirement instances.
def parse_requirements( filename, # type: str session, # type: PipSession finder=None, # type: Optional[PackageFinder] options=None, # type: Optional[optparse.Values] constraint=False, # type: bool ): # type: (...) -> Iterator[ParsedRequirement] """Parse a requirements file and yield Pa...
[ "def", "parse_requirements", "(", "filename", ",", "# type: str", "session", ",", "# type: PipSession", "finder", "=", "None", ",", "# type: Optional[PackageFinder]", "options", "=", "None", ",", "# type: Optional[optparse.Values]", "constraint", "=", "False", ",", "# t...
[ 130, 0 ]
[ 158, 28 ]
python
en
['en', 'en', 'en']
True
preprocess
(content)
Split, filter, and join lines, and return a line iterator :param content: the content of the requirements file
Split, filter, and join lines, and return a line iterator
def preprocess(content): # type: (Text) -> ReqFileLines """Split, filter, and join lines, and return a line iterator :param content: the content of the requirements file """ lines_enum = enumerate(content.splitlines(), start=1) # type: ReqFileLines lines_enum = join_lines(lines_enum) lines...
[ "def", "preprocess", "(", "content", ")", ":", "# type: (Text) -> ReqFileLines", "lines_enum", "=", "enumerate", "(", "content", ".", "splitlines", "(", ")", ",", "start", "=", "1", ")", "# type: ReqFileLines", "lines_enum", "=", "join_lines", "(", "lines_enum", ...
[ 161, 0 ]
[ 171, 21 ]
python
en
['en', 'en', 'en']
True
handle_line
( line, # type: ParsedLine options=None, # type: Optional[optparse.Values] finder=None, # type: Optional[PackageFinder] session=None, # type: Optional[PipSession] )
Handle a single parsed requirements line; This can result in creating/yielding requirements, or updating the finder. :param line: The parsed line to be processed. :param options: CLI options. :param finder: The finder - updated by non-requirement lines. :param session: The sessi...
Handle a single parsed requirements line; This can result in creating/yielding requirements, or updating the finder.
def handle_line( line, # type: ParsedLine options=None, # type: Optional[optparse.Values] finder=None, # type: Optional[PackageFinder] session=None, # type: Optional[PipSession] ): # type: (...) -> Optional[ParsedRequirement] """Handle a single parsed requirements line; This can result in ...
[ "def", "handle_line", "(", "line", ",", "# type: ParsedLine", "options", "=", "None", ",", "# type: Optional[optparse.Values]", "finder", "=", "None", ",", "# type: Optional[PackageFinder]", "session", "=", "None", ",", "# type: Optional[PipSession]", ")", ":", "# type:...
[ 281, 0 ]
[ 323, 19 ]
python
en
['en', 'en', 'en']
True
break_args_options
(line)
Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex.
Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex.
def break_args_options(line): # type: (Text) -> Tuple[str, Text] """Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex. """ tokens = line.split(' ') args = [] opti...
[ "def", "break_args_options", "(", "line", ")", ":", "# type: (Text) -> Tuple[str, Text]", "tokens", "=", "line", ".", "split", "(", "' '", ")", "args", "=", "[", "]", "options", "=", "tokens", "[", ":", "]", "for", "token", "in", "tokens", ":", "if", "to...
[ 426, 0 ]
[ 441, 44 ]
python
en
['en', 'en', 'en']
True
build_parser
()
Return a parser for parsing requirement lines
Return a parser for parsing requirement lines
def build_parser(): # type: () -> optparse.OptionParser """ Return a parser for parsing requirement lines """ parser = optparse.OptionParser(add_help_option=False) option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ for option_factory in option_factories: option = option_fa...
[ "def", "build_parser", "(", ")", ":", "# type: () -> optparse.OptionParser", "parser", "=", "optparse", ".", "OptionParser", "(", "add_help_option", "=", "False", ")", "option_factories", "=", "SUPPORTED_OPTIONS", "+", "SUPPORTED_OPTIONS_REQ", "for", "option_factory", "...
[ 450, 0 ]
[ 471, 17 ]
python
en
['en', 'error', 'th']
False
join_lines
(lines_enum)
Joins a line ending in '\' with the previous line (except when following comments). The joined line takes on the index of the first line.
Joins a line ending in '\' with the previous line (except when following comments). The joined line takes on the index of the first line.
def join_lines(lines_enum): # type: (ReqFileLines) -> ReqFileLines """Joins a line ending in '\' with the previous line (except when following comments). The joined line takes on the index of the first line. """ primary_line_number = None new_line = [] # type: List[Text] for line_number, l...
[ "def", "join_lines", "(", "lines_enum", ")", ":", "# type: (ReqFileLines) -> ReqFileLines", "primary_line_number", "=", "None", "new_line", "=", "[", "]", "# type: List[Text]", "for", "line_number", ",", "line", "in", "lines_enum", ":", "if", "not", "line", ".", "...
[ 474, 0 ]
[ 501, 52 ]
python
en
['en', 'en', 'en']
True
ignore_comments
(lines_enum)
Strips comments and filter empty lines.
Strips comments and filter empty lines.
def ignore_comments(lines_enum): # type: (ReqFileLines) -> ReqFileLines """ Strips comments and filter empty lines. """ for line_number, line in lines_enum: line = COMMENT_RE.sub('', line) line = line.strip() if line: yield line_number, line
[ "def", "ignore_comments", "(", "lines_enum", ")", ":", "# type: (ReqFileLines) -> ReqFileLines", "for", "line_number", ",", "line", "in", "lines_enum", ":", "line", "=", "COMMENT_RE", ".", "sub", "(", "''", ",", "line", ")", "line", "=", "line", ".", "strip", ...
[ 506, 0 ]
[ 515, 35 ]
python
en
['en', 'error', 'th']
False
expand_env_variables
(lines_enum)
Replace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that contain a `$` aren't accidentally (partially) expanded. 2. Ensure consistency across pl...
Replace all environment variables that can be retrieved via `os.getenv`.
def expand_env_variables(lines_enum): # type: (ReqFileLines) -> ReqFileLines """Replace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that con...
[ "def", "expand_env_variables", "(", "lines_enum", ")", ":", "# type: (ReqFileLines) -> ReqFileLines", "for", "line_number", ",", "line", "in", "lines_enum", ":", "for", "env_var", ",", "var_name", "in", "ENV_VAR_RE", ".", "findall", "(", "line", ")", ":", "value",...
[ 518, 0 ]
[ 543, 31 ]
python
en
['en', 'en', 'en']
True
get_file_content
(url, session)
Gets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. Respects # -*- coding: declarations on the retrieved files. :param url: File path or url. :param session: PipSession instance.
Gets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. Respects # -*- coding: declarations on the retrieved files.
def get_file_content(url, session): # type: (str, PipSession) -> Tuple[str, Text] """Gets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. Respects # -*- coding: declarations on the retrieved files. :param url: File pat...
[ "def", "get_file_content", "(", "url", ",", "session", ")", ":", "# type: (str, PipSession) -> Tuple[str, Text]", "scheme", "=", "get_url_scheme", "(", "url", ")", "if", "scheme", "in", "[", "'http'", ",", "'https'", "]", ":", "# FIXME: catch some errors", "resp", ...
[ 546, 0 ]
[ 573, 23 ]
python
en
['en', 'en', 'en']
True
RequirementsFileParser.parse
(self, filename, constraint)
Parse a given file, yielding parsed lines.
Parse a given file, yielding parsed lines.
def parse(self, filename, constraint): # type: (str, bool) -> Iterator[ParsedLine] """Parse a given file, yielding parsed lines. """ for line in self._parse_and_recurse(filename, constraint): yield line
[ "def", "parse", "(", "self", ",", "filename", ",", "constraint", ")", ":", "# type: (str, bool) -> Iterator[ParsedLine]", "for", "line", "in", "self", ".", "_parse_and_recurse", "(", "filename", ",", "constraint", ")", ":", "yield", "line" ]
[ 336, 4 ]
[ 341, 22 ]
python
en
['en', 'en', 'en']
True
_parse_codestream
(fp)
Parse the JPEG 2000 codestream to extract the size and component count from the SIZ marker segment, returning a PIL (size, mode) tuple.
Parse the JPEG 2000 codestream to extract the size and component count from the SIZ marker segment, returning a PIL (size, mode) tuple.
def _parse_codestream(fp): """Parse the JPEG 2000 codestream to extract the size and component count from the SIZ marker segment, returning a PIL (size, mode) tuple.""" hdr = fp.read(2) lsiz = struct.unpack(">H", hdr)[0] siz = hdr + fp.read(lsiz - 2) lsiz, rsiz, xsiz, ysiz, xosiz, yosiz, _, _, ...
[ "def", "_parse_codestream", "(", "fp", ")", ":", "hdr", "=", "fp", ".", "read", "(", "2", ")", "lsiz", "=", "struct", ".", "unpack", "(", "\">H\"", ",", "hdr", ")", "[", "0", "]", "siz", "=", "hdr", "+", "fp", ".", "read", "(", "lsiz", "-", "...
[ 21, 0 ]
[ 52, 23 ]
python
en
['en', 'en', 'en']
True
_parse_jp2_header
(fp)
Parse the JP2 header box to extract size, component count and color space information, returning a (size, mode, mimetype) tuple.
Parse the JP2 header box to extract size, component count and color space information, returning a (size, mode, mimetype) tuple.
def _parse_jp2_header(fp): """Parse the JP2 header box to extract size, component count and color space information, returning a (size, mode, mimetype) tuple.""" # Find the JP2 header box header = None mimetype = None while True: lbox, tbox = struct.unpack(">I4s", fp.read(8)) if...
[ "def", "_parse_jp2_header", "(", "fp", ")", ":", "# Find the JP2 header box", "header", "=", "None", "mimetype", "=", "None", "while", "True", ":", "lbox", ",", "tbox", "=", "struct", ".", "unpack", "(", "\">I4s\"", ",", "fp", ".", "read", "(", "8", ")",...
[ 55, 0 ]
[ 149, 33 ]
python
en
['en', 'en', 'en']
True
send_event
( realm: Realm, event: Mapping[str, Any], users: Union[Iterable[int], Iterable[Mapping[str, Any]]] )
`users` is a list of user IDs, or in the case of `message` type events, a list of dicts describing the users and metadata about the user/message pair.
`users` is a list of user IDs, or in the case of `message` type events, a list of dicts describing the users and metadata about the user/message pair.
def send_event( realm: Realm, event: Mapping[str, Any], users: Union[Iterable[int], Iterable[Mapping[str, Any]]] ) -> None: """`users` is a list of user IDs, or in the case of `message` type events, a list of dicts describing the users and metadata about the user/message pair.""" port = get_tornado_...
[ "def", "send_event", "(", "realm", ":", "Realm", ",", "event", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "users", ":", "Union", "[", "Iterable", "[", "int", "]", ",", "Iterable", "[", "Mapping", "[", "str", ",", "Any", "]", "]", "]", ")",...
[ 146, 0 ]
[ 157, 5 ]
python
en
['en', 'en', 'en']
True
Instance.set_capacity_value
(self)
Sets capacity according to capacity adjustment rule (no save)
Sets capacity according to capacity adjustment rule (no save)
def set_capacity_value(self): """Sets capacity according to capacity adjustment rule (no save)""" if self.enabled: lower_cap = min(self.mem_capacity, self.cpu_capacity) higher_cap = max(self.mem_capacity, self.cpu_capacity) self.capacity = lower_cap + (higher_cap - lo...
[ "def", "set_capacity_value", "(", "self", ")", ":", "if", "self", ".", "enabled", ":", "lower_cap", "=", "min", "(", "self", ".", "mem_capacity", ",", "self", ".", "cpu_capacity", ")", "higher_cap", "=", "max", "(", "self", ".", "mem_capacity", ",", "sel...
[ 179, 4 ]
[ 186, 29 ]
python
en
['en', 'fil', 'en']
True
Instance.refresh_capacity_fields
(self)
Update derived capacity fields from cpu and memory (no save)
Update derived capacity fields from cpu and memory (no save)
def refresh_capacity_fields(self): """Update derived capacity fields from cpu and memory (no save)""" self.cpu_capacity = get_cpu_effective_capacity(self.cpu) self.mem_capacity = get_mem_effective_capacity(self.memory) self.set_capacity_value()
[ "def", "refresh_capacity_fields", "(", "self", ")", ":", "self", ".", "cpu_capacity", "=", "get_cpu_effective_capacity", "(", "self", ".", "cpu", ")", "self", ".", "mem_capacity", "=", "get_mem_effective_capacity", "(", "self", ".", "memory", ")", "self", ".", ...
[ 188, 4 ]
[ 192, 33 ]
python
en
['en', 'en', 'en']
True
Instance.local_health_check
(self)
Only call this method on the instance that this record represents
Only call this method on the instance that this record represents
def local_health_check(self): """Only call this method on the instance that this record represents""" errors = None try: # if redis is down for some reason, that means we can't persist # playbook event data; we should consider this a zero capacity event redis....
[ "def", "local_health_check", "(", "self", ")", ":", "errors", "=", "None", "try", ":", "# if redis is down for some reason, that means we can't persist", "# playbook event data; we should consider this a zero capacity event", "redis", ".", "Redis", ".", "from_url", "(", "settin...
[ 231, 4 ]
[ 241, 129 ]
python
en
['en', 'en', 'en']
True
translate_pattern
(glob)
Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories.
Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories.
def translate_pattern(glob): """ Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories. """ pat = '' # This will spli...
[ "def", "translate_pattern", "(", "glob", ")", ":", "pat", "=", "''", "# This will split on '/' within [character classes]. This is deliberate.", "chunks", "=", "glob", ".", "split", "(", "os", ".", "path", ".", "sep", ")", "sep", "=", "re", ".", "escape", "(", ...
[ 33, 0 ]
[ 113, 58 ]
python
en
['en', 'error', 'th']
False
write_file
(filename, contents)
Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.
Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.
def write_file(filename, contents): """Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. """ contents = "\n".join(contents) # assuming the contents has been vetted for utf-8 encoding contents = contents.encode("utf-8") with o...
[ "def", "write_file", "(", "filename", ",", "contents", ")", ":", "contents", "=", "\"\\n\"", ".", "join", "(", "contents", ")", "# assuming the contents has been vetted for utf-8 encoding", "contents", "=", "contents", ".", "encode", "(", "\"utf-8\"", ")", "with", ...
[ 599, 0 ]
[ 609, 25 ]
python
en
['en', 'en', 'en']
True
get_pkg_info_revision
()
Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision.
Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision.
def get_pkg_info_revision(): """ Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. """ warnings.warn( "get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning) if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: ...
[ "def", "get_pkg_info_revision", "(", ")", ":", "warnings", ".", "warn", "(", "\"get_pkg_info_revision is deprecated.\"", ",", "EggInfoDeprecationWarning", ")", "if", "os", ".", "path", ".", "exists", "(", "'PKG-INFO'", ")", ":", "with", "io", ".", "open", "(", ...
[ 704, 0 ]
[ 717, 12 ]
python
en
['en', 'error', 'th']
False
InfoCommon._maybe_tag
(self, version)
egg_info may be called more than once for a distribution, in which case the version string already contains all tags.
egg_info may be called more than once for a distribution, in which case the version string already contains all tags.
def _maybe_tag(self, version): """ egg_info may be called more than once for a distribution, in which case the version string already contains all tags. """ return ( version if self.vtags and version.endswith(self.vtags) else version + self.vtags )
[ "def", "_maybe_tag", "(", "self", ",", "version", ")", ":", "return", "(", "version", "if", "self", ".", "vtags", "and", "version", ".", "endswith", "(", "self", ".", "vtags", ")", "else", "version", "+", "self", ".", "vtags", ")" ]
[ 127, 4 ]
[ 135, 9 ]
python
en
['en', 'error', 'th']
False
egg_info.save_version_info
(self, filename)
Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds.
Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds.
def save_version_info(self, filename): """ Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. """ egg_info = collections.OrderedDict() # follow the order these keys woul...
[ "def", "save_version_info", "(", "self", ",", "filename", ")", ":", "egg_info", "=", "collections", ".", "OrderedDict", "(", ")", "# follow the order these keys would have been added", "# when PYTHONHASHSEED=0", "egg_info", "[", "'tag_build'", "]", "=", "self", ".", "...
[ 182, 4 ]
[ 193, 54 ]
python
en
['en', 'error', 'th']
False
egg_info.write_or_delete_file
(self, what, filename, data, force=False)
Write `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which ...
Write `data` to `filename` or delete if empty
def write_or_delete_file(self, what, filename, data, force=False): """Write `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data`...
[ "def", "write_or_delete_file", "(", "self", ",", "what", ",", "filename", ",", "data", ",", "force", "=", "False", ")", ":", "if", "data", ":", "self", ".", "write_file", "(", "what", ",", "filename", ",", "data", ")", "elif", "os", ".", "path", ".",...
[ 244, 4 ]
[ 262, 42 ]
python
en
['en', 'el-Latn', 'en']
True
egg_info.write_file
(self, what, filename, data)
Write `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file.
Write `data` to `filename` (if not a dry run) after announcing it
def write_file(self, what, filename, data): """Write `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file. """ log.info("writing %s to %s", what, filename) data = data.encode("utf-8") ...
[ "def", "write_file", "(", "self", ",", "what", ",", "filename", ",", "data", ")", ":", "log", ".", "info", "(", "\"writing %s to %s\"", ",", "what", ",", "filename", ")", "data", "=", "data", ".", "encode", "(", "\"utf-8\"", ")", "if", "not", "self", ...
[ 264, 4 ]
[ 275, 21 ]
python
en
['en', 'en', 'en']
True
egg_info.delete_file
(self, filename)
Delete `filename` (if not a dry run) after announcing it
Delete `filename` (if not a dry run) after announcing it
def delete_file(self, filename): """Delete `filename` (if not a dry run) after announcing it""" log.info("deleting %s", filename) if not self.dry_run: os.unlink(filename)
[ "def", "delete_file", "(", "self", ",", "filename", ")", ":", "log", ".", "info", "(", "\"deleting %s\"", ",", "filename", ")", "if", "not", "self", ".", "dry_run", ":", "os", ".", "unlink", "(", "filename", ")" ]
[ 277, 4 ]
[ 281, 31 ]
python
en
['en', 'en', 'en']
True
egg_info.find_sources
(self)
Generate SOURCES.txt manifest file
Generate SOURCES.txt manifest file
def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") mm = manifest_maker(self.distribution) mm.manifest = manifest_filename mm.run() self.filelist = mm.filelist
[ "def", "find_sources", "(", "self", ")", ":", "manifest_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "egg_info", ",", "\"SOURCES.txt\"", ")", "mm", "=", "manifest_maker", "(", "self", ".", "distribution", ")", "mm", ".", "manifest", ...
[ 299, 4 ]
[ 305, 35 ]
python
en
['en', 'en', 'it']
True
FileList._remove_files
(self, predicate)
Remove all files from the file list that match the predicate. Return True if any matching files were removed
Remove all files from the file list that match the predicate. Return True if any matching files were removed
def _remove_files(self, predicate): """ Remove all files from the file list that match the predicate. Return True if any matching files were removed """ found = False for i in range(len(self.files) - 1, -1, -1): if predicate(self.files[i]): sel...
[ "def", "_remove_files", "(", "self", ",", "predicate", ")", ":", "found", "=", "False", "for", "i", "in", "range", "(", "len", "(", "self", ".", "files", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "predicate", "(", "self", "."...
[ 399, 4 ]
[ 410, 20 ]
python
en
['en', 'error', 'th']
False
FileList.include
(self, pattern)
Include files that match 'pattern'.
Include files that match 'pattern'.
def include(self, pattern): """Include files that match 'pattern'.""" found = [f for f in glob(pattern) if not os.path.isdir(f)] self.extend(found) return bool(found)
[ "def", "include", "(", "self", ",", "pattern", ")", ":", "found", "=", "[", "f", "for", "f", "in", "glob", "(", "pattern", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "f", ")", "]", "self", ".", "extend", "(", "found", ")", "return"...
[ 412, 4 ]
[ 416, 26 ]
python
en
['en', 'en', 'en']
True
FileList.exclude
(self, pattern)
Exclude files that match 'pattern'.
Exclude files that match 'pattern'.
def exclude(self, pattern): """Exclude files that match 'pattern'.""" match = translate_pattern(pattern) return self._remove_files(match.match)
[ "def", "exclude", "(", "self", ",", "pattern", ")", ":", "match", "=", "translate_pattern", "(", "pattern", ")", "return", "self", ".", "_remove_files", "(", "match", ".", "match", ")" ]
[ 418, 4 ]
[ 421, 46 ]
python
en
['en', 'en', 'en']
True
FileList.recursive_include
(self, dir, pattern)
Include all files anywhere in 'dir/' that match the pattern.
Include all files anywhere in 'dir/' that match the pattern.
def recursive_include(self, dir, pattern): """ Include all files anywhere in 'dir/' that match the pattern. """ full_pattern = os.path.join(dir, '**', pattern) found = [f for f in glob(full_pattern, recursive=True) if not os.path.isdir(f)] self.extend(fou...
[ "def", "recursive_include", "(", "self", ",", "dir", ",", "pattern", ")", ":", "full_pattern", "=", "os", ".", "path", ".", "join", "(", "dir", ",", "'**'", ",", "pattern", ")", "found", "=", "[", "f", "for", "f", "in", "glob", "(", "full_pattern", ...
[ 423, 4 ]
[ 431, 26 ]
python
en
['en', 'error', 'th']
False
FileList.recursive_exclude
(self, dir, pattern)
Exclude any file anywhere in 'dir/' that match the pattern.
Exclude any file anywhere in 'dir/' that match the pattern.
def recursive_exclude(self, dir, pattern): """ Exclude any file anywhere in 'dir/' that match the pattern. """ match = translate_pattern(os.path.join(dir, '**', pattern)) return self._remove_files(match.match)
[ "def", "recursive_exclude", "(", "self", ",", "dir", ",", "pattern", ")", ":", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'**'", ",", "pattern", ")", ")", "return", "self", ".", "_remove_files", "(", "matc...
[ 433, 4 ]
[ 438, 46 ]
python
en
['en', 'error', 'th']
False
FileList.graft
(self, dir)
Include all files from 'dir/'.
Include all files from 'dir/'.
def graft(self, dir): """Include all files from 'dir/'.""" found = [ item for match_dir in glob(dir) for item in distutils.filelist.findall(match_dir) ] self.extend(found) return bool(found)
[ "def", "graft", "(", "self", ",", "dir", ")", ":", "found", "=", "[", "item", "for", "match_dir", "in", "glob", "(", "dir", ")", "for", "item", "in", "distutils", ".", "filelist", ".", "findall", "(", "match_dir", ")", "]", "self", ".", "extend", "...
[ 440, 4 ]
[ 448, 26 ]
python
en
['en', 'en', 'en']
True
FileList.prune
(self, dir)
Filter out files from 'dir/'.
Filter out files from 'dir/'.
def prune(self, dir): """Filter out files from 'dir/'.""" match = translate_pattern(os.path.join(dir, '**')) return self._remove_files(match.match)
[ "def", "prune", "(", "self", ",", "dir", ")", ":", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'**'", ")", ")", "return", "self", ".", "_remove_files", "(", "match", ".", "match", ")" ]
[ 450, 4 ]
[ 453, 46 ]
python
en
['en', 'en', 'en']
True
FileList.global_include
(self, pattern)
Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees.
Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees.
def global_include(self, pattern): """ Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. """ if self.allfiles is None: self.findall() match = translate_pattern(os.path.join('**', pattern))...
[ "def", "global_include", "(", "self", ",", "pattern", ")", ":", "if", "self", ".", "allfiles", "is", "None", ":", "self", ".", "findall", "(", ")", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "'**'", ",", "pattern", "...
[ 455, 4 ]
[ 465, 26 ]
python
en
['en', 'error', 'th']
False
FileList.global_exclude
(self, pattern)
Exclude all files anywhere that match the pattern.
Exclude all files anywhere that match the pattern.
def global_exclude(self, pattern): """ Exclude all files anywhere that match the pattern. """ match = translate_pattern(os.path.join('**', pattern)) return self._remove_files(match.match)
[ "def", "global_exclude", "(", "self", ",", "pattern", ")", ":", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "'**'", ",", "pattern", ")", ")", "return", "self", ".", "_remove_files", "(", "match", ".", "match", ")" ]
[ 467, 4 ]
[ 472, 46 ]
python
en
['en', 'error', 'th']
False
FileList._repair
(self)
Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths.
Replace self.files with only safe paths
def _repair(self): """ Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths. """ self.files = list(filter(self._safe_path, self.files))
[ "def", "_repair", "(", "self", ")", ":", "self", ".", "files", "=", "list", "(", "filter", "(", "self", ".", "_safe_path", ",", "self", ".", "files", ")", ")" ]
[ 485, 4 ]
[ 493, 62 ]
python
en
['en', 'error', 'th']
False
manifest_maker.write_manifest
(self)
Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'.
Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'.
def write_manifest(self): """ Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ self.filelist._repair() # Now _repairs should encodability, but not unicode files = [self._manifest_normalize(f) for f in self.filelist.files] ...
[ "def", "write_manifest", "(", "self", ")", ":", "self", ".", "filelist", ".", "_repair", "(", ")", "# Now _repairs should encodability, but not unicode", "files", "=", "[", "self", ".", "_manifest_normalize", "(", "f", ")", "for", "f", "in", "self", ".", "file...
[ 547, 4 ]
[ 557, 61 ]
python
en
['en', 'error', 'th']
False
manifest_maker._should_suppress_warning
(msg)
suppress missing-file warnings from sdist
suppress missing-file warnings from sdist
def _should_suppress_warning(msg): """ suppress missing-file warnings from sdist """ return re.match(r"standard file .*not found", msg)
[ "def", "_should_suppress_warning", "(", "msg", ")", ":", "return", "re", ".", "match", "(", "r\"standard file .*not found\"", ",", "msg", ")" ]
[ 564, 4 ]
[ 568, 58 ]
python
en
['en', 'error', 'th']
False
Metasmoke.set_ms_up
(tell=True)
Switch metasmoke status to up
Switch metasmoke status to up
def set_ms_up(tell=True): """ Switch metasmoke status to up """ # We must first set metasmoke to up, then say that metasmoke is up, not the other way around. ms_msg = "" if GlobalVars.MSStatus.is_down(): ms_msg = "Metasmoke status: set to up." GlobalVars.MSStatus....
[ "def", "set_ms_up", "(", "tell", "=", "True", ")", ":", "# We must first set metasmoke to up, then say that metasmoke is up, not the other way around.", "ms_msg", "=", "\"\"", "if", "GlobalVars", ".", "MSStatus", ".", "is_down", "(", ")", ":", "ms_msg", "=", "\"Metasmok...
[ 125, 4 ]
[ 136, 102 ]
python
en
['en', 'jv', 'en']
True
Metasmoke.set_ms_down
(tell=True)
Switch metasmoke status to down
Switch metasmoke status to down
def set_ms_down(tell=True): """ Switch metasmoke status to down """ ms_msg = "" if GlobalVars.MSStatus.is_up(): ms_msg = "Metasmoke status: set to down." GlobalVars.MSStatus.set_down() if ms_msg: log("info", ms_msg) if tell: ...
[ "def", "set_ms_down", "(", "tell", "=", "True", ")", ":", "ms_msg", "=", "\"\"", "if", "GlobalVars", ".", "MSStatus", ".", "is_up", "(", ")", ":", "ms_msg", "=", "\"Metasmoke status: set to down.\"", "GlobalVars", ".", "MSStatus", ".", "set_down", "(", ")", ...
[ 139, 4 ]
[ 149, 102 ]
python
en
['en', 'jv', 'en']
True
Metasmoke.determine_if_autoflagged
(post_url)
Given the URL for a post, determine whether or not it has been autoflagged.
Given the URL for a post, determine whether or not it has been autoflagged.
def determine_if_autoflagged(post_url): """ Given the URL for a post, determine whether or not it has been autoflagged. """ payload = { 'key': GlobalVars.metasmoke_key, 'filter': 'GFGJGHFMHGOLMMJMJJJGHIGOMKFKKILF', # id and autoflagged 'urls': post_ur...
[ "def", "determine_if_autoflagged", "(", "post_url", ")", ":", "payload", "=", "{", "'key'", ":", "GlobalVars", ".", "metasmoke_key", ",", "'filter'", ":", "'GFGJGHFMHGOLMMJMJJJGHIGOMKFKKILF'", ",", "# id and autoflagged", "'urls'", ":", "post_url", "}", "try", ":", ...
[ 484, 4 ]
[ 511, 24 ]
python
en
['en', 'error', 'th']
False
unpack
(src_dir, dst_dir)
Move everything under `src_dir` to `dst_dir`, and delete the former.
Move everything under `src_dir` to `dst_dir`, and delete the former.
def unpack(src_dir, dst_dir): '''Move everything under `src_dir` to `dst_dir`, and delete the former.''' for dirpath, dirnames, filenames in os.walk(src_dir): subdir = os.path.relpath(dirpath, src_dir) for f in filenames: src = os.path.join(dirpath, f) dst = os.path.join(...
[ "def", "unpack", "(", "src_dir", ",", "dst_dir", ")", ":", "for", "dirpath", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "src_dir", ")", ":", "subdir", "=", "os", ".", "path", ".", "relpath", "(", "dirpath", ",", "src_dir", ")", ...
[ 29, 0 ]
[ 48, 25 ]
python
en
['en', 'en', 'en']
True
Wheel.tags
(self)
List tags (py_version, abi, platform) supported by this wheel.
List tags (py_version, abi, platform) supported by this wheel.
def tags(self): '''List tags (py_version, abi, platform) supported by this wheel.''' return itertools.product( self.py_version.split('.'), self.abi.split('.'), self.platform.split('.'), )
[ "def", "tags", "(", "self", ")", ":", "return", "itertools", ".", "product", "(", "self", ".", "py_version", ".", "split", "(", "'.'", ")", ",", "self", ".", "abi", ".", "split", "(", "'.'", ")", ",", "self", ".", "platform", ".", "split", "(", "...
[ 61, 4 ]
[ 67, 9 ]
python
en
['en', 'en', 'en']
True
Wheel.is_compatible
(self)
Is the wheel is compatible with the current platform?
Is the wheel is compatible with the current platform?
def is_compatible(self): '''Is the wheel is compatible with the current platform?''' supported_tags = set( (t.interpreter, t.abi, t.platform) for t in sys_tags()) return next((True for t in self.tags() if t in supported_tags), False)
[ "def", "is_compatible", "(", "self", ")", ":", "supported_tags", "=", "set", "(", "(", "t", ".", "interpreter", ",", "t", ".", "abi", ",", "t", ".", "platform", ")", "for", "t", "in", "sys_tags", "(", ")", ")", "return", "next", "(", "(", "True", ...
[ 69, 4 ]
[ 73, 78 ]
python
en
['en', 'en', 'en']
True
Wheel.install_as_egg
(self, destination_eggdir)
Install wheel as an egg directory.
Install wheel as an egg directory.
def install_as_egg(self, destination_eggdir): '''Install wheel as an egg directory.''' with zipfile.ZipFile(self.filename) as zf: self._install_as_egg(destination_eggdir, zf)
[ "def", "install_as_egg", "(", "self", ",", "destination_eggdir", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "self", ".", "filename", ")", "as", "zf", ":", "self", ".", "_install_as_egg", "(", "destination_eggdir", ",", "zf", ")" ]
[ 91, 4 ]
[ 94, 56 ]
python
en
['en', 'en', 'en']
True
Wheel._move_data_entries
(destination_eggdir, dist_data)
Move data entries to their correct location.
Move data entries to their correct location.
def _move_data_entries(destination_eggdir, dist_data): """Move data entries to their correct location.""" dist_data = os.path.join(destination_eggdir, dist_data) dist_data_scripts = os.path.join(dist_data, 'scripts') if os.path.exists(dist_data_scripts): egg_info_scripts = os...
[ "def", "_move_data_entries", "(", "destination_eggdir", ",", "dist_data", ")", ":", "dist_data", "=", "os", ".", "path", ".", "join", "(", "destination_eggdir", ",", "dist_data", ")", "dist_data_scripts", "=", "os", ".", "path", ".", "join", "(", "dist_data", ...
[ 171, 4 ]
[ 196, 31 ]
python
en
['en', 'en', 'en']
True
Command.get_handler
(self, *args, **options)
Returns the default WSGI handler for the runner.
Returns the default WSGI handler for the runner.
def get_handler(self, *args, **options): """ Returns the default WSGI handler for the runner. """ return get_internal_wsgi_application()
[ "def", "get_handler", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "return", "get_internal_wsgi_application", "(", ")" ]
[ 63, 4 ]
[ 67, 46 ]
python
en
['en', 'error', 'th']
False
Command.run
(self, **options)
Runs the server, using the autoreloader if needed
Runs the server, using the autoreloader if needed
def run(self, **options): """ Runs the server, using the autoreloader if needed """ use_reloader = options['use_reloader'] if use_reloader: autoreload.main(self.inner_run, None, options) else: self.inner_run(None, **options)
[ "def", "run", "(", "self", ",", "*", "*", "options", ")", ":", "use_reloader", "=", "options", "[", "'use_reloader'", "]", "if", "use_reloader", ":", "autoreload", ".", "main", "(", "self", ".", "inner_run", ",", "None", ",", "options", ")", "else", ":...
[ 102, 4 ]
[ 111, 43 ]
python
en
['en', 'error', 'th']
False
_expected_plot_size
(k: int)
Given the plot size parameter k (which is between 32 and 59), computes the expected size of the plot in bytes (times a constant factor). This is based on efficient encoding of the plot, and aims to be scale agnostic, so larger plots don't necessarily get more rewards per byte. The +1 is added to give h...
Given the plot size parameter k (which is between 32 and 59), computes the expected size of the plot in bytes (times a constant factor). This is based on efficient encoding of the plot, and aims to be scale agnostic, so larger plots don't necessarily get more rewards per byte. The +1 is added to give h...
def _expected_plot_size(k: int) -> uint64: """ Given the plot size parameter k (which is between 32 and 59), computes the expected size of the plot in bytes (times a constant factor). This is based on efficient encoding of the plot, and aims to be scale agnostic, so larger plots don't necessarily ge...
[ "def", "_expected_plot_size", "(", "k", ":", "int", ")", "->", "uint64", ":", "return", "(", "(", "2", "*", "k", ")", "+", "1", ")", "*", "(", "2", "**", "(", "k", "-", "1", ")", ")" ]
[ 7, 0 ]
[ 16, 41 ]
python
en
['en', 'error', 'th']
False
test_handle_content_type
(post, admin)
Tower should return 415 when wrong content type is in HTTP requests
Tower should return 415 when wrong content type is in HTTP requests
def test_handle_content_type(post, admin): '''Tower should return 415 when wrong content type is in HTTP requests''' post(reverse('api:project_list'), {'name': 't', 'organization': None}, admin, content_type='text/html', expect=415)
[ "def", "test_handle_content_type", "(", "post", ",", "admin", ")", ":", "post", "(", "reverse", "(", "'api:project_list'", ")", ",", "{", "'name'", ":", "'t'", ",", "'organization'", ":", "None", "}", ",", "admin", ",", "content_type", "=", "'text/html'", ...
[ 80, 0 ]
[ 82, 119 ]
python
en
['en', 'en', 'en']
True
_check_lazy_references
(apps, ignore=None)
Ensure all lazy (i.e. string) model references have been resolved. Lazy references are used in various places throughout Django, primarily in related fields and model signals. Identify those common cases and provide more helpful error messages for them. The ignore parameter is used by StateApps t...
Ensure all lazy (i.e. string) model references have been resolved.
def _check_lazy_references(apps, ignore=None): """ Ensure all lazy (i.e. string) model references have been resolved. Lazy references are used in various places throughout Django, primarily in related fields and model signals. Identify those common cases and provide more helpful error messages for ...
[ "def", "_check_lazy_references", "(", "apps", ",", "ignore", "=", "None", ")", ":", "pending_models", "=", "set", "(", "apps", ".", "_pending_operations", ")", "-", "(", "ignore", "or", "set", "(", ")", ")", "# Short circuit if there aren't any errors.", "if", ...
[ 33, 0 ]
[ 151, 36 ]
python
en
['en', 'error', 'th']
False
do_get_available_languages
(parser, token)
This will store a list of available languages in the context. Usage:: {% get_available_languages as languages %} {% for language in languages %} ... {% endfor %} This will just pull the LANGUAGES setting from your setting file (or the default settings) and put...
This will store a list of available languages in the context.
def do_get_available_languages(parser, token): """ This will store a list of available languages in the context. Usage:: {% get_available_languages as languages %} {% for language in languages %} ... {% endfor %} This will just pull the LANGUAGES setting from y...
[ "def", "do_get_available_languages", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "args", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "args", ")", ...
[ 196, 0 ]
[ 216, 45 ]
python
en
['en', 'error', 'th']
False
do_get_language_info
(parser, token)
This will store the language information dictionary for the given language code in a context variable. Usage:: {% get_language_info for LANGUAGE_CODE as l %} {{ l.code }} {{ l.name }} {{ l.name_translated }} {{ l.name_local }} {{ l.bidi|yesno:"bi-directiona...
This will store the language information dictionary for the given language code in a context variable.
def do_get_language_info(parser, token): """ This will store the language information dictionary for the given language code in a context variable. Usage:: {% get_language_info for LANGUAGE_CODE as l %} {{ l.code }} {{ l.name }} {{ l.name_translated }} {{ l.name...
[ "def", "do_get_language_info", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", "!=", "5", "or", "args", "[", "1", "]", "!=", "'for'", "or", "args", "[", "3", "]", "!=", ...
[ 220, 0 ]
[ 237, 71 ]
python
en
['en', 'error', 'th']
False
do_get_language_info_list
(parser, token)
This will store a list of language information dictionaries for the given language codes in a context variable. The language codes can be specified either as a list of strings or a settings.LANGUAGES style list (or any sequence of sequences whose first items are language codes). Usage:: {...
This will store a list of language information dictionaries for the given language codes in a context variable. The language codes can be specified either as a list of strings or a settings.LANGUAGES style list (or any sequence of sequences whose first items are language codes).
def do_get_language_info_list(parser, token): """ This will store a list of language information dictionaries for the given language codes in a context variable. The language codes can be specified either as a list of strings or a settings.LANGUAGES style list (or any sequence of sequences whose fir...
[ "def", "do_get_language_info_list", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", "!=", "5", "or", "args", "[", "1", "]", "!=", "'for'", "or", "args", "[", "3", "]", "!=...
[ 241, 0 ]
[ 262, 75 ]
python
en
['en', 'error', 'th']
False
do_get_current_language
(parser, token)
This will store the current language in the context. Usage:: {% get_current_language as language %} This will fetch the currently active language and put it's value into the ``language`` context variable.
This will store the current language in the context.
def do_get_current_language(parser, token): """ This will store the current language in the context. Usage:: {% get_current_language as language %} This will fetch the currently active language and put it's value into the ``language`` context variable. """ # token.split_conten...
[ "def", "do_get_current_language", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "args", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "args", ")", "!=...
[ 287, 0 ]
[ 303, 42 ]
python
en
['en', 'error', 'th']
False
do_get_current_language_bidi
(parser, token)
This will store the current language layout in the context. Usage:: {% get_current_language_bidi as bidi %} This will fetch the currently active language's layout and put it's value into the ``bidi`` context variable. True indicates right-to-left layout, otherwise left-to-right
This will store the current language layout in the context.
def do_get_current_language_bidi(parser, token): """ This will store the current language layout in the context. Usage:: {% get_current_language_bidi as bidi %} This will fetch the currently active language's layout and put it's value into the ``bidi`` context variable. True indicates...
[ "def", "do_get_current_language_bidi", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "args", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "args", ")", ...
[ 307, 0 ]
[ 323, 46 ]
python
en
['en', 'error', 'th']
False
do_translate
(parser, token)
This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and will run the string through the translati...
This will mark a string for translation and will translate the string for the current language.
def do_translate(parser, token): """ This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and w...
[ "def", "do_translate", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes at least one argument\"", "%", "bits", "[", ...
[ 327, 0 ]
[ 415, 70 ]
python
en
['en', 'error', 'th']
False
do_block_translate
(parser, token)
This will translate a block of text with parameters. Usage:: {% blocktrans with bar=foo|filter boo=baz|filter %} This is {{ bar }} and {{ boo }}. {% endblocktrans %} Additionally, this supports pluralization:: {% blocktrans count count=var|length %} There is {{ c...
This will translate a block of text with parameters.
def do_block_translate(parser, token): """ This will translate a block of text with parameters. Usage:: {% blocktrans with bar=foo|filter boo=baz|filter %} This is {{ bar }} and {{ boo }}. {% endblocktrans %} Additionally, this supports pluralization:: {% blocktrans c...
[ "def", "do_block_translate", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "options", "=", "{", "}", "remaining_bits", "=", "bits", "[", "1", ":", "]", "asvar", "=", "None", "while", "remaining_bits", ":", ...
[ 419, 0 ]
[ 537, 42 ]
python
en
['en', 'error', 'th']
False
language
(parser, token)
This will enable the given language just for this block. Usage:: {% language "de" %} This is {{ bar }} and {{ boo }}. {% endlanguage %}
This will enable the given language just for this block.
def language(parser, token): """ This will enable the given language just for this block. Usage:: {% language "de" %} This is {{ bar }} and {{ boo }}. {% endlanguage %} """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("'%s' take...
[ "def", "language", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes one argument (language)\"", "%", "bits", "[", ...
[ 541, 0 ]
[ 557, 43 ]
python
en
['en', 'error', 'th']
False
main
()
A simple main for testing via command line.
A simple main for testing via command line.
def main(): """A simple main for testing via command line.""" parser = argparse.ArgumentParser( description='A manual test for ros-pull-request-builder access' 'to a GitHub repo.') parser.add_argument('user', type=str) parser.add_argument('repo', type=str) parser.add_argu...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'A manual test for ros-pull-request-builder access'", "'to a GitHub repo.'", ")", "parser", ".", "add_argument", "(", "'user'", ",", "type", "=", "str", ")", ...
[ 115, 0 ]
[ 150, 12 ]
python
en
['en', 'en', 'en']
True
test_build_script_remote_empty_browser
(self)
taurus should not wipe browserName (from capabilities)
taurus should not wipe browserName (from capabilities)
def test_build_script_remote_empty_browser(self): """ taurus should not wipe browserName (from capabilities) """ self.configure({ "execution": [{ "executor": "selenium", "remote": "http://addr-of-remote-server.com", "scenario": "remote_sc"}], ...
[ "def", "test_build_script_remote_empty_browser", "(", "self", ")", ":", "self", ".", "configure", "(", "{", "\"execution\"", ":", "[", "{", "\"executor\"", ":", "\"selenium\"", ",", "\"remote\"", ":", "\"http://addr-of-remote-server.com\"", ",", "\"scenario\"", ":", ...
[ 841, 4 ]
[ 864, 38 ]
python
en
['en', 'en', 'en']
True
test_build_script_remote_browser
(self)
taurus should not wipe browserName (from capabilities)
taurus should not wipe browserName (from capabilities)
def test_build_script_remote_browser(self): """ taurus should not wipe browserName (from capabilities) """ self.configure({ "execution": [{ "executor": "selenium", "remote": "http://addr-of-remote-server.com", "scenario": "remote_sc"}], ...
[ "def", "test_build_script_remote_browser", "(", "self", ")", ":", "self", ".", "configure", "(", "{", "\"execution\"", ":", "[", "{", "\"executor\"", ":", "\"selenium\"", ",", "\"remote\"", ":", "\"http://addr-of-remote-server.com\"", ",", "\"scenario\"", ":", "\"re...
[ 866, 4 ]
[ 889, 38 ]
python
en
['en', 'en', 'en']
True
test_build_script_remote_Firefox_browser
(self)
check usage of 'browser' scenario options as browserName (from capabilities)
check usage of 'browser' scenario options as browserName (from capabilities)
def test_build_script_remote_Firefox_browser(self): """ check usage of 'browser' scenario options as browserName (from capabilities) """ self.configure({ "execution": [{ "executor": "selenium", "remote": "http://addr-of-remote-server.com", "sce...
[ "def", "test_build_script_remote_Firefox_browser", "(", "self", ")", ":", "self", ".", "configure", "(", "{", "\"execution\"", ":", "[", "{", "\"executor\"", ":", "\"selenium\"", ",", "\"remote\"", ":", "\"http://addr-of-remote-server.com\"", ",", "\"scenario\"", ":",...
[ 891, 4 ]
[ 913, 38 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseCreation._nodb_connection
(self)
Used to be defined here, now moved to DatabaseWrapper.
Used to be defined here, now moved to DatabaseWrapper.
def _nodb_connection(self): """ Used to be defined here, now moved to DatabaseWrapper. """ return self.connection._nodb_connection
[ "def", "_nodb_connection", "(", "self", ")", ":", "return", "self", ".", "connection", ".", "_nodb_connection" ]
[ 23, 4 ]
[ 27, 47 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.create_test_db
(self, verbosity=1, autoclobber=False, serialize=True, keepdb=False)
Creates a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created.
Creates a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created.
def create_test_db(self, verbosity=1, autoclobber=False, serialize=True, keepdb=False): """ Creates a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created. """ # Don't import django.core.management if it ...
[ "def", "create_test_db", "(", "self", ",", "verbosity", "=", "1", ",", "autoclobber", "=", "False", ",", "serialize", "=", "True", ",", "keepdb", "=", "False", ")", ":", "# Don't import django.core.management if it isn't needed.", "from", "django", ".", "core", ...
[ 29, 4 ]
[ 83, 33 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.set_as_test_mirror
(self, primary_settings_dict)
Set this database up to be used in testing as a mirror of a primary database whose settings are given
Set this database up to be used in testing as a mirror of a primary database whose settings are given
def set_as_test_mirror(self, primary_settings_dict): """ Set this database up to be used in testing as a mirror of a primary database whose settings are given """ self.connection.settings_dict['NAME'] = primary_settings_dict['NAME']
[ "def", "set_as_test_mirror", "(", "self", ",", "primary_settings_dict", ")", ":", "self", ".", "connection", ".", "settings_dict", "[", "'NAME'", "]", "=", "primary_settings_dict", "[", "'NAME'", "]" ]
[ 85, 4 ]
[ 90, 77 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.serialize_db_to_string
(self)
Serializes all data in the database into a JSON string. Designed only for test runner usage; will not handle large amounts of data.
Serializes all data in the database into a JSON string. Designed only for test runner usage; will not handle large amounts of data.
def serialize_db_to_string(self): """ Serializes all data in the database into a JSON string. Designed only for test runner usage; will not handle large amounts of data. """ # Build list of all apps to serialize from django.db.migrations.loader import MigrationLoa...
[ "def", "serialize_db_to_string", "(", "self", ")", ":", "# Build list of all apps to serialize", "from", "django", ".", "db", ".", "migrations", ".", "loader", "import", "MigrationLoader", "loader", "=", "MigrationLoader", "(", "self", ".", "connection", ")", "app_l...
[ 92, 4 ]
[ 121, 29 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.deserialize_db_from_string
(self, data)
Reloads the database with data from a string generated by the serialize_db_to_string method.
Reloads the database with data from a string generated by the serialize_db_to_string method.
def deserialize_db_from_string(self, data): """ Reloads the database with data from a string generated by the serialize_db_to_string method. """ data = StringIO(data) for obj in serializers.deserialize("json", data, using=self.connection.alias): obj.save()
[ "def", "deserialize_db_from_string", "(", "self", ",", "data", ")", ":", "data", "=", "StringIO", "(", "data", ")", "for", "obj", "in", "serializers", ".", "deserialize", "(", "\"json\"", ",", "data", ",", "using", "=", "self", ".", "connection", ".", "a...
[ 123, 4 ]
[ 130, 22 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation._get_database_display_str
(self, verbosity, database_name)
Return display string for a database for use in various actions.
Return display string for a database for use in various actions.
def _get_database_display_str(self, verbosity, database_name): """ Return display string for a database for use in various actions. """ return "'%s'%s" % ( self.connection.alias, (" ('%s')" % database_name) if verbosity >= 2 else '', )
[ "def", "_get_database_display_str", "(", "self", ",", "verbosity", ",", "database_name", ")", ":", "return", "\"'%s'%s\"", "%", "(", "self", ".", "connection", ".", "alias", ",", "(", "\" ('%s')\"", "%", "database_name", ")", "if", "verbosity", ">=", "2", "e...
[ 132, 4 ]
[ 139, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation._get_test_db_name
(self)
Internal implementation - returns the name of the test DB that will be created. Only useful when called from create_test_db() and _create_test_db() and when no external munging is done with the 'NAME' settings.
Internal implementation - returns the name of the test DB that will be created. Only useful when called from create_test_db() and _create_test_db() and when no external munging is done with the 'NAME' settings.
def _get_test_db_name(self): """ Internal implementation - returns the name of the test DB that will be created. Only useful when called from create_test_db() and _create_test_db() and when no external munging is done with the 'NAME' settings. """ if self.connecti...
[ "def", "_get_test_db_name", "(", "self", ")", ":", "if", "self", ".", "connection", ".", "settings_dict", "[", "'TEST'", "]", "[", "'NAME'", "]", ":", "return", "self", ".", "connection", ".", "settings_dict", "[", "'TEST'", "]", "[", "'NAME'", "]", "ret...
[ 141, 4 ]
[ 150, 75 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation._create_test_db
(self, verbosity, autoclobber, keepdb=False)
Internal implementation - creates the test db tables.
Internal implementation - creates the test db tables.
def _create_test_db(self, verbosity, autoclobber, keepdb=False): """ Internal implementation - creates the test db tables. """ suffix = self.sql_table_creation_suffix() test_database_name = self._get_test_db_name() qn = self.connection.ops.quote_name # Create t...
[ "def", "_create_test_db", "(", "self", ",", "verbosity", ",", "autoclobber", ",", "keepdb", "=", "False", ")", ":", "suffix", "=", "self", ".", "sql_table_creation_suffix", "(", ")", "test_database_name", "=", "self", ".", "_get_test_db_name", "(", ")", "qn", ...
[ 152, 4 ]
[ 198, 33 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.clone_test_db
(self, number, verbosity=1, autoclobber=False, keepdb=False)
Clone a test database.
Clone a test database.
def clone_test_db(self, number, verbosity=1, autoclobber=False, keepdb=False): """ Clone a test database. """ source_database_name = self.connection.settings_dict['NAME'] if verbosity >= 1: action = 'Cloning test database' if keepdb: actio...
[ "def", "clone_test_db", "(", "self", ",", "number", ",", "verbosity", "=", "1", ",", "autoclobber", "=", "False", ",", "keepdb", "=", "False", ")", ":", "source_database_name", "=", "self", ".", "connection", ".", "settings_dict", "[", "'NAME'", "]", "if",...
[ 200, 4 ]
[ 217, 54 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.get_test_db_clone_settings
(self, number)
Return a modified connection settings dict for the n-th clone of a DB.
Return a modified connection settings dict for the n-th clone of a DB.
def get_test_db_clone_settings(self, number): """ Return a modified connection settings dict for the n-th clone of a DB. """ # When this function is called, the test database has been created # already and its name has been copied to settings_dict['NAME'] so # we don't ne...
[ "def", "get_test_db_clone_settings", "(", "self", ",", "number", ")", ":", "# When this function is called, the test database has been created", "# already and its name has been copied to settings_dict['NAME'] so", "# we don't need to call _get_test_db_name.", "orig_settings_dict", "=", "s...
[ 219, 4 ]
[ 229, 32 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation._clone_test_db
(self, number, verbosity, keepdb=False)
Internal implementation - duplicate the test db tables.
Internal implementation - duplicate the test db tables.
def _clone_test_db(self, number, verbosity, keepdb=False): """ Internal implementation - duplicate the test db tables. """ raise NotImplementedError( "The database backend doesn't support cloning databases. " "Disable the option to run tests in parallel processes....
[ "def", "_clone_test_db", "(", "self", ",", "number", ",", "verbosity", ",", "keepdb", "=", "False", ")", ":", "raise", "NotImplementedError", "(", "\"The database backend doesn't support cloning databases. \"", "\"Disable the option to run tests in parallel processes.\"", ")" ]
[ 231, 4 ]
[ 237, 69 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.destroy_test_db
(self, old_database_name=None, verbosity=1, keepdb=False, number=None)
Destroy a test database, prompting the user for confirmation if the database already exists.
Destroy a test database, prompting the user for confirmation if the database already exists.
def destroy_test_db(self, old_database_name=None, verbosity=1, keepdb=False, number=None): """ Destroy a test database, prompting the user for confirmation if the database already exists. """ self.connection.close() if number is None: test_database_name = self...
[ "def", "destroy_test_db", "(", "self", ",", "old_database_name", "=", "None", ",", "verbosity", "=", "1", ",", "keepdb", "=", "False", ",", "number", "=", "None", ")", ":", "self", ".", "connection", ".", "close", "(", ")", "if", "number", "is", "None"...
[ 239, 4 ]
[ 267, 69 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation._destroy_test_db
(self, test_database_name, verbosity)
Internal implementation - remove the test db tables.
Internal implementation - remove the test db tables.
def _destroy_test_db(self, test_database_name, verbosity): """ Internal implementation - remove the test db tables. """ # Remove the test database to clean up after # ourselves. Connect to the previous database (not the test database) # to do so, because it's not allowed ...
[ "def", "_destroy_test_db", "(", "self", ",", "test_database_name", ",", "verbosity", ")", ":", "# Remove the test database to clean up after", "# ourselves. Connect to the previous database (not the test database)", "# to do so, because it's not allowed to delete a database while being", "...
[ 269, 4 ]
[ 279, 80 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.sql_table_creation_suffix
(self)
SQL to append to the end of the test table creation statements.
SQL to append to the end of the test table creation statements.
def sql_table_creation_suffix(self): """ SQL to append to the end of the test table creation statements. """ return ''
[ "def", "sql_table_creation_suffix", "(", "self", ")", ":", "return", "''" ]
[ 281, 4 ]
[ 285, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseCreation.test_db_signature
(self)
Returns a tuple with elements of self.connection.settings_dict (a DATABASES setting value) that uniquely identify a database accordingly to the RDBMS particularities.
Returns a tuple with elements of self.connection.settings_dict (a DATABASES setting value) that uniquely identify a database accordingly to the RDBMS particularities.
def test_db_signature(self): """ Returns a tuple with elements of self.connection.settings_dict (a DATABASES setting value) that uniquely identify a database accordingly to the RDBMS particularities. """ settings_dict = self.connection.settings_dict return ( ...
[ "def", "test_db_signature", "(", "self", ")", ":", "settings_dict", "=", "self", ".", "connection", ".", "settings_dict", "return", "(", "settings_dict", "[", "'HOST'", "]", ",", "settings_dict", "[", "'PORT'", "]", ",", "settings_dict", "[", "'ENGINE'", "]", ...
[ 287, 4 ]
[ 299, 9 ]
python
en
['en', 'error', 'th']
False
VotingBot.streams
(self)
Standardizes a list of streams in the form [{'name': stream}]
Standardizes a list of streams in the form [{'name': stream}]
def streams(self): ''' Standardizes a list of streams in the form [{'name': stream}] ''' if not self.subscribed_streams: streams = [{'name': stream['name']} for stream in self.get_all_zulip_streams()] return streams else: streams...
[ "def", "streams", "(", "self", ")", ":", "if", "not", "self", ".", "subscribed_streams", ":", "streams", "=", "[", "{", "'name'", ":", "stream", "[", "'name'", "]", "}", "for", "stream", "in", "self", ".", "get_all_zulip_streams", "(", ")", "]", "retur...
[ 32, 4 ]
[ 41, 26 ]
python
en
['en', 'en', 'en']
True
VotingBot.get_all_zulip_streams
(self)
Call Zulip API to get a list of all streams
Call Zulip API to get a list of all streams
def get_all_zulip_streams(self): ''' Call Zulip API to get a list of all streams ''' response = requests.get('https://api.zulip.com/v1/streams', auth=(self.username, self.api_key)) if response.status_code == 200: return response.json()['stream...
[ "def", "get_all_zulip_streams", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "'https://api.zulip.com/v1/streams'", ",", "auth", "=", "(", "self", ".", "username", ",", "self", ".", "api_key", ")", ")", "if", "response", ".", "status_c...
[ 43, 4 ]
[ 56, 79 ]
python
en
['en', 'en', 'en']
True