id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
222,200
kennethreitz/legit
legit/cli.py
publish
def publish(scm, to_branch, verbose, fake): """Pushes an unpublished branch to a remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(to_branch) if not branch: branch = scm.get_current_branch_name() ...
python
def publish(scm, to_branch, verbose, fake): """Pushes an unpublished branch to a remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(to_branch) if not branch: branch = scm.get_current_branch_name() ...
[ "def", "publish", "(", "scm", ",", "to_branch", ",", "verbose", ",", "fake", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", "require_remote", "=", "True", ")", "branch", ...
Pushes an unpublished branch to a remote repository.
[ "Pushes", "an", "unpublished", "branch", "to", "a", "remote", "repository", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L181-L207
222,201
kennethreitz/legit
legit/cli.py
unpublish
def unpublish(scm, published_branch, verbose, fake): """Removes a published branch from the remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(published_branch) if not branch: scm.display_available_bra...
python
def unpublish(scm, published_branch, verbose, fake): """Removes a published branch from the remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(published_branch) if not branch: scm.display_available_bra...
[ "def", "unpublish", "(", "scm", ",", "published_branch", ",", "verbose", ",", "fake", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", "require_remote", "=", "True", ")", "br...
Removes a published branch from the remote repository.
[ "Removes", "a", "published", "branch", "from", "the", "remote", "repository", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L215-L235
222,202
kennethreitz/legit
legit/cli.py
undo
def undo(scm, verbose, fake, hard): """Removes the last commit from history.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check() status_log(scm.undo, 'Last commit removed from history.', hard)
python
def undo(scm, verbose, fake, hard): """Removes the last commit from history.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check() status_log(scm.undo, 'Last commit removed from history.', hard)
[ "def", "undo", "(", "scm", ",", "verbose", ",", "fake", ",", "hard", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", ")", "status_log", "(", "scm", ".", "undo", ",", "...
Removes the last commit from history.
[ "Removes", "the", "last", "commit", "from", "history", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L243-L250
222,203
kennethreitz/legit
legit/cli.py
do_install
def do_install(ctx, verbose, fake): """Installs legit git aliases.""" click.echo('The following git aliases will be installed:\n') aliases = cli.list_commands(ctx) output_aliases(aliases) if click.confirm('\n{}Install aliases above?'.format('FAKE ' if fake else ''), default=fake): for alias...
python
def do_install(ctx, verbose, fake): """Installs legit git aliases.""" click.echo('The following git aliases will be installed:\n') aliases = cli.list_commands(ctx) output_aliases(aliases) if click.confirm('\n{}Install aliases above?'.format('FAKE ' if fake else ''), default=fake): for alias...
[ "def", "do_install", "(", "ctx", ",", "verbose", ",", "fake", ")", ":", "click", ".", "echo", "(", "'The following git aliases will be installed:\\n'", ")", "aliases", "=", "cli", ".", "list_commands", "(", "ctx", ")", "output_aliases", "(", "aliases", ")", "i...
Installs legit git aliases.
[ "Installs", "legit", "git", "aliases", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L262-L278
222,204
kennethreitz/legit
legit/cli.py
do_uninstall
def do_uninstall(ctx, verbose, fake): """Uninstalls legit git aliases, including deprecated legit sub-commands.""" aliases = cli.list_commands(ctx) # Add deprecated aliases aliases.extend(['graft', 'harvest', 'sprout', 'resync', 'settings', 'install', 'uninstall']) for alias in aliases: syst...
python
def do_uninstall(ctx, verbose, fake): """Uninstalls legit git aliases, including deprecated legit sub-commands.""" aliases = cli.list_commands(ctx) # Add deprecated aliases aliases.extend(['graft', 'harvest', 'sprout', 'resync', 'settings', 'install', 'uninstall']) for alias in aliases: syst...
[ "def", "do_uninstall", "(", "ctx", ",", "verbose", ",", "fake", ")", ":", "aliases", "=", "cli", ".", "list_commands", "(", "ctx", ")", "# Add deprecated aliases", "aliases", ".", "extend", "(", "[", "'graft'", ",", "'harvest'", ",", "'sprout'", ",", "'res...
Uninstalls legit git aliases, including deprecated legit sub-commands.
[ "Uninstalls", "legit", "git", "aliases", "including", "deprecated", "legit", "sub", "-", "commands", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L281-L293
222,205
kennethreitz/legit
legit/cli.py
do_edit_settings
def do_edit_settings(fake): """Opens legit settings in editor.""" path = resources.user.open('config.ini').name click.echo('Legit Settings:\n') for (option, _, description) in legit_settings.config_defaults: click.echo(columns([crayons.yellow(option), 25], [description, None])) click.echo...
python
def do_edit_settings(fake): """Opens legit settings in editor.""" path = resources.user.open('config.ini').name click.echo('Legit Settings:\n') for (option, _, description) in legit_settings.config_defaults: click.echo(columns([crayons.yellow(option), 25], [description, None])) click.echo...
[ "def", "do_edit_settings", "(", "fake", ")", ":", "path", "=", "resources", ".", "user", ".", "open", "(", "'config.ini'", ")", ".", "name", "click", ".", "echo", "(", "'Legit Settings:\\n'", ")", "for", "(", "option", ",", "_", ",", "description", ")", ...
Opens legit settings in editor.
[ "Opens", "legit", "settings", "in", "editor", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L296-L310
222,206
kennethreitz/legit
legit/cli.py
LegitGroup.get_command
def get_command(self, ctx, cmd_name): """Override to handle command aliases""" rv = click.Group.get_command(self, ctx, cmd_name) if rv is not None: return rv cmd_name = self.command_aliases.get(cmd_name, "") return click.Group.get_command(self, ctx, cmd_name)
python
def get_command(self, ctx, cmd_name): """Override to handle command aliases""" rv = click.Group.get_command(self, ctx, cmd_name) if rv is not None: return rv cmd_name = self.command_aliases.get(cmd_name, "") return click.Group.get_command(self, ctx, cmd_name)
[ "def", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", ":", "rv", "=", "click", ".", "Group", ".", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", "if", "rv", "is", "not", "None", ":", "return", "rv", "cmd_name", "=", "s...
Override to handle command aliases
[ "Override", "to", "handle", "command", "aliases" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L42-L48
222,207
nschloe/meshio
meshio/cli.py
_get_parser
def _get_parser(): """Parse input options.""" import argparse parser = argparse.ArgumentParser(description=("Convert between mesh formats.")) parser.add_argument("infile", type=str, help="mesh file to be read from") parser.add_argument( "--input-format", "-i", type=str, ...
python
def _get_parser(): """Parse input options.""" import argparse parser = argparse.ArgumentParser(description=("Convert between mesh formats.")) parser.add_argument("infile", type=str, help="mesh file to be read from") parser.add_argument( "--input-format", "-i", type=str, ...
[ "def", "_get_parser", "(", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "(", "\"Convert between mesh formats.\"", ")", ")", "parser", ".", "add_argument", "(", "\"infile\"", ",", "type", "=", "str", ...
Parse input options.
[ "Parse", "input", "options", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/cli.py#L43-L93
222,208
nschloe/meshio
meshio/msh_io/main.py
_read_header
def _read_header(f): """Read the mesh format block specified as version(ASCII double; currently 4.1) file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) data-size(ASCII int; sizeof(size_t)) < int with value one; only in binary mode, to detect endianness > though here the ver...
python
def _read_header(f): """Read the mesh format block specified as version(ASCII double; currently 4.1) file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) data-size(ASCII int; sizeof(size_t)) < int with value one; only in binary mode, to detect endianness > though here the ver...
[ "def", "_read_header", "(", "f", ")", ":", "# http://gmsh.info/doc/texinfo/gmsh.html#MSH-file-format", "line", "=", "f", ".", "readline", "(", ")", ".", "decode", "(", "\"utf-8\"", ")", "# Split the line", "# 4.1 0 8", "# into its components.", "str_list", "=", "list"...
Read the mesh format block specified as version(ASCII double; currently 4.1) file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) data-size(ASCII int; sizeof(size_t)) < int with value one; only in binary mode, to detect endianness > though here the version is left as str
[ "Read", "the", "mesh", "format", "block" ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/msh_io/main.py#L48-L81
222,209
nschloe/meshio
meshio/msh_io/main.py
write
def write(filename, mesh, fmt_version, write_binary=True): """Writes a Gmsh msh file. """ try: writer = _writers[fmt_version] except KeyError: try: writer = _writers[fmt_version.split(".")[0]] except KeyError: raise ValueError( "Need mesh f...
python
def write(filename, mesh, fmt_version, write_binary=True): """Writes a Gmsh msh file. """ try: writer = _writers[fmt_version] except KeyError: try: writer = _writers[fmt_version.split(".")[0]] except KeyError: raise ValueError( "Need mesh f...
[ "def", "write", "(", "filename", ",", "mesh", ",", "fmt_version", ",", "write_binary", "=", "True", ")", ":", "try", ":", "writer", "=", "_writers", "[", "fmt_version", "]", "except", "KeyError", ":", "try", ":", "writer", "=", "_writers", "[", "fmt_vers...
Writes a Gmsh msh file.
[ "Writes", "a", "Gmsh", "msh", "file", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/msh_io/main.py#L84-L99
222,210
nschloe/meshio
meshio/helpers.py
write
def write(filename, mesh, file_format=None, **kwargs): """Writes mesh together with data to a file. :params filename: File to write to. :type filename: str :params point_data: Named additional point data to write to the file. :type point_data: dict """ if not file_format: # deduce ...
python
def write(filename, mesh, file_format=None, **kwargs): """Writes mesh together with data to a file. :params filename: File to write to. :type filename: str :params point_data: Named additional point data to write to the file. :type point_data: dict """ if not file_format: # deduce ...
[ "def", "write", "(", "filename", ",", "mesh", ",", "file_format", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "file_format", ":", "# deduce file format from extension", "file_format", "=", "_filetype_from_filename", "(", "filename", ")", "# chec...
Writes mesh together with data to a file. :params filename: File to write to. :type filename: str :params point_data: Named additional point data to write to the file. :type point_data: dict
[ "Writes", "mesh", "together", "with", "data", "to", "a", "file", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/helpers.py#L193-L227
222,211
nschloe/meshio
meshio/medit_io.py
_ItemReader.next_items
def next_items(self, n): """Returns the next n items. Throws StopIteration when there is not enough data to return n items. """ items = [] while len(items) < n: if self._line_ptr >= len(self._line): # Load the next line. line = next(se...
python
def next_items(self, n): """Returns the next n items. Throws StopIteration when there is not enough data to return n items. """ items = [] while len(items) < n: if self._line_ptr >= len(self._line): # Load the next line. line = next(se...
[ "def", "next_items", "(", "self", ",", "n", ")", ":", "items", "=", "[", "]", "while", "len", "(", "items", ")", "<", "n", ":", "if", "self", ".", "_line_ptr", ">=", "len", "(", "self", ".", "_line", ")", ":", "# Load the next line.", "line", "=", ...
Returns the next n items. Throws StopIteration when there is not enough data to return n items.
[ "Returns", "the", "next", "n", "items", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/medit_io.py#L35-L53
222,212
nschloe/meshio
meshio/abaqus_io.py
get_param_map
def get_param_map(word, required_keys=None): """ get the optional arguments on a line Example ------- >>> iline = 0 >>> word = 'elset,instance=dummy2,generate' >>> params = get_param_map(iline, word, required_keys=['instance']) params = { 'elset' : None, 'instance' : 'du...
python
def get_param_map(word, required_keys=None): """ get the optional arguments on a line Example ------- >>> iline = 0 >>> word = 'elset,instance=dummy2,generate' >>> params = get_param_map(iline, word, required_keys=['instance']) params = { 'elset' : None, 'instance' : 'du...
[ "def", "get_param_map", "(", "word", ",", "required_keys", "=", "None", ")", ":", "if", "required_keys", "is", "None", ":", "required_keys", "=", "[", "]", "words", "=", "word", ".", "split", "(", "\",\"", ")", "param_map", "=", "{", "}", "for", "wordi...
get the optional arguments on a line Example ------- >>> iline = 0 >>> word = 'elset,instance=dummy2,generate' >>> params = get_param_map(iline, word, required_keys=['instance']) params = { 'elset' : None, 'instance' : 'dummy2, 'generate' : None, }
[ "get", "the", "optional", "arguments", "on", "a", "line" ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/abaqus_io.py#L193-L229
222,213
spulec/moto
moto/ssm/models.py
SimpleSystemManagerBackend.get_parameters_by_path
def get_parameters_by_path(self, path, with_decryption, recursive, filters=None): """Implement the get-parameters-by-path-API in the backend.""" result = [] # path could be with or without a trailing /. we handle this # difference here. path = path.rstrip('/') + '/' for p...
python
def get_parameters_by_path(self, path, with_decryption, recursive, filters=None): """Implement the get-parameters-by-path-API in the backend.""" result = [] # path could be with or without a trailing /. we handle this # difference here. path = path.rstrip('/') + '/' for p...
[ "def", "get_parameters_by_path", "(", "self", ",", "path", ",", "with_decryption", ",", "recursive", ",", "filters", "=", "None", ")", ":", "result", "=", "[", "]", "# path could be with or without a trailing /. we handle this", "# difference here.", "path", "=", "pat...
Implement the get-parameters-by-path-API in the backend.
[ "Implement", "the", "get", "-", "parameters", "-", "by", "-", "path", "-", "API", "in", "the", "backend", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ssm/models.py#L255-L270
222,214
spulec/moto
moto/ssm/models.py
SimpleSystemManagerBackend._match_filters
def _match_filters(parameter, filters=None): """Return True if the given parameter matches all the filters""" for filter_obj in (filters or []): key = filter_obj['Key'] option = filter_obj.get('Option', 'Equals') values = filter_obj.get('Values', []) what...
python
def _match_filters(parameter, filters=None): """Return True if the given parameter matches all the filters""" for filter_obj in (filters or []): key = filter_obj['Key'] option = filter_obj.get('Option', 'Equals') values = filter_obj.get('Values', []) what...
[ "def", "_match_filters", "(", "parameter", ",", "filters", "=", "None", ")", ":", "for", "filter_obj", "in", "(", "filters", "or", "[", "]", ")", ":", "key", "=", "filter_obj", "[", "'Key'", "]", "option", "=", "filter_obj", ".", "get", "(", "'Option'"...
Return True if the given parameter matches all the filters
[ "Return", "True", "if", "the", "given", "parameter", "matches", "all", "the", "filters" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ssm/models.py#L273-L293
222,215
spulec/moto
scripts/scaffold.py
initialize_service
def initialize_service(service, operation, api_protocol): """create lib and test dirs if not exist """ lib_dir = get_lib_dir(service) test_dir = get_test_dir(service) print_progress('Initializing service', service, 'green') client = boto3.client(service) service_class = client.__class__.__...
python
def initialize_service(service, operation, api_protocol): """create lib and test dirs if not exist """ lib_dir = get_lib_dir(service) test_dir = get_test_dir(service) print_progress('Initializing service', service, 'green') client = boto3.client(service) service_class = client.__class__.__...
[ "def", "initialize_service", "(", "service", ",", "operation", ",", "api_protocol", ")", ":", "lib_dir", "=", "get_lib_dir", "(", "service", ")", "test_dir", "=", "get_test_dir", "(", "service", ")", "print_progress", "(", "'Initializing service'", ",", "service",...
create lib and test dirs if not exist
[ "create", "lib", "and", "test", "dirs", "if", "not", "exist" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/scripts/scaffold.py#L167-L216
222,216
spulec/moto
scripts/scaffold.py
get_response_query_template
def get_response_query_template(service, operation): """refers to definition of API in botocore, and autogenerates template Assume that response format is xml when protocol is query You can see example of elbv2 from link below. https://github.com/boto/botocore/blob/develop/botocore/data/elbv2/2015-12...
python
def get_response_query_template(service, operation): """refers to definition of API in botocore, and autogenerates template Assume that response format is xml when protocol is query You can see example of elbv2 from link below. https://github.com/boto/botocore/blob/develop/botocore/data/elbv2/2015-12...
[ "def", "get_response_query_template", "(", "service", ",", "operation", ")", ":", "client", "=", "boto3", ".", "client", "(", "service", ")", "aws_operation_name", "=", "to_upper_camel_case", "(", "operation", ")", "op_model", "=", "client", ".", "_service_model",...
refers to definition of API in botocore, and autogenerates template Assume that response format is xml when protocol is query You can see example of elbv2 from link below. https://github.com/boto/botocore/blob/develop/botocore/data/elbv2/2015-12-01/service-2.json
[ "refers", "to", "definition", "of", "API", "in", "botocore", "and", "autogenerates", "template", "Assume", "that", "response", "format", "is", "xml", "when", "protocol", "is", "query" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/scripts/scaffold.py#L324-L382
222,217
spulec/moto
moto/core/utils.py
camelcase_to_underscores
def camelcase_to_underscores(argument): ''' Converts a camelcase param like theNewAttribute to the equivalent python underscore variable like the_new_attribute''' result = '' prev_char_title = True if not argument: return argument for index, char in enumerate(argument): try: ...
python
def camelcase_to_underscores(argument): ''' Converts a camelcase param like theNewAttribute to the equivalent python underscore variable like the_new_attribute''' result = '' prev_char_title = True if not argument: return argument for index, char in enumerate(argument): try: ...
[ "def", "camelcase_to_underscores", "(", "argument", ")", ":", "result", "=", "''", "prev_char_title", "=", "True", "if", "not", "argument", ":", "return", "argument", "for", "index", ",", "char", "in", "enumerate", "(", "argument", ")", ":", "try", ":", "n...
Converts a camelcase param like theNewAttribute to the equivalent python underscore variable like the_new_attribute
[ "Converts", "a", "camelcase", "param", "like", "theNewAttribute", "to", "the", "equivalent", "python", "underscore", "variable", "like", "the_new_attribute" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/utils.py#L17-L40
222,218
spulec/moto
moto/core/utils.py
underscores_to_camelcase
def underscores_to_camelcase(argument): ''' Converts a camelcase param like the_new_attribute to the equivalent camelcase version like theNewAttribute. Note that the first letter is NOT capitalized by this function ''' result = '' previous_was_underscore = False for char in argument: if ...
python
def underscores_to_camelcase(argument): ''' Converts a camelcase param like the_new_attribute to the equivalent camelcase version like theNewAttribute. Note that the first letter is NOT capitalized by this function ''' result = '' previous_was_underscore = False for char in argument: if ...
[ "def", "underscores_to_camelcase", "(", "argument", ")", ":", "result", "=", "''", "previous_was_underscore", "=", "False", "for", "char", "in", "argument", ":", "if", "char", "!=", "'_'", ":", "if", "previous_was_underscore", ":", "result", "+=", "char", ".",...
Converts a camelcase param like the_new_attribute to the equivalent camelcase version like theNewAttribute. Note that the first letter is NOT capitalized by this function
[ "Converts", "a", "camelcase", "param", "like", "the_new_attribute", "to", "the", "equivalent", "camelcase", "version", "like", "theNewAttribute", ".", "Note", "that", "the", "first", "letter", "is", "NOT", "capitalized", "by", "this", "function" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/utils.py#L43-L56
222,219
spulec/moto
moto/core/utils.py
convert_regex_to_flask_path
def convert_regex_to_flask_path(url_path): """ Converts a regex matching url to one that can be used with flask """ for token in ["$"]: url_path = url_path.replace(token, "") def caller(reg): match_name, match_pattern = reg.groups() return '<regex("{0}"):{1}>'.format(match_p...
python
def convert_regex_to_flask_path(url_path): """ Converts a regex matching url to one that can be used with flask """ for token in ["$"]: url_path = url_path.replace(token, "") def caller(reg): match_name, match_pattern = reg.groups() return '<regex("{0}"):{1}>'.format(match_p...
[ "def", "convert_regex_to_flask_path", "(", "url_path", ")", ":", "for", "token", "in", "[", "\"$\"", "]", ":", "url_path", "=", "url_path", ".", "replace", "(", "token", ",", "\"\"", ")", "def", "caller", "(", "reg", ")", ":", "match_name", ",", "match_p...
Converts a regex matching url to one that can be used with flask
[ "Converts", "a", "regex", "matching", "url", "to", "one", "that", "can", "be", "used", "with", "flask" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/utils.py#L80-L96
222,220
spulec/moto
moto/emr/responses.py
generate_boto3_response
def generate_boto3_response(operation): """The decorator to convert an XML response to JSON, if the request is determined to be from boto3. Pass the API action as a parameter. """ def _boto3_request(method): @wraps(method) def f(self, *args, **kwargs): rendered = method(self...
python
def generate_boto3_response(operation): """The decorator to convert an XML response to JSON, if the request is determined to be from boto3. Pass the API action as a parameter. """ def _boto3_request(method): @wraps(method) def f(self, *args, **kwargs): rendered = method(self...
[ "def", "generate_boto3_response", "(", "operation", ")", ":", "def", "_boto3_request", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "rendered", "=", "method", ...
The decorator to convert an XML response to JSON, if the request is determined to be from boto3. Pass the API action as a parameter.
[ "The", "decorator", "to", "convert", "an", "XML", "response", "to", "JSON", "if", "the", "request", "is", "determined", "to", "be", "from", "boto3", ".", "Pass", "the", "API", "action", "as", "a", "parameter", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/emr/responses.py#L18-L37
222,221
spulec/moto
moto/ecr/models.py
ECRBackend.describe_repositories
def describe_repositories(self, registry_id=None, repository_names=None): """ maxResults and nextToken not implemented """ if repository_names: for repository_name in repository_names: if repository_name not in self.repositories: raise Repo...
python
def describe_repositories(self, registry_id=None, repository_names=None): """ maxResults and nextToken not implemented """ if repository_names: for repository_name in repository_names: if repository_name not in self.repositories: raise Repo...
[ "def", "describe_repositories", "(", "self", ",", "registry_id", "=", "None", ",", "repository_names", "=", "None", ")", ":", "if", "repository_names", ":", "for", "repository_name", "in", "repository_names", ":", "if", "repository_name", "not", "in", "self", "....
maxResults and nextToken not implemented
[ "maxResults", "and", "nextToken", "not", "implemented" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecr/models.py#L174-L195
222,222
spulec/moto
moto/ecr/models.py
ECRBackend.list_images
def list_images(self, repository_name, registry_id=None): """ maxResults and filtering not implemented """ repository = None found = False if repository_name in self.repositories: repository = self.repositories[repository_name] if registry_id: ...
python
def list_images(self, repository_name, registry_id=None): """ maxResults and filtering not implemented """ repository = None found = False if repository_name in self.repositories: repository = self.repositories[repository_name] if registry_id: ...
[ "def", "list_images", "(", "self", ",", "repository_name", ",", "registry_id", "=", "None", ")", ":", "repository", "=", "None", "found", "=", "False", "if", "repository_name", "in", "self", ".", "repositories", ":", "repository", "=", "self", ".", "reposito...
maxResults and filtering not implemented
[ "maxResults", "and", "filtering", "not", "implemented" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecr/models.py#L208-L228
222,223
spulec/moto
moto/packages/httpretty/core.py
httprettified
def httprettified(test): "A decorator tests that use HTTPretty" def decorate_class(klass): for attr in dir(klass): if not attr.startswith('test_'): continue attr_value = getattr(klass, attr) if not hasattr(attr_value, "__call__"): cont...
python
def httprettified(test): "A decorator tests that use HTTPretty" def decorate_class(klass): for attr in dir(klass): if not attr.startswith('test_'): continue attr_value = getattr(klass, attr) if not hasattr(attr_value, "__call__"): cont...
[ "def", "httprettified", "(", "test", ")", ":", "def", "decorate_class", "(", "klass", ")", ":", "for", "attr", "in", "dir", "(", "klass", ")", ":", "if", "not", "attr", ".", "startswith", "(", "'test_'", ")", ":", "continue", "attr_value", "=", "getatt...
A decorator tests that use HTTPretty
[ "A", "decorator", "tests", "that", "use", "HTTPretty" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/core.py#L1089-L1116
222,224
spulec/moto
moto/packages/httpretty/core.py
URIMatcher.get_next_entry
def get_next_entry(self, method, info, request): """Cycle through available responses, but only once. Any subsequent requests will receive the last response""" if method not in self.current_entries: self.current_entries[method] = 0 # restrict selection to entries that match...
python
def get_next_entry(self, method, info, request): """Cycle through available responses, but only once. Any subsequent requests will receive the last response""" if method not in self.current_entries: self.current_entries[method] = 0 # restrict selection to entries that match...
[ "def", "get_next_entry", "(", "self", ",", "method", ",", "info", ",", "request", ")", ":", "if", "method", "not", "in", "self", ".", "current_entries", ":", "self", ".", "current_entries", "[", "method", "]", "=", "0", "# restrict selection to entries that ma...
Cycle through available responses, but only once. Any subsequent requests will receive the last response
[ "Cycle", "through", "available", "responses", "but", "only", "once", ".", "Any", "subsequent", "requests", "will", "receive", "the", "last", "response" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/core.py#L809-L837
222,225
spulec/moto
moto/xray/mock_client.py
mock_xray_client
def mock_xray_client(f): """ Mocks the X-Ray sdk by pwning its evil singleton with our methods The X-Ray SDK has normally been imported and `patched()` called long before we start mocking. This means the Context() will be very unhappy if an env var isnt present, so we set that, save the old context...
python
def mock_xray_client(f): """ Mocks the X-Ray sdk by pwning its evil singleton with our methods The X-Ray SDK has normally been imported and `patched()` called long before we start mocking. This means the Context() will be very unhappy if an env var isnt present, so we set that, save the old context...
[ "def", "mock_xray_client", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "_wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "\"Starting X-Ray Patch\"", ")", "old_xray_context_var", "=", "os", ".", "environ", ".", "...
Mocks the X-Ray sdk by pwning its evil singleton with our methods The X-Ray SDK has normally been imported and `patched()` called long before we start mocking. This means the Context() will be very unhappy if an env var isnt present, so we set that, save the old context, then supply our new context. We...
[ "Mocks", "the", "X", "-", "Ray", "sdk", "by", "pwning", "its", "evil", "singleton", "with", "our", "methods" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/xray/mock_client.py#L32-L65
222,226
spulec/moto
moto/iot/models.py
FakeCertificate.to_description_dict
def to_description_dict(self): """ You might need keys below in some situation - caCertificateId - previousOwnedBy """ return { 'certificateArn': self.arn, 'certificateId': self.certificate_id, 'status': self.status, 'ce...
python
def to_description_dict(self): """ You might need keys below in some situation - caCertificateId - previousOwnedBy """ return { 'certificateArn': self.arn, 'certificateId': self.certificate_id, 'status': self.status, 'ce...
[ "def", "to_description_dict", "(", "self", ")", ":", "return", "{", "'certificateArn'", ":", "self", ".", "arn", ",", "'certificateId'", ":", "self", ".", "certificate_id", ",", "'status'", ":", "self", ".", "status", ",", "'certificatePem'", ":", "self", "....
You might need keys below in some situation - caCertificateId - previousOwnedBy
[ "You", "might", "need", "keys", "below", "in", "some", "situation", "-", "caCertificateId", "-", "previousOwnedBy" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iot/models.py#L122-L137
222,227
spulec/moto
moto/opsworks/models.py
OpsworkInstance.start
def start(self): """ create an ec2 reservation if one doesn't already exist and call start_instance. Update instance attributes to the newly created instance attributes """ if self.instance is None: reservation = self.ec2_backend.add_instances( ...
python
def start(self): """ create an ec2 reservation if one doesn't already exist and call start_instance. Update instance attributes to the newly created instance attributes """ if self.instance is None: reservation = self.ec2_backend.add_instances( ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "instance", "is", "None", ":", "reservation", "=", "self", ".", "ec2_backend", ".", "add_instances", "(", "image_id", "=", "self", ".", "ami_id", ",", "count", "=", "1", ",", "user_data", "=", ...
create an ec2 reservation if one doesn't already exist and call start_instance. Update instance attributes to the newly created instance attributes
[ "create", "an", "ec2", "reservation", "if", "one", "doesn", "t", "already", "exist", "and", "call", "start_instance", ".", "Update", "instance", "attributes", "to", "the", "newly", "created", "instance", "attributes" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/opsworks/models.py#L84-L116
222,228
spulec/moto
moto/core/responses.py
flatten_json_request_body
def flatten_json_request_body(prefix, dict_body, spec): """Convert a JSON request body into query params.""" if len(spec) == 1 and 'type' in spec: return {prefix: to_str(dict_body, spec)} flat = {} for key, value in dict_body.items(): node_type = spec[key]['type'] if node_type =...
python
def flatten_json_request_body(prefix, dict_body, spec): """Convert a JSON request body into query params.""" if len(spec) == 1 and 'type' in spec: return {prefix: to_str(dict_body, spec)} flat = {} for key, value in dict_body.items(): node_type = spec[key]['type'] if node_type =...
[ "def", "flatten_json_request_body", "(", "prefix", ",", "dict_body", ",", "spec", ")", ":", "if", "len", "(", "spec", ")", "==", "1", "and", "'type'", "in", "spec", ":", "return", "{", "prefix", ":", "to_str", "(", "dict_body", ",", "spec", ")", "}", ...
Convert a JSON request body into query params.
[ "Convert", "a", "JSON", "request", "body", "into", "query", "params", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/responses.py#L751-L776
222,229
spulec/moto
moto/core/responses.py
xml_to_json_response
def xml_to_json_response(service_spec, operation, xml, result_node=None): """Convert rendered XML response to JSON for use with boto3.""" def transform(value, spec): """Apply transformations to make the output JSON comply with the expected form. This function applies: (1) Type cast t...
python
def xml_to_json_response(service_spec, operation, xml, result_node=None): """Convert rendered XML response to JSON for use with boto3.""" def transform(value, spec): """Apply transformations to make the output JSON comply with the expected form. This function applies: (1) Type cast t...
[ "def", "xml_to_json_response", "(", "service_spec", ",", "operation", ",", "xml", ",", "result_node", "=", "None", ")", ":", "def", "transform", "(", "value", ",", "spec", ")", ":", "\"\"\"Apply transformations to make the output JSON comply with the\n expected for...
Convert rendered XML response to JSON for use with boto3.
[ "Convert", "rendered", "XML", "response", "to", "JSON", "for", "use", "with", "boto3", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/responses.py#L779-L852
222,230
spulec/moto
moto/core/responses.py
BaseResponse.get_current_user
def get_current_user(self): """ Returns the access key id used in this request as the current user id """ if 'Authorization' in self.headers: match = self.access_key_regex.search(self.headers['Authorization']) if match: return match.group(1) ...
python
def get_current_user(self): """ Returns the access key id used in this request as the current user id """ if 'Authorization' in self.headers: match = self.access_key_regex.search(self.headers['Authorization']) if match: return match.group(1) ...
[ "def", "get_current_user", "(", "self", ")", ":", "if", "'Authorization'", "in", "self", ".", "headers", ":", "match", "=", "self", ".", "access_key_regex", ".", "search", "(", "self", ".", "headers", "[", "'Authorization'", "]", ")", "if", "match", ":", ...
Returns the access key id used in this request as the current user id
[ "Returns", "the", "access", "key", "id", "used", "in", "this", "request", "as", "the", "current", "user", "id" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/responses.py#L183-L196
222,231
spulec/moto
moto/kms/models.py
KmsBackend.delete_alias
def delete_alias(self, alias_name): """Delete the alias.""" for aliases in self.key_to_aliases.values(): if alias_name in aliases: aliases.remove(alias_name)
python
def delete_alias(self, alias_name): """Delete the alias.""" for aliases in self.key_to_aliases.values(): if alias_name in aliases: aliases.remove(alias_name)
[ "def", "delete_alias", "(", "self", ",", "alias_name", ")", ":", "for", "aliases", "in", "self", ".", "key_to_aliases", ".", "values", "(", ")", ":", "if", "alias_name", "in", "aliases", ":", "aliases", ".", "remove", "(", "alias_name", ")" ]
Delete the alias.
[ "Delete", "the", "alias", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/kms/models.py#L132-L136
222,232
spulec/moto
moto/dynamodb/models.py
DynamoType.compare
def compare(self, range_comparison, range_objs): """ Compares this type against comparison filters """ range_values = [obj.value for obj in range_objs] comparison_func = get_comparison_func(range_comparison) return comparison_func(self.value, *range_values)
python
def compare(self, range_comparison, range_objs): """ Compares this type against comparison filters """ range_values = [obj.value for obj in range_objs] comparison_func = get_comparison_func(range_comparison) return comparison_func(self.value, *range_values)
[ "def", "compare", "(", "self", ",", "range_comparison", ",", "range_objs", ")", ":", "range_values", "=", "[", "obj", ".", "value", "for", "obj", "in", "range_objs", "]", "comparison_func", "=", "get_comparison_func", "(", "range_comparison", ")", "return", "c...
Compares this type against comparison filters
[ "Compares", "this", "type", "against", "comparison", "filters" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb/models.py#L47-L53
222,233
spulec/moto
moto/cognitoidp/models.py
paginate
def paginate(limit, start_arg="next_token", limit_arg="max_results"): """Returns a limited result list, and an offset into list of remaining items Takes the next_token, and max_results kwargs given to a function and handles the slicing of the results. The kwarg `next_token` is the offset into the list ...
python
def paginate(limit, start_arg="next_token", limit_arg="max_results"): """Returns a limited result list, and an offset into list of remaining items Takes the next_token, and max_results kwargs given to a function and handles the slicing of the results. The kwarg `next_token` is the offset into the list ...
[ "def", "paginate", "(", "limit", ",", "start_arg", "=", "\"next_token\"", ",", "limit_arg", "=", "\"max_results\"", ")", ":", "default_start", "=", "0", "def", "outer_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def",...
Returns a limited result list, and an offset into list of remaining items Takes the next_token, and max_results kwargs given to a function and handles the slicing of the results. The kwarg `next_token` is the offset into the list to begin slicing from. `max_results` is the size of the result required ...
[ "Returns", "a", "limited", "result", "list", "and", "an", "offset", "into", "list", "of", "remaining", "items" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/cognitoidp/models.py#L24-L54
222,234
spulec/moto
moto/core/models.py
CallbackResponse._url_matches
def _url_matches(self, url, other, match_querystring=False): ''' Need to override this so we can fix querystrings breaking regex matching ''' if not match_querystring: other = other.split('?', 1)[0] if responses._is_string(url): if responses._has_unicode(...
python
def _url_matches(self, url, other, match_querystring=False): ''' Need to override this so we can fix querystrings breaking regex matching ''' if not match_querystring: other = other.split('?', 1)[0] if responses._is_string(url): if responses._has_unicode(...
[ "def", "_url_matches", "(", "self", ",", "url", ",", "other", ",", "match_querystring", "=", "False", ")", ":", "if", "not", "match_querystring", ":", "other", "=", "other", ".", "split", "(", "'?'", ",", "1", ")", "[", "0", "]", "if", "responses", "...
Need to override this so we can fix querystrings breaking regex matching
[ "Need", "to", "override", "this", "so", "we", "can", "fix", "querystrings", "breaking", "regex", "matching" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L175-L191
222,235
spulec/moto
moto/core/models.py
BaseBackend.urls
def urls(self): """ A dictionary of the urls to be mocked with this service and the handlers that should be called in their place """ url_bases = self._url_module.url_bases unformatted_paths = self._url_module.url_paths urls = {} for url_base in url_bases...
python
def urls(self): """ A dictionary of the urls to be mocked with this service and the handlers that should be called in their place """ url_bases = self._url_module.url_bases unformatted_paths = self._url_module.url_paths urls = {} for url_base in url_bases...
[ "def", "urls", "(", "self", ")", ":", "url_bases", "=", "self", ".", "_url_module", ".", "url_bases", "unformatted_paths", "=", "self", ".", "_url_module", ".", "url_paths", "urls", "=", "{", "}", "for", "url_base", "in", "url_bases", ":", "for", "url_path...
A dictionary of the urls to be mocked with this service and the handlers that should be called in their place
[ "A", "dictionary", "of", "the", "urls", "to", "be", "mocked", "with", "this", "service", "and", "the", "handlers", "that", "should", "be", "called", "in", "their", "place" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L484-L498
222,236
spulec/moto
moto/core/models.py
BaseBackend.url_paths
def url_paths(self): """ A dictionary of the paths of the urls to be mocked with this service and the handlers that should be called in their place """ unformatted_paths = self._url_module.url_paths paths = {} for unformatted_path, handler in unformatted_paths.it...
python
def url_paths(self): """ A dictionary of the paths of the urls to be mocked with this service and the handlers that should be called in their place """ unformatted_paths = self._url_module.url_paths paths = {} for unformatted_path, handler in unformatted_paths.it...
[ "def", "url_paths", "(", "self", ")", ":", "unformatted_paths", "=", "self", ".", "_url_module", ".", "url_paths", "paths", "=", "{", "}", "for", "unformatted_path", ",", "handler", "in", "unformatted_paths", ".", "items", "(", ")", ":", "path", "=", "unfo...
A dictionary of the paths of the urls to be mocked with this service and the handlers that should be called in their place
[ "A", "dictionary", "of", "the", "paths", "of", "the", "urls", "to", "be", "mocked", "with", "this", "service", "and", "the", "handlers", "that", "should", "be", "called", "in", "their", "place" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L501-L513
222,237
spulec/moto
moto/core/models.py
BaseBackend.flask_paths
def flask_paths(self): """ The url paths that will be used for the flask server """ paths = {} for url_path, handler in self.url_paths.items(): url_path = convert_regex_to_flask_path(url_path) paths[url_path] = handler return paths
python
def flask_paths(self): """ The url paths that will be used for the flask server """ paths = {} for url_path, handler in self.url_paths.items(): url_path = convert_regex_to_flask_path(url_path) paths[url_path] = handler return paths
[ "def", "flask_paths", "(", "self", ")", ":", "paths", "=", "{", "}", "for", "url_path", ",", "handler", "in", "self", ".", "url_paths", ".", "items", "(", ")", ":", "url_path", "=", "convert_regex_to_flask_path", "(", "url_path", ")", "paths", "[", "url_...
The url paths that will be used for the flask server
[ "The", "url", "paths", "that", "will", "be", "used", "for", "the", "flask", "server" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L523-L532
222,238
spulec/moto
moto/cloudformation/utils.py
yaml_tag_constructor
def yaml_tag_constructor(loader, tag, node): """convert shorthand intrinsic function to full name """ def _f(loader, tag, node): if tag == '!GetAtt': return node.value.split('.') elif type(node) == yaml.SequenceNode: return loader.construct_sequence(node) else...
python
def yaml_tag_constructor(loader, tag, node): """convert shorthand intrinsic function to full name """ def _f(loader, tag, node): if tag == '!GetAtt': return node.value.split('.') elif type(node) == yaml.SequenceNode: return loader.construct_sequence(node) else...
[ "def", "yaml_tag_constructor", "(", "loader", ",", "tag", ",", "node", ")", ":", "def", "_f", "(", "loader", ",", "tag", ",", "node", ")", ":", "if", "tag", "==", "'!GetAtt'", ":", "return", "node", ".", "value", ".", "split", "(", "'.'", ")", "eli...
convert shorthand intrinsic function to full name
[ "convert", "shorthand", "intrinsic", "function", "to", "full", "name" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/cloudformation/utils.py#L36-L52
222,239
spulec/moto
moto/dynamodb/responses.py
DynamoHandler.get_endpoint_name
def get_endpoint_name(self, headers): """Parses request headers and extracts part od the X-Amz-Target that corresponds to a method of DynamoHandler ie: X-Amz-Target: DynamoDB_20111205.ListTables -> ListTables """ # Headers are case-insensitive. Probably a better way to do this. ...
python
def get_endpoint_name(self, headers): """Parses request headers and extracts part od the X-Amz-Target that corresponds to a method of DynamoHandler ie: X-Amz-Target: DynamoDB_20111205.ListTables -> ListTables """ # Headers are case-insensitive. Probably a better way to do this. ...
[ "def", "get_endpoint_name", "(", "self", ",", "headers", ")", ":", "# Headers are case-insensitive. Probably a better way to do this.", "match", "=", "headers", ".", "get", "(", "'x-amz-target'", ")", "or", "headers", ".", "get", "(", "'X-Amz-Target'", ")", "if", "m...
Parses request headers and extracts part od the X-Amz-Target that corresponds to a method of DynamoHandler ie: X-Amz-Target: DynamoDB_20111205.ListTables -> ListTables
[ "Parses", "request", "headers", "and", "extracts", "part", "od", "the", "X", "-", "Amz", "-", "Target", "that", "corresponds", "to", "a", "method", "of", "DynamoHandler" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb/responses.py#L12-L21
222,240
spulec/moto
moto/ec2/models.py
InstanceBackend.get_reservations_by_instance_ids
def get_reservations_by_instance_ids(self, instance_ids, filters=None): """ Go through all of the reservations and filter to only return those associated with the given instance_ids. """ reservations = [] for reservation in self.all_reservations(): reservation_instanc...
python
def get_reservations_by_instance_ids(self, instance_ids, filters=None): """ Go through all of the reservations and filter to only return those associated with the given instance_ids. """ reservations = [] for reservation in self.all_reservations(): reservation_instanc...
[ "def", "get_reservations_by_instance_ids", "(", "self", ",", "instance_ids", ",", "filters", "=", "None", ")", ":", "reservations", "=", "[", "]", "for", "reservation", "in", "self", ".", "all_reservations", "(", ")", ":", "reservation_instance_ids", "=", "[", ...
Go through all of the reservations and filter to only return those associated with the given instance_ids.
[ "Go", "through", "all", "of", "the", "reservations", "and", "filter", "to", "only", "return", "those", "associated", "with", "the", "given", "instance_ids", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ec2/models.py#L829-L851
222,241
spulec/moto
moto/ecs/models.py
EC2ContainerServiceBackend.list_task_definitions
def list_task_definitions(self): """ Filtering not implemented """ task_arns = [] for task_definition_list in self.task_definitions.values(): task_arns.extend( [task_definition.arn for task_definition in task_definition_list]) return task_arns
python
def list_task_definitions(self): """ Filtering not implemented """ task_arns = [] for task_definition_list in self.task_definitions.values(): task_arns.extend( [task_definition.arn for task_definition in task_definition_list]) return task_arns
[ "def", "list_task_definitions", "(", "self", ")", ":", "task_arns", "=", "[", "]", "for", "task_definition_list", "in", "self", ".", "task_definitions", ".", "values", "(", ")", ":", "task_arns", ".", "extend", "(", "[", "task_definition", ".", "arn", "for",...
Filtering not implemented
[ "Filtering", "not", "implemented" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecs/models.py#L481-L489
222,242
spulec/moto
moto/iotdata/models.py
FakeShadow.create_from_previous_version
def create_from_previous_version(cls, previous_shadow, payload): """ set None to payload when you want to delete shadow """ version, previous_payload = (previous_shadow.version + 1, previous_shadow.to_dict(include_delta=False)) if previous_shadow else (1, {}) if payload is None:...
python
def create_from_previous_version(cls, previous_shadow, payload): """ set None to payload when you want to delete shadow """ version, previous_payload = (previous_shadow.version + 1, previous_shadow.to_dict(include_delta=False)) if previous_shadow else (1, {}) if payload is None:...
[ "def", "create_from_previous_version", "(", "cls", ",", "previous_shadow", ",", "payload", ")", ":", "version", ",", "previous_payload", "=", "(", "previous_shadow", ".", "version", "+", "1", ",", "previous_shadow", ".", "to_dict", "(", "include_delta", "=", "Fa...
set None to payload when you want to delete shadow
[ "set", "None", "to", "payload", "when", "you", "want", "to", "delete", "shadow" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iotdata/models.py#L30-L52
222,243
spulec/moto
moto/iotdata/models.py
FakeShadow.to_dict
def to_dict(self, include_delta=True): """returning nothing except for just top-level keys for now. """ if self.deleted: return { 'timestamp': self.timestamp, 'version': self.version } delta = self.parse_payload(self.desired, self.r...
python
def to_dict(self, include_delta=True): """returning nothing except for just top-level keys for now. """ if self.deleted: return { 'timestamp': self.timestamp, 'version': self.version } delta = self.parse_payload(self.desired, self.r...
[ "def", "to_dict", "(", "self", ",", "include_delta", "=", "True", ")", ":", "if", "self", ".", "deleted", ":", "return", "{", "'timestamp'", ":", "self", ".", "timestamp", ",", "'version'", ":", "self", ".", "version", "}", "delta", "=", "self", ".", ...
returning nothing except for just top-level keys for now.
[ "returning", "nothing", "except", "for", "just", "top", "-", "level", "keys", "for", "now", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iotdata/models.py#L102-L130
222,244
spulec/moto
moto/iotdata/models.py
IoTDataPlaneBackend.delete_thing_shadow
def delete_thing_shadow(self, thing_name): """after deleting, get_thing_shadow will raise ResourceNotFound. But version of the shadow keep increasing... """ thing = iot_backends[self.region_name].describe_thing(thing_name) if thing.thing_shadow is None: raise Resource...
python
def delete_thing_shadow(self, thing_name): """after deleting, get_thing_shadow will raise ResourceNotFound. But version of the shadow keep increasing... """ thing = iot_backends[self.region_name].describe_thing(thing_name) if thing.thing_shadow is None: raise Resource...
[ "def", "delete_thing_shadow", "(", "self", ",", "thing_name", ")", ":", "thing", "=", "iot_backends", "[", "self", ".", "region_name", "]", ".", "describe_thing", "(", "thing_name", ")", "if", "thing", ".", "thing_shadow", "is", "None", ":", "raise", "Resour...
after deleting, get_thing_shadow will raise ResourceNotFound. But version of the shadow keep increasing...
[ "after", "deleting", "get_thing_shadow", "will", "raise", "ResourceNotFound", ".", "But", "version", "of", "the", "shadow", "keep", "increasing", "..." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iotdata/models.py#L175-L185
222,245
spulec/moto
moto/acm/models.py
AWSCertificateManagerBackend._get_arn_from_idempotency_token
def _get_arn_from_idempotency_token(self, token): """ If token doesnt exist, return None, later it will be set with an expiry and arn. If token expiry has passed, delete entry and return None Else return ARN :param token: String token :return: None or ARN ...
python
def _get_arn_from_idempotency_token(self, token): """ If token doesnt exist, return None, later it will be set with an expiry and arn. If token expiry has passed, delete entry and return None Else return ARN :param token: String token :return: None or ARN ...
[ "def", "_get_arn_from_idempotency_token", "(", "self", ",", "token", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "if", "token", "in", "self", ".", "_idempotency_tokens", ":", "if", "self", ".", "_idempotency_tokens", "[", "token"...
If token doesnt exist, return None, later it will be set with an expiry and arn. If token expiry has passed, delete entry and return None Else return ARN :param token: String token :return: None or ARN
[ "If", "token", "doesnt", "exist", "return", "None", "later", "it", "will", "be", "set", "with", "an", "expiry", "and", "arn", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/acm/models.py#L287-L308
222,246
spulec/moto
moto/iam/models.py
IAMBackend._validate_tag_key
def _validate_tag_key(self, tag_key, exception_param='tags.X.member.key'): """Validates the tag key. :param all_tags: Dict to check if there is a duplicate tag. :param tag_key: The tag key to check against. :param exception_param: The exception parameter to send over to help format the ...
python
def _validate_tag_key(self, tag_key, exception_param='tags.X.member.key'): """Validates the tag key. :param all_tags: Dict to check if there is a duplicate tag. :param tag_key: The tag key to check against. :param exception_param: The exception parameter to send over to help format the ...
[ "def", "_validate_tag_key", "(", "self", ",", "tag_key", ",", "exception_param", "=", "'tags.X.member.key'", ")", ":", "# Validate that the key length is correct:", "if", "len", "(", "tag_key", ")", ">", "128", ":", "raise", "TagKeyTooBig", "(", "tag_key", ",", "p...
Validates the tag key. :param all_tags: Dict to check if there is a duplicate tag. :param tag_key: The tag key to check against. :param exception_param: The exception parameter to send over to help format the message. This is to reflect the difference between the...
[ "Validates", "the", "tag", "key", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iam/models.py#L639-L657
222,247
spulec/moto
moto/iam/models.py
IAMBackend.enable_mfa_device
def enable_mfa_device(self, user_name, serial_number, authentication_code_1, authentication_code_2): """Enable MFA Device for user.""" user = self.get_user(user_name) if serial_number in user....
python
def enable_mfa_device(self, user_name, serial_number, authentication_code_1, authentication_code_2): """Enable MFA Device for user.""" user = self.get_user(user_name) if serial_number in user....
[ "def", "enable_mfa_device", "(", "self", ",", "user_name", ",", "serial_number", ",", "authentication_code_1", ",", "authentication_code_2", ")", ":", "user", "=", "self", ".", "get_user", "(", "user_name", ")", "if", "serial_number", "in", "user", ".", "mfa_dev...
Enable MFA Device for user.
[ "Enable", "MFA", "Device", "for", "user", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iam/models.py#L1066-L1083
222,248
spulec/moto
moto/iam/models.py
IAMBackend.deactivate_mfa_device
def deactivate_mfa_device(self, user_name, serial_number): """Deactivate and detach MFA Device from user if device exists.""" user = self.get_user(user_name) if serial_number not in user.mfa_devices: raise IAMNotFoundException( "Device {0} not found".format(serial_num...
python
def deactivate_mfa_device(self, user_name, serial_number): """Deactivate and detach MFA Device from user if device exists.""" user = self.get_user(user_name) if serial_number not in user.mfa_devices: raise IAMNotFoundException( "Device {0} not found".format(serial_num...
[ "def", "deactivate_mfa_device", "(", "self", ",", "user_name", ",", "serial_number", ")", ":", "user", "=", "self", ".", "get_user", "(", "user_name", ")", "if", "serial_number", "not", "in", "user", ".", "mfa_devices", ":", "raise", "IAMNotFoundException", "(...
Deactivate and detach MFA Device from user if device exists.
[ "Deactivate", "and", "detach", "MFA", "Device", "from", "user", "if", "device", "exists", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iam/models.py#L1085-L1093
222,249
spulec/moto
moto/route53/models.py
RecordSet.delete
def delete(self, *args, **kwargs): ''' Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored ''' hosted_zone = route53_backend.get_hosted_zone_by_name( self.hosted_zone_name) if not hosted_zone: hosted_zone = route53_backend.get_hosted_zone(s...
python
def delete(self, *args, **kwargs): ''' Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored ''' hosted_zone = route53_backend.get_hosted_zone_by_name( self.hosted_zone_name) if not hosted_zone: hosted_zone = route53_backend.get_hosted_zone(s...
[ "def", "delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "hosted_zone", "=", "route53_backend", ".", "get_hosted_zone_by_name", "(", "self", ".", "hosted_zone_name", ")", "if", "not", "hosted_zone", ":", "hosted_zone", "=", "route53...
Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored
[ "Not", "exposed", "as", "part", "of", "the", "Route", "53", "API", "-", "used", "for", "CloudFormation", ".", "args", "are", "ignored" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/route53/models.py#L159-L165
222,250
spulec/moto
moto/packages/httpretty/http.py
last_requestline
def last_requestline(sent_data): """ Find the last line in sent_data that can be parsed with parse_requestline """ for line in reversed(sent_data): try: parse_requestline(decode_utf8(line)) except ValueError: pass else: return line
python
def last_requestline(sent_data): """ Find the last line in sent_data that can be parsed with parse_requestline """ for line in reversed(sent_data): try: parse_requestline(decode_utf8(line)) except ValueError: pass else: return line
[ "def", "last_requestline", "(", "sent_data", ")", ":", "for", "line", "in", "reversed", "(", "sent_data", ")", ":", "try", ":", "parse_requestline", "(", "decode_utf8", "(", "line", ")", ")", "except", "ValueError", ":", "pass", "else", ":", "return", "lin...
Find the last line in sent_data that can be parsed with parse_requestline
[ "Find", "the", "last", "line", "in", "sent_data", "that", "can", "be", "parsed", "with", "parse_requestline" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/http.py#L144-L154
222,251
spulec/moto
moto/sqs/models.py
Message.attribute_md5
def attribute_md5(self): """ The MD5 of all attributes is calculated by first generating a utf-8 string from each attribute and MD5-ing the concatenation of them all. Each attribute is encoded with some bytes that describe the length of each part and the type of attribute. ...
python
def attribute_md5(self): """ The MD5 of all attributes is calculated by first generating a utf-8 string from each attribute and MD5-ing the concatenation of them all. Each attribute is encoded with some bytes that describe the length of each part and the type of attribute. ...
[ "def", "attribute_md5", "(", "self", ")", ":", "def", "utf8", "(", "str", ")", ":", "if", "isinstance", "(", "str", ",", "six", ".", "string_types", ")", ":", "return", "str", ".", "encode", "(", "'utf-8'", ")", "return", "str", "md5", "=", "hashlib"...
The MD5 of all attributes is calculated by first generating a utf-8 string from each attribute and MD5-ing the concatenation of them all. Each attribute is encoded with some bytes that describe the length of each part and the type of attribute. Not yet implemented: List type...
[ "The", "MD5", "of", "all", "attributes", "is", "calculated", "by", "first", "generating", "a", "utf", "-", "8", "string", "from", "each", "attribute", "and", "MD5", "-", "ing", "the", "concatenation", "of", "them", "all", ".", "Each", "attribute", "is", ...
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/sqs/models.py#L54-L100
222,252
spulec/moto
moto/sqs/models.py
Message.mark_received
def mark_received(self, visibility_timeout=None): """ When a message is received we will set the first receive timestamp, tap the ``approximate_receive_count`` and the ``visible_at`` time. """ if visibility_timeout: visibility_timeout = int(visibility_timeout) ...
python
def mark_received(self, visibility_timeout=None): """ When a message is received we will set the first receive timestamp, tap the ``approximate_receive_count`` and the ``visible_at`` time. """ if visibility_timeout: visibility_timeout = int(visibility_timeout) ...
[ "def", "mark_received", "(", "self", ",", "visibility_timeout", "=", "None", ")", ":", "if", "visibility_timeout", ":", "visibility_timeout", "=", "int", "(", "visibility_timeout", ")", "else", ":", "visibility_timeout", "=", "0", "if", "not", "self", ".", "ap...
When a message is received we will set the first receive timestamp, tap the ``approximate_receive_count`` and the ``visible_at`` time.
[ "When", "a", "message", "is", "received", "we", "will", "set", "the", "first", "receive", "timestamp", "tap", "the", "approximate_receive_count", "and", "the", "visible_at", "time", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/sqs/models.py#L111-L131
222,253
spulec/moto
moto/sqs/models.py
SQSBackend.receive_messages
def receive_messages(self, queue_name, count, wait_seconds_timeout, visibility_timeout): """ Attempt to retrieve visible messages from a queue. If a message was read by client and not deleted it is considered to be "inflight" and cannot be read. We make attempts to obtain ``count`` ...
python
def receive_messages(self, queue_name, count, wait_seconds_timeout, visibility_timeout): """ Attempt to retrieve visible messages from a queue. If a message was read by client and not deleted it is considered to be "inflight" and cannot be read. We make attempts to obtain ``count`` ...
[ "def", "receive_messages", "(", "self", ",", "queue_name", ",", "count", ",", "wait_seconds_timeout", ",", "visibility_timeout", ")", ":", "queue", "=", "self", ".", "get_queue", "(", "queue_name", ")", "result", "=", "[", "]", "previous_result_count", "=", "l...
Attempt to retrieve visible messages from a queue. If a message was read by client and not deleted it is considered to be "inflight" and cannot be read. We make attempts to obtain ``count`` messages but we may return less if messages are in-flight or there are simple not enough messages...
[ "Attempt", "to", "retrieve", "visible", "messages", "from", "a", "queue", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/sqs/models.py#L469-L542
222,254
spulec/moto
moto/dynamodb2/models.py
DynamoDBBackend.get_table_keys_name
def get_table_keys_name(self, table_name, keys): """ Given a set of keys, extracts the key and range key """ table = self.tables.get(table_name) if not table: return None, None else: if len(keys) == 1: for key in keys: ...
python
def get_table_keys_name(self, table_name, keys): """ Given a set of keys, extracts the key and range key """ table = self.tables.get(table_name) if not table: return None, None else: if len(keys) == 1: for key in keys: ...
[ "def", "get_table_keys_name", "(", "self", ",", "table_name", ",", "keys", ")", ":", "table", "=", "self", ".", "tables", ".", "get", "(", "table_name", ")", "if", "not", "table", ":", "return", "None", ",", "None", "else", ":", "if", "len", "(", "ke...
Given a set of keys, extracts the key and range key
[ "Given", "a", "set", "of", "keys", "extracts", "the", "key", "and", "range", "key" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb2/models.py#L834-L855
222,255
spulec/moto
moto/instance_metadata/responses.py
InstanceMetadataResponse.metadata_response
def metadata_response(self, request, full_url, headers): """ Mock response for localhost metadata http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html """ parsed_url = urlparse(full_url) tomorrow = datetime.datetime.utcnow() + datetime.time...
python
def metadata_response(self, request, full_url, headers): """ Mock response for localhost metadata http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html """ parsed_url = urlparse(full_url) tomorrow = datetime.datetime.utcnow() + datetime.time...
[ "def", "metadata_response", "(", "self", ",", "request", ",", "full_url", ",", "headers", ")", ":", "parsed_url", "=", "urlparse", "(", "full_url", ")", "tomorrow", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "+", "datetime", ".", "timedelta...
Mock response for localhost metadata http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
[ "Mock", "response", "for", "localhost", "metadata" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/instance_metadata/responses.py#L11-L49
222,256
spulec/moto
moto/cloudwatch/models.py
CloudWatchBackend._list_element_starts_with
def _list_element_starts_with(items, needle): """True of any of the list elements starts with needle""" for item in items: if item.startswith(needle): return True return False
python
def _list_element_starts_with(items, needle): """True of any of the list elements starts with needle""" for item in items: if item.startswith(needle): return True return False
[ "def", "_list_element_starts_with", "(", "items", ",", "needle", ")", ":", "for", "item", "in", "items", ":", "if", "item", ".", "startswith", "(", "needle", ")", ":", "return", "True", "return", "False" ]
True of any of the list elements starts with needle
[ "True", "of", "any", "of", "the", "list", "elements", "starts", "with", "needle" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/cloudwatch/models.py#L193-L198
222,257
spulec/moto
moto/batch/models.py
BatchBackend._validate_compute_resources
def _validate_compute_resources(self, cr): """ Checks contents of sub dictionary for managed clusters :param cr: computeResources :type cr: dict """ for param in ('instanceRole', 'maxvCpus', 'minvCpus', 'instanceTypes', 'securityGroupIds', 'subnets', 'type'): ...
python
def _validate_compute_resources(self, cr): """ Checks contents of sub dictionary for managed clusters :param cr: computeResources :type cr: dict """ for param in ('instanceRole', 'maxvCpus', 'minvCpus', 'instanceTypes', 'securityGroupIds', 'subnets', 'type'): ...
[ "def", "_validate_compute_resources", "(", "self", ",", "cr", ")", ":", "for", "param", "in", "(", "'instanceRole'", ",", "'maxvCpus'", ",", "'minvCpus'", ",", "'instanceTypes'", ",", "'securityGroupIds'", ",", "'subnets'", ",", "'type'", ")", ":", "if", "para...
Checks contents of sub dictionary for managed clusters :param cr: computeResources :type cr: dict
[ "Checks", "contents", "of", "sub", "dictionary", "for", "managed", "clusters" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L669-L716
222,258
spulec/moto
moto/batch/models.py
BatchBackend.find_min_instances_to_meet_vcpus
def find_min_instances_to_meet_vcpus(instance_types, target): """ Finds the minimum needed instances to meed a vcpu target :param instance_types: Instance types, like ['t2.medium', 't2.small'] :type instance_types: list of str :param target: VCPU target :type target: flo...
python
def find_min_instances_to_meet_vcpus(instance_types, target): """ Finds the minimum needed instances to meed a vcpu target :param instance_types: Instance types, like ['t2.medium', 't2.small'] :type instance_types: list of str :param target: VCPU target :type target: flo...
[ "def", "find_min_instances_to_meet_vcpus", "(", "instance_types", ",", "target", ")", ":", "# vcpus = [ (vcpus, instance_type), (vcpus, instance_type), ... ]", "instance_vcpus", "=", "[", "]", "instances", "=", "[", "]", "for", "instance_type", "in", "instance_types", ":", ...
Finds the minimum needed instances to meed a vcpu target :param instance_types: Instance types, like ['t2.medium', 't2.small'] :type instance_types: list of str :param target: VCPU target :type target: float :return: List of instance types :rtype: list of str
[ "Finds", "the", "minimum", "needed", "instances", "to", "meed", "a", "vcpu", "target" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L719-L766
222,259
spulec/moto
moto/batch/models.py
BatchBackend.create_job_queue
def create_job_queue(self, queue_name, priority, state, compute_env_order): """ Create a job queue :param queue_name: Queue name :type queue_name: str :param priority: Queue priority :type priority: int :param state: Queue state :type state: string ...
python
def create_job_queue(self, queue_name, priority, state, compute_env_order): """ Create a job queue :param queue_name: Queue name :type queue_name: str :param priority: Queue priority :type priority: int :param state: Queue state :type state: string ...
[ "def", "create_job_queue", "(", "self", ",", "queue_name", ",", "priority", ",", "state", ",", "compute_env_order", ")", ":", "for", "variable", ",", "var_name", "in", "(", "(", "queue_name", ",", "'jobQueueName'", ")", ",", "(", "priority", ",", "'priority'...
Create a job queue :param queue_name: Queue name :type queue_name: str :param priority: Queue priority :type priority: int :param state: Queue state :type state: string :param compute_env_order: Compute environment list :type compute_env_order: list of di...
[ "Create", "a", "job", "queue" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L814-L857
222,260
spulec/moto
moto/batch/models.py
BatchBackend.update_job_queue
def update_job_queue(self, queue_name, priority, state, compute_env_order): """ Update a job queue :param queue_name: Queue name :type queue_name: str :param priority: Queue priority :type priority: int :param state: Queue state :type state: string ...
python
def update_job_queue(self, queue_name, priority, state, compute_env_order): """ Update a job queue :param queue_name: Queue name :type queue_name: str :param priority: Queue priority :type priority: int :param state: Queue state :type state: string ...
[ "def", "update_job_queue", "(", "self", ",", "queue_name", ",", "priority", ",", "state", ",", "compute_env_order", ")", ":", "if", "queue_name", "is", "None", ":", "raise", "ClientException", "(", "'jobQueueName must be provided'", ")", "job_queue", "=", "self", ...
Update a job queue :param queue_name: Queue name :type queue_name: str :param priority: Queue priority :type priority: int :param state: Queue state :type state: string :param compute_env_order: Compute environment list :type compute_env_order: list of di...
[ "Update", "a", "job", "queue" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L874-L924
222,261
chrismattmann/tika-python
tika/tika.py
toFilename
def toFilename(url): ''' gets url and returns filename ''' urlp = urlparse(url) path = urlp.path if not path: path = "file_{}".format(int(time.time())) value = re.sub(r'[^\w\s\.\-]', '-', path).strip().lower() return re.sub(r'[-\s]+', '-', value).strip("-")[-200:]
python
def toFilename(url): ''' gets url and returns filename ''' urlp = urlparse(url) path = urlp.path if not path: path = "file_{}".format(int(time.time())) value = re.sub(r'[^\w\s\.\-]', '-', path).strip().lower() return re.sub(r'[-\s]+', '-', value).strip("-")[-200:]
[ "def", "toFilename", "(", "url", ")", ":", "urlp", "=", "urlparse", "(", "url", ")", "path", "=", "urlp", ".", "path", "if", "not", "path", ":", "path", "=", "\"file_{}\"", ".", "format", "(", "int", "(", "time", ".", "time", "(", ")", ")", ")", ...
gets url and returns filename
[ "gets", "url", "and", "returns", "filename" ]
ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a
https://github.com/chrismattmann/tika-python/blob/ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a/tika/tika.py#L672-L681
222,262
chrismattmann/tika-python
tika/tika.py
main
def main(argv=None): """Run Tika from command line according to USAGE.""" global Verbose global EncodeUtf8 global csvOutput if argv is None: argv = sys.argv if (len(argv) < 3 and not (('-h' in argv) or ('--help' in argv))): log.exception('Bad args') raise TikaException('...
python
def main(argv=None): """Run Tika from command line according to USAGE.""" global Verbose global EncodeUtf8 global csvOutput if argv is None: argv = sys.argv if (len(argv) < 3 and not (('-h' in argv) or ('--help' in argv))): log.exception('Bad args') raise TikaException('...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "global", "Verbose", "global", "EncodeUtf8", "global", "csvOutput", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "if", "(", "len", "(", "argv", ")", "<", "3", "and", "not", "("...
Run Tika from command line according to USAGE.
[ "Run", "Tika", "from", "command", "line", "according", "to", "USAGE", "." ]
ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a
https://github.com/chrismattmann/tika-python/blob/ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a/tika/tika.py#L771-L812
222,263
ahupp/python-magic
magic.py
from_file
def from_file(filename, mime=False): """" Accepts a filename and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_file("testdata/test.pdf", mime=True) 'application/pdf' """ m = _get_magic_type(mime) return m.f...
python
def from_file(filename, mime=False): """" Accepts a filename and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_file("testdata/test.pdf", mime=True) 'application/pdf' """ m = _get_magic_type(mime) return m.f...
[ "def", "from_file", "(", "filename", ",", "mime", "=", "False", ")", ":", "m", "=", "_get_magic_type", "(", "mime", ")", "return", "m", ".", "from_file", "(", "filename", ")" ]
Accepts a filename and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_file("testdata/test.pdf", mime=True) 'application/pdf'
[ "Accepts", "a", "filename", "and", "returns", "the", "detected", "filetype", ".", "Return", "value", "is", "the", "mimetype", "if", "mime", "=", "True", "otherwise", "a", "human", "readable", "name", "." ]
c5b386b08bfbc01330e2ba836d97749d242429dc
https://github.com/ahupp/python-magic/blob/c5b386b08bfbc01330e2ba836d97749d242429dc/magic.py#L133-L143
222,264
ahupp/python-magic
magic.py
from_buffer
def from_buffer(buffer, mime=False): """ Accepts a binary string and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_buffer(open("testdata/test.pdf").read(1024)) 'PDF document, version 1.2' """ m = _get_magic_typ...
python
def from_buffer(buffer, mime=False): """ Accepts a binary string and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_buffer(open("testdata/test.pdf").read(1024)) 'PDF document, version 1.2' """ m = _get_magic_typ...
[ "def", "from_buffer", "(", "buffer", ",", "mime", "=", "False", ")", ":", "m", "=", "_get_magic_type", "(", "mime", ")", "return", "m", ".", "from_buffer", "(", "buffer", ")" ]
Accepts a binary string and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_buffer(open("testdata/test.pdf").read(1024)) 'PDF document, version 1.2'
[ "Accepts", "a", "binary", "string", "and", "returns", "the", "detected", "filetype", ".", "Return", "value", "is", "the", "mimetype", "if", "mime", "=", "True", "otherwise", "a", "human", "readable", "name", "." ]
c5b386b08bfbc01330e2ba836d97749d242429dc
https://github.com/ahupp/python-magic/blob/c5b386b08bfbc01330e2ba836d97749d242429dc/magic.py#L146-L156
222,265
yhat/ggpy
ggplot/colors/palettes.py
desaturate
def desaturate(color, prop): """Decrease the saturation channel of a color by some percent. Parameters ---------- color : matplotlib color hex, rgb-tuple, or html color name prop : float saturation channel of color will be multiplied by this value Returns ------- new_co...
python
def desaturate(color, prop): """Decrease the saturation channel of a color by some percent. Parameters ---------- color : matplotlib color hex, rgb-tuple, or html color name prop : float saturation channel of color will be multiplied by this value Returns ------- new_co...
[ "def", "desaturate", "(", "color", ",", "prop", ")", ":", "# Check inputs", "if", "not", "0", "<=", "prop", "<=", "1", ":", "raise", "ValueError", "(", "\"prop must be between 0 and 1\"", ")", "# Get rgb tuple rep", "rgb", "=", "mplcol", ".", "colorConverter", ...
Decrease the saturation channel of a color by some percent. Parameters ---------- color : matplotlib color hex, rgb-tuple, or html color name prop : float saturation channel of color will be multiplied by this value Returns ------- new_color : rgb tuple desaturated ...
[ "Decrease", "the", "saturation", "channel", "of", "a", "color", "by", "some", "percent", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L17-L49
222,266
yhat/ggpy
ggplot/colors/palettes.py
color_palette
def color_palette(name=None, n_colors=6, desat=None): """Return a list of colors defining a color palette. Availible seaborn palette names: deep, muted, bright, pastel, dark, colorblind Other options: hls, husl, any matplotlib palette Matplotlib paletes can be specified as reversed pa...
python
def color_palette(name=None, n_colors=6, desat=None): """Return a list of colors defining a color palette. Availible seaborn palette names: deep, muted, bright, pastel, dark, colorblind Other options: hls, husl, any matplotlib palette Matplotlib paletes can be specified as reversed pa...
[ "def", "color_palette", "(", "name", "=", "None", ",", "n_colors", "=", "6", ",", "desat", "=", "None", ")", ":", "seaborn_palettes", "=", "dict", "(", "deep", "=", "[", "\"#4C72B0\"", ",", "\"#55A868\"", ",", "\"#C44E52\"", ",", "\"#8172B2\"", ",", "\"#...
Return a list of colors defining a color palette. Availible seaborn palette names: deep, muted, bright, pastel, dark, colorblind Other options: hls, husl, any matplotlib palette Matplotlib paletes can be specified as reversed palettes by appending "_r" to the name or as dark palettes ...
[ "Return", "a", "list", "of", "colors", "defining", "a", "color", "palette", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L67-L165
222,267
yhat/ggpy
ggplot/colors/palettes.py
mpl_palette
def mpl_palette(name, n_colors=6): """Return discrete colors from a matplotlib palette. Note that this handles the qualitative colorbrewer palettes properly, although if you ask for more colors than a particular qualitative palette can provide you will fewer than you are expecting. Parameters ...
python
def mpl_palette(name, n_colors=6): """Return discrete colors from a matplotlib palette. Note that this handles the qualitative colorbrewer palettes properly, although if you ask for more colors than a particular qualitative palette can provide you will fewer than you are expecting. Parameters ...
[ "def", "mpl_palette", "(", "name", ",", "n_colors", "=", "6", ")", ":", "brewer_qual_pals", "=", "{", "\"Accent\"", ":", "8", ",", "\"Dark2\"", ":", "8", ",", "\"Paired\"", ":", "12", ",", "\"Pastel1\"", ":", "9", ",", "\"Pastel2\"", ":", "8", ",", "...
Return discrete colors from a matplotlib palette. Note that this handles the qualitative colorbrewer palettes properly, although if you ask for more colors than a particular qualitative palette can provide you will fewer than you are expecting. Parameters ---------- name : string n...
[ "Return", "discrete", "colors", "from", "a", "matplotlib", "palette", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L232-L269
222,268
yhat/ggpy
ggplot/colors/palettes.py
dark_palette
def dark_palette(color, n_colors=6, reverse=False, as_cmap=False): """Make a palette that blends from a deep gray to `color`. Parameters ---------- color : matplotlib color hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette reverse : bool...
python
def dark_palette(color, n_colors=6, reverse=False, as_cmap=False): """Make a palette that blends from a deep gray to `color`. Parameters ---------- color : matplotlib color hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette reverse : bool...
[ "def", "dark_palette", "(", "color", ",", "n_colors", "=", "6", ",", "reverse", "=", "False", ",", "as_cmap", "=", "False", ")", ":", "gray", "=", "\"#222222\"", "colors", "=", "[", "color", ",", "gray", "]", "if", "reverse", "else", "[", "gray", ","...
Make a palette that blends from a deep gray to `color`. Parameters ---------- color : matplotlib color hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette reverse : bool, optional if True, reverse the direction of the blend as_cmap...
[ "Make", "a", "palette", "that", "blends", "from", "a", "deep", "gray", "to", "color", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L272-L293
222,269
yhat/ggpy
ggplot/colors/palettes.py
blend_palette
def blend_palette(colors, n_colors=6, as_cmap=False): """Make a palette that blends between a list of colors. Parameters ---------- colors : sequence of matplotlib colors hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette as_cmap : bool, ...
python
def blend_palette(colors, n_colors=6, as_cmap=False): """Make a palette that blends between a list of colors. Parameters ---------- colors : sequence of matplotlib colors hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette as_cmap : bool, ...
[ "def", "blend_palette", "(", "colors", ",", "n_colors", "=", "6", ",", "as_cmap", "=", "False", ")", ":", "name", "=", "\"-\"", ".", "join", "(", "map", "(", "str", ",", "colors", ")", ")", "pal", "=", "mpl", ".", "colors", ".", "LinearSegmentedColor...
Make a palette that blends between a list of colors. Parameters ---------- colors : sequence of matplotlib colors hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette as_cmap : bool, optional if True, return as a matplotlib colormap ins...
[ "Make", "a", "palette", "that", "blends", "between", "a", "list", "of", "colors", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L296-L317
222,270
yhat/ggpy
ggplot/colors/palettes.py
xkcd_palette
def xkcd_palette(colors): """Make a palette with color names from the xkcd color survey. This is just a simple wrapper around the seaborn.xkcd_rbg dictionary. See xkcd for the full list of colors: http://xkcd.com/color/rgb/ """ palette = [xkcd_rgb[name] for name in colors] return color_palett...
python
def xkcd_palette(colors): """Make a palette with color names from the xkcd color survey. This is just a simple wrapper around the seaborn.xkcd_rbg dictionary. See xkcd for the full list of colors: http://xkcd.com/color/rgb/ """ palette = [xkcd_rgb[name] for name in colors] return color_palett...
[ "def", "xkcd_palette", "(", "colors", ")", ":", "palette", "=", "[", "xkcd_rgb", "[", "name", "]", "for", "name", "in", "colors", "]", "return", "color_palette", "(", "palette", ",", "len", "(", "palette", ")", ")" ]
Make a palette with color names from the xkcd color survey. This is just a simple wrapper around the seaborn.xkcd_rbg dictionary. See xkcd for the full list of colors: http://xkcd.com/color/rgb/
[ "Make", "a", "palette", "with", "color", "names", "from", "the", "xkcd", "color", "survey", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L320-L329
222,271
yhat/ggpy
ggplot/colors/palettes.py
cubehelix_palette
def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8, light=.85, dark=.15, reverse=False, as_cmap=False): """Make a sequential palette from the cubehelix system. This produces a colormap with linearly-decreasing (or increasing) brightness. That means that information ...
python
def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8, light=.85, dark=.15, reverse=False, as_cmap=False): """Make a sequential palette from the cubehelix system. This produces a colormap with linearly-decreasing (or increasing) brightness. That means that information ...
[ "def", "cubehelix_palette", "(", "n_colors", "=", "6", ",", "start", "=", "0", ",", "rot", "=", ".4", ",", "gamma", "=", "1.0", ",", "hue", "=", "0.8", ",", "light", "=", ".85", ",", "dark", "=", ".15", ",", "reverse", "=", "False", ",", "as_cmap...
Make a sequential palette from the cubehelix system. This produces a colormap with linearly-decreasing (or increasing) brightness. That means that information will be preserved if printed to black and white or viewed by someone who is colorblind. "cubehelix" is also availible as a matplotlib-based pal...
[ "Make", "a", "sequential", "palette", "from", "the", "cubehelix", "system", "." ]
b6d23c22d52557b983da8ce7a3a6992501dadcd6
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L332-L392
222,272
kkroening/ffmpeg-python
ffmpeg/_run.py
get_args
def get_args(stream_spec, overwrite_output=False): """Build command-line arguments to be passed to ffmpeg.""" nodes = get_stream_spec_nodes(stream_spec) args = [] # TODO: group nodes together, e.g. `-i somefile -r somerate`. sorted_nodes, outgoing_edge_maps = topo_sort(nodes) input_nodes = [node...
python
def get_args(stream_spec, overwrite_output=False): """Build command-line arguments to be passed to ffmpeg.""" nodes = get_stream_spec_nodes(stream_spec) args = [] # TODO: group nodes together, e.g. `-i somefile -r somerate`. sorted_nodes, outgoing_edge_maps = topo_sort(nodes) input_nodes = [node...
[ "def", "get_args", "(", "stream_spec", ",", "overwrite_output", "=", "False", ")", ":", "nodes", "=", "get_stream_spec_nodes", "(", "stream_spec", ")", "args", "=", "[", "]", "# TODO: group nodes together, e.g. `-i somefile -r somerate`.", "sorted_nodes", ",", "outgoing...
Build command-line arguments to be passed to ffmpeg.
[ "Build", "command", "-", "line", "arguments", "to", "be", "passed", "to", "ffmpeg", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L135-L154
222,273
kkroening/ffmpeg-python
ffmpeg/_run.py
compile
def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): """Build command-line for invoking ffmpeg. The :meth:`run` function uses this to build the commnad line arguments and should work in most cases, but calling this function directly is useful for debugging or if you need to invoke ffmpeg ...
python
def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): """Build command-line for invoking ffmpeg. The :meth:`run` function uses this to build the commnad line arguments and should work in most cases, but calling this function directly is useful for debugging or if you need to invoke ffmpeg ...
[ "def", "compile", "(", "stream_spec", ",", "cmd", "=", "'ffmpeg'", ",", "overwrite_output", "=", "False", ")", ":", "if", "isinstance", "(", "cmd", ",", "basestring", ")", ":", "cmd", "=", "[", "cmd", "]", "elif", "type", "(", "cmd", ")", "!=", "list...
Build command-line for invoking ffmpeg. The :meth:`run` function uses this to build the commnad line arguments and should work in most cases, but calling this function directly is useful for debugging or if you need to invoke ffmpeg manually for whatever reason. This is the same as calling :meth:`...
[ "Build", "command", "-", "line", "for", "invoking", "ffmpeg", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L158-L173
222,274
kkroening/ffmpeg-python
ffmpeg/_run.py
run_async
def run_async( stream_spec, cmd='ffmpeg', pipe_stdin=False, pipe_stdout=False, pipe_stderr=False, quiet=False, overwrite_output=False): """Asynchronously invoke ffmpeg for the supplied node graph. Args: pipe_stdin: if True, connect pipe to subprocess stdin (to be used with `...
python
def run_async( stream_spec, cmd='ffmpeg', pipe_stdin=False, pipe_stdout=False, pipe_stderr=False, quiet=False, overwrite_output=False): """Asynchronously invoke ffmpeg for the supplied node graph. Args: pipe_stdin: if True, connect pipe to subprocess stdin (to be used with `...
[ "def", "run_async", "(", "stream_spec", ",", "cmd", "=", "'ffmpeg'", ",", "pipe_stdin", "=", "False", ",", "pipe_stdout", "=", "False", ",", "pipe_stderr", "=", "False", ",", "quiet", "=", "False", ",", "overwrite_output", "=", "False", ")", ":", "args", ...
Asynchronously invoke ffmpeg for the supplied node graph. Args: pipe_stdin: if True, connect pipe to subprocess stdin (to be used with ``pipe:`` ffmpeg inputs). pipe_stdout: if True, connect pipe to subprocess stdout (to be used with ``pipe:`` ffmpeg outputs). pipe_s...
[ "Asynchronously", "invoke", "ffmpeg", "for", "the", "supplied", "node", "graph", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L177-L262
222,275
kkroening/ffmpeg-python
ffmpeg/_run.py
run
def run( stream_spec, cmd='ffmpeg', capture_stdout=False, capture_stderr=False, input=None, quiet=False, overwrite_output=False): """Invoke ffmpeg for the supplied node graph. Args: capture_stdout: if True, capture stdout (to be used with ``pipe:`` ffmpeg outputs). c...
python
def run( stream_spec, cmd='ffmpeg', capture_stdout=False, capture_stderr=False, input=None, quiet=False, overwrite_output=False): """Invoke ffmpeg for the supplied node graph. Args: capture_stdout: if True, capture stdout (to be used with ``pipe:`` ffmpeg outputs). c...
[ "def", "run", "(", "stream_spec", ",", "cmd", "=", "'ffmpeg'", ",", "capture_stdout", "=", "False", ",", "capture_stderr", "=", "False", ",", "input", "=", "None", ",", "quiet", "=", "False", ",", "overwrite_output", "=", "False", ")", ":", "process", "=...
Invoke ffmpeg for the supplied node graph. Args: capture_stdout: if True, capture stdout (to be used with ``pipe:`` ffmpeg outputs). capture_stderr: if True, capture stderr. quiet: shorthand for setting ``capture_stdout`` and ``capture_stderr``. input: text to be sent to...
[ "Invoke", "ffmpeg", "for", "the", "supplied", "node", "graph", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L266-L296
222,276
kkroening/ffmpeg-python
ffmpeg/_ffmpeg.py
output
def output(*streams_and_filename, **kwargs): """Output file URL Syntax: `ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)` Any supplied keyword arguments are passed to ffmpeg verbatim (e.g. ``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``, etc.). Some k...
python
def output(*streams_and_filename, **kwargs): """Output file URL Syntax: `ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)` Any supplied keyword arguments are passed to ffmpeg verbatim (e.g. ``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``, etc.). Some k...
[ "def", "output", "(", "*", "streams_and_filename", ",", "*", "*", "kwargs", ")", ":", "streams_and_filename", "=", "list", "(", "streams_and_filename", ")", "if", "'filename'", "not", "in", "kwargs", ":", "if", "not", "isinstance", "(", "streams_and_filename", ...
Output file URL Syntax: `ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)` Any supplied keyword arguments are passed to ffmpeg verbatim (e.g. ``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``, etc.). Some keyword-arguments are handled specially, as shown bel...
[ "Output", "file", "URL" ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_ffmpeg.py#L59-L94
222,277
kkroening/ffmpeg-python
examples/show_progress.py
_do_watch_progress
def _do_watch_progress(filename, sock, handler): """Function to run in a separate gevent greenlet to read progress events from a unix-domain socket.""" connection, client_address = sock.accept() data = b'' try: while True: more_data = connection.recv(16) if not more_d...
python
def _do_watch_progress(filename, sock, handler): """Function to run in a separate gevent greenlet to read progress events from a unix-domain socket.""" connection, client_address = sock.accept() data = b'' try: while True: more_data = connection.recv(16) if not more_d...
[ "def", "_do_watch_progress", "(", "filename", ",", "sock", ",", "handler", ")", ":", "connection", ",", "client_address", "=", "sock", ".", "accept", "(", ")", "data", "=", "b''", "try", ":", "while", "True", ":", "more_data", "=", "connection", ".", "re...
Function to run in a separate gevent greenlet to read progress events from a unix-domain socket.
[ "Function", "to", "run", "in", "a", "separate", "gevent", "greenlet", "to", "read", "progress", "events", "from", "a", "unix", "-", "domain", "socket", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/show_progress.py#L42-L62
222,278
kkroening/ffmpeg-python
examples/show_progress.py
_watch_progress
def _watch_progress(handler): """Context manager for creating a unix-domain socket and listen for ffmpeg progress events. The socket filename is yielded from the context manager and the socket is closed when the context manager is exited. Args: handler: a function to be called when progres...
python
def _watch_progress(handler): """Context manager for creating a unix-domain socket and listen for ffmpeg progress events. The socket filename is yielded from the context manager and the socket is closed when the context manager is exited. Args: handler: a function to be called when progres...
[ "def", "_watch_progress", "(", "handler", ")", ":", "with", "_tmpdir_scope", "(", ")", "as", "tmpdir", ":", "socket_filename", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "'sock'", ")", "sock", "=", "socket", ".", "socket", "(", "socket", ...
Context manager for creating a unix-domain socket and listen for ffmpeg progress events. The socket filename is yielded from the context manager and the socket is closed when the context manager is exited. Args: handler: a function to be called when progress events are received; re...
[ "Context", "manager", "for", "creating", "a", "unix", "-", "domain", "socket", "and", "listen", "for", "ffmpeg", "progress", "events", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/show_progress.py#L66-L92
222,279
kkroening/ffmpeg-python
examples/show_progress.py
show_progress
def show_progress(total_duration): """Create a unix-domain socket to watch progress and render tqdm progress bar.""" with tqdm(total=round(total_duration, 2)) as bar: def handler(key, value): if key == 'out_time_ms': time = round(float(value) / 1000000., 2) ...
python
def show_progress(total_duration): """Create a unix-domain socket to watch progress and render tqdm progress bar.""" with tqdm(total=round(total_duration, 2)) as bar: def handler(key, value): if key == 'out_time_ms': time = round(float(value) / 1000000., 2) ...
[ "def", "show_progress", "(", "total_duration", ")", ":", "with", "tqdm", "(", "total", "=", "round", "(", "total_duration", ",", "2", ")", ")", "as", "bar", ":", "def", "handler", "(", "key", ",", "value", ")", ":", "if", "key", "==", "'out_time_ms'", ...
Create a unix-domain socket to watch progress and render tqdm progress bar.
[ "Create", "a", "unix", "-", "domain", "socket", "to", "watch", "progress", "and", "render", "tqdm", "progress", "bar", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/show_progress.py#L97-L108
222,280
kkroening/ffmpeg-python
ffmpeg/_probe.py
probe
def probe(filename, cmd='ffprobe', **kwargs): """Run ffprobe on the specified file and return a JSON representation of the output. Raises: :class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code, an :class:`Error` is returned with a generic error message. The stderr outpu...
python
def probe(filename, cmd='ffprobe', **kwargs): """Run ffprobe on the specified file and return a JSON representation of the output. Raises: :class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code, an :class:`Error` is returned with a generic error message. The stderr outpu...
[ "def", "probe", "(", "filename", ",", "cmd", "=", "'ffprobe'", ",", "*", "*", "kwargs", ")", ":", "args", "=", "[", "cmd", ",", "'-show_format'", ",", "'-show_streams'", ",", "'-of'", ",", "'json'", "]", "args", "+=", "convert_kwargs_to_cmd_line_args", "("...
Run ffprobe on the specified file and return a JSON representation of the output. Raises: :class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code, an :class:`Error` is returned with a generic error message. The stderr output can be retrieved by accessing the ``std...
[ "Run", "ffprobe", "on", "the", "specified", "file", "and", "return", "a", "JSON", "representation", "of", "the", "output", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_probe.py#L7-L24
222,281
kkroening/ffmpeg-python
ffmpeg/_filters.py
filter_multi_output
def filter_multi_output(stream_spec, filter_name, *args, **kwargs): """Apply custom filter with one or more outputs. This is the same as ``filter_`` except that the filter can produce more than one output. To reference an output stream, use either the ``.stream`` operator or bracket shorthand: Exampl...
python
def filter_multi_output(stream_spec, filter_name, *args, **kwargs): """Apply custom filter with one or more outputs. This is the same as ``filter_`` except that the filter can produce more than one output. To reference an output stream, use either the ``.stream`` operator or bracket shorthand: Exampl...
[ "def", "filter_multi_output", "(", "stream_spec", ",", "filter_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "FilterNode", "(", "stream_spec", ",", "filter_name", ",", "args", "=", "args", ",", "kwargs", "=", "kwargs", ",", "max_inp...
Apply custom filter with one or more outputs. This is the same as ``filter_`` except that the filter can produce more than one output. To reference an output stream, use either the ``.stream`` operator or bracket shorthand: Example: ``` split = ffmpeg.input('in.mp4').filter_multi_output(...
[ "Apply", "custom", "filter", "with", "one", "or", "more", "outputs", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L8-L24
222,282
kkroening/ffmpeg-python
ffmpeg/_filters.py
filter
def filter(stream_spec, filter_name, *args, **kwargs): """Apply custom filter. ``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name ...
python
def filter(stream_spec, filter_name, *args, **kwargs): """Apply custom filter. ``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name ...
[ "def", "filter", "(", "stream_spec", ",", "filter_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "filter_multi_output", "(", "stream_spec", ",", "filter_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "stream", "(", "...
Apply custom filter. ``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name and arguments to ffmpeg verbatim. Args: stream_...
[ "Apply", "custom", "filter", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L28-L47
222,283
kkroening/ffmpeg-python
ffmpeg/_filters.py
filter_
def filter_(stream_spec, filter_name, *args, **kwargs): """Alternate name for ``filter``, so as to not collide with the built-in python ``filter`` operator. """ return filter(stream_spec, filter_name, *args, **kwargs)
python
def filter_(stream_spec, filter_name, *args, **kwargs): """Alternate name for ``filter``, so as to not collide with the built-in python ``filter`` operator. """ return filter(stream_spec, filter_name, *args, **kwargs)
[ "def", "filter_", "(", "stream_spec", ",", "filter_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "filter", "(", "stream_spec", ",", "filter_name", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Alternate name for ``filter``, so as to not collide with the built-in python ``filter`` operator.
[ "Alternate", "name", "for", "filter", "so", "as", "to", "not", "collide", "with", "the", "built", "-", "in", "python", "filter", "operator", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L51-L55
222,284
kkroening/ffmpeg-python
ffmpeg/_filters.py
trim
def trim(stream, **kwargs): """Trim the input so that the output contains one continuous subpart of the input. Args: start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the first frame in the output. end: Specify the time of the ...
python
def trim(stream, **kwargs): """Trim the input so that the output contains one continuous subpart of the input. Args: start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the first frame in the output. end: Specify the time of the ...
[ "def", "trim", "(", "stream", ",", "*", "*", "kwargs", ")", ":", "return", "FilterNode", "(", "stream", ",", "trim", ".", "__name__", ",", "kwargs", "=", "kwargs", ")", ".", "stream", "(", ")" ]
Trim the input so that the output contains one continuous subpart of the input. Args: start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the first frame in the output. end: Specify the time of the first frame that will be dropped, i...
[ "Trim", "the", "input", "so", "that", "the", "output", "contains", "one", "continuous", "subpart", "of", "the", "input", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L81-L99
222,285
kkroening/ffmpeg-python
ffmpeg/_filters.py
overlay
def overlay(main_parent_node, overlay_parent_node, eof_action='repeat', **kwargs): """Overlay one video on top of another. Args: x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In case the expression is invalid, it is set to a huge va...
python
def overlay(main_parent_node, overlay_parent_node, eof_action='repeat', **kwargs): """Overlay one video on top of another. Args: x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In case the expression is invalid, it is set to a huge va...
[ "def", "overlay", "(", "main_parent_node", ",", "overlay_parent_node", ",", "eof_action", "=", "'repeat'", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'eof_action'", "]", "=", "eof_action", "return", "FilterNode", "(", "[", "main_parent_node", ",", "ove...
Overlay one video on top of another. Args: x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In case the expression is invalid, it is set to a huge value (meaning that the overlay will not be displayed within the output visible ...
[ "Overlay", "one", "video", "on", "top", "of", "another", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L103-L147
222,286
kkroening/ffmpeg-python
ffmpeg/_filters.py
crop
def crop(stream, x, y, width, height, **kwargs): """Crop the input video. Args: x: The horizontal position, in the input video, of the left edge of the output video. y: The vertical position, in the input video, of the top edge of the output video. width: The width...
python
def crop(stream, x, y, width, height, **kwargs): """Crop the input video. Args: x: The horizontal position, in the input video, of the left edge of the output video. y: The vertical position, in the input video, of the top edge of the output video. width: The width...
[ "def", "crop", "(", "stream", ",", "x", ",", "y", ",", "width", ",", "height", ",", "*", "*", "kwargs", ")", ":", "return", "FilterNode", "(", "stream", ",", "crop", ".", "__name__", ",", "args", "=", "[", "width", ",", "height", ",", "x", ",", ...
Crop the input video. Args: x: The horizontal position, in the input video, of the left edge of the output video. y: The vertical position, in the input video, of the top edge of the output video. width: The width of the output video. Must be greater than 0. he...
[ "Crop", "the", "input", "video", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L169-L187
222,287
kkroening/ffmpeg-python
ffmpeg/_filters.py
drawbox
def drawbox(stream, x, y, width, height, color, thickness=None, **kwargs): """Draw a colored box on the input image. Args: x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0. y: The expression which specifies the top left corner y coordinate of the b...
python
def drawbox(stream, x, y, width, height, color, thickness=None, **kwargs): """Draw a colored box on the input image. Args: x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0. y: The expression which specifies the top left corner y coordinate of the b...
[ "def", "drawbox", "(", "stream", ",", "x", ",", "y", ",", "width", ",", "height", ",", "color", ",", "thickness", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "thickness", ":", "kwargs", "[", "'t'", "]", "=", "thickness", "return", "Filter...
Draw a colored box on the input image. Args: x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0. y: The expression which specifies the top left corner y coordinate of the box. It defaults to 0. width: Specify the width of the box; if 0 interprete...
[ "Draw", "a", "colored", "box", "on", "the", "input", "image", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L191-L212
222,288
kkroening/ffmpeg-python
ffmpeg/_filters.py
drawtext
def drawtext(stream, text=None, x=0, y=0, escape_text=True, **kwargs): """Draw a text string or text from a specified file on top of a video, using the libfreetype library. To enable compilation of this filter, you need to configure FFmpeg with ``--enable-libfreetype``. To enable default font fallback and ...
python
def drawtext(stream, text=None, x=0, y=0, escape_text=True, **kwargs): """Draw a text string or text from a specified file on top of a video, using the libfreetype library. To enable compilation of this filter, you need to configure FFmpeg with ``--enable-libfreetype``. To enable default font fallback and ...
[ "def", "drawtext", "(", "stream", ",", "text", "=", "None", ",", "x", "=", "0", ",", "y", "=", "0", ",", "escape_text", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "text", "is", "not", "None", ":", "if", "escape_text", ":", "text", "=...
Draw a text string or text from a specified file on top of a video, using the libfreetype library. To enable compilation of this filter, you need to configure FFmpeg with ``--enable-libfreetype``. To enable default font fallback and the font option you need to configure FFmpeg with ``--enable-libfontconfig``. ...
[ "Draw", "a", "text", "string", "or", "text", "from", "a", "specified", "file", "on", "top", "of", "a", "video", "using", "the", "libfreetype", "library", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L216-L354
222,289
kkroening/ffmpeg-python
ffmpeg/_filters.py
concat
def concat(*streams, **kwargs): """Concatenate audio and video streams, joining them together one after the other. The filter works on segments of synchronized video and audio streams. All segments must have the same number of streams of each type, and that will also be the number of streams at output. ...
python
def concat(*streams, **kwargs): """Concatenate audio and video streams, joining them together one after the other. The filter works on segments of synchronized video and audio streams. All segments must have the same number of streams of each type, and that will also be the number of streams at output. ...
[ "def", "concat", "(", "*", "streams", ",", "*", "*", "kwargs", ")", ":", "video_stream_count", "=", "kwargs", ".", "get", "(", "'v'", ",", "1", ")", "audio_stream_count", "=", "kwargs", ".", "get", "(", "'a'", ",", "0", ")", "stream_count", "=", "vid...
Concatenate audio and video streams, joining them together one after the other. The filter works on segments of synchronized video and audio streams. All segments must have the same number of streams of each type, and that will also be the number of streams at output. Args: unsafe: Activate unsafe...
[ "Concatenate", "audio", "and", "video", "streams", "joining", "them", "together", "one", "after", "the", "other", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L358-L391
222,290
kkroening/ffmpeg-python
ffmpeg/_filters.py
zoompan
def zoompan(stream, **kwargs): """Apply Zoom & Pan effect. Args: zoom: Set the zoom expression. Default is 1. x: Set the x expression. Default is 0. y: Set the y expression. Default is 0. d: Set the duration expression in number of frames. This sets for how many number of frames...
python
def zoompan(stream, **kwargs): """Apply Zoom & Pan effect. Args: zoom: Set the zoom expression. Default is 1. x: Set the x expression. Default is 0. y: Set the y expression. Default is 0. d: Set the duration expression in number of frames. This sets for how many number of frames...
[ "def", "zoompan", "(", "stream", ",", "*", "*", "kwargs", ")", ":", "return", "FilterNode", "(", "stream", ",", "zoompan", ".", "__name__", ",", "kwargs", "=", "kwargs", ")", ".", "stream", "(", ")" ]
Apply Zoom & Pan effect. Args: zoom: Set the zoom expression. Default is 1. x: Set the x expression. Default is 0. y: Set the y expression. Default is 0. d: Set the duration expression in number of frames. This sets for how many number of frames effect will last for sing...
[ "Apply", "Zoom", "&", "Pan", "effect", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L395-L410
222,291
kkroening/ffmpeg-python
ffmpeg/_filters.py
colorchannelmixer
def colorchannelmixer(stream, *args, **kwargs): """Adjust video input frames by re-mixing color channels. Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__ """ return FilterNode(stream, colorchannelmixer.__name__, kwargs=kwargs).stream()
python
def colorchannelmixer(stream, *args, **kwargs): """Adjust video input frames by re-mixing color channels. Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__ """ return FilterNode(stream, colorchannelmixer.__name__, kwargs=kwargs).stream()
[ "def", "colorchannelmixer", "(", "stream", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "FilterNode", "(", "stream", ",", "colorchannelmixer", ".", "__name__", ",", "kwargs", "=", "kwargs", ")", ".", "stream", "(", ")" ]
Adjust video input frames by re-mixing color channels. Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__
[ "Adjust", "video", "input", "frames", "by", "re", "-", "mixing", "color", "channels", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L429-L434
222,292
kkroening/ffmpeg-python
ffmpeg/_utils.py
_recursive_repr
def _recursive_repr(item): """Hack around python `repr` to deterministically represent dictionaries. This is able to represent more things than json.dumps, since it does not require things to be JSON serializable (e.g. datetimes). """ if isinstance(item, basestring): result = str(item) ...
python
def _recursive_repr(item): """Hack around python `repr` to deterministically represent dictionaries. This is able to represent more things than json.dumps, since it does not require things to be JSON serializable (e.g. datetimes). """ if isinstance(item, basestring): result = str(item) ...
[ "def", "_recursive_repr", "(", "item", ")", ":", "if", "isinstance", "(", "item", ",", "basestring", ")", ":", "result", "=", "str", "(", "item", ")", "elif", "isinstance", "(", "item", ",", "list", ")", ":", "result", "=", "'[{}]'", ".", "format", "...
Hack around python `repr` to deterministically represent dictionaries. This is able to represent more things than json.dumps, since it does not require things to be JSON serializable (e.g. datetimes).
[ "Hack", "around", "python", "repr", "to", "deterministically", "represent", "dictionaries", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L44-L59
222,293
kkroening/ffmpeg-python
ffmpeg/_utils.py
escape_chars
def escape_chars(text, chars): """Helper function to escape uncomfortable characters.""" text = str(text) chars = list(set(chars)) if '\\' in chars: chars.remove('\\') chars.insert(0, '\\') for ch in chars: text = text.replace(ch, '\\' + ch) return text
python
def escape_chars(text, chars): """Helper function to escape uncomfortable characters.""" text = str(text) chars = list(set(chars)) if '\\' in chars: chars.remove('\\') chars.insert(0, '\\') for ch in chars: text = text.replace(ch, '\\' + ch) return text
[ "def", "escape_chars", "(", "text", ",", "chars", ")", ":", "text", "=", "str", "(", "text", ")", "chars", "=", "list", "(", "set", "(", "chars", ")", ")", "if", "'\\\\'", "in", "chars", ":", "chars", ".", "remove", "(", "'\\\\'", ")", "chars", "...
Helper function to escape uncomfortable characters.
[ "Helper", "function", "to", "escape", "uncomfortable", "characters", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L71-L80
222,294
kkroening/ffmpeg-python
ffmpeg/_utils.py
convert_kwargs_to_cmd_line_args
def convert_kwargs_to_cmd_line_args(kwargs): """Helper function to build command line arguments out of dict.""" args = [] for k in sorted(kwargs.keys()): v = kwargs[k] args.append('-{}'.format(k)) if v is not None: args.append('{}'.format(v)) return args
python
def convert_kwargs_to_cmd_line_args(kwargs): """Helper function to build command line arguments out of dict.""" args = [] for k in sorted(kwargs.keys()): v = kwargs[k] args.append('-{}'.format(k)) if v is not None: args.append('{}'.format(v)) return args
[ "def", "convert_kwargs_to_cmd_line_args", "(", "kwargs", ")", ":", "args", "=", "[", "]", "for", "k", "in", "sorted", "(", "kwargs", ".", "keys", "(", ")", ")", ":", "v", "=", "kwargs", "[", "k", "]", "args", ".", "append", "(", "'-{}'", ".", "form...
Helper function to build command line arguments out of dict.
[ "Helper", "function", "to", "build", "command", "line", "arguments", "out", "of", "dict", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L83-L91
222,295
kkroening/ffmpeg-python
ffmpeg/nodes.py
Node.stream
def stream(self, label=None, selector=None): """Create an outgoing stream originating from this node. More nodes may be attached onto the outgoing stream. """ return self.__outgoing_stream_type(self, label, upstream_selector=selector)
python
def stream(self, label=None, selector=None): """Create an outgoing stream originating from this node. More nodes may be attached onto the outgoing stream. """ return self.__outgoing_stream_type(self, label, upstream_selector=selector)
[ "def", "stream", "(", "self", ",", "label", "=", "None", ",", "selector", "=", "None", ")", ":", "return", "self", ".", "__outgoing_stream_type", "(", "self", ",", "label", ",", "upstream_selector", "=", "selector", ")" ]
Create an outgoing stream originating from this node. More nodes may be attached onto the outgoing stream.
[ "Create", "an", "outgoing", "stream", "originating", "from", "this", "node", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/nodes.py#L128-L133
222,296
kkroening/ffmpeg-python
examples/tensorflow_stream.py
DeepDream._tffunc
def _tffunc(*argtypes): '''Helper that transforms TF-graph generating function into a regular one. See `_resize` function below. ''' placeholders = list(map(tf.placeholder, argtypes)) def wrap(f): out = f(*placeholders) def wrapper(*args, **kw): ...
python
def _tffunc(*argtypes): '''Helper that transforms TF-graph generating function into a regular one. See `_resize` function below. ''' placeholders = list(map(tf.placeholder, argtypes)) def wrap(f): out = f(*placeholders) def wrapper(*args, **kw): ...
[ "def", "_tffunc", "(", "*", "argtypes", ")", ":", "placeholders", "=", "list", "(", "map", "(", "tf", ".", "placeholder", ",", "argtypes", ")", ")", "def", "wrap", "(", "f", ")", ":", "out", "=", "f", "(", "*", "placeholders", ")", "def", "wrapper"...
Helper that transforms TF-graph generating function into a regular one. See `_resize` function below.
[ "Helper", "that", "transforms", "TF", "-", "graph", "generating", "function", "into", "a", "regular", "one", ".", "See", "_resize", "function", "below", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L159-L169
222,297
kkroening/ffmpeg-python
examples/tensorflow_stream.py
DeepDream._base_resize
def _base_resize(img, size): '''Helper function that uses TF to resize an image''' img = tf.expand_dims(img, 0) return tf.image.resize_bilinear(img, size)[0,:,:,:]
python
def _base_resize(img, size): '''Helper function that uses TF to resize an image''' img = tf.expand_dims(img, 0) return tf.image.resize_bilinear(img, size)[0,:,:,:]
[ "def", "_base_resize", "(", "img", ",", "size", ")", ":", "img", "=", "tf", ".", "expand_dims", "(", "img", ",", "0", ")", "return", "tf", ".", "image", ".", "resize_bilinear", "(", "img", ",", "size", ")", "[", "0", ",", ":", ",", ":", ",", ":...
Helper function that uses TF to resize an image
[ "Helper", "function", "that", "uses", "TF", "to", "resize", "an", "image" ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L172-L175
222,298
kkroening/ffmpeg-python
examples/tensorflow_stream.py
DeepDream._calc_grad_tiled
def _calc_grad_tiled(self, img, t_grad, tile_size=512): '''Compute the value of tensor t_grad over the image in a tiled way. Random shifts are applied to the image to blur tile boundaries over multiple iterations.''' sz = tile_size h, w = img.shape[:2] sx, sy = np.random...
python
def _calc_grad_tiled(self, img, t_grad, tile_size=512): '''Compute the value of tensor t_grad over the image in a tiled way. Random shifts are applied to the image to blur tile boundaries over multiple iterations.''' sz = tile_size h, w = img.shape[:2] sx, sy = np.random...
[ "def", "_calc_grad_tiled", "(", "self", ",", "img", ",", "t_grad", ",", "tile_size", "=", "512", ")", ":", "sz", "=", "tile_size", "h", ",", "w", "=", "img", ".", "shape", "[", ":", "2", "]", "sx", ",", "sy", "=", "np", ".", "random", ".", "ran...
Compute the value of tensor t_grad over the image in a tiled way. Random shifts are applied to the image to blur tile boundaries over multiple iterations.
[ "Compute", "the", "value", "of", "tensor", "t_grad", "over", "the", "image", "in", "a", "tiled", "way", ".", "Random", "shifts", "are", "applied", "to", "the", "image", "to", "blur", "tile", "boundaries", "over", "multiple", "iterations", "." ]
ac111dc3a976ddbb872bc7d6d4fe24a267c1a956
https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L199-L213
222,299
python-diamond/Diamond
src/collectors/xen_collector/xen_collector.py
XENCollector.collect
def collect(self): """ Collect libvirt data """ if libvirt is None: self.log.error('Unable to import either libvirt') return {} # Open a restricted (non-root) connection to the hypervisor conn = libvirt.openReadOnly(None) # Get hardware inf...
python
def collect(self): """ Collect libvirt data """ if libvirt is None: self.log.error('Unable to import either libvirt') return {} # Open a restricted (non-root) connection to the hypervisor conn = libvirt.openReadOnly(None) # Get hardware inf...
[ "def", "collect", "(", "self", ")", ":", "if", "libvirt", "is", "None", ":", "self", ".", "log", ".", "error", "(", "'Unable to import either libvirt'", ")", "return", "{", "}", "# Open a restricted (non-root) connection to the hypervisor", "conn", "=", "libvirt", ...
Collect libvirt data
[ "Collect", "libvirt", "data" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/xen_collector/xen_collector.py#L38-L82