partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Order.history
show payment history
coincheck/order.py
def history(self): ''' show payment history ''' url= 'https://coincheck.com/api/exchange/orders/transactions' headers = make_header(url,access_key=self.access_key,secret_key=self.secret_key) r = requests.get(url,headers=headers) return json.loads(r.text)
def history(self): ''' show payment history ''' url= 'https://coincheck.com/api/exchange/orders/transactions' headers = make_header(url,access_key=self.access_key,secret_key=self.secret_key) r = requests.get(url,headers=headers) return json.loads(r.text)
[ "show", "payment", "history" ]
kmn/coincheck
python
https://github.com/kmn/coincheck/blob/4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc/coincheck/order.py#L68-L74
[ "def", "history", "(", "self", ")", ":", "url", "=", "'https://coincheck.com/api/exchange/orders/transactions'", "headers", "=", "make_header", "(", "url", ",", "access_key", "=", "self", ".", "access_key", ",", "secret_key", "=", "self", ".", "secret_key", ")", ...
4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc
train
_length_hint
Returns the length hint of an object.
be/vendor/click/_termui_impl.py
def _length_hint(obj): """Returns the length hint of an object.""" try: return len(obj) except TypeError: try: get_hint = type(obj).__length_hint__ except AttributeError: return None try: hint = get_hint(obj) except TypeError: ...
def _length_hint(obj): """Returns the length hint of an object.""" try: return len(obj) except TypeError: try: get_hint = type(obj).__length_hint__ except AttributeError: return None try: hint = get_hint(obj) except TypeError: ...
[ "Returns", "the", "length", "hint", "of", "an", "object", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/_termui_impl.py#L30-L47
[ "def", "_length_hint", "(", "obj", ")", ":", "try", ":", "return", "len", "(", "obj", ")", "except", "TypeError", ":", "try", ":", "get_hint", "=", "type", "(", "obj", ")", ".", "__length_hint__", "except", "AttributeError", ":", "return", "None", "try",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
pager
Decide what method to use for paging through text.
be/vendor/click/_termui_impl.py
def pager(text, color=None): """Decide what method to use for paging through text.""" stdout = _default_text_stdout() if not isatty(sys.stdin) or not isatty(stdout): return _nullpager(stdout, text, color) if 'PAGER' in os.environ: if WIN: return _tempfilepager(text, os.enviro...
def pager(text, color=None): """Decide what method to use for paging through text.""" stdout = _default_text_stdout() if not isatty(sys.stdin) or not isatty(stdout): return _nullpager(stdout, text, color) if 'PAGER' in os.environ: if WIN: return _tempfilepager(text, os.enviro...
[ "Decide", "what", "method", "to", "use", "for", "paging", "through", "text", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/_termui_impl.py#L255-L279
[ "def", "pager", "(", "text", ",", "color", "=", "None", ")", ":", "stdout", "=", "_default_text_stdout", "(", ")", "if", "not", "isatty", "(", "sys", ".", "stdin", ")", "or", "not", "isatty", "(", "stdout", ")", ":", "return", "_nullpager", "(", "std...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Retry.from_int
Backwards-compatibility for the old retries format.
be/vendor/requests/packages/urllib3/util/retry.py
def from_int(cls, retries, redirect=True, default=None): """ Backwards-compatibility for the old retries format.""" if retries is None: retries = default if default is not None else cls.DEFAULT if isinstance(retries, Retry): return retries redirect = bool(redire...
def from_int(cls, retries, redirect=True, default=None): """ Backwards-compatibility for the old retries format.""" if retries is None: retries = default if default is not None else cls.DEFAULT if isinstance(retries, Retry): return retries redirect = bool(redire...
[ "Backwards", "-", "compatibility", "for", "the", "old", "retries", "format", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/retry.py#L145-L156
[ "def", "from_int", "(", "cls", ",", "retries", ",", "redirect", "=", "True", ",", "default", "=", "None", ")", ":", "if", "retries", "is", "None", ":", "retries", "=", "default", "if", "default", "is", "not", "None", "else", "cls", ".", "DEFAULT", "i...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Retry.get_backoff_time
Formula for computing the current backoff :rtype: float
be/vendor/requests/packages/urllib3/util/retry.py
def get_backoff_time(self): """ Formula for computing the current backoff :rtype: float """ if self._observed_errors <= 1: return 0 backoff_value = self.backoff_factor * (2 ** (self._observed_errors - 1)) return min(self.BACKOFF_MAX, backoff_value)
def get_backoff_time(self): """ Formula for computing the current backoff :rtype: float """ if self._observed_errors <= 1: return 0 backoff_value = self.backoff_factor * (2 ** (self._observed_errors - 1)) return min(self.BACKOFF_MAX, backoff_value)
[ "Formula", "for", "computing", "the", "current", "backoff" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/retry.py#L158-L167
[ "def", "get_backoff_time", "(", "self", ")", ":", "if", "self", ".", "_observed_errors", "<=", "1", ":", "return", "0", "backoff_value", "=", "self", ".", "backoff_factor", "*", "(", "2", "**", "(", "self", ".", "_observed_errors", "-", "1", ")", ")", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Retry.is_forced_retry
Is this method/status code retryable? (Based on method/codes whitelists)
be/vendor/requests/packages/urllib3/util/retry.py
def is_forced_retry(self, method, status_code): """ Is this method/status code retryable? (Based on method/codes whitelists) """ if self.method_whitelist and method.upper() not in self.method_whitelist: return False return self.status_forcelist and status_code in self.status...
def is_forced_retry(self, method, status_code): """ Is this method/status code retryable? (Based on method/codes whitelists) """ if self.method_whitelist and method.upper() not in self.method_whitelist: return False return self.status_forcelist and status_code in self.status...
[ "Is", "this", "method", "/", "status", "code", "retryable?", "(", "Based", "on", "method", "/", "codes", "whitelists", ")" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/retry.py#L192-L198
[ "def", "is_forced_retry", "(", "self", ",", "method", ",", "status_code", ")", ":", "if", "self", ".", "method_whitelist", "and", "method", ".", "upper", "(", ")", "not", "in", "self", ".", "method_whitelist", ":", "return", "False", "return", "self", ".",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
convert_type
Converts a callable or python ty into the most appropriate param ty.
be/vendor/click/types.py
def convert_type(ty, default=None): """Converts a callable or python ty into the most appropriate param ty. """ if isinstance(ty, tuple): return Tuple(ty) if isinstance(ty, ParamType): return ty guessed_type = False if ty is None and default is not None: ty = type(def...
def convert_type(ty, default=None): """Converts a callable or python ty into the most appropriate param ty. """ if isinstance(ty, tuple): return Tuple(ty) if isinstance(ty, ParamType): return ty guessed_type = False if ty is None and default is not None: ty = type(def...
[ "Converts", "a", "callable", "or", "python", "ty", "into", "the", "most", "appropriate", "param", "ty", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/types.py#L445-L480
[ "def", "convert_type", "(", "ty", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "ty", ",", "tuple", ")", ":", "return", "Tuple", "(", "ty", ")", "if", "isinstance", "(", "ty", ",", "ParamType", ")", ":", "return", "ty", "guessed_typ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
wrap_text
A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intelligently handle paragraphs (defined by two empty lines). If paragraphs are handled, a paragraph can be prefixed wit...
be/vendor/click/formatting.py
def wrap_text(text, width=78, initial_indent='', subsequent_indent='', preserve_paragraphs=False): """A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intellige...
def wrap_text(text, width=78, initial_indent='', subsequent_indent='', preserve_paragraphs=False): """A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intellige...
[ "A", "helper", "function", "that", "intelligently", "wraps", "text", ".", "By", "default", "it", "assumes", "that", "it", "operates", "on", "a", "single", "paragraph", "of", "text", "but", "if", "the", "preserve_paragraphs", "parameter", "is", "provided", "it"...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/formatting.py#L27-L92
[ "def", "wrap_text", "(", "text", ",", "width", "=", "78", ",", "initial_indent", "=", "''", ",", "subsequent_indent", "=", "''", ",", "preserve_paragraphs", "=", "False", ")", ":", "from", ".", "_textwrap", "import", "TextWrapper", "text", "=", "text", "."...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HelpFormatter.write_usage
Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line.
be/vendor/click/formatting.py
def write_usage(self, prog, args='', prefix='Usage: '): """Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line. """ prefix = '%*s%s' % (self.current_indent, ...
def write_usage(self, prog, args='', prefix='Usage: '): """Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line. """ prefix = '%*s%s' % (self.current_indent, ...
[ "Writes", "a", "usage", "line", "into", "the", "buffer", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/formatting.py#L129-L145
[ "def", "write_usage", "(", "self", ",", "prog", ",", "args", "=", "''", ",", "prefix", "=", "'Usage: '", ")", ":", "prefix", "=", "'%*s%s'", "%", "(", "self", ".", "current_indent", ",", "prefix", ",", "prog", ")", "self", ".", "write", "(", "prefix"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
in_
Set the current topics to `topics` Environment: BE_PROJECT: First topic BE_CWD: Current `be` working directory BE_TOPICS: Arguments to `in` BE_DEVELOPMENTDIR: Absolute path to current development directory BE_PROJECTROOT: Absolute path to current project BE_PROJECTSR...
be/cli.py
def in_(ctx, topics, yes, as_, enter): """Set the current topics to `topics` Environment: BE_PROJECT: First topic BE_CWD: Current `be` working directory BE_TOPICS: Arguments to `in` BE_DEVELOPMENTDIR: Absolute path to current development directory BE_PROJECTROOT: Absolut...
def in_(ctx, topics, yes, as_, enter): """Set the current topics to `topics` Environment: BE_PROJECT: First topic BE_CWD: Current `be` working directory BE_TOPICS: Arguments to `in` BE_DEVELOPMENTDIR: Absolute path to current development directory BE_PROJECTROOT: Absolut...
[ "Set", "the", "current", "topics", "to", "topics" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L77-L274
[ "def", "in_", "(", "ctx", ",", "topics", ",", "yes", ",", "as_", ",", "enter", ")", ":", "topics", "=", "map", "(", "str", ",", "topics", ")", "# They enter as unicode", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERRO...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
new
Create new default preset \b Usage: $ be new ad "blue_unicorn" created $ be new film --name spiderman "spiderman" created
be/cli.py
def new(preset, name, silent, update): """Create new default preset \b Usage: $ be new ad "blue_unicorn" created $ be new film --name spiderman "spiderman" created """ if self.isactive(): lib.echo("Please exit current preset before starting a new") ...
def new(preset, name, silent, update): """Create new default preset \b Usage: $ be new ad "blue_unicorn" created $ be new film --name spiderman "spiderman" created """ if self.isactive(): lib.echo("Please exit current preset before starting a new") ...
[ "Create", "new", "default", "preset" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L284-L374
[ "def", "new", "(", "preset", ",", "name", ",", "silent", ",", "update", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"Please exit current preset before starting a new\"", ")", "sys", ".", "exit", "(", "lib", ".", "US...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
update
Update a local preset This command will cause `be` to pull a preset already available locally. \b Usage: $ be update ad Updating "ad"..
be/cli.py
def update(preset, clean): """Update a local preset This command will cause `be` to pull a preset already available locally. \b Usage: $ be update ad Updating "ad".. """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ER...
def update(preset, clean): """Update a local preset This command will cause `be` to pull a preset already available locally. \b Usage: $ be update ad Updating "ad".. """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ER...
[ "Update", "a", "local", "preset" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L380-L427
[ "def", "update", "(", "preset", ",", "clean", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "presets", "=", "_extern"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
tab
Utility sub-command for tabcompletion This command is meant to be called by a tab completion function and is given a the currently entered topics, along with a boolean indicating whether or not the last entered argument is complete.
be/cli.py
def tab(topics, complete): """Utility sub-command for tabcompletion This command is meant to be called by a tab completion function and is given a the currently entered topics, along with a boolean indicating whether or not the last entered argument is complete. """ # Discard `be tab` ...
def tab(topics, complete): """Utility sub-command for tabcompletion This command is meant to be called by a tab completion function and is given a the currently entered topics, along with a boolean indicating whether or not the last entered argument is complete. """ # Discard `be tab` ...
[ "Utility", "sub", "-", "command", "for", "tabcompletion" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L433-L512
[ "def", "tab", "(", "topics", ",", "complete", ")", ":", "# Discard `be tab`", "topics", "=", "list", "(", "topics", ")", "[", "2", ":", "]", "# When given an incomplete argument,", "# the argument is *sometimes* returned twice (?)", "# .. note:: Seen in Git Bash on Windows"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
activate
Enter into an environment with support for tab-completion This command drops you into a subshell, similar to the one generated via `be in ...`, except no topic is present and instead it enables tab-completion for supported shells. See documentation for further information. https://github.com/motto...
be/cli.py
def activate(): """Enter into an environment with support for tab-completion This command drops you into a subshell, similar to the one generated via `be in ...`, except no topic is present and instead it enables tab-completion for supported shells. See documentation for further information. h...
def activate(): """Enter into an environment with support for tab-completion This command drops you into a subshell, similar to the one generated via `be in ...`, except no topic is present and instead it enables tab-completion for supported shells. See documentation for further information. h...
[ "Enter", "into", "an", "environment", "with", "support", "for", "tab", "-", "completion" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L516-L546
[ "def", "activate", "(", ")", ":", "parent", "=", "lib", ".", "parent", "(", ")", "try", ":", "cmd", "=", "lib", ".", "cmd", "(", "parent", ")", "except", "SystemError", "as", "exc", ":", "lib", ".", "echo", "(", "exc", ")", "sys", ".", "exit", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
ls
List contents of current context \b Usage: $ be ls - spiderman - hulk $ be ls spiderman - peter - mjay $ be ls spiderman seq01 - 1000 - 2000 - 2500 Return codes: 0 Normal 2 When insufficient arguments are suppl...
be/cli.py
def ls(topics): """List contents of current context \b Usage: $ be ls - spiderman - hulk $ be ls spiderman - peter - mjay $ be ls spiderman seq01 - 1000 - 2000 - 2500 Return codes: 0 Normal 2 When insuffici...
def ls(topics): """List contents of current context \b Usage: $ be ls - spiderman - hulk $ be ls spiderman - peter - mjay $ be ls spiderman seq01 - 1000 - 2000 - 2500 Return codes: 0 Normal 2 When insuffici...
[ "List", "contents", "of", "current", "context" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L551-L608
[ "def", "ls", "(", "topics", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "# List projects", "if", "len", "(", "topic...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
mkdir
Create directory with template for topic of the current environment
be/cli.py
def mkdir(dir, enter): """Create directory with template for topic of the current environment """ if not os.path.exists(dir): os.makedirs(dir)
def mkdir(dir, enter): """Create directory with template for topic of the current environment """ if not os.path.exists(dir): os.makedirs(dir)
[ "Create", "directory", "with", "template", "for", "topic", "of", "the", "current", "environment" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L614-L620
[ "def", "mkdir", "(", "dir", ",", "enter", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dir", ")", ":", "os", ".", "makedirs", "(", "dir", ")" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
preset_ls
List presets \b Usage: $ be preset ls - ad - game - film
be/cli.py
def preset_ls(remote): """List presets \b Usage: $ be preset ls - ad - game - film """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) if remote: presets = _extern.github_presets() else: ...
def preset_ls(remote): """List presets \b Usage: $ be preset ls - ad - game - film """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) if remote: presets = _extern.github_presets() else: ...
[ "List", "presets" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L630-L656
[ "def", "preset_ls", "(", "remote", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "if", "remote", ":", "presets", "=",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
preset_find
Find preset from hub \b $ be find ad https://github.com/mottosso/be-ad.git
be/cli.py
def preset_find(query): """Find preset from hub \b $ be find ad https://github.com/mottosso/be-ad.git """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) found = _extern.github_presets().get(query) if found: lib.echo(...
def preset_find(query): """Find preset from hub \b $ be find ad https://github.com/mottosso/be-ad.git """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) found = _extern.github_presets().get(query) if found: lib.echo(...
[ "Find", "preset", "from", "hub" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L661-L678
[ "def", "preset_find", "(", "query", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "found", "=", "_extern", ".", "gith...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
dump
Print current environment Environment is outputted in a YAML-friendly format \b Usage: $ be dump Prefixed: - BE_TOPICS=hulk bruce animation - ...
be/cli.py
def dump(): """Print current environment Environment is outputted in a YAML-friendly format \b Usage: $ be dump Prefixed: - BE_TOPICS=hulk bruce animation - ... """ if not self.isactive(): lib.echo("ERROR: Enter a project first") sys.exit(lib.U...
def dump(): """Print current environment Environment is outputted in a YAML-friendly format \b Usage: $ be dump Prefixed: - BE_TOPICS=hulk bruce animation - ... """ if not self.isactive(): lib.echo("ERROR: Enter a project first") sys.exit(lib.U...
[ "Print", "current", "environment" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L682-L727
[ "def", "dump", "(", ")", ":", "if", "not", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Enter a project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "# Print custom environment variables first", "custom",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
what
Print current topics
be/cli.py
def what(): """Print current topics""" if not self.isactive(): lib.echo("No topic") sys.exit(lib.USER_ERROR) lib.echo(os.environ.get("BE_TOPICS", "This is a bug"))
def what(): """Print current topics""" if not self.isactive(): lib.echo("No topic") sys.exit(lib.USER_ERROR) lib.echo(os.environ.get("BE_TOPICS", "This is a bug"))
[ "Print", "current", "topics" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L731-L738
[ "def", "what", "(", ")", ":", "if", "not", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"No topic\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "lib", ".", "echo", "(", "os", ".", "environ", ".", "get", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
get_netrc_auth
Returns the Requests tuple auth for a given url from netrc.
be/vendor/requests/utils.py
def get_netrc_auth(url): """Returns the Requests tuple auth for a given url from netrc.""" try: from netrc import netrc, NetrcParseError netrc_path = None for f in NETRC_FILES: try: loc = os.path.expanduser('~/{0}'.format(f)) except KeyError: ...
def get_netrc_auth(url): """Returns the Requests tuple auth for a given url from netrc.""" try: from netrc import netrc, NetrcParseError netrc_path = None for f in NETRC_FILES: try: loc = os.path.expanduser('~/{0}'.format(f)) except KeyError: ...
[ "Returns", "the", "Requests", "tuple", "auth", "for", "a", "given", "url", "from", "netrc", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L70-L113
[ "def", "get_netrc_auth", "(", "url", ")", ":", "try", ":", "from", "netrc", "import", "netrc", ",", "NetrcParseError", "netrc_path", "=", "None", "for", "f", "in", "NETRC_FILES", ":", "try", ":", "loc", "=", "os", ".", "path", ".", "expanduser", "(", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
add_dict_to_cookiejar
Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar.
be/vendor/requests/utils.py
def add_dict_to_cookiejar(cj, cookie_dict): """Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. """ cj2 = cookiejar_from_dict(cookie_dict) cj.update(cj2) return cj
def add_dict_to_cookiejar(cj, cookie_dict): """Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. """ cj2 = cookiejar_from_dict(cookie_dict) cj.update(cj2) return cj
[ "Returns", "a", "CookieJar", "from", "a", "key", "/", "value", "dictionary", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L276-L285
[ "def", "add_dict_to_cookiejar", "(", "cj", ",", "cookie_dict", ")", ":", "cj2", "=", "cookiejar_from_dict", "(", "cookie_dict", ")", "cj", ".", "update", "(", "cj2", ")", "return", "cj" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
should_bypass_proxies
Returns whether we should bypass proxies or not.
be/vendor/requests/utils.py
def should_bypass_proxies(url): """ Returns whether we should bypass proxies or not. """ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper()) # First check whether no_proxy is defined. If it is, check that the URL # we're getting isn't in the no_proxy list. no_proxy = get_pr...
def should_bypass_proxies(url): """ Returns whether we should bypass proxies or not. """ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper()) # First check whether no_proxy is defined. If it is, check that the URL # we're getting isn't in the no_proxy list. no_proxy = get_pr...
[ "Returns", "whether", "we", "should", "bypass", "proxies", "or", "not", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L487-L530
[ "def", "should_bypass_proxies", "(", "url", ")", ":", "get_proxy", "=", "lambda", "k", ":", "os", ".", "environ", ".", "get", "(", "k", ")", "or", "os", ".", "environ", ".", "get", "(", "k", ".", "upper", "(", ")", ")", "# First check whether no_proxy ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
default_user_agent
Return a string representing the default user agent.
be/vendor/requests/utils.py
def default_user_agent(name="python-requests"): """Return a string representing the default user agent.""" _implementation = platform.python_implementation() if _implementation == 'CPython': _implementation_version = platform.python_version() elif _implementation == 'PyPy': _implementat...
def default_user_agent(name="python-requests"): """Return a string representing the default user agent.""" _implementation = platform.python_implementation() if _implementation == 'CPython': _implementation_version = platform.python_version() elif _implementation == 'PyPy': _implementat...
[ "Return", "a", "string", "representing", "the", "default", "user", "agent", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L540-L568
[ "def", "default_user_agent", "(", "name", "=", "\"python-requests\"", ")", ":", "_implementation", "=", "platform", ".", "python_implementation", "(", ")", "if", "_implementation", "==", "'CPython'", ":", "_implementation_version", "=", "platform", ".", "python_versio...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
to_native_string
Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise.
be/vendor/requests/utils.py
def to_native_string(string, encoding='ascii'): """ Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise. """ out = None if isinstance(string, builtin_str...
def to_native_string(string, encoding='ascii'): """ Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise. """ out = None if isinstance(string, builtin_str...
[ "Given", "a", "string", "object", "regardless", "of", "type", "returns", "a", "representation", "of", "that", "string", "in", "the", "native", "string", "type", "encoding", "and", "decoding", "where", "necessary", ".", "This", "assumes", "ASCII", "unless", "to...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L676-L692
[ "def", "to_native_string", "(", "string", ",", "encoding", "=", "'ascii'", ")", ":", "out", "=", "None", "if", "isinstance", "(", "string", ",", "builtin_str", ")", ":", "out", "=", "string", "else", ":", "if", "is_py2", ":", "out", "=", "string", ".",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
_bashcomplete
Internal handler for the bash completion support.
be/vendor/click/core.py
def _bashcomplete(cmd, prog_name, complete_var=None): """Internal handler for the bash completion support.""" if complete_var is None: complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper() complete_instr = os.environ.get(complete_var) if not complete_instr: return fr...
def _bashcomplete(cmd, prog_name, complete_var=None): """Internal handler for the bash completion support.""" if complete_var is None: complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper() complete_instr = os.environ.get(complete_var) if not complete_instr: return fr...
[ "Internal", "handler", "for", "the", "bash", "completion", "support", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L25-L35
[ "def", "_bashcomplete", "(", "cmd", ",", "prog_name", ",", "complete_var", "=", "None", ")", ":", "if", "complete_var", "is", "None", ":", "complete_var", "=", "'_%s_COMPLETE'", "%", "(", "prog_name", ".", "replace", "(", "'-'", ",", "'_'", ")", ")", "."...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Context.invoke
Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first argument is a click command object. In t...
be/vendor/click/core.py
def invoke(*args, **kwargs): """Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first a...
def invoke(*args, **kwargs): """Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first a...
[ "Invokes", "a", "command", "callback", "in", "exactly", "the", "way", "it", "expects", ".", "There", "are", "two", "ways", "to", "invoke", "this", "method", ":" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L418-L475
[ "def", "invoke", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ",", "callback", "=", "args", "[", ":", "2", "]", "ctx", "=", "self", "# This is just to improve the error message in cases where old", "# code incorrectly invoked this method. This will ev...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
BaseCommand.make_context
This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation. Generally this is the most descriptive name fo...
be/vendor/click/core.py
def make_context(self, info_name, args, parent=None, **extra): """This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation....
def make_context(self, info_name, args, parent=None, **extra): """This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation....
[ "This", "function", "when", "given", "an", "info", "name", "and", "arguments", "will", "kick", "off", "the", "parsing", "and", "create", "a", "new", ":", "class", ":", "Context", ".", "It", "does", "not", "invoke", "the", "actual", "command", "callback", ...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L541-L561
[ "def", "make_context", "(", "self", ",", "info_name", ",", "args", ",", "parent", "=", "None", ",", "*", "*", "extra", ")", ":", "for", "key", ",", "value", "in", "iteritems", "(", "self", ".", "context_settings", ")", ":", "if", "key", "not", "in", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
BaseCommand.main
This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``SystemExit`` needs to be caught. This method is also available by directly calling the instance of ...
be/vendor/click/core.py
def main(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra): """This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``Syste...
def main(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra): """This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``Syste...
[ "This", "is", "the", "way", "to", "invoke", "a", "script", "with", "all", "the", "bells", "and", "whistles", "as", "a", "command", "line", "application", ".", "This", "will", "always", "terminate", "the", "application", "after", "a", "call", ".", "If", "...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L577-L660
[ "def", "main", "(", "self", ",", "args", "=", "None", ",", "prog_name", "=", "None", ",", "complete_var", "=", "None", ",", "standalone_mode", "=", "True", ",", "*", "*", "extra", ")", ":", "# If we are in Python 3, we will verify that the environment is", "# sa...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Command.make_parser
Creates the underlying option parser for this command.
be/vendor/click/core.py
def make_parser(self, ctx): """Creates the underlying option parser for this command.""" parser = OptionParser(ctx) parser.allow_interspersed_args = ctx.allow_interspersed_args parser.ignore_unknown_options = ctx.ignore_unknown_options for param in self.get_params(ctx): ...
def make_parser(self, ctx): """Creates the underlying option parser for this command.""" parser = OptionParser(ctx) parser.allow_interspersed_args = ctx.allow_interspersed_args parser.ignore_unknown_options = ctx.ignore_unknown_options for param in self.get_params(ctx): ...
[ "Creates", "the", "underlying", "option", "parser", "for", "this", "command", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L758-L765
[ "def", "make_parser", "(", "self", ",", "ctx", ")", ":", "parser", "=", "OptionParser", "(", "ctx", ")", "parser", ".", "allow_interspersed_args", "=", "ctx", ".", "allow_interspersed_args", "parser", ".", "ignore_unknown_options", "=", "ctx", ".", "ignore_unkno...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Command.format_help_text
Writes the help text to the formatter if it exists.
be/vendor/click/core.py
def format_help_text(self, ctx, formatter): """Writes the help text to the formatter if it exists.""" if self.help: formatter.write_paragraph() with formatter.indentation(): formatter.write_text(self.help)
def format_help_text(self, ctx, formatter): """Writes the help text to the formatter if it exists.""" if self.help: formatter.write_paragraph() with formatter.indentation(): formatter.write_text(self.help)
[ "Writes", "the", "help", "text", "to", "the", "formatter", "if", "it", "exists", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L790-L795
[ "def", "format_help_text", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "if", "self", ".", "help", ":", "formatter", ".", "write_paragraph", "(", ")", "with", "formatter", ".", "indentation", "(", ")", ":", "formatter", ".", "write_text", "(", "s...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
Group.add_command
Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used.
be/vendor/click/core.py
def add_command(self, cmd, name=None): """Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used. """ name = name or cmd.name if name is None: raise TypeError('Command has no name.') self.commands[name...
def add_command(self, cmd, name=None): """Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used. """ name = name or cmd.name if name is None: raise TypeError('Command has no name.') self.commands[name...
[ "Registers", "another", ":", "class", ":", "Command", "with", "this", "group", ".", "If", "the", "name", "is", "not", "provided", "the", "name", "of", "the", "command", "is", "used", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L1071-L1078
[ "def", "add_command", "(", "self", ",", "cmd", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "cmd", ".", "name", "if", "name", "is", "None", ":", "raise", "TypeError", "(", "'Command has no name.'", ")", "self", ".", "commands", "[", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
pass_obj
Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system.
be/vendor/click/decorators.py
def pass_obj(f): """Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system. """ @pass_context def new_func(*args, **kwargs): ctx = args[0] return ctx.invoke(f, ...
def pass_obj(f): """Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system. """ @pass_context def new_func(*args, **kwargs): ctx = args[0] return ctx.invoke(f, ...
[ "Similar", "to", ":", "func", ":", "pass_context", "but", "only", "pass", "the", "object", "on", "the", "context", "onwards", "(", ":", "attr", ":", "Context", ".", "obj", ")", ".", "This", "is", "useful", "if", "that", "object", "represents", "the", "...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/decorators.py#L18-L27
[ "def", "pass_obj", "(", "f", ")", ":", "@", "pass_context", "def", "new_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "args", "[", "0", "]", "return", "ctx", ".", "invoke", "(", "f", ",", "ctx", ".", "obj", ",", "*", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
option
Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attaching it to the :attr:`Command.params` list. ...
be/vendor/click/decorators.py
def option(*param_decls, **attrs): """Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attachin...
def option(*param_decls, **attrs): """Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attachin...
[ "Attaches", "an", "option", "to", "the", "command", ".", "All", "positional", "arguments", "are", "passed", "as", "parameter", "declarations", "to", ":", "class", ":", "Option", ";", "all", "keyword", "arguments", "are", "forwarded", "unchanged", "(", "except"...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/decorators.py#L153-L169
[ "def", "option", "(", "*", "param_decls", ",", "*", "*", "attrs", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "'help'", "in", "attrs", ":", "attrs", "[", "'help'", "]", "=", "inspect", ".", "cleandoc", "(", "attrs", "[", "'help'", "]", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
version_option
Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. If not provided Click attempts an auto disc...
be/vendor/click/decorators.py
def version_option(version=None, *param_decls, **attrs): """Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. ...
def version_option(version=None, *param_decls, **attrs): """Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. ...
[ "Adds", "a", "--", "version", "option", "which", "immediately", "ends", "the", "program", "printing", "out", "the", "version", "number", ".", "This", "is", "implemented", "as", "an", "eager", "option", "that", "prints", "the", "version", "and", "exits", "the...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/decorators.py#L222-L273
[ "def", "version_option", "(", "version", "=", "None", ",", "*", "param_decls", ",", "*", "*", "attrs", ")", ":", "if", "version", "is", "None", ":", "module", "=", "sys", ".", "_getframe", "(", "1", ")", ".", "f_globals", ".", "get", "(", "'__name__'...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
_basic_auth_str
Returns a Basic Auth string.
be/vendor/requests/auth.py
def _basic_auth_str(username, password): """Returns a Basic Auth string.""" authstr = 'Basic ' + to_native_string( b64encode(('%s:%s' % (username, password)).encode('latin1')).strip() ) return authstr
def _basic_auth_str(username, password): """Returns a Basic Auth string.""" authstr = 'Basic ' + to_native_string( b64encode(('%s:%s' % (username, password)).encode('latin1')).strip() ) return authstr
[ "Returns", "a", "Basic", "Auth", "string", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/auth.py#L26-L33
[ "def", "_basic_auth_str", "(", "username", ",", "password", ")", ":", "authstr", "=", "'Basic '", "+", "to_native_string", "(", "b64encode", "(", "(", "'%s:%s'", "%", "(", "username", ",", "password", ")", ")", ".", "encode", "(", "'latin1'", ")", ")", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
ls
List topic from external datastore Arguments: topic (str): One or more topics, e.g. ("project", "item", "task") root (str, optional): Absolute path to where projects reside, defaults to os.getcwd() backend (callable, optional): Function to call with absolute path as ...
be/util.py
def ls(*topic, **kwargs): """List topic from external datastore Arguments: topic (str): One or more topics, e.g. ("project", "item", "task") root (str, optional): Absolute path to where projects reside, defaults to os.getcwd() backend (callable, optional): Function to call w...
def ls(*topic, **kwargs): """List topic from external datastore Arguments: topic (str): One or more topics, e.g. ("project", "item", "task") root (str, optional): Absolute path to where projects reside, defaults to os.getcwd() backend (callable, optional): Function to call w...
[ "List", "topic", "from", "external", "datastore" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/util.py#L7-L82
[ "def", "ls", "(", "*", "topic", ",", "*", "*", "kwargs", ")", ":", "context", "=", "dump", "(", ")", "root", "=", "kwargs", ".", "get", "(", "\"root\"", ")", "or", "context", ".", "get", "(", "\"cwd\"", ")", "or", "os", ".", "getcwd", "(", ")",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
dump
Dump current environment as a dictionary Arguments: context (dict, optional): Current context, defaults to the current environment.
be/util.py
def dump(context=os.environ): """Dump current environment as a dictionary Arguments: context (dict, optional): Current context, defaults to the current environment. """ output = {} for key, value in context.iteritems(): if not key.startswith("BE_"): continu...
def dump(context=os.environ): """Dump current environment as a dictionary Arguments: context (dict, optional): Current context, defaults to the current environment. """ output = {} for key, value in context.iteritems(): if not key.startswith("BE_"): continu...
[ "Dump", "current", "environment", "as", "a", "dictionary" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/util.py#L100-L115
[ "def", "dump", "(", "context", "=", "os", ".", "environ", ")", ":", "output", "=", "{", "}", "for", "key", ",", "value", "in", "context", ".", "iteritems", "(", ")", ":", "if", "not", "key", ".", "startswith", "(", "\"BE_\"", ")", ":", "continue", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
cwd
Return the be current working directory
be/_extern.py
def cwd(): """Return the be current working directory""" cwd = os.environ.get("BE_CWD") if cwd and not os.path.isdir(cwd): sys.stderr.write("ERROR: %s is not a directory" % cwd) sys.exit(lib.USER_ERROR) return cwd or os.getcwd().replace("\\", "/")
def cwd(): """Return the be current working directory""" cwd = os.environ.get("BE_CWD") if cwd and not os.path.isdir(cwd): sys.stderr.write("ERROR: %s is not a directory" % cwd) sys.exit(lib.USER_ERROR) return cwd or os.getcwd().replace("\\", "/")
[ "Return", "the", "be", "current", "working", "directory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L52-L58
[ "def", "cwd", "(", ")", ":", "cwd", "=", "os", ".", "environ", ".", "get", "(", "\"BE_CWD\"", ")", "if", "cwd", "and", "not", "os", ".", "path", ".", "isdir", "(", "cwd", ")", ":", "sys", ".", "stderr", ".", "write", "(", "\"ERROR: %s is not a dire...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
write_script
Write script to a temporary directory Arguments: script (list): Commands which to put into a file Returns: Absolute path to script
be/_extern.py
def write_script(script, tempdir): """Write script to a temporary directory Arguments: script (list): Commands which to put into a file Returns: Absolute path to script """ name = "script" + self.suffix path = os.path.join(tempdir, name) with open(path, "w") as f: ...
def write_script(script, tempdir): """Write script to a temporary directory Arguments: script (list): Commands which to put into a file Returns: Absolute path to script """ name = "script" + self.suffix path = os.path.join(tempdir, name) with open(path, "w") as f: ...
[ "Write", "script", "to", "a", "temporary", "directory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L105-L122
[ "def", "write_script", "(", "script", ",", "tempdir", ")", ":", "name", "=", "\"script\"", "+", "self", ".", "suffix", "path", "=", "os", ".", "path", ".", "join", "(", "tempdir", ",", "name", ")", "with", "open", "(", "path", ",", "\"w\"", ")", "a...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
write_aliases
Write aliases to temporary directory Arguments: aliases (dict): {name: value} dict of aliases tempdir (str): Absolute path to where aliases will be stored
be/_extern.py
def write_aliases(aliases, tempdir): """Write aliases to temporary directory Arguments: aliases (dict): {name: value} dict of aliases tempdir (str): Absolute path to where aliases will be stored """ platform = lib.platform() if platform == "unix": home_alias = "cd $BE_DEVE...
def write_aliases(aliases, tempdir): """Write aliases to temporary directory Arguments: aliases (dict): {name: value} dict of aliases tempdir (str): Absolute path to where aliases will be stored """ platform = lib.platform() if platform == "unix": home_alias = "cd $BE_DEVE...
[ "Write", "aliases", "to", "temporary", "directory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L125-L160
[ "def", "write_aliases", "(", "aliases", ",", "tempdir", ")", ":", "platform", "=", "lib", ".", "platform", "(", ")", "if", "platform", "==", "\"unix\"", ":", "home_alias", "=", "\"cd $BE_DEVELOPMENTDIR\"", "else", ":", "home_alias", "=", "\"cd %BE_DEVELOPMENTDIR...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
presets_dir
Return presets directory
be/_extern.py
def presets_dir(): """Return presets directory""" default_presets_dir = os.path.join( os.path.expanduser("~"), ".be", "presets") presets_dir = os.environ.get(BE_PRESETSDIR) or default_presets_dir if not os.path.exists(presets_dir): os.makedirs(presets_dir) return presets_dir
def presets_dir(): """Return presets directory""" default_presets_dir = os.path.join( os.path.expanduser("~"), ".be", "presets") presets_dir = os.environ.get(BE_PRESETSDIR) or default_presets_dir if not os.path.exists(presets_dir): os.makedirs(presets_dir) return presets_dir
[ "Return", "presets", "directory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L168-L175
[ "def", "presets_dir", "(", ")", ":", "default_presets_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "\".be\"", ",", "\"presets\"", ")", "presets_dir", "=", "os", ".", "environ", ".", "get"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
remove_preset
Physically delete local preset Arguments: preset (str): Name of preset
be/_extern.py
def remove_preset(preset): """Physically delete local preset Arguments: preset (str): Name of preset """ preset_dir = os.path.join(presets_dir(), preset) try: shutil.rmtree(preset_dir) except IOError: lib.echo("\"%s\" did not exist" % preset)
def remove_preset(preset): """Physically delete local preset Arguments: preset (str): Name of preset """ preset_dir = os.path.join(presets_dir(), preset) try: shutil.rmtree(preset_dir) except IOError: lib.echo("\"%s\" did not exist" % preset)
[ "Physically", "delete", "local", "preset" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L178-L191
[ "def", "remove_preset", "(", "preset", ")", ":", "preset_dir", "=", "os", ".", "path", ".", "join", "(", "presets_dir", "(", ")", ",", "preset", ")", "try", ":", "shutil", ".", "rmtree", "(", "preset_dir", ")", "except", "IOError", ":", "lib", ".", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
get
requests.get wrapper
be/_extern.py
def get(path, **kwargs): """requests.get wrapper""" token = os.environ.get(BE_GITHUB_API_TOKEN) if token: kwargs["headers"] = { "Authorization": "token %s" % token } try: response = requests.get(path, verify=False, **kwargs) if response.status_code == 403: ...
def get(path, **kwargs): """requests.get wrapper""" token = os.environ.get(BE_GITHUB_API_TOKEN) if token: kwargs["headers"] = { "Authorization": "token %s" % token } try: response = requests.get(path, verify=False, **kwargs) if response.status_code == 403: ...
[ "requests", ".", "get", "wrapper" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L194-L216
[ "def", "get", "(", "path", ",", "*", "*", "kwargs", ")", ":", "token", "=", "os", ".", "environ", ".", "get", "(", "BE_GITHUB_API_TOKEN", ")", "if", "token", ":", "kwargs", "[", "\"headers\"", "]", "=", "{", "\"Authorization\"", ":", "\"token %s\"", "%...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
_gist_is_preset
Evaluate whether gist is a be package Arguments: gist (str): username/id pair e.g. mottosso/2bb4651a05af85711cde
be/_extern.py
def _gist_is_preset(repo): """Evaluate whether gist is a be package Arguments: gist (str): username/id pair e.g. mottosso/2bb4651a05af85711cde """ _, gistid = repo.split("/") gist_template = "https://api.github.com/gists/{}" gist_path = gist_template.format(gistid) response = ge...
def _gist_is_preset(repo): """Evaluate whether gist is a be package Arguments: gist (str): username/id pair e.g. mottosso/2bb4651a05af85711cde """ _, gistid = repo.split("/") gist_template = "https://api.github.com/gists/{}" gist_path = gist_template.format(gistid) response = ge...
[ "Evaluate", "whether", "gist", "is", "a", "be", "package" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L239-L272
[ "def", "_gist_is_preset", "(", "repo", ")", ":", "_", ",", "gistid", "=", "repo", ".", "split", "(", "\"/\"", ")", "gist_template", "=", "\"https://api.github.com/gists/{}\"", "gist_path", "=", "gist_template", ".", "format", "(", "gistid", ")", "response", "=...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
_repo_is_preset
Evaluate whether GitHub repository is a be package Arguments: gist (str): username/id pair e.g. mottosso/be-ad
be/_extern.py
def _repo_is_preset(repo): """Evaluate whether GitHub repository is a be package Arguments: gist (str): username/id pair e.g. mottosso/be-ad """ package_template = "https://raw.githubusercontent.com" package_template += "/{repo}/master/package.json" package_path = package_template.for...
def _repo_is_preset(repo): """Evaluate whether GitHub repository is a be package Arguments: gist (str): username/id pair e.g. mottosso/be-ad """ package_template = "https://raw.githubusercontent.com" package_template += "/{repo}/master/package.json" package_path = package_template.for...
[ "Evaluate", "whether", "GitHub", "repository", "is", "a", "be", "package" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L275-L299
[ "def", "_repo_is_preset", "(", "repo", ")", ":", "package_template", "=", "\"https://raw.githubusercontent.com\"", "package_template", "+=", "\"/{repo}/master/package.json\"", "package_path", "=", "package_template", ".", "format", "(", "repo", "=", "repo", ")", "response...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
github_presets
Return remote presets hosted on GitHub
be/_extern.py
def github_presets(): """Return remote presets hosted on GitHub""" addr = ("https://raw.githubusercontent.com" "/mottosso/be-presets/master/presets.json") response = get(addr) if response.status_code == 404: lib.echo("Could not connect with preset database") sys.exit(lib.PRO...
def github_presets(): """Return remote presets hosted on GitHub""" addr = ("https://raw.githubusercontent.com" "/mottosso/be-presets/master/presets.json") response = get(addr) if response.status_code == 404: lib.echo("Could not connect with preset database") sys.exit(lib.PRO...
[ "Return", "remote", "presets", "hosted", "on", "GitHub" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L383-L394
[ "def", "github_presets", "(", ")", ":", "addr", "=", "(", "\"https://raw.githubusercontent.com\"", "\"/mottosso/be-presets/master/presets.json\"", ")", "response", "=", "get", "(", "addr", ")", "if", "response", ".", "status_code", "==", "404", ":", "lib", ".", "e...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
copy_preset
Copy contents of preset into new project If package.json contains the key "contents", limit the files copied to those present in this list. Arguments: preset_dir (str): Absolute path to preset project_dir (str): Absolute path to new project
be/_extern.py
def copy_preset(preset_dir, project_dir): """Copy contents of preset into new project If package.json contains the key "contents", limit the files copied to those present in this list. Arguments: preset_dir (str): Absolute path to preset project_dir (str): Absolute path to new project ...
def copy_preset(preset_dir, project_dir): """Copy contents of preset into new project If package.json contains the key "contents", limit the files copied to those present in this list. Arguments: preset_dir (str): Absolute path to preset project_dir (str): Absolute path to new project ...
[ "Copy", "contents", "of", "preset", "into", "new", "project" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L397-L427
[ "def", "copy_preset", "(", "preset_dir", ",", "project_dir", ")", ":", "os", ".", "makedirs", "(", "project_dir", ")", "package_file", "=", "os", ".", "path", ".", "join", "(", "preset_dir", ",", "\"package.json\"", ")", "with", "open", "(", "package_file", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
_resolve_references
Resolve {@} occurences by expansion Given a dictionary {"a": "{@b}/x", "b": "{key}/y"} Return {"a", "{key}/y/x", "b": "{key}/y"} { key: {@reference}/{variable} # pattern } In plain english, it looks within `pattern` for references and replaces them with the value of the matching k...
be/_extern.py
def _resolve_references(templates): """Resolve {@} occurences by expansion Given a dictionary {"a": "{@b}/x", "b": "{key}/y"} Return {"a", "{key}/y/x", "b": "{key}/y"} { key: {@reference}/{variable} # pattern } In plain english, it looks within `pattern` for references and replace...
def _resolve_references(templates): """Resolve {@} occurences by expansion Given a dictionary {"a": "{@b}/x", "b": "{key}/y"} Return {"a", "{key}/y/x", "b": "{key}/y"} { key: {@reference}/{variable} # pattern } In plain english, it looks within `pattern` for references and replace...
[ "Resolve", "{", "@", "}", "occurences", "by", "expansion" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L430-L474
[ "def", "_resolve_references", "(", "templates", ")", ":", "def", "repl", "(", "match", ")", ":", "lib", ".", "echo", "(", "\"Deprecation warning: The {@ref} syntax is being removed\"", ")", "key", "=", "pattern", "[", "match", ".", "start", "(", ")", ":", "mat...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPHeaderDict.add
Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz'
be/vendor/requests/packages/urllib3/_collections.py
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = key...
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = key...
[ "Adds", "a", "(", "name", "value", ")", "pair", "doesn", "t", "overwrite", "the", "value", "if", "it", "already", "exists", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L207-L228
[ "def", "add", "(", "self", ",", "key", ",", "val", ")", ":", "key_lower", "=", "key", ".", "lower", "(", ")", "new_vals", "=", "key", ",", "val", "# Keep the common case aka no item present as fast as possible", "vals", "=", "_dict_setdefault", "(", "self", ",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPHeaderDict.getlist
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.
be/vendor/requests/packages/urllib3/_collections.py
def getlist(self, key): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = _dict_getitem(self, key.lower()) except KeyError: return [] else: if isinstance(vals, tuple): ...
def getlist(self, key): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = _dict_getitem(self, key.lower()) except KeyError: return [] else: if isinstance(vals, tuple): ...
[ "Returns", "a", "list", "of", "all", "the", "values", "for", "the", "named", "field", ".", "Returns", "an", "empty", "list", "if", "the", "key", "doesn", "t", "exist", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L256-L267
[ "def", "getlist", "(", "self", ",", "key", ")", ":", "try", ":", "vals", "=", "_dict_getitem", "(", "self", ",", "key", ".", "lower", "(", ")", ")", "except", "KeyError", ":", "return", "[", "]", "else", ":", "if", "isinstance", "(", "vals", ",", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPHeaderDict.iteritems
Iterate over all header lines, including duplicate ones.
be/vendor/requests/packages/urllib3/_collections.py
def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = _dict_getitem(self, key) for val in vals[1:]: yield vals[0], val
def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = _dict_getitem(self, key) for val in vals[1:]: yield vals[0], val
[ "Iterate", "over", "all", "header", "lines", "including", "duplicate", "ones", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L290-L295
[ "def", "iteritems", "(", "self", ")", ":", "for", "key", "in", "self", ":", "vals", "=", "_dict_getitem", "(", "self", ",", "key", ")", "for", "val", "in", "vals", "[", "1", ":", "]", ":", "yield", "vals", "[", "0", "]", ",", "val" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPHeaderDict.itermerged
Iterate over all headers, merging duplicate ones together.
be/vendor/requests/packages/urllib3/_collections.py
def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = _dict_getitem(self, key) yield val[0], ', '.join(val[1:])
def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = _dict_getitem(self, key) yield val[0], ', '.join(val[1:])
[ "Iterate", "over", "all", "headers", "merging", "duplicate", "ones", "together", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L297-L301
[ "def", "itermerged", "(", "self", ")", ":", "for", "key", "in", "self", ":", "val", "=", "_dict_getitem", "(", "self", ",", "key", ")", "yield", "val", "[", "0", "]", ",", "', '", ".", "join", "(", "val", "[", "1", ":", "]", ")" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPHeaderDict.from_httplib
Read headers from a Python 2 httplib message object.
be/vendor/requests/packages/urllib3/_collections.py
def from_httplib(cls, message, duplicates=('set-cookie',)): # Python 2 """Read headers from a Python 2 httplib message object.""" ret = cls(message.items()) # ret now contains only the last header line for each duplicate. # Importing with all duplicates would be nice, but this would ...
def from_httplib(cls, message, duplicates=('set-cookie',)): # Python 2 """Read headers from a Python 2 httplib message object.""" ret = cls(message.items()) # ret now contains only the last header line for each duplicate. # Importing with all duplicates would be nice, but this would ...
[ "Read", "headers", "from", "a", "Python", "2", "httplib", "message", "object", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L307-L320
[ "def", "from_httplib", "(", "cls", ",", "message", ",", "duplicates", "=", "(", "'set-cookie'", ",", ")", ")", ":", "# Python 2", "ret", "=", "cls", "(", "message", ".", "items", "(", ")", ")", "# ret now contains only the last header line for each duplicate.", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
RequestMethods.request_encode_url
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
be/vendor/requests/packages/urllib3/request.py
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): """ 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) ...
[ "Make", "a", "request", "using", ":", "meth", ":", "urlopen", "with", "the", "fields", "encoded", "in", "the", "url", ".", "This", "is", "useful", "for", "request", "methods", "like", "GET", "HEAD", "DELETE", "etc", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/request.py#L74-L81
[ "def", "request_encode_url", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "*", "*", "urlopen_kw", ")", ":", "if", "fields", ":", "url", "+=", "'?'", "+", "urlencode", "(", "fields", ")", "return", "self", ".", "urlopen", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
make_str
Converts a value into a valid string.
be/vendor/click/utils.py
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): """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)
[ "Converts", "a", "value", "into", "a", "valid", "string", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/utils.py#L89-L96
[ "def", "make_str", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "try", ":", "return", "value", ".", "decode", "(", "sys", ".", "getfilesystemencoding", "(", ")", ")", "except", "UnicodeError", ":", "return", "value", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
echo
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...
be/vendor/click/utils.py
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): """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...
[ "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"...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/utils.py#L213-L296
[ "def", "echo", "(", "message", "=", "None", ",", "file", "=", "None", ",", "nl", "=", "True", ",", "err", "=", "False", ",", "color", "=", "None", ")", ":", "if", "file", "is", "None", ":", "if", "err", ":", "file", "=", "_default_text_stderr", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
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.exe, then the full ...
be/lib.py
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(): """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...
[ "Determine", "subshell", "matching", "the", "currently", "running", "shell" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L23-L67
[ "def", "parent", "(", ")", ":", "if", "self", ".", "_parent", ":", "return", "self", ".", "_parent", "if", "\"BE_SHELL\"", "in", "os", ".", "environ", ":", "self", ".", "_parent", "=", "os", ".", "environ", "[", "\"BE_SHELL\"", "]", "else", ":", "# I...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
platform
Return platform for the current shell, e.g. windows or unix
be/lib.py
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(): """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...
[ "Return", "platform", "for", "the", "current", "shell", "e", ".", "g", ".", "windows", "or", "unix" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L70-L81
[ "def", "platform", "(", ")", ":", "executable", "=", "parent", "(", ")", "basename", "=", "os", ".", "path", ".", "basename", "(", "executable", ")", "basename", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "basename", ")", "if", "basename...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
cmd
Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable
be/lib.py
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): """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")...
[ "Determine", "subshell", "command", "for", "subprocess", ".", "call" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L84-L114
[ "def", "cmd", "(", "parent", ")", ":", "shell_name", "=", "os", ".", "path", ".", "basename", "(", "parent", ")", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "0", "]", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
context
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.
be/lib.py
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=""): """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":...
[ "Produce", "the", "be", "environment" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L117-L152
[ "def", "context", "(", "root", ",", "project", "=", "\"\"", ")", ":", "environment", "=", "os", ".", "environ", ".", "copy", "(", ")", "environment", ".", "update", "(", "{", "\"BE_PROJECT\"", ":", "project", ",", "\"BE_PROJECTROOT\"", ":", "(", "os", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
random_name
Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus
be/lib.py
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(): """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" ...
[ "Return", "a", "random", "name" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L155-L168
[ "def", "random_name", "(", ")", ":", "adj", "=", "_data", ".", "adjectives", "[", "random", ".", "randint", "(", "0", ",", "len", "(", "_data", ".", "adjectives", ")", "-", "1", ")", "]", "noun", "=", "_data", ".", "nouns", "[", "random", ".", "r...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
isproject
Return whether or not `path` is a project Arguments: path (str): Absolute path
be/lib.py
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): """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...
[ "Return", "whether", "or", "not", "path", "is", "a", "project" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L171-L191
[ "def", "isproject", "(", "path", ")", ":", "try", ":", "if", "os", ".", "path", ".", "basename", "(", "path", ")", "[", "0", "]", "in", "(", "\".\"", ",", "\"_\"", ")", ":", "return", "False", "if", "not", "os", ".", "path", ".", "isdir", "(", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
echo
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.
be/lib.py
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): """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 ...
[ "Print", "to", "the", "console" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L194-L206
[ "def", "echo", "(", "text", ",", "silent", "=", "False", ",", "newline", "=", "True", ")", ":", "if", "silent", ":", "return", "print", "(", "text", ")", "if", "newline", "else", "sys", ".", "stdout", ".", "write", "(", "text", ")" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
list_projects
List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory.
be/lib.py
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): """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...
[ "List", "projects", "at", "root" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L209-L223
[ "def", "list_projects", "(", "root", ",", "backend", "=", "os", ".", "listdir", ")", ":", "projects", "=", "list", "(", ")", "for", "project", "in", "sorted", "(", "backend", "(", "root", ")", ")", ":", "abspath", "=", "os", ".", "path", ".", "join...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
list_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
be/lib.py
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): """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...
[ "List", "a", "projects", "inventory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L226-L242
[ "def", "list_inventory", "(", "inventory", ")", ":", "inverted", "=", "invert_inventory", "(", "inventory", ")", "items", "=", "list", "(", ")", "for", "item", "in", "sorted", "(", "inverted", ",", "key", "=", "lambda", "a", ":", "(", "inverted", "[", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
list_template
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...
be/lib.py
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): """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...
[ "List", "contents", "for", "resolved", "template" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L245-L324
[ "def", "list_template", "(", "root", ",", "topics", ",", "templates", ",", "inventory", ",", "be", ",", "absolute", "=", "False", ")", ":", "project", "=", "topics", "[", "0", "]", "# Get item", "try", ":", "key", "=", "be", ".", "get", "(", "\"templ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
invert_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
be/lib.py
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): """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...
[ "Return", "{", "item", ":", "binding", "}", "from", "{", "binding", ":", "item", "}" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L327-L351
[ "def", "invert_inventory", "(", "inventory", ")", ":", "inverted", "=", "dict", "(", ")", "for", "binding", ",", "items", "in", "inventory", ".", "iteritems", "(", ")", ":", "for", "item", "in", "items", ":", "if", "isinstance", "(", "item", ",", "dict...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
pos_development_directory
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...
be/lib.py
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): """Return absolute path to development directory Arguments: templates (...
[ "Return", "absolute", "path", "to", "development", "directory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L358-L395
[ "def", "pos_development_directory", "(", "templates", ",", "inventory", ",", "context", ",", "topics", ",", "user", ",", "item", ")", ":", "replacement_fields", "=", "replacement_fields_from_context", "(", "context", ")", "binding", "=", "binding_from_item", "(", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
fixed_development_directory
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
be/lib.py
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): """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` ...
[ "Return", "absolute", "path", "to", "development", "directory" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L398-L439
[ "def", "fixed_development_directory", "(", "templates", ",", "inventory", ",", "topics", ",", "user", ")", ":", "echo", "(", "\"Fixed syntax has been deprecated, see positional syntax\"", ")", "project", ",", "item", ",", "task", "=", "topics", "[", "0", "]", ".",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
replacement_fields_from_context
Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context
be/lib.py
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): """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_"))
[ "Convert", "context", "replacement", "fields" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L442-L454
[ "def", "replacement_fields_from_context", "(", "context", ")", ":", "return", "dict", "(", "(", "k", "[", "3", ":", "]", ".", "lower", "(", ")", ",", "context", "[", "k", "]", ")", "for", "k", "in", "context", "if", "k", ".", "startswith", "(", "\"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
item_from_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 the key
be/lib.py
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): """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...
[ "Get", "binding", "from", "topics", "via", "key" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L457-L484
[ "def", "item_from_topics", "(", "key", ",", "topics", ")", ":", "if", "re", ".", "match", "(", "\"{\\d+}\"", ",", "key", ")", ":", "pos", "=", "int", "(", "key", ".", "strip", "(", "\"{}\"", ")", ")", "try", ":", "binding", "=", "topics", "[", "p...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
pattern_from_template
Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name
be/lib.py
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): """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]
[ "Return", "pattern", "for", "name" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L510-L523
[ "def", "pattern_from_template", "(", "templates", ",", "name", ")", ":", "if", "name", "not", "in", "templates", ":", "echo", "(", "\"No template named \\\"%s\\\"\"", "%", "name", ")", "sys", ".", "exit", "(", "1", ")", "return", "templates", "[", "name", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
binding_from_item
Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item
be/lib.py
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): """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...
[ "Return", "binding", "for", "item" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L526-L552
[ "def", "binding_from_item", "(", "inventory", ",", "item", ")", ":", "if", "item", "in", "self", ".", "bindings", ":", "return", "self", ".", "bindings", "[", "item", "]", "bindings", "=", "invert_inventory", "(", "inventory", ")", "try", ":", "self", "....
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
parse_environment
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}
be/lib.py
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): """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...
[ "Resolve", "the", "be", ".", "yaml", "environment", "key" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L555-L633
[ "def", "parse_environment", "(", "fields", ",", "context", ",", "topics", ")", ":", "def", "_resolve_environment_lists", "(", "context", ")", ":", "\"\"\"Concatenate environment lists\"\"\"", "for", "key", ",", "value", "in", "context", ".", "copy", "(", ")", "....
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
parse_redirect
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
be/lib.py
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): """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" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L636-L653
[ "def", "parse_redirect", "(", "redirect", ",", "topics", ",", "context", ")", ":", "for", "map_source", ",", "map_dest", "in", "redirect", ".", "items", "(", ")", ":", "if", "re", ".", "match", "(", "\"{\\d+}\"", ",", "map_source", ")", ":", "topics_inde...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
slice
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}'
be/lib.py
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): """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...
[ "Slice", "a", "template", "based", "on", "it", "s", "positional", "argument" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L656-L675
[ "def", "slice", "(", "index", ",", "template", ")", ":", "try", ":", "return", "re", ".", "match", "(", "\"^.*{[%i]}\"", "%", "index", ",", "template", ")", ".", "group", "(", ")", "except", "AttributeError", ":", "raise", "ValueError", "(", "\"Index %i ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPAdapter.proxy_manager_for
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...
be/vendor/requests/adapters.py
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): """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...
[ "Return", "urllib3", "ProxyManager", "for", "the", "given", "proxy", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L136-L157
[ "def", "proxy_manager_for", "(", "self", ",", "proxy", ",", "*", "*", "proxy_kwargs", ")", ":", "if", "not", "proxy", "in", "self", ".", "proxy_manager", ":", "proxy_headers", "=", "self", ".", "proxy_headers", "(", "proxy", ")", "self", ".", "proxy_manage...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPAdapter.cert_verify
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. :...
be/vendor/requests/adapters.py
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): """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...
[ "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", ...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L159-L194
[ "def", "cert_verify", "(", "self", ",", "conn", ",", "url", ",", "verify", ",", "cert", ")", ":", "if", "url", ".", "lower", "(", ")", ".", "startswith", "(", "'https'", ")", "and", "verify", ":", "cert_loc", "=", "None", "# Allow self-specified cert loc...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPAdapter.get_connection
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...
be/vendor/requests/adapters.py
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): """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...
[ "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...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L232-L253
[ "def", "get_connection", "(", "self", ",", "url", ",", "proxies", "=", "None", ")", ":", "proxies", "=", "proxies", "or", "{", "}", "proxy", "=", "proxies", ".", "get", "(", "urlparse", "(", "url", ".", "lower", "(", ")", ")", ".", "scheme", ")", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPAdapter.request_url
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 ...
be/vendor/requests/adapters.py
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): """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...
[ "Obtain", "the", "url", "to", "use", "when", "making", "the", "final", "request", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L263-L285
[ "def", "request_url", "(", "self", ",", "request", ",", "proxies", ")", ":", "proxies", "=", "proxies", "or", "{", "}", "scheme", "=", "urlparse", "(", "request", ".", "url", ")", ".", "scheme", "proxy", "=", "proxies", ".", "get", "(", "scheme", ")"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPAdapter.proxy_headers
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...
be/vendor/requests/adapters.py
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): """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...
[ "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", ...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/adapters.py#L301-L321
[ "def", "proxy_headers", "(", "self", ",", "proxy", ")", ":", "headers", "=", "{", "}", "username", ",", "password", "=", "get_auth_from_url", "(", "proxy", ")", "if", "username", "and", "password", ":", "headers", "[", "'Proxy-Authorization'", "]", "=", "_...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
request
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...
be/vendor/requests/api.py
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): """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`...
[ "Constructs", "and", "sends", "a", ":", "class", ":", "Request", "<Request", ">", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/api.py#L17-L55
[ "def", "request", "(", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "session", "=", "sessions", ".", "Session", "(", ")", "response", "=", "session", ".", "request", "(", "method", "=", "method", ",", "url", "=", "url", ",", "*", "*", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
is_connection_dropped
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.
be/vendor/requests/packages/urllib3/util/connection.py
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 """ 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...
[ "Returns", "True", "if", "the", "connection", "is", "dropped", "and", "should", "be", "closed", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/connection.py#L12-L43
[ "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...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
morsel_to_cookie
Convert a Morsel object into a Cookie containing the one k/v pair.
be/vendor/requests/cookies.py
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): """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( ...
[ "Convert", "a", "Morsel", "object", "into", "a", "Cookie", "containing", "the", "one", "k", "/", "v", "pair", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/cookies.py#L397-L421
[ "def", "morsel_to_cookie", "(", "morsel", ")", ":", "expires", "=", "None", "if", "morsel", "[", "'max-age'", "]", ":", "expires", "=", "time", ".", "time", "(", ")", "+", "morsel", "[", "'max-age'", "]", "elif", "morsel", "[", "'expires'", "]", ":", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
RequestsCookieJar.get_dict
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.
be/vendor/requests/cookies.py
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): """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...
[ "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", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/cookies.py#L264-L273
[ "def", "get_dict", "(", "self", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "dictionary", "=", "{", "}", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "(", "domain", "is", "None", "or", "cookie", ".", "domain", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
CharDistributionAnalysis.feed
feed a character with known length
be/vendor/requests/packages/chardet/chardistribution.py
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): """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 +=...
[ "feed", "a", "character", "with", "known", "length" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardistribution.py#L68-L80
[ "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", "=", "-...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
CharDistributionAnalysis.get_confidence
return confidence based on existing data
be/vendor/requests/packages/chardet/chardistribution.py
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): """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...
[ "return", "confidence", "based", "on", "existing", "data" ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardistribution.py#L82-L96
[ "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", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
add_stderr_logger
Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it.
be/vendor/requests/packages/urllib3/__init__.py
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): """ 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...
[ "Helper", "for", "quickly", "adding", "a", "StreamHandler", "to", "the", "logger", ".", "Useful", "for", "debugging", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/__init__.py#L37-L52
[ "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__", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
assert_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.
be/vendor/requests/packages/urllib3/util/ssl_.py
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): """ 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...
[ "Checks", "if", "given", "fingerprint", "matches", "the", "supplied", "certificate", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/ssl_.py#L94-L128
[ "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", ",", "}", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
create_urllib3_context
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...
be/vendor/requests/packages/urllib3/util/ssl_.py
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): """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:...
[ "All", "arguments", "have", "the", "same", "meaning", "as", "ssl_wrap_socket", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/ssl_.py#L170-L227
[ "def", "create_urllib3_context", "(", "ssl_version", "=", "None", ",", "cert_reqs", "=", "ssl", ".", "CERT_REQUIRED", ",", "options", "=", "None", ",", "ciphers", "=", "None", ")", ":", "context", "=", "SSLContext", "(", "ssl_version", "or", "ssl", ".", "P...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
ssl_wrap_socket
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...
be/vendor/requests/packages/urllib3/util/ssl_.py
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=None, ssl_context=None): """ All arguments except for server_hostname and ssl_context have the same meaning as they do when using :fun...
[ "All", "arguments", "except", "for", "server_hostname", "and", "ssl_context", "have", "the", "same", "meaning", "as", "they", "do", "when", "using", ":", "func", ":", "ssl", ".", "wrap_socket", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/ssl_.py#L230-L266
[ "def", "ssl_wrap_socket", "(", "sock", ",", "keyfile", "=", "None", ",", "certfile", "=", "None", ",", "cert_reqs", "=", "None", ",", "ca_certs", "=", "None", ",", "server_hostname", "=", "None", ",", "ssl_version", "=", "None", ",", "ciphers", "=", "Non...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
connection_from_url
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...
be/vendor/requests/packages/urllib3/connectionpool.py
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): """ 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...
[ "Given", "a", "url", "return", "an", ":", "class", ":", ".", "ConnectionPool", "instance", "of", "its", "host", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L772-L796
[ "def", "connection_from_url", "(", "url", ",", "*", "*", "kw", ")", ":", "scheme", ",", "host", ",", "port", "=", "get_host", "(", "url", ")", "if", "scheme", "==", "'https'", ":", "return", "HTTPSConnectionPool", "(", "host", ",", "port", "=", "port",...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPConnectionPool._put_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 because we exceeded maxsize. If connections are...
be/vendor/requests/packages/urllib3/connectionpool.py
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): """ 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 ...
[ "Put", "a", "connection", "back", "into", "the", "pool", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L248-L276
[ "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...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPConnectionPool._make_request
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...
be/vendor/requests/packages/urllib3/connectionpool.py
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): """ 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: ...
[ "Perform", "a", "request", "on", "a", "given", "urllib", "connection", "object", "taken", "from", "our", "pool", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L317-L384
[ "def", "_make_request", "(", "self", ",", "conn", ",", "method", ",", "url", ",", "timeout", "=", "_Default", ",", "*", "*", "httplib_request_kw", ")", ":", "self", ".", "num_requests", "+=", "1", "timeout_obj", "=", "self", ".", "_get_timeout", "(", "ti...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPConnectionPool.urlopen
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 ...
be/vendor/requests/packages/urllib3/connectionpool.py
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, pool_timeout=None, release_conn=None, **response_kw): """ Get a connection from the pool and perform an HTTP request. This is the lowest l...
[ "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", ...
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L421-L650
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "retries", "=", "None", ",", "redirect", "=", "True", ",", "assert_same_host", "=", "True", ",", "timeout", "=", "_Default", ",", "p...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPSConnectionPool._new_conn
Return a fresh :class:`httplib.HTTPSConnection`.
be/vendor/requests/packages/urllib3/connectionpool.py
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): """ 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...
[ "Return", "a", "fresh", ":", "class", ":", "httplib", ".", "HTTPSConnection", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L729-L752
[ "def", "_new_conn", "(", "self", ")", ":", "self", ".", "num_connections", "+=", "1", "log", ".", "info", "(", "\"Starting new HTTPS connection (%d): %s\"", "%", "(", "self", ".", "num_connections", ",", "self", ".", "host", ")", ")", "if", "not", "self", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
HTTPSConnectionPool._validate_conn
Called right before a request is made, after the socket is created.
be/vendor/requests/packages/urllib3/connectionpool.py
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): """ 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...
[ "Called", "right", "before", "a", "request", "is", "made", "after", "the", "socket", "is", "created", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L754-L769
[ "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", ",", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
description_of
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
be/vendor/requests/packages/chardet/chardetect.py
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'): """ 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...
[ "Return", "a", "string", "describing", "the", "probable", "encoding", "of", "a", "file", "or", "list", "of", "strings", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardetect.py#L26-L45
[ "def", "description_of", "(", "lines", ",", "name", "=", "'stdin'", ")", ":", "u", "=", "UniversalDetector", "(", ")", "for", "line", "in", "lines", ":", "u", ".", "feed", "(", "line", ")", "u", ".", "close", "(", ")", "result", "=", "u", ".", "r...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
train
main
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
be/vendor/requests/packages/chardet/chardetect.py
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): ''' 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...
[ "Handles", "command", "line", "arguments", "and", "gets", "things", "started", "." ]
mottosso/be
python
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/chardet/chardetect.py#L48-L76
[ "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"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71