repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
mottosso/be
be/vendor/requests/packages/urllib3/request.py
RequestMethods.request_encode_url
def request_encode_url(self, method, url, fields=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. """ if fields: url += '?' + urlencode(fields) ...
python
def request_encode_url(self, method, url, fields=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. """ if fields: url += '?' + urlencode(fields) ...
[ "def", "request_encode_url", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "*", "*", "urlopen_kw", ")", ":", "if", "fields", ":", "url", "+=", "'?'", "+", "urlencode", "(", "fields", ")", "return", "self", ".", "urlopen", "...
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
[ "Make", "a", "request", "using", ":", "meth", ":", "urlopen", "with", "the", "fields", "encoded", "in", "the", "url", ".", "This", "is", "useful", "for", "request", "methods", "like", "GET", "HEAD", "DELETE", "etc", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/request.py#L74-L81
mottosso/be
be/vendor/click/utils.py
make_str
def make_str(value): """Converts a value into a valid string.""" if isinstance(value, bytes): try: return value.decode(sys.getfilesystemencoding()) except UnicodeError: return value.decode('utf-8', 'replace') return text_type(value)
python
def make_str(value): """Converts a value into a valid string.""" if isinstance(value, bytes): try: return value.decode(sys.getfilesystemencoding()) except UnicodeError: return value.decode('utf-8', 'replace') return text_type(value)
[ "def", "make_str", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "try", ":", "return", "value", ".", "decode", "(", "sys", ".", "getfilesystemencoding", "(", ")", ")", "except", "UnicodeError", ":", "return", "value", ...
Converts a value into a valid string.
[ "Converts", "a", "value", "into", "a", "valid", "string", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/utils.py#L89-L96
mottosso/be
be/vendor/click/utils.py
echo
def echo(message=None, file=None, nl=True, err=False, color=None): """Prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode and binary data that does not fail no matter how badly configured the s...
python
def echo(message=None, file=None, nl=True, err=False, color=None): """Prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode and binary data that does not fail no matter how badly configured the s...
[ "def", "echo", "(", "message", "=", "None", ",", "file", "=", "None", ",", "nl", "=", "True", ",", "err", "=", "False", ",", "color", "=", "None", ")", ":", "if", "file", "is", "None", ":", "if", "err", ":", "file", "=", "_default_text_stderr", "...
Prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode and binary data that does not fail no matter how badly configured the system is. Primarily it means that you can print binary data as well a...
[ "Prints", "a", "message", "plus", "a", "newline", "to", "the", "given", "file", "or", "stdout", ".", "On", "first", "sight", "this", "looks", "like", "the", "print", "function", "but", "it", "has", "improved", "support", "for", "handling", "Unicode", "and"...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/utils.py#L213-L296
mottosso/be
be/lib.py
parent
def parent(): """Determine subshell matching the currently running shell The shell is determined by either a pre-defined BE_SHELL environment variable, or, if none is found, via psutil which looks at the parent process directly through system-level calls. For example, is `be` is run from cmd.e...
python
def parent(): """Determine subshell matching the currently running shell The shell is determined by either a pre-defined BE_SHELL environment variable, or, if none is found, via psutil which looks at the parent process directly through system-level calls. For example, is `be` is run from cmd.e...
[ "def", "parent", "(", ")", ":", "if", "self", ".", "_parent", ":", "return", "self", ".", "_parent", "if", "\"BE_SHELL\"", "in", "os", ".", "environ", ":", "self", ".", "_parent", "=", "os", ".", "environ", "[", "\"BE_SHELL\"", "]", "else", ":", "# I...
Determine subshell matching the currently running shell The shell is determined by either a pre-defined BE_SHELL environment variable, or, if none is found, via psutil which looks at the parent process directly through system-level calls. For example, is `be` is run from cmd.exe, then the full ...
[ "Determine", "subshell", "matching", "the", "currently", "running", "shell" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L23-L67
mottosso/be
be/lib.py
platform
def platform(): """Return platform for the current shell, e.g. windows or unix""" executable = parent() basename = os.path.basename(executable) basename, _ = os.path.splitext(basename) if basename in ("bash", "sh"): return "unix" if basename in ("cmd", "powershell"): return "win...
python
def platform(): """Return platform for the current shell, e.g. windows or unix""" executable = parent() basename = os.path.basename(executable) basename, _ = os.path.splitext(basename) if basename in ("bash", "sh"): return "unix" if basename in ("cmd", "powershell"): return "win...
[ "def", "platform", "(", ")", ":", "executable", "=", "parent", "(", ")", "basename", "=", "os", ".", "path", ".", "basename", "(", "executable", ")", "basename", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "basename", ")", "if", "basename...
Return platform for the current shell, e.g. windows or unix
[ "Return", "platform", "for", "the", "current", "shell", "e", ".", "g", ".", "windows", "or", "unix" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L70-L81
mottosso/be
be/lib.py
cmd
def cmd(parent): """Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable """ shell_name = os.path.basename(parent).rsplit(".", 1)[0] dirname = os.path.dirname(__file__) # Support for Bash if shell_name in ("bash", "sh")...
python
def cmd(parent): """Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable """ shell_name = os.path.basename(parent).rsplit(".", 1)[0] dirname = os.path.dirname(__file__) # Support for Bash if shell_name in ("bash", "sh")...
[ "def", "cmd", "(", "parent", ")", ":", "shell_name", "=", "os", ".", "path", ".", "basename", "(", "parent", ")", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "0", "]", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ...
Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable
[ "Determine", "subshell", "command", "for", "subprocess", ".", "call" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L84-L114
mottosso/be
be/lib.py
context
def context(root, project=""): """Produce the be environment The environment is an exact replica of the active environment of the current process, with a few additional variables, all of which are listed below. """ environment = os.environ.copy() environment.update({ "BE_PROJECT":...
python
def context(root, project=""): """Produce the be environment The environment is an exact replica of the active environment of the current process, with a few additional variables, all of which are listed below. """ environment = os.environ.copy() environment.update({ "BE_PROJECT":...
[ "def", "context", "(", "root", ",", "project", "=", "\"\"", ")", ":", "environment", "=", "os", ".", "environ", ".", "copy", "(", ")", "environment", ".", "update", "(", "{", "\"BE_PROJECT\"", ":", "project", ",", "\"BE_PROJECTROOT\"", ":", "(", "os", ...
Produce the be environment The environment is an exact replica of the active environment of the current process, with a few additional variables, all of which are listed below.
[ "Produce", "the", "be", "environment" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L117-L152
mottosso/be
be/lib.py
random_name
def random_name(): """Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus """ adj = _data.adjectives[random.randint(0, len(_data.adjectives) - 1)] noun = _data.nouns[random.randint(0, len(_data.nouns) - 1)] return "%s_%s" ...
python
def random_name(): """Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus """ adj = _data.adjectives[random.randint(0, len(_data.adjectives) - 1)] noun = _data.nouns[random.randint(0, len(_data.nouns) - 1)] return "%s_%s" ...
[ "def", "random_name", "(", ")", ":", "adj", "=", "_data", ".", "adjectives", "[", "random", ".", "randint", "(", "0", ",", "len", "(", "_data", ".", "adjectives", ")", "-", "1", ")", "]", "noun", "=", "_data", ".", "nouns", "[", "random", ".", "r...
Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus
[ "Return", "a", "random", "name" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L155-L168
mottosso/be
be/lib.py
isproject
def isproject(path): """Return whether or not `path` is a project Arguments: path (str): Absolute path """ try: if os.path.basename(path)[0] in (".", "_"): return False if not os.path.isdir(path): return False if not any(fname in os.listdir(path...
python
def isproject(path): """Return whether or not `path` is a project Arguments: path (str): Absolute path """ try: if os.path.basename(path)[0] in (".", "_"): return False if not os.path.isdir(path): return False if not any(fname in os.listdir(path...
[ "def", "isproject", "(", "path", ")", ":", "try", ":", "if", "os", ".", "path", ".", "basename", "(", "path", ")", "[", "0", "]", "in", "(", "\".\"", ",", "\"_\"", ")", ":", "return", "False", "if", "not", "os", ".", "path", ".", "isdir", "(", ...
Return whether or not `path` is a project Arguments: path (str): Absolute path
[ "Return", "whether", "or", "not", "path", "is", "a", "project" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L171-L191
mottosso/be
be/lib.py
echo
def echo(text, silent=False, newline=True): """Print to the console Arguments: text (str): Text to print to the console silen (bool, optional): Whether or not to produce any output newline (bool, optional): Whether or not to append a newline. """ if silent: return ...
python
def echo(text, silent=False, newline=True): """Print to the console Arguments: text (str): Text to print to the console silen (bool, optional): Whether or not to produce any output newline (bool, optional): Whether or not to append a newline. """ if silent: return ...
[ "def", "echo", "(", "text", ",", "silent", "=", "False", ",", "newline", "=", "True", ")", ":", "if", "silent", ":", "return", "print", "(", "text", ")", "if", "newline", "else", "sys", ".", "stdout", ".", "write", "(", "text", ")" ]
Print to the console Arguments: text (str): Text to print to the console silen (bool, optional): Whether or not to produce any output newline (bool, optional): Whether or not to append a newline.
[ "Print", "to", "the", "console" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L194-L206
mottosso/be
be/lib.py
list_projects
def list_projects(root, backend=os.listdir): """List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. """ projects = list() for project in sorted(backend(root)): abspath = os.path.join(root, pro...
python
def list_projects(root, backend=os.listdir): """List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. """ projects = list() for project in sorted(backend(root)): abspath = os.path.join(root, pro...
[ "def", "list_projects", "(", "root", ",", "backend", "=", "os", ".", "listdir", ")", ":", "projects", "=", "list", "(", ")", "for", "project", "in", "sorted", "(", "backend", "(", "root", ")", ")", ":", "abspath", "=", "os", ".", "path", ".", "join...
List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory.
[ "List", "projects", "at", "root" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L209-L223
mottosso/be
be/lib.py
list_inventory
def list_inventory(inventory): """List a projects inventory Given a project, simply list the contents of `inventory.yaml` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. inventory (dict): inventory.yaml """ inv...
python
def list_inventory(inventory): """List a projects inventory Given a project, simply list the contents of `inventory.yaml` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. inventory (dict): inventory.yaml """ inv...
[ "def", "list_inventory", "(", "inventory", ")", ":", "inverted", "=", "invert_inventory", "(", "inventory", ")", "items", "=", "list", "(", ")", "for", "item", "in", "sorted", "(", "inverted", ",", "key", "=", "lambda", "a", ":", "(", "inverted", "[", ...
List a projects inventory Given a project, simply list the contents of `inventory.yaml` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. inventory (dict): inventory.yaml
[ "List", "a", "projects", "inventory" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L226-L242
mottosso/be
be/lib.py
list_template
def list_template(root, topics, templates, inventory, be, absolute=False): """List contents for resolved template Resolve a template as far as possible via the given `topics`. For example, if a template supports 5 arguments, but only 3 are given, resolve the template until its 4th argument and list...
python
def list_template(root, topics, templates, inventory, be, absolute=False): """List contents for resolved template Resolve a template as far as possible via the given `topics`. For example, if a template supports 5 arguments, but only 3 are given, resolve the template until its 4th argument and list...
[ "def", "list_template", "(", "root", ",", "topics", ",", "templates", ",", "inventory", ",", "be", ",", "absolute", "=", "False", ")", ":", "project", "=", "topics", "[", "0", "]", "# Get item", "try", ":", "key", "=", "be", ".", "get", "(", "\"templ...
List contents for resolved template Resolve a template as far as possible via the given `topics`. For example, if a template supports 5 arguments, but only 3 are given, resolve the template until its 4th argument and list the contents thereafter. In some cases, an additional path is present follow...
[ "List", "contents", "for", "resolved", "template" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L245-L324
mottosso/be
be/lib.py
invert_inventory
def invert_inventory(inventory): """Return {item: binding} from {binding: item} Protect against items with additional metadata and items whose type is a number Returns: Dictionary of inverted inventory """ inverted = dict() for binding, items in inventory.iteritems(): for...
python
def invert_inventory(inventory): """Return {item: binding} from {binding: item} Protect against items with additional metadata and items whose type is a number Returns: Dictionary of inverted inventory """ inverted = dict() for binding, items in inventory.iteritems(): for...
[ "def", "invert_inventory", "(", "inventory", ")", ":", "inverted", "=", "dict", "(", ")", "for", "binding", ",", "items", "in", "inventory", ".", "iteritems", "(", ")", ":", "for", "item", "in", "items", ":", "if", "isinstance", "(", "item", ",", "dict...
Return {item: binding} from {binding: item} Protect against items with additional metadata and items whose type is a number Returns: Dictionary of inverted inventory
[ "Return", "{", "item", ":", "binding", "}", "from", "{", "binding", ":", "item", "}" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L327-L351
mottosso/be
be/lib.py
pos_development_directory
def pos_development_directory(templates, inventory, context, topics, user, item): """Return absolute path to development directory Arguments: templates (...
python
def pos_development_directory(templates, inventory, context, topics, user, item): """Return absolute path to development directory Arguments: templates (...
[ "def", "pos_development_directory", "(", "templates", ",", "inventory", ",", "context", ",", "topics", ",", "user", ",", "item", ")", ":", "replacement_fields", "=", "replacement_fields_from_context", "(", "context", ")", "binding", "=", "binding_from_item", "(", ...
Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` user (str): Current `be` user item (str): Item from template-bin...
[ "Return", "absolute", "path", "to", "development", "directory" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L358-L395
mottosso/be
be/lib.py
fixed_development_directory
def fixed_development_directory(templates, inventory, topics, user): """Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` ...
python
def fixed_development_directory(templates, inventory, topics, user): """Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` ...
[ "def", "fixed_development_directory", "(", "templates", ",", "inventory", ",", "topics", ",", "user", ")", ":", "echo", "(", "\"Fixed syntax has been deprecated, see positional syntax\"", ")", "project", ",", "item", ",", "task", "=", "topics", "[", "0", "]", ".",...
Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` user (str): Current `be` user
[ "Return", "absolute", "path", "to", "development", "directory" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L398-L439
mottosso/be
be/lib.py
replacement_fields_from_context
def replacement_fields_from_context(context): """Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context """ return dict((k[3:].lower(), context[k]) for k in context if k.startswith("BE_"))
python
def replacement_fields_from_context(context): """Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context """ return dict((k[3:].lower(), context[k]) for k in context if k.startswith("BE_"))
[ "def", "replacement_fields_from_context", "(", "context", ")", ":", "return", "dict", "(", "(", "k", "[", "3", ":", "]", ".", "lower", "(", ")", ",", "context", "[", "k", "]", ")", "for", "k", "in", "context", "if", "k", ".", "startswith", "(", "\"...
Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context
[ "Convert", "context", "replacement", "fields" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L442-L454
mottosso/be
be/lib.py
item_from_topics
def item_from_topics(key, topics): """Get binding from `topics` via `key` Example: {0} == hello --> be in hello world {1} == world --> be in hello world Returns: Single topic matching the key Raises: IndexError (int): With number of required arguments for t...
python
def item_from_topics(key, topics): """Get binding from `topics` via `key` Example: {0} == hello --> be in hello world {1} == world --> be in hello world Returns: Single topic matching the key Raises: IndexError (int): With number of required arguments for t...
[ "def", "item_from_topics", "(", "key", ",", "topics", ")", ":", "if", "re", ".", "match", "(", "\"{\\d+}\"", ",", "key", ")", ":", "pos", "=", "int", "(", "key", ".", "strip", "(", "\"{}\"", ")", ")", "try", ":", "binding", "=", "topics", "[", "p...
Get binding from `topics` via `key` Example: {0} == hello --> be in hello world {1} == world --> be in hello world Returns: Single topic matching the key Raises: IndexError (int): With number of required arguments for the key
[ "Get", "binding", "from", "topics", "via", "key" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L457-L484
mottosso/be
be/lib.py
pattern_from_template
def pattern_from_template(templates, name): """Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name """ if name not in templates: echo("No template named \"%s\"" % name) sys.exit(1) return templates[name]
python
def pattern_from_template(templates, name): """Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name """ if name not in templates: echo("No template named \"%s\"" % name) sys.exit(1) return templates[name]
[ "def", "pattern_from_template", "(", "templates", ",", "name", ")", ":", "if", "name", "not", "in", "templates", ":", "echo", "(", "\"No template named \\\"%s\\\"\"", "%", "name", ")", "sys", ".", "exit", "(", "1", ")", "return", "templates", "[", "name", ...
Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name
[ "Return", "pattern", "for", "name" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L510-L523
mottosso/be
be/lib.py
binding_from_item
def binding_from_item(inventory, item): """Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item """ if item in self.bindings: return self.bindings[item] bindin...
python
def binding_from_item(inventory, item): """Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item """ if item in self.bindings: return self.bindings[item] bindin...
[ "def", "binding_from_item", "(", "inventory", ",", "item", ")", ":", "if", "item", "in", "self", ".", "bindings", ":", "return", "self", ".", "bindings", "[", "item", "]", "bindings", "=", "invert_inventory", "(", "inventory", ")", "try", ":", "self", "....
Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item
[ "Return", "binding", "for", "item" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L526-L552
mottosso/be
be/lib.py
parse_environment
def parse_environment(fields, context, topics): """Resolve the be.yaml environment key Features: - Lists, e.g. ["/path1", "/path2"] - Environment variable references, via $ - Replacement field references, e.g. {key} - Topic references, e.g. {1} """ def _resolve_environ...
python
def parse_environment(fields, context, topics): """Resolve the be.yaml environment key Features: - Lists, e.g. ["/path1", "/path2"] - Environment variable references, via $ - Replacement field references, e.g. {key} - Topic references, e.g. {1} """ def _resolve_environ...
[ "def", "parse_environment", "(", "fields", ",", "context", ",", "topics", ")", ":", "def", "_resolve_environment_lists", "(", "context", ")", ":", "\"\"\"Concatenate environment lists\"\"\"", "for", "key", ",", "value", "in", "context", ".", "copy", "(", ")", "....
Resolve the be.yaml environment key Features: - Lists, e.g. ["/path1", "/path2"] - Environment variable references, via $ - Replacement field references, e.g. {key} - Topic references, e.g. {1}
[ "Resolve", "the", "be", ".", "yaml", "environment", "key" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L555-L633
mottosso/be
be/lib.py
parse_redirect
def parse_redirect(redirect, topics, context): """Resolve the be.yaml redirect key Arguments: redirect (dict): Source/destination pairs, e.g. {BE_ACTIVE: ACTIVE} topics (tuple): Topics from which to sample, e.g. (project, item, task) context (dict): Context from which to sample """...
python
def parse_redirect(redirect, topics, context): """Resolve the be.yaml redirect key Arguments: redirect (dict): Source/destination pairs, e.g. {BE_ACTIVE: ACTIVE} topics (tuple): Topics from which to sample, e.g. (project, item, task) context (dict): Context from which to sample """...
[ "def", "parse_redirect", "(", "redirect", ",", "topics", ",", "context", ")", ":", "for", "map_source", ",", "map_dest", "in", "redirect", ".", "items", "(", ")", ":", "if", "re", ".", "match", "(", "\"{\\d+}\"", ",", "map_source", ")", ":", "topics_inde...
Resolve the be.yaml redirect key Arguments: redirect (dict): Source/destination pairs, e.g. {BE_ACTIVE: ACTIVE} topics (tuple): Topics from which to sample, e.g. (project, item, task) context (dict): Context from which to sample
[ "Resolve", "the", "be", ".", "yaml", "redirect", "key" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L636-L653
mottosso/be
be/lib.py
slice
def slice(index, template): """Slice a template based on it's positional argument Arguments: index (int): Position at which to slice template (str): Template to slice Example: >>> slice(0, "{cwd}/{0}/assets/{1}/{2}") '{cwd}/{0}' >>> slice(1, "{cwd}/{0}/assets/{1}/{2...
python
def slice(index, template): """Slice a template based on it's positional argument Arguments: index (int): Position at which to slice template (str): Template to slice Example: >>> slice(0, "{cwd}/{0}/assets/{1}/{2}") '{cwd}/{0}' >>> slice(1, "{cwd}/{0}/assets/{1}/{2...
[ "def", "slice", "(", "index", ",", "template", ")", ":", "try", ":", "return", "re", ".", "match", "(", "\"^.*{[%i]}\"", "%", "index", ",", "template", ")", ".", "group", "(", ")", "except", "AttributeError", ":", "raise", "ValueError", "(", "\"Index %i ...
Slice a template based on it's positional argument Arguments: index (int): Position at which to slice template (str): Template to slice Example: >>> slice(0, "{cwd}/{0}/assets/{1}/{2}") '{cwd}/{0}' >>> slice(1, "{cwd}/{0}/assets/{1}/{2}") '{cwd}/{0}/assets/{1}'
[ "Slice", "a", "template", "based", "on", "it", "s", "positional", "argument" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L656-L675
mottosso/be
be/vendor/requests/adapters.py
HTTPAdapter.proxy_manager_for
def proxy_manager_for(self, proxy, **proxy_kwargs): """Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The prox...
python
def proxy_manager_for(self, proxy, **proxy_kwargs): """Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The prox...
[ "def", "proxy_manager_for", "(", "self", ",", "proxy", ",", "*", "*", "proxy_kwargs", ")", ":", "if", "not", "proxy", "in", "self", ".", "proxy_manager", ":", "proxy_headers", "=", "self", ".", "proxy_headers", "(", "proxy", ")", "self", ".", "proxy_manage...
Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The proxy to return a urllib3 ProxyManager for. :param proxy_kw...
[ "Return", "urllib3", "ProxyManager", "for", "the", "given", "proxy", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L136-L157
mottosso/be
be/vendor/requests/adapters.py
HTTPAdapter.cert_verify
def cert_verify(self, conn, url, verify, cert): """Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with...
python
def cert_verify(self, conn, url, verify, cert): """Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with...
[ "def", "cert_verify", "(", "self", ",", "conn", ",", "url", ",", "verify", ",", "cert", ")", ":", "if", "url", ".", "lower", "(", ")", ".", "startswith", "(", "'https'", ")", "and", "verify", ":", "cert_loc", "=", "None", "# Allow self-specified cert loc...
Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with the cert. :param url: The requested URL. :...
[ "Verify", "a", "SSL", "certificate", ".", "This", "method", "should", "not", "be", "called", "from", "user", "code", "and", "is", "only", "exposed", "for", "use", "when", "subclassing", "the", ":", "class", ":", "HTTPAdapter", "<requests", ".", "adapters", ...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L159-L194
mottosso/be
be/vendor/requests/adapters.py
HTTPAdapter.get_connection
def get_connection(self, url, proxies=None): """Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :pa...
python
def get_connection(self, url, proxies=None): """Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :pa...
[ "def", "get_connection", "(", "self", ",", "url", ",", "proxies", "=", "None", ")", ":", "proxies", "=", "proxies", "or", "{", "}", "proxy", "=", "proxies", ".", "get", "(", "urlparse", "(", "url", ".", "lower", "(", ")", ")", ".", "scheme", ")", ...
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :param proxies: (optional) A Requests-style dictionary of p...
[ "Returns", "a", "urllib3", "connection", "for", "the", "given", "URL", ".", "This", "should", "not", "be", "called", "from", "user", "code", "and", "is", "only", "exposed", "for", "use", "when", "subclassing", "the", ":", "class", ":", "HTTPAdapter", "<req...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L232-L253
mottosso/be
be/vendor/requests/adapters.py
HTTPAdapter.request_url
def request_url(self, request, proxies): """Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is o...
python
def request_url(self, request, proxies): """Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is o...
[ "def", "request_url", "(", "self", ",", "request", ",", "proxies", ")", ":", "proxies", "=", "proxies", "or", "{", "}", "scheme", "=", "urlparse", "(", "request", ".", "url", ")", ".", "scheme", "proxy", "=", "proxies", ".", "get", "(", "scheme", ")"...
Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is only exposed for use when subclassing the ...
[ "Obtain", "the", "url", "to", "use", "when", "making", "the", "final", "request", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L263-L285
mottosso/be
be/vendor/requests/adapters.py
HTTPAdapter.proxy_headers
def proxy_headers(self, proxy): """Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be c...
python
def proxy_headers(self, proxy): """Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be c...
[ "def", "proxy_headers", "(", "self", ",", "proxy", ")", ":", "headers", "=", "{", "}", "username", ",", "password", "=", "get_auth_from_url", "(", "proxy", ")", "if", "username", "and", "password", ":", "headers", "[", "'Proxy-Authorization'", "]", "=", "_...
Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be called from user code, and is only exposed f...
[ "Returns", "a", "dictionary", "of", "the", "headers", "to", "add", "to", "any", "request", "sent", "through", "a", "proxy", ".", "This", "works", "with", "urllib3", "magic", "to", "ensure", "that", "they", "are", "correctly", "sent", "to", "the", "proxy", ...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L301-L321
mottosso/be
be/vendor/requests/api.py
request
def request(method, url, **kwargs): """Constructs and sends a :class:`Request <Request>`. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`...
python
def request(method, url, **kwargs): """Constructs and sends a :class:`Request <Request>`. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`...
[ "def", "request", "(", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "session", "=", "sessions", ".", "Session", "(", ")", "response", "=", "session", ".", "request", "(", "method", "=", "method", ",", "url", "=", "url", ",", "*", "*", ...
Constructs and sends a :class:`Request <Request>`. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. :param data: (optional) Dictionary, b...
[ "Constructs", "and", "sends", "a", ":", "class", ":", "Request", "<Request", ">", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/api.py#L17-L55
mottosso/be
be/vendor/requests/packages/urllib3/util/connection.py
is_connection_dropped
def is_connection_dropped(conn): # Platform-specific """ Returns True if the connection is dropped and should be closed. :param conn: :class:`httplib.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycli...
python
def is_connection_dropped(conn): # Platform-specific """ Returns True if the connection is dropped and should be closed. :param conn: :class:`httplib.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycli...
[ "def", "is_connection_dropped", "(", "conn", ")", ":", "# Platform-specific", "sock", "=", "getattr", "(", "conn", ",", "'sock'", ",", "False", ")", "if", "sock", "is", "False", ":", "# Platform-specific: AppEngine", "return", "False", "if", "sock", "is", "Non...
Returns True if the connection is dropped and should be closed. :param conn: :class:`httplib.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycling transparently for us.
[ "Returns", "True", "if", "the", "connection", "is", "dropped", "and", "should", "be", "closed", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/connection.py#L12-L43
mottosso/be
be/vendor/requests/cookies.py
morsel_to_cookie
def morsel_to_cookie(morsel): """Convert a Morsel object into a Cookie containing the one k/v pair.""" expires = None if morsel['max-age']: expires = time.time() + morsel['max-age'] elif morsel['expires']: time_template = '%a, %d-%b-%Y %H:%M:%S GMT' expires = time.mktime( ...
python
def morsel_to_cookie(morsel): """Convert a Morsel object into a Cookie containing the one k/v pair.""" expires = None if morsel['max-age']: expires = time.time() + morsel['max-age'] elif morsel['expires']: time_template = '%a, %d-%b-%Y %H:%M:%S GMT' expires = time.mktime( ...
[ "def", "morsel_to_cookie", "(", "morsel", ")", ":", "expires", "=", "None", "if", "morsel", "[", "'max-age'", "]", ":", "expires", "=", "time", ".", "time", "(", ")", "+", "morsel", "[", "'max-age'", "]", "elif", "morsel", "[", "'expires'", "]", ":", ...
Convert a Morsel object into a Cookie containing the one k/v pair.
[ "Convert", "a", "Morsel", "object", "into", "a", "Cookie", "containing", "the", "one", "k", "/", "v", "pair", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/cookies.py#L397-L421
mottosso/be
be/vendor/requests/cookies.py
RequestsCookieJar.get_dict
def get_dict(self, domain=None, path=None): """Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements.""" dictionary = {} for cookie in iter(self): if (domain is None or cookie.dom...
python
def get_dict(self, domain=None, path=None): """Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements.""" dictionary = {} for cookie in iter(self): if (domain is None or cookie.dom...
[ "def", "get_dict", "(", "self", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "dictionary", "=", "{", "}", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "(", "domain", "is", "None", "or", "cookie", ".", "domain", "...
Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements.
[ "Takes", "as", "an", "argument", "an", "optional", "domain", "and", "path", "and", "returns", "a", "plain", "old", "Python", "dict", "of", "name", "-", "value", "pairs", "of", "cookies", "that", "meet", "the", "requirements", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/cookies.py#L264-L273
mottosso/be
be/vendor/requests/packages/chardet/chardistribution.py
CharDistributionAnalysis.feed
def feed(self, aBuf, aCharLen): """feed a character with known length""" if aCharLen == 2: # we only care about 2-bytes character in our distribution analysis order = self.get_order(aBuf) else: order = -1 if order >= 0: self._mTotalChars +=...
python
def feed(self, aBuf, aCharLen): """feed a character with known length""" if aCharLen == 2: # we only care about 2-bytes character in our distribution analysis order = self.get_order(aBuf) else: order = -1 if order >= 0: self._mTotalChars +=...
[ "def", "feed", "(", "self", ",", "aBuf", ",", "aCharLen", ")", ":", "if", "aCharLen", "==", "2", ":", "# we only care about 2-bytes character in our distribution analysis", "order", "=", "self", ".", "get_order", "(", "aBuf", ")", "else", ":", "order", "=", "-...
feed a character with known length
[ "feed", "a", "character", "with", "known", "length" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardistribution.py#L68-L80
mottosso/be
be/vendor/requests/packages/chardet/chardistribution.py
CharDistributionAnalysis.get_confidence
def get_confidence(self): """return confidence based on existing data""" # if we didn't receive any character in our consideration range, # return negative answer if self._mTotalChars <= 0 or self._mFreqChars <= MINIMUM_DATA_THRESHOLD: return SURE_NO if self._mTotalC...
python
def get_confidence(self): """return confidence based on existing data""" # if we didn't receive any character in our consideration range, # return negative answer if self._mTotalChars <= 0 or self._mFreqChars <= MINIMUM_DATA_THRESHOLD: return SURE_NO if self._mTotalC...
[ "def", "get_confidence", "(", "self", ")", ":", "# if we didn't receive any character in our consideration range,", "# return negative answer", "if", "self", ".", "_mTotalChars", "<=", "0", "or", "self", ".", "_mFreqChars", "<=", "MINIMUM_DATA_THRESHOLD", ":", "return", "...
return confidence based on existing data
[ "return", "confidence", "based", "on", "existing", "data" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardistribution.py#L82-L96
mottosso/be
be/vendor/requests/packages/urllib3/__init__.py
add_stderr_logger
def add_stderr_logger(level=logging.DEBUG): """ Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it. """ # This method needs to be in this __init__.py to get the __name__ correct # even if urllib3 is vendored within another pack...
python
def add_stderr_logger(level=logging.DEBUG): """ Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it. """ # This method needs to be in this __init__.py to get the __name__ correct # even if urllib3 is vendored within another pack...
[ "def", "add_stderr_logger", "(", "level", "=", "logging", ".", "DEBUG", ")", ":", "# This method needs to be in this __init__.py to get the __name__ correct", "# even if urllib3 is vendored within another package.", "logger", "=", "logging", ".", "getLogger", "(", "__name__", "...
Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it.
[ "Helper", "for", "quickly", "adding", "a", "StreamHandler", "to", "the", "logger", ".", "Useful", "for", "debugging", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/__init__.py#L37-L52
mottosso/be
be/vendor/requests/packages/urllib3/util/ssl_.py
assert_fingerprint
def assert_fingerprint(cert, fingerprint): """ Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. """ # Maps the length of a digest to a p...
python
def assert_fingerprint(cert, fingerprint): """ Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. """ # Maps the length of a digest to a p...
[ "def", "assert_fingerprint", "(", "cert", ",", "fingerprint", ")", ":", "# Maps the length of a digest to a possible hash function producing", "# this digest.", "hashfunc_map", "=", "{", "16", ":", "md5", ",", "20", ":", "sha1", ",", "32", ":", "sha256", ",", "}", ...
Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons.
[ "Checks", "if", "given", "fingerprint", "matches", "the", "supplied", "certificate", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/ssl_.py#L94-L128
mottosso/be
be/vendor/requests/packages/urllib3/util/ssl_.py
create_urllib3_context
def create_urllib3_context(ssl_version=None, cert_reqs=ssl.CERT_REQUIRED, options=None, ciphers=None): """All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It:...
python
def create_urllib3_context(ssl_version=None, cert_reqs=ssl.CERT_REQUIRED, options=None, ciphers=None): """All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It:...
[ "def", "create_urllib3_context", "(", "ssl_version", "=", "None", ",", "cert_reqs", "=", "ssl", ".", "CERT_REQUIRED", ",", "options", "=", "None", ",", "ciphers", "=", "None", ")", ":", "context", "=", "SSLContext", "(", "ssl_version", "or", "ssl", ".", "P...
All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It: - Disables SSLv2, SSLv3, and compression - Sets a restricted set of server ciphers If you wish to enable SSLv3, you can do...
[ "All", "arguments", "have", "the", "same", "meaning", "as", "ssl_wrap_socket", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/ssl_.py#L170-L227
mottosso/be
be/vendor/requests/packages/urllib3/util/ssl_.py
ssl_wrap_socket
def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None): """ All arguments except for server_hostname and ssl_context have the same meaning as they do when using :fun...
python
def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None): """ All arguments except for server_hostname and ssl_context have the same meaning as they do when using :fun...
[ "def", "ssl_wrap_socket", "(", "sock", ",", "keyfile", "=", "None", ",", "certfile", "=", "None", ",", "cert_reqs", "=", "None", ",", "ca_certs", "=", "None", ",", "server_hostname", "=", "None", ",", "ssl_version", "=", "None", ",", "ciphers", "=", "Non...
All arguments except for server_hostname and ssl_context have the same meaning as they do when using :func:`ssl.wrap_socket`. :param server_hostname: When SNI is supported, the expected hostname of the certificate :param ssl_context: A pre-made :class:`SSLContext` object. If none is provide...
[ "All", "arguments", "except", "for", "server_hostname", "and", "ssl_context", "have", "the", "same", "meaning", "as", "they", "do", "when", "using", ":", "func", ":", "ssl", ".", "wrap_socket", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/ssl_.py#L230-L266
mottosso/be
be/vendor/requests/packages/urllib3/connectionpool.py
connection_from_url
def connection_from_url(url, **kw): """ Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must...
python
def connection_from_url(url, **kw): """ Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must...
[ "def", "connection_from_url", "(", "url", ",", "*", "*", "kw", ")", ":", "scheme", ",", "host", ",", "port", "=", "get_host", "(", "url", ")", "if", "scheme", "==", "'https'", ":", "return", "HTTPSConnectionPool", "(", "host", ",", "port", "=", "port",...
Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must include the scheme. Port is optional. :par...
[ "Given", "a", "url", "return", "an", ":", "class", ":", ".", "ConnectionPool", "instance", "of", "its", "host", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L772-L796
mottosso/be
be/vendor/requests/packages/urllib3/connectionpool.py
HTTPConnectionPool._put_conn
def _put_conn(self, conn): """ Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded ...
python
def _put_conn(self, conn): """ Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded ...
[ "def", "_put_conn", "(", "self", ",", "conn", ")", ":", "try", ":", "self", ".", "pool", ".", "put", "(", "conn", ",", "block", "=", "False", ")", "return", "# Everything is dandy, done.", "except", "AttributeError", ":", "# self.pool is None.", "pass", "exc...
Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded because we exceeded maxsize. If connections are...
[ "Put", "a", "connection", "back", "into", "the", "pool", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L248-L276
mottosso/be
be/vendor/requests/packages/urllib3/connectionpool.py
HTTPConnectionPool._make_request
def _make_request(self, conn, method, url, timeout=_Default, **httplib_request_kw): """ Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: ...
python
def _make_request(self, conn, method, url, timeout=_Default, **httplib_request_kw): """ Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: ...
[ "def", "_make_request", "(", "self", ",", "conn", ",", "method", ",", "url", ",", "timeout", "=", "_Default", ",", "*", "*", "httplib_request_kw", ")", ":", "self", ".", "num_requests", "+=", "1", "timeout_obj", "=", "self", ".", "_get_timeout", "(", "ti...
Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: Socket timeout in seconds for the request. This can be a float or integer, which will set the same timeout v...
[ "Perform", "a", "request", "on", "a", "given", "urllib", "connection", "object", "taken", "from", "our", "pool", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L317-L384
mottosso/be
be/vendor/requests/packages/urllib3/connectionpool.py
HTTPConnectionPool.urlopen
def urlopen(self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, **response_kw): """ Get a connection from the pool and perform an HTTP request. This is the lowest l...
python
def urlopen(self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, **response_kw): """ Get a connection from the pool and perform an HTTP request. This is the lowest l...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "retries", "=", "None", ",", "redirect", "=", "True", ",", "assert_same_host", "=", "True", ",", "timeout", "=", "_Default", ",", "p...
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details. .. note:: More commonly, it's appropriate to use a convenience method provided by :class:`.RequestMethods`, such ...
[ "Get", "a", "connection", "from", "the", "pool", "and", "perform", "an", "HTTP", "request", ".", "This", "is", "the", "lowest", "level", "call", "for", "making", "a", "request", "so", "you", "ll", "need", "to", "specify", "all", "the", "raw", "details", ...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L421-L650
mottosso/be
be/vendor/requests/packages/urllib3/connectionpool.py
HTTPSConnectionPool._new_conn
def _new_conn(self): """ Return a fresh :class:`httplib.HTTPSConnection`. """ self.num_connections += 1 log.info("Starting new HTTPS connection (%d): %s" % (self.num_connections, self.host)) if not self.ConnectionCls or self.ConnectionCls is DummyConnect...
python
def _new_conn(self): """ Return a fresh :class:`httplib.HTTPSConnection`. """ self.num_connections += 1 log.info("Starting new HTTPS connection (%d): %s" % (self.num_connections, self.host)) if not self.ConnectionCls or self.ConnectionCls is DummyConnect...
[ "def", "_new_conn", "(", "self", ")", ":", "self", ".", "num_connections", "+=", "1", "log", ".", "info", "(", "\"Starting new HTTPS connection (%d): %s\"", "%", "(", "self", ".", "num_connections", ",", "self", ".", "host", ")", ")", "if", "not", "self", ...
Return a fresh :class:`httplib.HTTPSConnection`.
[ "Return", "a", "fresh", ":", "class", ":", "httplib", ".", "HTTPSConnection", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L729-L752
mottosso/be
be/vendor/requests/packages/urllib3/connectionpool.py
HTTPSConnectionPool._validate_conn
def _validate_conn(self, conn): """ Called right before a request is made, after the socket is created. """ super(HTTPSConnectionPool, self)._validate_conn(conn) # Force connect early to allow us to validate the connection. if not getattr(conn, 'sock', None): # AppEngin...
python
def _validate_conn(self, conn): """ Called right before a request is made, after the socket is created. """ super(HTTPSConnectionPool, self)._validate_conn(conn) # Force connect early to allow us to validate the connection. if not getattr(conn, 'sock', None): # AppEngin...
[ "def", "_validate_conn", "(", "self", ",", "conn", ")", ":", "super", "(", "HTTPSConnectionPool", ",", "self", ")", ".", "_validate_conn", "(", "conn", ")", "# Force connect early to allow us to validate the connection.", "if", "not", "getattr", "(", "conn", ",", ...
Called right before a request is made, after the socket is created.
[ "Called", "right", "before", "a", "request", "is", "made", "after", "the", "socket", "is", "created", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L754-L769
mottosso/be
be/vendor/requests/packages/chardet/chardetect.py
description_of
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...
python
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", ":", "u", ".", "feed", "(", "line", ")", "u", ".", "close", "(", ")", "result", "=", "u", ".", "r...
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", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardetect.py#L26-L45
mottosso/be
be/vendor/requests/packages/chardet/chardetect.py
main
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...
python
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\"", ",", "formatter_class"...
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", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardetect.py#L48-L76
mottosso/be
be/vendor/click/termui.py
get_terminal_size
def get_terminal_size(): """Returns the current size of the terminal as tuple in the form ``(width, height)`` in columns and rows. """ # If shutil has get_terminal_size() (Python 3.3 and later) use that if sys.version_info >= (3, 3): import shutil shutil_get_terminal_size = getattr(s...
python
def get_terminal_size(): """Returns the current size of the terminal as tuple in the form ``(width, height)`` in columns and rows. """ # If shutil has get_terminal_size() (Python 3.3 and later) use that if sys.version_info >= (3, 3): import shutil shutil_get_terminal_size = getattr(s...
[ "def", "get_terminal_size", "(", ")", ":", "# If shutil has get_terminal_size() (Python 3.3 and later) use that", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "3", ")", ":", "import", "shutil", "shutil_get_terminal_size", "=", "getattr", "(", "shutil", ",", ...
Returns the current size of the terminal as tuple in the form ``(width, height)`` in columns and rows.
[ "Returns", "the", "current", "size", "of", "the", "terminal", "as", "tuple", "in", "the", "form", "(", "width", "height", ")", "in", "columns", "and", "rows", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/termui.py#L148-L186
mottosso/be
be/vendor/click/termui.py
style
def style(text, fg=None, bg=None, bold=None, dim=None, underline=None, blink=None, reverse=None, reset=True): """Styles a text with ANSI styles and returns the new string. By default the styling is self contained which means that at the end of the string a reset code is issued. This can be preve...
python
def style(text, fg=None, bg=None, bold=None, dim=None, underline=None, blink=None, reverse=None, reset=True): """Styles a text with ANSI styles and returns the new string. By default the styling is self contained which means that at the end of the string a reset code is issued. This can be preve...
[ "def", "style", "(", "text", ",", "fg", "=", "None", ",", "bg", "=", "None", ",", "bold", "=", "None", ",", "dim", "=", "None", ",", "underline", "=", "None", ",", "blink", "=", "None", ",", "reverse", "=", "None", ",", "reset", "=", "True", ")...
Styles a text with ANSI styles and returns the new string. By default the styling is self contained which means that at the end of the string a reset code is issued. This can be prevented by passing ``reset=False``. Examples:: click.echo(click.style('Hello World!', fg='green')) click...
[ "Styles", "a", "text", "with", "ANSI", "styles", "and", "returns", "the", "new", "string", ".", "By", "default", "the", "styling", "is", "self", "contained", "which", "means", "that", "at", "the", "end", "of", "the", "string", "a", "reset", "code", "is",...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/termui.py#L316-L382
mottosso/be
be/vendor/click/termui.py
secho
def secho(text, file=None, nl=True, err=False, color=None, **styles): """This function combines :func:`echo` and :func:`style` into one call. As such the following two calls are the same:: click.secho('Hello World!', fg='green') click.echo(click.style('Hello World!', fg='green')) All keyw...
python
def secho(text, file=None, nl=True, err=False, color=None, **styles): """This function combines :func:`echo` and :func:`style` into one call. As such the following two calls are the same:: click.secho('Hello World!', fg='green') click.echo(click.style('Hello World!', fg='green')) All keyw...
[ "def", "secho", "(", "text", ",", "file", "=", "None", ",", "nl", "=", "True", ",", "err", "=", "False", ",", "color", "=", "None", ",", "*", "*", "styles", ")", ":", "return", "echo", "(", "style", "(", "text", ",", "*", "*", "styles", ")", ...
This function combines :func:`echo` and :func:`style` into one call. As such the following two calls are the same:: click.secho('Hello World!', fg='green') click.echo(click.style('Hello World!', fg='green')) All keyword arguments are forwarded to the underlying functions depending on whic...
[ "This", "function", "combines", ":", "func", ":", "echo", "and", ":", "func", ":", "style", "into", "one", "call", ".", "As", "such", "the", "following", "two", "calls", "are", "the", "same", "::" ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/termui.py#L397-L409
mottosso/be
be/vendor/requests/sessions.py
merge_setting
def merge_setting(request_setting, session_setting, dict_class=OrderedDict): """ Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` ...
python
def merge_setting(request_setting, session_setting, dict_class=OrderedDict): """ Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` ...
[ "def", "merge_setting", "(", "request_setting", ",", "session_setting", ",", "dict_class", "=", "OrderedDict", ")", ":", "if", "session_setting", "is", "None", ":", "return", "request_setting", "if", "request_setting", "is", "None", ":", "return", "session_setting",...
Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class`
[ "Determines", "appropriate", "setting", "for", "a", "given", "request", "taking", "into", "account", "the", "explicit", "setting", "on", "that", "request", "and", "the", "setting", "in", "the", "session", ".", "If", "a", "setting", "is", "a", "dictionary", "...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/sessions.py#L42-L72
mottosso/be
be/vendor/requests/sessions.py
SessionRedirectMixin.resolve_redirects
def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Receives a Response. Returns a generator of Responses.""" i = 0 hist = [] # keep track of history while resp.is_redirect: prepared_request ...
python
def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Receives a Response. Returns a generator of Responses.""" i = 0 hist = [] # keep track of history while resp.is_redirect: prepared_request ...
[ "def", "resolve_redirects", "(", "self", ",", "resp", ",", "req", ",", "stream", "=", "False", ",", "timeout", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ",", "proxies", "=", "None", ")", ":", "i", "=", "0", "hist", "=", "...
Receives a Response. Returns a generator of Responses.
[ "Receives", "a", "Response", ".", "Returns", "a", "generator", "of", "Responses", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/sessions.py#L92-L201
mottosso/be
be/vendor/requests/sessions.py
Session.send
def send(self, request, **kwargs): """Send a given PreparedRequest.""" # Set defaults that the hooks can utilize to ensure they always have # the correct parameters to reproduce the previous request. kwargs.setdefault('stream', self.stream) kwargs.setdefault('verify', self.verify...
python
def send(self, request, **kwargs): """Send a given PreparedRequest.""" # Set defaults that the hooks can utilize to ensure they always have # the correct parameters to reproduce the previous request. kwargs.setdefault('stream', self.stream) kwargs.setdefault('verify', self.verify...
[ "def", "send", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# Set defaults that the hooks can utilize to ensure they always have", "# the correct parameters to reproduce the previous request.", "kwargs", ".", "setdefault", "(", "'stream'", ",", "self", "...
Send a given PreparedRequest.
[ "Send", "a", "given", "PreparedRequest", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/sessions.py#L538-L615
mottosso/be
be/vendor/requests/packages/urllib3/response.py
HTTPResponse.stream
def stream(self, amt=2**16, decode_content=None): """ A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator wil...
python
def stream(self, amt=2**16, decode_content=None): """ A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator wil...
[ "def", "stream", "(", "self", ",", "amt", "=", "2", "**", "16", ",", "decode_content", "=", "None", ")", ":", "while", "not", "is_fp_closed", "(", "self", ".", "_fp", ")", ":", "data", "=", "self", ".", "read", "(", "amt", "=", "amt", ",", "decod...
A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator will return up to much data per iteration, but may return les...
[ "A", "generator", "wrapper", "for", "the", "read", "()", "method", ".", "A", "call", "will", "block", "until", "amt", "bytes", "have", "been", "read", "from", "the", "connection", "or", "until", "the", "connection", "is", "closed", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/response.py#L256-L276
mottosso/be
be/vendor/requests/models.py
PreparedRequest.prepare_method
def prepare_method(self, method): """Prepares the given HTTP method.""" self.method = method if self.method is not None: self.method = self.method.upper()
python
def prepare_method(self, method): """Prepares the given HTTP method.""" self.method = method if self.method is not None: self.method = self.method.upper()
[ "def", "prepare_method", "(", "self", ",", "method", ")", ":", "self", ".", "method", "=", "method", "if", "self", ".", "method", "is", "not", "None", ":", "self", ".", "method", "=", "self", ".", "method", ".", "upper", "(", ")" ]
Prepares the given HTTP method.
[ "Prepares", "the", "given", "HTTP", "method", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/models.py#L328-L332
mottosso/be
be/vendor/requests/models.py
PreparedRequest.prepare_headers
def prepare_headers(self, headers): """Prepares the given HTTP headers.""" if headers: self.headers = CaseInsensitiveDict((to_native_string(name), value) for name, value in headers.items()) else: self.headers = CaseInsensitiveDict()
python
def prepare_headers(self, headers): """Prepares the given HTTP headers.""" if headers: self.headers = CaseInsensitiveDict((to_native_string(name), value) for name, value in headers.items()) else: self.headers = CaseInsensitiveDict()
[ "def", "prepare_headers", "(", "self", ",", "headers", ")", ":", "if", "headers", ":", "self", ".", "headers", "=", "CaseInsensitiveDict", "(", "(", "to_native_string", "(", "name", ")", ",", "value", ")", "for", "name", ",", "value", "in", "headers", "....
Prepares the given HTTP headers.
[ "Prepares", "the", "given", "HTTP", "headers", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/models.py#L406-L412
mottosso/be
be/vendor/requests/models.py
Response.iter_content
def iter_content(self, chunk_size=1, decode_unicode=False): """Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is no...
python
def iter_content(self, chunk_size=1, decode_unicode=False): """Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is no...
[ "def", "iter_content", "(", "self", ",", "chunk_size", "=", "1", ",", "decode_unicode", "=", "False", ")", ":", "def", "generate", "(", ")", ":", "try", ":", "# Special case for urllib3.", "try", ":", "for", "chunk", "in", "self", ".", "raw", ".", "strea...
Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can ...
[ "Iterates", "over", "the", "response", "data", ".", "When", "stream", "=", "True", "is", "set", "on", "the", "request", "this", "avoids", "reading", "the", "content", "at", "once", "into", "memory", "for", "large", "responses", ".", "The", "chunk", "size",...
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/models.py#L642-L686
mottosso/be
be/vendor/requests/models.py
Response.json
def json(self, **kwargs): """Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. """ if not self.encoding and len(self.content) > 3: # No encoding set. JSON RFC 4627 section 3 states we should expect ...
python
def json(self, **kwargs): """Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. """ if not self.encoding and len(self.content) > 3: # No encoding set. JSON RFC 4627 section 3 states we should expect ...
[ "def", "json", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "encoding", "and", "len", "(", "self", ".", "content", ")", ">", "3", ":", "# No encoding set. JSON RFC 4627 section 3 states we should expect", "# UTF-8, -16 or -32. Detect w...
Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes.
[ "Returns", "the", "json", "-", "encoded", "content", "of", "a", "response", "if", "any", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/models.py#L781-L802
mottosso/be
be/vendor/requests/models.py
Response.raise_for_status
def raise_for_status(self): """Raises stored :class:`HTTPError`, if one occurred.""" http_error_msg = '' if 400 <= self.status_code < 500: http_error_msg = '%s Client Error: %s' % (self.status_code, self.reason) elif 500 <= self.status_code < 600: http_error_ms...
python
def raise_for_status(self): """Raises stored :class:`HTTPError`, if one occurred.""" http_error_msg = '' if 400 <= self.status_code < 500: http_error_msg = '%s Client Error: %s' % (self.status_code, self.reason) elif 500 <= self.status_code < 600: http_error_ms...
[ "def", "raise_for_status", "(", "self", ")", ":", "http_error_msg", "=", "''", "if", "400", "<=", "self", ".", "status_code", "<", "500", ":", "http_error_msg", "=", "'%s Client Error: %s'", "%", "(", "self", ".", "status_code", ",", "self", ".", "reason", ...
Raises stored :class:`HTTPError`, if one occurred.
[ "Raises", "stored", ":", "class", ":", "HTTPError", "if", "one", "occurred", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/models.py#L822-L834
mottosso/be
be/vendor/requests/packages/urllib3/poolmanager.py
PoolManager._new_pool
def _new_pool(self, scheme, host, port): """ Create a new :class:`ConnectionPool` based on host, port and scheme. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for cust...
python
def _new_pool(self, scheme, host, port): """ Create a new :class:`ConnectionPool` based on host, port and scheme. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for cust...
[ "def", "_new_pool", "(", "self", ",", "scheme", ",", "host", ",", "port", ")", ":", "pool_cls", "=", "pool_classes_by_scheme", "[", "scheme", "]", "kwargs", "=", "self", ".", "connection_pool_kw", "if", "scheme", "==", "'http'", ":", "kwargs", "=", "self",...
Create a new :class:`ConnectionPool` based on host, port and scheme. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for customization.
[ "Create", "a", "new", ":", "class", ":", "ConnectionPool", "based", "on", "host", "port", "and", "scheme", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/poolmanager.py#L75-L90
mottosso/be
be/vendor/requests/packages/urllib3/poolmanager.py
PoolManager.connection_from_host
def connection_from_host(self, host, port=None, scheme='http'): """ Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. """ if not host: ...
python
def connection_from_host(self, host, port=None, scheme='http'): """ Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. """ if not host: ...
[ "def", "connection_from_host", "(", "self", ",", "host", ",", "port", "=", "None", ",", "scheme", "=", "'http'", ")", ":", "if", "not", "host", ":", "raise", "LocationValueError", "(", "\"No host specified.\"", ")", "scheme", "=", "scheme", "or", "'http'", ...
Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``.
[ "Get", "a", ":", "class", ":", "ConnectionPool", "based", "on", "the", "host", "port", "and", "scheme", "." ]
train
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/poolmanager.py#L101-L127
box/genty
genty/genty_repeat.py
genty_repeat
def genty_repeat(count): """ To use in conjunction with a TestClass wrapped with @genty. Runs the wrapped test 'count' times: @genty_repeat(count) def test_some_function(self) ... Can also wrap a test already decorated with @genty_dataset @genty_repeat(3) @g...
python
def genty_repeat(count): """ To use in conjunction with a TestClass wrapped with @genty. Runs the wrapped test 'count' times: @genty_repeat(count) def test_some_function(self) ... Can also wrap a test already decorated with @genty_dataset @genty_repeat(3) @g...
[ "def", "genty_repeat", "(", "count", ")", ":", "if", "count", "<", "0", ":", "raise", "ValueError", "(", "\"Really? Can't have {0} iterations. Please pick a value >= 0.\"", ".", "format", "(", "count", ")", ")", "def", "wrap", "(", "test_method", ")", ":", "test...
To use in conjunction with a TestClass wrapped with @genty. Runs the wrapped test 'count' times: @genty_repeat(count) def test_some_function(self) ... Can also wrap a test already decorated with @genty_dataset @genty_repeat(3) @genty_dataset(True, False) def...
[ "To", "use", "in", "conjunction", "with", "a", "TestClass", "wrapped", "with", "@genty", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty_repeat.py#L6-L36
abingham/docopt-subcommands
docopt_subcommands/__init__.py
command
def command(name=None): """A decorator to register a subcommand with the global `Subcommands` instance. """ def decorator(f): _commands.append((name, f)) return f return decorator
python
def command(name=None): """A decorator to register a subcommand with the global `Subcommands` instance. """ def decorator(f): _commands.append((name, f)) return f return decorator
[ "def", "command", "(", "name", "=", "None", ")", ":", "def", "decorator", "(", "f", ")", ":", "_commands", ".", "append", "(", "(", "name", ",", "f", ")", ")", "return", "f", "return", "decorator" ]
A decorator to register a subcommand with the global `Subcommands` instance.
[ "A", "decorator", "to", "register", "a", "subcommand", "with", "the", "global", "Subcommands", "instance", "." ]
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/__init__.py#L8-L14
abingham/docopt-subcommands
docopt_subcommands/__init__.py
main
def main(program=None, version=None, doc_template=None, commands=None, argv=None, exit_at_end=True): """Top-level driver for creating subcommand-based programs. Args: program: The name of your program. version: The version string for your program. ...
python
def main(program=None, version=None, doc_template=None, commands=None, argv=None, exit_at_end=True): """Top-level driver for creating subcommand-based programs. Args: program: The name of your program. version: The version string for your program. ...
[ "def", "main", "(", "program", "=", "None", ",", "version", "=", "None", ",", "doc_template", "=", "None", ",", "commands", "=", "None", ",", "argv", "=", "None", ",", "exit_at_end", "=", "True", ")", ":", "if", "commands", "is", "None", ":", "if", ...
Top-level driver for creating subcommand-based programs. Args: program: The name of your program. version: The version string for your program. doc_template: The top-level docstring template for your program. If `None`, a standard default version is applied. commands: A ...
[ "Top", "-", "level", "driver", "for", "creating", "subcommand", "-", "based", "programs", "." ]
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/__init__.py#L17-L69
alecxe/scrapy-beautifulsoup
scrapy_beautifulsoup/middleware.py
BeautifulSoupMiddleware.process_response
def process_response(self, request, response, spider): """Overridden process_response would "pipe" response.body through BeautifulSoup.""" return response.replace(body=str(BeautifulSoup(response.body, self.parser)))
python
def process_response(self, request, response, spider): """Overridden process_response would "pipe" response.body through BeautifulSoup.""" return response.replace(body=str(BeautifulSoup(response.body, self.parser)))
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ",", "spider", ")", ":", "return", "response", ".", "replace", "(", "body", "=", "str", "(", "BeautifulSoup", "(", "response", ".", "body", ",", "self", ".", "parser", ")", ")", "...
Overridden process_response would "pipe" response.body through BeautifulSoup.
[ "Overridden", "process_response", "would", "pipe", "response", ".", "body", "through", "BeautifulSoup", "." ]
train
https://github.com/alecxe/scrapy-beautifulsoup/blob/733f50e83a5b60edc9325e4f14cd4ab2b3914555/scrapy_beautifulsoup/middleware.py#L14-L16
box/genty
genty/genty.py
genty
def genty(target_cls): """ This decorator takes the information provided by @genty_dataset, @genty_dataprovider, and @genty_repeat and generates the corresponding test methods. :param target_cls: Test class whose test methods have been decorated. :type target_cls: `class` ""...
python
def genty(target_cls): """ This decorator takes the information provided by @genty_dataset, @genty_dataprovider, and @genty_repeat and generates the corresponding test methods. :param target_cls: Test class whose test methods have been decorated. :type target_cls: `class` ""...
[ "def", "genty", "(", "target_cls", ")", ":", "tests", "=", "_expand_tests", "(", "target_cls", ")", "tests_with_datasets", "=", "_expand_datasets", "(", "tests", ")", "tests_with_datasets_and_repeats", "=", "_expand_repeats", "(", "tests_with_datasets", ")", "_add_new...
This decorator takes the information provided by @genty_dataset, @genty_dataprovider, and @genty_repeat and generates the corresponding test methods. :param target_cls: Test class whose test methods have been decorated. :type target_cls: `class`
[ "This", "decorator", "takes", "the", "information", "provided", "by", "@genty_dataset", "@genty_dataprovider", "and", "@genty_repeat", "and", "generates", "the", "corresponding", "test", "methods", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L21-L38
box/genty
genty/genty.py
_expand_datasets
def _expand_datasets(test_functions): """ Generator producing test_methods, with an optional dataset. :param test_functions: Iterator over tuples of test name and test unbound function. :type test_functions: `iterator` of `tuple` of (`unicode`, `function`) :return: Generator...
python
def _expand_datasets(test_functions): """ Generator producing test_methods, with an optional dataset. :param test_functions: Iterator over tuples of test name and test unbound function. :type test_functions: `iterator` of `tuple` of (`unicode`, `function`) :return: Generator...
[ "def", "_expand_datasets", "(", "test_functions", ")", ":", "for", "name", ",", "func", "in", "test_functions", ":", "dataset_tuples", "=", "chain", "(", "[", "(", "None", ",", "getattr", "(", "func", ",", "'genty_datasets'", ",", "{", "}", ")", ")", "]"...
Generator producing test_methods, with an optional dataset. :param test_functions: Iterator over tuples of test name and test unbound function. :type test_functions: `iterator` of `tuple` of (`unicode`, `function`) :return: Generator yielding a tuple of - method_name : ...
[ "Generator", "producing", "test_methods", "with", "an", "optional", "dataset", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L62-L101
box/genty
genty/genty.py
_expand_repeats
def _expand_repeats(test_functions): """ Generator producing test_methods, with any repeat count unrolled. :param test_functions: Sequence of tuples of - method_name : Name of the test method - unbound function : Unbound function that will be the test method. - dataset ...
python
def _expand_repeats(test_functions): """ Generator producing test_methods, with any repeat count unrolled. :param test_functions: Sequence of tuples of - method_name : Name of the test method - unbound function : Unbound function that will be the test method. - dataset ...
[ "def", "_expand_repeats", "(", "test_functions", ")", ":", "for", "name", ",", "func", ",", "dataset_name", ",", "dataset", ",", "dataprovider", "in", "test_functions", ":", "repeat_count", "=", "getattr", "(", "func", ",", "'genty_repeat_count'", ",", "0", ")...
Generator producing test_methods, with any repeat count unrolled. :param test_functions: Sequence of tuples of - method_name : Name of the test method - unbound function : Unbound function that will be the test method. - dataset name : String representation of the given dat...
[ "Generator", "producing", "test_methods", "with", "any", "repeat", "count", "unrolled", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L104-L139
box/genty
genty/genty.py
_is_referenced_in_argv
def _is_referenced_in_argv(method_name): """ Various test runners allow one to run a specific test like so: python -m unittest -v <test_module>.<test_name> Return True is the given method name is so referenced. :param method_name: Base name of the method to add. :type method_name: ...
python
def _is_referenced_in_argv(method_name): """ Various test runners allow one to run a specific test like so: python -m unittest -v <test_module>.<test_name> Return True is the given method name is so referenced. :param method_name: Base name of the method to add. :type method_name: ...
[ "def", "_is_referenced_in_argv", "(", "method_name", ")", ":", "expr", "=", "'.*[:.]{0}$'", ".", "format", "(", "method_name", ")", "regex", "=", "re", ".", "compile", "(", "expr", ")", "return", "any", "(", "regex", ".", "match", "(", "arg", ")", "for",...
Various test runners allow one to run a specific test like so: python -m unittest -v <test_module>.<test_name> Return True is the given method name is so referenced. :param method_name: Base name of the method to add. :type method_name: `unicode` :return: Is the given m...
[ "Various", "test", "runners", "allow", "one", "to", "run", "a", "specific", "test", "like", "so", ":", "python", "-", "m", "unittest", "-", "v", "<test_module", ">", ".", "<test_name", ">" ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L193-L211
box/genty
genty/genty.py
_build_repeat_suffix
def _build_repeat_suffix(iteration, count): """ Return the suffix string to identify iteration X out of Y. For example, with a count of 100, this will build strings like "iteration_053" or "iteration_008". :param iteration: Current iteration. :type iteration: `int` :param c...
python
def _build_repeat_suffix(iteration, count): """ Return the suffix string to identify iteration X out of Y. For example, with a count of 100, this will build strings like "iteration_053" or "iteration_008". :param iteration: Current iteration. :type iteration: `int` :param c...
[ "def", "_build_repeat_suffix", "(", "iteration", ",", "count", ")", ":", "format_width", "=", "int", "(", "math", ".", "ceil", "(", "math", ".", "log", "(", "count", "+", "1", ",", "10", ")", ")", ")", "new_suffix", "=", "'iteration_{0:0{width}d}'", ".",...
Return the suffix string to identify iteration X out of Y. For example, with a count of 100, this will build strings like "iteration_053" or "iteration_008". :param iteration: Current iteration. :type iteration: `int` :param count: Total number of iterations. :type coun...
[ "Return", "the", "suffix", "string", "to", "identify", "iteration", "X", "out", "of", "Y", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L214-L239
box/genty
genty/genty.py
_build_final_method_name
def _build_final_method_name( method_name, dataset_name, dataprovider_name, repeat_suffix, ): """ Return a nice human friendly name, that almost looks like code. Example: a test called 'test_something' with a dataset of (5, 'hello') Return: "test_something(5, 'hell...
python
def _build_final_method_name( method_name, dataset_name, dataprovider_name, repeat_suffix, ): """ Return a nice human friendly name, that almost looks like code. Example: a test called 'test_something' with a dataset of (5, 'hello') Return: "test_something(5, 'hell...
[ "def", "_build_final_method_name", "(", "method_name", ",", "dataset_name", ",", "dataprovider_name", ",", "repeat_suffix", ",", ")", ":", "# For tests using a dataprovider, append \"_<dataprovider_name>\" to", "# the test method name", "suffix", "=", "''", "if", "dataprovider...
Return a nice human friendly name, that almost looks like code. Example: a test called 'test_something' with a dataset of (5, 'hello') Return: "test_something(5, 'hello')" Example: a test called 'test_other_stuff' with dataset of (9) and repeats Return: "test_other_stuff(9) iteration_<X>" ...
[ "Return", "a", "nice", "human", "friendly", "name", "that", "almost", "looks", "like", "code", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L270-L335
box/genty
genty/genty.py
_build_dataset_method
def _build_dataset_method(method, dataset): """ Return a fabricated method that marshals the dataset into parameters for given 'method' :param method: The underlying test method. :type method: `callable` :param dataset: Tuple or GentyArgs instance containing the args of t...
python
def _build_dataset_method(method, dataset): """ Return a fabricated method that marshals the dataset into parameters for given 'method' :param method: The underlying test method. :type method: `callable` :param dataset: Tuple or GentyArgs instance containing the args of t...
[ "def", "_build_dataset_method", "(", "method", ",", "dataset", ")", ":", "if", "isinstance", "(", "dataset", ",", "GentyArgs", ")", ":", "test_method", "=", "lambda", "my_self", ":", "method", "(", "my_self", ",", "*", "dataset", ".", "args", ",", "*", "...
Return a fabricated method that marshals the dataset into parameters for given 'method' :param method: The underlying test method. :type method: `callable` :param dataset: Tuple or GentyArgs instance containing the args of the dataset. :type dataset: `tuple` or :class...
[ "Return", "a", "fabricated", "method", "that", "marshals", "the", "dataset", "into", "parameters", "for", "given", "method", ":", "param", "method", ":", "The", "underlying", "test", "method", ".", ":", "type", "method", ":", "callable", ":", "param", "datas...
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L338-L366
box/genty
genty/genty.py
_build_dataprovider_method
def _build_dataprovider_method(method, dataset, dataprovider): """ Return a fabricated method that calls the dataprovider with the given dataset, and marshals the return value from that into params to the underlying test 'method'. :param method: The underlying test method. :type method: ...
python
def _build_dataprovider_method(method, dataset, dataprovider): """ Return a fabricated method that calls the dataprovider with the given dataset, and marshals the return value from that into params to the underlying test 'method'. :param method: The underlying test method. :type method: ...
[ "def", "_build_dataprovider_method", "(", "method", ",", "dataset", ",", "dataprovider", ")", ":", "if", "isinstance", "(", "dataset", ",", "GentyArgs", ")", ":", "final_args", "=", "dataset", ".", "args", "final_kwargs", "=", "dataset", ".", "kwargs", "else",...
Return a fabricated method that calls the dataprovider with the given dataset, and marshals the return value from that into params to the underlying test 'method'. :param method: The underlying test method. :type method: `callable` :param dataset: Tuple or GentyArgs instance ...
[ "Return", "a", "fabricated", "method", "that", "calls", "the", "dataprovider", "with", "the", "given", "dataset", "and", "marshals", "the", "return", "value", "from", "that", "into", "params", "to", "the", "underlying", "test", "method", ".", ":", "param", "...
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L369-L416
box/genty
genty/genty.py
_add_method_to_class
def _add_method_to_class( target_cls, method_name, func, dataset_name, dataset, dataprovider, repeat_suffix, ): """ Add the described method to the given class. :param target_cls: Test class to which to add a method. :type target_cls: ...
python
def _add_method_to_class( target_cls, method_name, func, dataset_name, dataset, dataprovider, repeat_suffix, ): """ Add the described method to the given class. :param target_cls: Test class to which to add a method. :type target_cls: ...
[ "def", "_add_method_to_class", "(", "target_cls", ",", "method_name", ",", "func", ",", "dataset_name", ",", "dataset", ",", "dataprovider", ",", "repeat_suffix", ",", ")", ":", "# pylint: disable=too-many-arguments", "test_method_name_for_dataset", "=", "_build_final_met...
Add the described method to the given class. :param target_cls: Test class to which to add a method. :type target_cls: `class` :param method_name: Base name of the method to add. :type method_name: `unicode` :param func: The underlying test function to call. ...
[ "Add", "the", "described", "method", "to", "the", "given", "class", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L450-L514
bcbnz/python-rofi
rofi.py
Rofi.close
def close(self): """Close any open window. Note that this only works with non-blocking methods. """ if self._process: # Be nice first. self._process.send_signal(signal.SIGINT) # If it doesn't close itself promptly, be brutal. # Python 3....
python
def close(self): """Close any open window. Note that this only works with non-blocking methods. """ if self._process: # Be nice first. self._process.send_signal(signal.SIGINT) # If it doesn't close itself promptly, be brutal. # Python 3....
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_process", ":", "# Be nice first.", "self", ".", "_process", ".", "send_signal", "(", "signal", ".", "SIGINT", ")", "# If it doesn't close itself promptly, be brutal.", "# Python 3.2+ added the timeout option to...
Close any open window. Note that this only works with non-blocking methods.
[ "Close", "any", "open", "window", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L157-L190
bcbnz/python-rofi
rofi.py
Rofi._run_blocking
def _run_blocking(self, args, input=None): """Internal API: run a blocking command with subprocess. This closes any open non-blocking dialog before running the command. Parameters ---------- args: Popen constructor arguments Command to run. input: string ...
python
def _run_blocking(self, args, input=None): """Internal API: run a blocking command with subprocess. This closes any open non-blocking dialog before running the command. Parameters ---------- args: Popen constructor arguments Command to run. input: string ...
[ "def", "_run_blocking", "(", "self", ",", "args", ",", "input", "=", "None", ")", ":", "# Close any existing dialog.", "if", "self", ".", "_process", ":", "self", ".", "close", "(", ")", "# Make sure we grab stdout as text (not bytes).", "kwargs", "=", "{", "}",...
Internal API: run a blocking command with subprocess. This closes any open non-blocking dialog before running the command. Parameters ---------- args: Popen constructor arguments Command to run. input: string Value to feed to the stdin of the process. ...
[ "Internal", "API", ":", "run", "a", "blocking", "command", "with", "subprocess", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L193-L238
bcbnz/python-rofi
rofi.py
Rofi._run_nonblocking
def _run_nonblocking(self, args, input=None): """Internal API: run a non-blocking command with subprocess. This closes any open non-blocking dialog before running the command. Parameters ---------- args: Popen constructor arguments Command to run. input: str...
python
def _run_nonblocking(self, args, input=None): """Internal API: run a non-blocking command with subprocess. This closes any open non-blocking dialog before running the command. Parameters ---------- args: Popen constructor arguments Command to run. input: str...
[ "def", "_run_nonblocking", "(", "self", ",", "args", ",", "input", "=", "None", ")", ":", "# Close any existing dialog.", "if", "self", ".", "_process", ":", "self", ".", "close", "(", ")", "# Start the new one.", "self", ".", "_process", "=", "subprocess", ...
Internal API: run a non-blocking command with subprocess. This closes any open non-blocking dialog before running the command. Parameters ---------- args: Popen constructor arguments Command to run. input: string Value to feed to the stdin of the process...
[ "Internal", "API", ":", "run", "a", "non", "-", "blocking", "command", "with", "subprocess", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L241-L259
bcbnz/python-rofi
rofi.py
Rofi.error
def error(self, message, rofi_args=None, **kwargs): """Show an error window. This method blocks until the user presses a key. Fullscreen mode is not supported for error windows, and if specified will be ignored. Parameters ---------- message: string ...
python
def error(self, message, rofi_args=None, **kwargs): """Show an error window. This method blocks until the user presses a key. Fullscreen mode is not supported for error windows, and if specified will be ignored. Parameters ---------- message: string ...
[ "def", "error", "(", "self", ",", "message", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "rofi_args", "=", "rofi_args", "or", "[", "]", "# Generate arguments list.", "args", "=", "[", "'rofi'", ",", "'-e'", ",", "message", "]", "a...
Show an error window. This method blocks until the user presses a key. Fullscreen mode is not supported for error windows, and if specified will be ignored. Parameters ---------- message: string Error message to show.
[ "Show", "an", "error", "window", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L295-L316
bcbnz/python-rofi
rofi.py
Rofi.status
def status(self, message, rofi_args=None, **kwargs): """Show a status message. This method is non-blocking, and intended to give a status update to the user while something is happening in the background. To close the window, either call the close() method or use any of the dis...
python
def status(self, message, rofi_args=None, **kwargs): """Show a status message. This method is non-blocking, and intended to give a status update to the user while something is happening in the background. To close the window, either call the close() method or use any of the dis...
[ "def", "status", "(", "self", ",", "message", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "rofi_args", "=", "rofi_args", "or", "[", "]", "# Generate arguments list.", "args", "=", "[", "'rofi'", ",", "'-e'", ",", "message", "]", "...
Show a status message. This method is non-blocking, and intended to give a status update to the user while something is happening in the background. To close the window, either call the close() method or use any of the display methods to replace it with a different window. Ful...
[ "Show", "a", "status", "message", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L319-L344
bcbnz/python-rofi
rofi.py
Rofi.select
def select(self, prompt, options, rofi_args=None, message="", select=None, **kwargs): """Show a list of options and return user selection. This method blocks until the user makes their choice. Parameters ---------- prompt: string The prompt telling the user what the...
python
def select(self, prompt, options, rofi_args=None, message="", select=None, **kwargs): """Show a list of options and return user selection. This method blocks until the user makes their choice. Parameters ---------- prompt: string The prompt telling the user what the...
[ "def", "select", "(", "self", ",", "prompt", ",", "options", ",", "rofi_args", "=", "None", ",", "message", "=", "\"\"", ",", "select", "=", "None", ",", "*", "*", "kwargs", ")", ":", "rofi_args", "=", "rofi_args", "or", "[", "]", "# Replace newlines a...
Show a list of options and return user selection. This method blocks until the user makes their choice. Parameters ---------- prompt: string The prompt telling the user what they are selecting. options: list of strings The options they can choose from. A...
[ "Show", "a", "list", "of", "options", "and", "return", "user", "selection", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L347-L462
bcbnz/python-rofi
rofi.py
Rofi.generic_entry
def generic_entry(self, prompt, validator=None, message=None, rofi_args=None, **kwargs): """A generic entry box. Parameters ---------- prompt: string Text prompt for the entry. validator: function, optional A function to validate and convert the value ent...
python
def generic_entry(self, prompt, validator=None, message=None, rofi_args=None, **kwargs): """A generic entry box. Parameters ---------- prompt: string Text prompt for the entry. validator: function, optional A function to validate and convert the value ent...
[ "def", "generic_entry", "(", "self", ",", "prompt", ",", "validator", "=", "None", ",", "message", "=", "None", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "error", "=", "\"\"", "rofi_args", "=", "rofi_args", "or", "[", "]", "# ...
A generic entry box. Parameters ---------- prompt: string Text prompt for the entry. validator: function, optional A function to validate and convert the value entered by the user. It should take one parameter, the string that the user entered, and ...
[ "A", "generic", "entry", "box", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L465-L533
bcbnz/python-rofi
rofi.py
Rofi.text_entry
def text_entry(self, prompt, message=None, allow_blank=False, strip=True, rofi_args=None, **kwargs): """Prompt the user to enter a piece of text. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Mes...
python
def text_entry(self, prompt, message=None, allow_blank=False, strip=True, rofi_args=None, **kwargs): """Prompt the user to enter a piece of text. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Mes...
[ "def", "text_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "allow_blank", "=", "False", ",", "strip", "=", "True", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "text_validator", "(", "text", ")", ":...
Prompt the user to enter a piece of text. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. allow_blank: Boolean Whether to allow blank entries. strip...
[ "Prompt", "the", "user", "to", "enter", "a", "piece", "of", "text", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L536-L566
bcbnz/python-rofi
rofi.py
Rofi.integer_entry
def integer_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter an integer. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the...
python
def integer_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter an integer. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the...
[ "def", "integer_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "min", "=", "None", ",", "max", "=", "None", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Sanity check.", "if", "(", "min", "is", "not", "...
Prompt the user to enter an integer. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. min, max: integer, optional Minimum and maximum values to allow. If Non...
[ "Prompt", "the", "user", "to", "enter", "an", "integer", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L569-L607
bcbnz/python-rofi
rofi.py
Rofi.float_entry
def float_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter a floating point number. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to displa...
python
def float_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter a floating point number. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to displa...
[ "def", "float_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "min", "=", "None", ",", "max", "=", "None", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Sanity check.", "if", "(", "min", "is", "not", "No...
Prompt the user to enter a floating point number. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. min, max: float, optional Minimum and maximum values to al...
[ "Prompt", "the", "user", "to", "enter", "a", "floating", "point", "number", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L610-L648
bcbnz/python-rofi
rofi.py
Rofi.decimal_entry
def decimal_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter a decimal number. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display und...
python
def decimal_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter a decimal number. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display und...
[ "def", "decimal_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "min", "=", "None", ",", "max", "=", "None", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Sanity check.", "if", "(", "min", "is", "not", "...
Prompt the user to enter a decimal number. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. min, max: Decimal, optional Minimum and maximum values to allow. ...
[ "Prompt", "the", "user", "to", "enter", "a", "decimal", "number", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L651-L689
bcbnz/python-rofi
rofi.py
Rofi.date_entry
def date_entry(self, prompt, message=None, formats=['%x', '%d/%m/%Y'], show_example=False, rofi_args=None, **kwargs): """Prompt the user to enter a date. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional ...
python
def date_entry(self, prompt, message=None, formats=['%x', '%d/%m/%Y'], show_example=False, rofi_args=None, **kwargs): """Prompt the user to enter a date. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional ...
[ "def", "date_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "formats", "=", "[", "'%x'", ",", "'%d/%m/%Y'", "]", ",", "show_example", "=", "False", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "date_...
Prompt the user to enter a date. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. formats: list of strings, optional The formats that the user can enter date...
[ "Prompt", "the", "user", "to", "enter", "a", "date", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L692-L737
bcbnz/python-rofi
rofi.py
Rofi.time_entry
def time_entry(self, prompt, message=None, formats=['%X', '%H:%M', '%I:%M', '%H.%M', '%I.%M'], show_example=False, rofi_args=None, **kwargs): """Prompt the user to enter a time. Parameters ---------- prompt: string Prompt to display to the user. message: stri...
python
def time_entry(self, prompt, message=None, formats=['%X', '%H:%M', '%I:%M', '%H.%M', '%I.%M'], show_example=False, rofi_args=None, **kwargs): """Prompt the user to enter a time. Parameters ---------- prompt: string Prompt to display to the user. message: stri...
[ "def", "time_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "formats", "=", "[", "'%X'", ",", "'%H:%M'", ",", "'%I:%M'", ",", "'%H.%M'", ",", "'%I.%M'", "]", ",", "show_example", "=", "False", ",", "rofi_args", "=", "None", ",", ...
Prompt the user to enter a time. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. formats: list of strings, optional The formats that the user can enter time...
[ "Prompt", "the", "user", "to", "enter", "a", "time", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L740-L785
bcbnz/python-rofi
rofi.py
Rofi.datetime_entry
def datetime_entry(self, prompt, message=None, formats=['%x %X'], show_example=False, rofi_args=None, **kwargs): """Prompt the user to enter a date and time. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional ...
python
def datetime_entry(self, prompt, message=None, formats=['%x %X'], show_example=False, rofi_args=None, **kwargs): """Prompt the user to enter a date and time. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional ...
[ "def", "datetime_entry", "(", "self", ",", "prompt", ",", "message", "=", "None", ",", "formats", "=", "[", "'%x %X'", "]", ",", "show_example", "=", "False", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "datetime_validator", ...
Prompt the user to enter a date and time. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. formats: list of strings, optional The formats that the user can e...
[ "Prompt", "the", "user", "to", "enter", "a", "date", "and", "time", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L788-L833
bcbnz/python-rofi
rofi.py
Rofi.exit_with_error
def exit_with_error(self, error, **kwargs): """Report an error and exit. This raises a SystemExit exception to ask the interpreter to quit. Parameters ---------- error: string The error to report before quitting. """ self.error(error, **kwargs) ...
python
def exit_with_error(self, error, **kwargs): """Report an error and exit. This raises a SystemExit exception to ask the interpreter to quit. Parameters ---------- error: string The error to report before quitting. """ self.error(error, **kwargs) ...
[ "def", "exit_with_error", "(", "self", ",", "error", ",", "*", "*", "kwargs", ")", ":", "self", ".", "error", "(", "error", ",", "*", "*", "kwargs", ")", "raise", "SystemExit", "(", "error", ")" ]
Report an error and exit. This raises a SystemExit exception to ask the interpreter to quit. Parameters ---------- error: string The error to report before quitting.
[ "Report", "an", "error", "and", "exit", "." ]
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L836-L848
box/genty
genty/private/__init__.py
format_kwarg
def format_kwarg(key, value): """ Return a string of form: "key=<value>" If 'value' is a string, we want it quoted. The goal is to make the string a named parameter in a method call. """ translator = repr if isinstance(value, six.string_types) else six.text_type arg_value = translator(valu...
python
def format_kwarg(key, value): """ Return a string of form: "key=<value>" If 'value' is a string, we want it quoted. The goal is to make the string a named parameter in a method call. """ translator = repr if isinstance(value, six.string_types) else six.text_type arg_value = translator(valu...
[ "def", "format_kwarg", "(", "key", ",", "value", ")", ":", "translator", "=", "repr", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", "else", "six", ".", "text_type", "arg_value", "=", "translator", "(", "value", ")", "return", "'...
Return a string of form: "key=<value>" If 'value' is a string, we want it quoted. The goal is to make the string a named parameter in a method call.
[ "Return", "a", "string", "of", "form", ":", "key", "=", "<value", ">" ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/private/__init__.py#L7-L17
box/genty
genty/private/__init__.py
format_arg
def format_arg(value): """ :param value: Some value in a dataset. :type value: varies :return: unicode representation of that value :rtype: `unicode` """ translator = repr if isinstance(value, six.string_types) else six.text_type return translator(value)
python
def format_arg(value): """ :param value: Some value in a dataset. :type value: varies :return: unicode representation of that value :rtype: `unicode` """ translator = repr if isinstance(value, six.string_types) else six.text_type return translator(value)
[ "def", "format_arg", "(", "value", ")", ":", "translator", "=", "repr", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", "else", "six", ".", "text_type", "return", "translator", "(", "value", ")" ]
:param value: Some value in a dataset. :type value: varies :return: unicode representation of that value :rtype: `unicode`
[ ":", "param", "value", ":", "Some", "value", "in", "a", "dataset", ".", ":", "type", "value", ":", "varies", ":", "return", ":", "unicode", "representation", "of", "that", "value", ":", "rtype", ":", "unicode" ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/private/__init__.py#L20-L32
box/genty
genty/private/__init__.py
encode_non_ascii_string
def encode_non_ascii_string(string): """ :param string: The string to be encoded :type string: unicode or str :return: The encoded string :rtype: str """ encoded_string = string.encode('utf-8', 'replace') if six.PY3: encoded_string = encoded_string...
python
def encode_non_ascii_string(string): """ :param string: The string to be encoded :type string: unicode or str :return: The encoded string :rtype: str """ encoded_string = string.encode('utf-8', 'replace') if six.PY3: encoded_string = encoded_string...
[ "def", "encode_non_ascii_string", "(", "string", ")", ":", "encoded_string", "=", "string", ".", "encode", "(", "'utf-8'", ",", "'replace'", ")", "if", "six", ".", "PY3", ":", "encoded_string", "=", "encoded_string", ".", "decode", "(", ")", "return", "encod...
:param string: The string to be encoded :type string: unicode or str :return: The encoded string :rtype: str
[ ":", "param", "string", ":", "The", "string", "to", "be", "encoded", ":", "type", "string", ":", "unicode", "or", "str", ":", "return", ":", "The", "encoded", "string", ":", "rtype", ":", "str" ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/private/__init__.py#L35-L50
box/genty
genty/genty_dataset.py
genty_dataprovider
def genty_dataprovider(builder_function): """Decorator defining that this test gets parameters from the given build_function. :param builder_function: A callable that returns parameters that will be passed to the method decorated by this decorator. If the builder_function returns a...
python
def genty_dataprovider(builder_function): """Decorator defining that this test gets parameters from the given build_function. :param builder_function: A callable that returns parameters that will be passed to the method decorated by this decorator. If the builder_function returns a...
[ "def", "genty_dataprovider", "(", "builder_function", ")", ":", "datasets", "=", "getattr", "(", "builder_function", ",", "'genty_datasets'", ",", "{", "None", ":", "(", ")", "}", ")", "def", "wrap", "(", "test_method", ")", ":", "# Save the data providers in th...
Decorator defining that this test gets parameters from the given build_function. :param builder_function: A callable that returns parameters that will be passed to the method decorated by this decorator. If the builder_function returns a tuple or list, then that will be passed ...
[ "Decorator", "defining", "that", "this", "test", "gets", "parameters", "from", "the", "given", "build_function", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty_dataset.py#L15-L47
box/genty
genty/genty_dataset.py
genty_dataset
def genty_dataset(*args, **kwargs): """Decorator defining data sets to provide to a test. Inspired by http://sebastian-bergmann.de/archives/ 702-Data-Providers-in-PHPUnit-3.2.html The canonical way to call @genty_dataset, with each argument each representing a data set to be injected in the test m...
python
def genty_dataset(*args, **kwargs): """Decorator defining data sets to provide to a test. Inspired by http://sebastian-bergmann.de/archives/ 702-Data-Providers-in-PHPUnit-3.2.html The canonical way to call @genty_dataset, with each argument each representing a data set to be injected in the test m...
[ "def", "genty_dataset", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "datasets", "=", "_build_datasets", "(", "*", "args", ",", "*", "*", "kwargs", ")", "def", "wrap", "(", "test_method", ")", ":", "# Save the datasets in the test method. This data wil...
Decorator defining data sets to provide to a test. Inspired by http://sebastian-bergmann.de/archives/ 702-Data-Providers-in-PHPUnit-3.2.html The canonical way to call @genty_dataset, with each argument each representing a data set to be injected in the test method call: @genty_dataset( ...
[ "Decorator", "defining", "data", "sets", "to", "provide", "to", "a", "test", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty_dataset.py#L50-L148
box/genty
genty/genty_dataset.py
_build_datasets
def _build_datasets(*args, **kwargs): """Build the datasets into a dict, where the keys are the name of the data set and the values are the data sets themselves. :param args: Tuple of unnamed data sets. :type args: `tuple` of varies :param kwargs: Dict of pre-named data sets...
python
def _build_datasets(*args, **kwargs): """Build the datasets into a dict, where the keys are the name of the data set and the values are the data sets themselves. :param args: Tuple of unnamed data sets. :type args: `tuple` of varies :param kwargs: Dict of pre-named data sets...
[ "def", "_build_datasets", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "datasets", "=", "OrderedDict", "(", ")", "_add_arg_datasets", "(", "datasets", ",", "args", ")", "_add_kwarg_datasets", "(", "datasets", ",", "kwargs", ")", "return", "datasets" ...
Build the datasets into a dict, where the keys are the name of the data set and the values are the data sets themselves. :param args: Tuple of unnamed data sets. :type args: `tuple` of varies :param kwargs: Dict of pre-named data sets. :type kwargs: `dict` of `unicod...
[ "Build", "the", "datasets", "into", "a", "dict", "where", "the", "keys", "are", "the", "name", "of", "the", "data", "set", "and", "the", "values", "are", "the", "data", "sets", "themselves", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty_dataset.py#L151-L171
box/genty
genty/genty_dataset.py
_add_arg_datasets
def _add_arg_datasets(datasets, args): """Add data sets of the given args. :param datasets: The dict where to accumulate data sets. :type datasets: `dict` :param args: Tuple of unnamed data sets. :type args: `tuple` of varies """ for dataset in args: ...
python
def _add_arg_datasets(datasets, args): """Add data sets of the given args. :param datasets: The dict where to accumulate data sets. :type datasets: `dict` :param args: Tuple of unnamed data sets. :type args: `tuple` of varies """ for dataset in args: ...
[ "def", "_add_arg_datasets", "(", "datasets", ",", "args", ")", ":", "for", "dataset", "in", "args", ":", "# turn a value into a 1-tuple.", "if", "not", "isinstance", "(", "dataset", ",", "(", "tuple", ",", "GentyArgs", ")", ")", ":", "dataset", "=", "(", "...
Add data sets of the given args. :param datasets: The dict where to accumulate data sets. :type datasets: `dict` :param args: Tuple of unnamed data sets. :type args: `tuple` of varies
[ "Add", "data", "sets", "of", "the", "given", "args", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty_dataset.py#L174-L198
box/genty
genty/genty_dataset.py
_add_kwarg_datasets
def _add_kwarg_datasets(datasets, kwargs): """Add data sets of the given kwargs. :param datasets: The dict where to accumulate data sets. :type datasets: `dict` :param kwargs: Dict of pre-named data sets. :type kwargs: `dict` of `unicode` to varies """ for te...
python
def _add_kwarg_datasets(datasets, kwargs): """Add data sets of the given kwargs. :param datasets: The dict where to accumulate data sets. :type datasets: `dict` :param kwargs: Dict of pre-named data sets. :type kwargs: `dict` of `unicode` to varies """ for te...
[ "def", "_add_kwarg_datasets", "(", "datasets", ",", "kwargs", ")", ":", "for", "test_method_suffix", ",", "dataset", "in", "six", ".", "iteritems", "(", "kwargs", ")", ":", "datasets", "[", "test_method_suffix", "]", "=", "dataset" ]
Add data sets of the given kwargs. :param datasets: The dict where to accumulate data sets. :type datasets: `dict` :param kwargs: Dict of pre-named data sets. :type kwargs: `dict` of `unicode` to varies
[ "Add", "data", "sets", "of", "the", "given", "kwargs", "." ]
train
https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty_dataset.py#L201-L214
abingham/docopt-subcommands
docopt_subcommands/subcommands.py
dedent
def dedent(s): """Removes the hanging dedent from all the first line of a string.""" head, _, tail = s.partition('\n') dedented_tail = textwrap.dedent(tail) result = "{head}\n{tail}".format( head=head, tail=dedented_tail) return result
python
def dedent(s): """Removes the hanging dedent from all the first line of a string.""" head, _, tail = s.partition('\n') dedented_tail = textwrap.dedent(tail) result = "{head}\n{tail}".format( head=head, tail=dedented_tail) return result
[ "def", "dedent", "(", "s", ")", ":", "head", ",", "_", ",", "tail", "=", "s", ".", "partition", "(", "'\\n'", ")", "dedented_tail", "=", "textwrap", ".", "dedent", "(", "tail", ")", "result", "=", "\"{head}\\n{tail}\"", ".", "format", "(", "head", "=...
Removes the hanging dedent from all the first line of a string.
[ "Removes", "the", "hanging", "dedent", "from", "all", "the", "first", "line", "of", "a", "string", "." ]
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/subcommands.py#L20-L27
abingham/docopt-subcommands
docopt_subcommands/subcommands.py
Subcommands.top_level_doc
def top_level_doc(self): """The top-level documentation string for the program. """ return self._doc_template.format( available_commands='\n '.join(sorted(self._commands)), program=self.program)
python
def top_level_doc(self): """The top-level documentation string for the program. """ return self._doc_template.format( available_commands='\n '.join(sorted(self._commands)), program=self.program)
[ "def", "top_level_doc", "(", "self", ")", ":", "return", "self", ".", "_doc_template", ".", "format", "(", "available_commands", "=", "'\\n '", ".", "join", "(", "sorted", "(", "self", ".", "_commands", ")", ")", ",", "program", "=", "self", ".", "progr...
The top-level documentation string for the program.
[ "The", "top", "-", "level", "documentation", "string", "for", "the", "program", "." ]
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/subcommands.py#L83-L88
abingham/docopt-subcommands
docopt_subcommands/subcommands.py
Subcommands.command
def command(self, name=None): """A decorator to add subcommands. """ def decorator(f): self.add_command(f, name) return f return decorator
python
def command(self, name=None): """A decorator to add subcommands. """ def decorator(f): self.add_command(f, name) return f return decorator
[ "def", "command", "(", "self", ",", "name", "=", "None", ")", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "add_command", "(", "f", ",", "name", ")", "return", "f", "return", "decorator" ]
A decorator to add subcommands.
[ "A", "decorator", "to", "add", "subcommands", "." ]
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/subcommands.py#L90-L96
abingham/docopt-subcommands
docopt_subcommands/subcommands.py
Subcommands.add_command
def add_command(self, handler, name=None): """Add a subcommand `name` which invokes `handler`. """ if name is None: name = docstring_to_subcommand(handler.__doc__) # TODO: Prevent overwriting 'help'? self._commands[name] = handler
python
def add_command(self, handler, name=None): """Add a subcommand `name` which invokes `handler`. """ if name is None: name = docstring_to_subcommand(handler.__doc__) # TODO: Prevent overwriting 'help'? self._commands[name] = handler
[ "def", "add_command", "(", "self", ",", "handler", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "docstring_to_subcommand", "(", "handler", ".", "__doc__", ")", "# TODO: Prevent overwriting 'help'?", "self", ".", "_commands"...
Add a subcommand `name` which invokes `handler`.
[ "Add", "a", "subcommand", "name", "which", "invokes", "handler", "." ]
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/subcommands.py#L98-L105