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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
hayd/pep8radius
pep8radius/shell.py
from_dir
def from_dir(cwd): "Context manager to ensure in the cwd directory." import os curdir = os.getcwd() try: os.chdir(cwd) yield finally: os.chdir(curdir)
python
def from_dir(cwd): "Context manager to ensure in the cwd directory." import os curdir = os.getcwd() try: os.chdir(cwd) yield finally: os.chdir(curdir)
[ "def", "from_dir", "(", "cwd", ")", ":", "import", "os", "curdir", "=", "os", ".", "getcwd", "(", ")", "try", ":", "os", ".", "chdir", "(", "cwd", ")", "yield", "finally", ":", "os", ".", "chdir", "(", "curdir", ")" ]
Context manager to ensure in the cwd directory.
[ "Context", "manager", "to", "ensure", "in", "the", "cwd", "directory", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/shell.py#L79-L87
train
63,600
python-thumbnails/python-thumbnails
thumbnails/templatetags/thumbnails.py
text_filter
def text_filter(regex_base, value): """ A text-filter helper, used in ``markdown_thumbnails``-filter and ``html_thumbnails``-filter. It can be used to build custom thumbnail text-filters. :param regex_base: A string with a regex that contains ``%(captions)s`` and ``%(image)s`` where ...
python
def text_filter(regex_base, value): """ A text-filter helper, used in ``markdown_thumbnails``-filter and ``html_thumbnails``-filter. It can be used to build custom thumbnail text-filters. :param regex_base: A string with a regex that contains ``%(captions)s`` and ``%(image)s`` where ...
[ "def", "text_filter", "(", "regex_base", ",", "value", ")", ":", "from", "thumbnails", "import", "get_thumbnail", "regex", "=", "regex_base", "%", "{", "'caption'", ":", "'[a-zA-Z0-9\\.\\,:;/_ \\(\\)\\-\\!\\?\\\"]+'", ",", "'image'", ":", "'[a-zA-Z0-9\\.:/_\\-\\% ]+'", ...
A text-filter helper, used in ``markdown_thumbnails``-filter and ``html_thumbnails``-filter. It can be used to build custom thumbnail text-filters. :param regex_base: A string with a regex that contains ``%(captions)s`` and ``%(image)s`` where the caption and image should be. :param ...
[ "A", "text", "-", "filter", "helper", "used", "in", "markdown_thumbnails", "-", "filter", "and", "html_thumbnails", "-", "filter", ".", "It", "can", "be", "used", "to", "build", "custom", "thumbnail", "text", "-", "filters", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/templatetags/thumbnails.py#L57-L82
train
63,601
zyga/guacamole
guacamole/core.py
Bowl.eat
def eat(self, argv=None): """ Eat the guacamole. :param argv: Command line arguments or None. None means that sys.argv is used :return: Whatever is returned by the first ingredient that agrees to perform the command dispatch. The eat method i...
python
def eat(self, argv=None): """ Eat the guacamole. :param argv: Command line arguments or None. None means that sys.argv is used :return: Whatever is returned by the first ingredient that agrees to perform the command dispatch. The eat method i...
[ "def", "eat", "(", "self", ",", "argv", "=", "None", ")", ":", "# The setup phase, here KeyboardInterrupt is a silent sign to exit the", "# application. Any error that happens here will result in a raw", "# backtrace being printed to the user.", "try", ":", "self", ".", "context", ...
Eat the guacamole. :param argv: Command line arguments or None. None means that sys.argv is used :return: Whatever is returned by the first ingredient that agrees to perform the command dispatch. The eat method is called to run the application, as if it was ...
[ "Eat", "the", "guacamole", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/core.py#L212-L258
train
63,602
fredRos/pypmc
pypmc/tools/parallel_sampler.py
MPISampler.clear
def clear(self): """Delete the history.""" self.sampler.clear() self.samples_list = self._comm.gather(self.sampler.samples, root=0) if hasattr(self.sampler, 'weights'): self.weights_list = self._comm.gather(self.sampler.weights, root=0) else: self.weights_...
python
def clear(self): """Delete the history.""" self.sampler.clear() self.samples_list = self._comm.gather(self.sampler.samples, root=0) if hasattr(self.sampler, 'weights'): self.weights_list = self._comm.gather(self.sampler.weights, root=0) else: self.weights_...
[ "def", "clear", "(", "self", ")", ":", "self", ".", "sampler", ".", "clear", "(", ")", "self", ".", "samples_list", "=", "self", ".", "_comm", ".", "gather", "(", "self", ".", "sampler", ".", "samples", ",", "root", "=", "0", ")", "if", "hasattr", ...
Delete the history.
[ "Delete", "the", "history", "." ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/tools/parallel_sampler.py#L73-L80
train
63,603
python-thumbnails/python-thumbnails
thumbnails/storage_backends.py
BaseStorageBackend.path
def path(self, path): """ Creates a path based on the location attribute of the backend and the path argument of the function. If the path argument is an absolute path the path is returned. :param path: The path that should be joined with the backends location. """ if os...
python
def path(self, path): """ Creates a path based on the location attribute of the backend and the path argument of the function. If the path argument is an absolute path the path is returned. :param path: The path that should be joined with the backends location. """ if os...
[ "def", "path", "(", "self", ",", "path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "return", "path", "return", "os", ".", "path", ".", "join", "(", "self", ".", "location", ",", "path", ")" ]
Creates a path based on the location attribute of the backend and the path argument of the function. If the path argument is an absolute path the path is returned. :param path: The path that should be joined with the backends location.
[ "Creates", "a", "path", "based", "on", "the", "location", "attribute", "of", "the", "backend", "and", "the", "path", "argument", "of", "the", "function", ".", "If", "the", "path", "argument", "is", "an", "absolute", "path", "the", "path", "is", "returned",...
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/storage_backends.py#L16-L25
train
63,604
fredRos/pypmc
pypmc/mix_adapt/hierarchical.py
Hierarchical.run
def run(self, eps=1e-4, kill=True, max_steps=50, verbose=False): r"""Perform the clustering on the input components updating the initial guess. The result is available in the member ``self.g``. Return the number of iterations at convergence, or None. :param eps: If relativ...
python
def run(self, eps=1e-4, kill=True, max_steps=50, verbose=False): r"""Perform the clustering on the input components updating the initial guess. The result is available in the member ``self.g``. Return the number of iterations at convergence, or None. :param eps: If relativ...
[ "def", "run", "(", "self", ",", "eps", "=", "1e-4", ",", "kill", "=", "True", ",", "max_steps", "=", "50", ",", "verbose", "=", "False", ")", ":", "old_distance", "=", "np", ".", "finfo", "(", "np", ".", "float64", ")", ".", "max", "new_distance", ...
r"""Perform the clustering on the input components updating the initial guess. The result is available in the member ``self.g``. Return the number of iterations at convergence, or None. :param eps: If relative change of distance between current and last step falls below ``eps``, ...
[ "r", "Perform", "the", "clustering", "on", "the", "input", "components", "updating", "the", "initial", "guess", ".", "The", "result", "is", "available", "in", "the", "member", "self", ".", "g", "." ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/mix_adapt/hierarchical.py#L153-L219
train
63,605
infoxchange/supervisor-logging
supervisor_logging/__init__.py
eventdata
def eventdata(payload): """ Parse a Supervisor event. """ headerinfo, data = payload.split('\n', 1) headers = get_headers(headerinfo) return headers, data
python
def eventdata(payload): """ Parse a Supervisor event. """ headerinfo, data = payload.split('\n', 1) headers = get_headers(headerinfo) return headers, data
[ "def", "eventdata", "(", "payload", ")", ":", "headerinfo", ",", "data", "=", "payload", ".", "split", "(", "'\\n'", ",", "1", ")", "headers", "=", "get_headers", "(", "headerinfo", ")", "return", "headers", ",", "data" ]
Parse a Supervisor event.
[ "Parse", "a", "Supervisor", "event", "." ]
2d4411378fb52799bc506a68f1a914cbe671b13b
https://github.com/infoxchange/supervisor-logging/blob/2d4411378fb52799bc506a68f1a914cbe671b13b/supervisor_logging/__init__.py#L74-L81
train
63,606
infoxchange/supervisor-logging
supervisor_logging/__init__.py
supervisor_events
def supervisor_events(stdin, stdout): """ An event stream from Supervisor. """ while True: stdout.write('READY\n') stdout.flush() line = stdin.readline() headers = get_headers(line) payload = stdin.read(int(headers['len'])) event_headers, event_data = e...
python
def supervisor_events(stdin, stdout): """ An event stream from Supervisor. """ while True: stdout.write('READY\n') stdout.flush() line = stdin.readline() headers = get_headers(line) payload = stdin.read(int(headers['len'])) event_headers, event_data = e...
[ "def", "supervisor_events", "(", "stdin", ",", "stdout", ")", ":", "while", "True", ":", "stdout", ".", "write", "(", "'READY\\n'", ")", "stdout", ".", "flush", "(", ")", "line", "=", "stdin", ".", "readline", "(", ")", "headers", "=", "get_headers", "...
An event stream from Supervisor.
[ "An", "event", "stream", "from", "Supervisor", "." ]
2d4411378fb52799bc506a68f1a914cbe671b13b
https://github.com/infoxchange/supervisor-logging/blob/2d4411378fb52799bc506a68f1a914cbe671b13b/supervisor_logging/__init__.py#L84-L102
train
63,607
infoxchange/supervisor-logging
supervisor_logging/__init__.py
main
def main(): """ Main application loop. """ env = os.environ try: host = env['SYSLOG_SERVER'] port = int(env['SYSLOG_PORT']) socktype = socket.SOCK_DGRAM if env['SYSLOG_PROTO'] == 'udp' \ else socket.SOCK_STREAM except KeyError: sys.exit("SYSLOG_SERVE...
python
def main(): """ Main application loop. """ env = os.environ try: host = env['SYSLOG_SERVER'] port = int(env['SYSLOG_PORT']) socktype = socket.SOCK_DGRAM if env['SYSLOG_PROTO'] == 'udp' \ else socket.SOCK_STREAM except KeyError: sys.exit("SYSLOG_SERVE...
[ "def", "main", "(", ")", ":", "env", "=", "os", ".", "environ", "try", ":", "host", "=", "env", "[", "'SYSLOG_SERVER'", "]", "port", "=", "int", "(", "env", "[", "'SYSLOG_PORT'", "]", ")", "socktype", "=", "socket", ".", "SOCK_DGRAM", "if", "env", ...
Main application loop.
[ "Main", "application", "loop", "." ]
2d4411378fb52799bc506a68f1a914cbe671b13b
https://github.com/infoxchange/supervisor-logging/blob/2d4411378fb52799bc506a68f1a914cbe671b13b/supervisor_logging/__init__.py#L105-L137
train
63,608
infoxchange/supervisor-logging
supervisor_logging/__init__.py
PalletFormatter.formatTime
def formatTime(self, record, datefmt=None): """ Format time, including milliseconds. """ formatted = super(PalletFormatter, self).formatTime( record, datefmt=datefmt) return formatted + '.%03dZ' % record.msecs
python
def formatTime(self, record, datefmt=None): """ Format time, including milliseconds. """ formatted = super(PalletFormatter, self).formatTime( record, datefmt=datefmt) return formatted + '.%03dZ' % record.msecs
[ "def", "formatTime", "(", "self", ",", "record", ",", "datefmt", "=", "None", ")", ":", "formatted", "=", "super", "(", "PalletFormatter", ",", "self", ")", ".", "formatTime", "(", "record", ",", "datefmt", "=", "datefmt", ")", "return", "formatted", "+"...
Format time, including milliseconds.
[ "Format", "time", "including", "milliseconds", "." ]
2d4411378fb52799bc506a68f1a914cbe671b13b
https://github.com/infoxchange/supervisor-logging/blob/2d4411378fb52799bc506a68f1a914cbe671b13b/supervisor_logging/__init__.py#L49-L56
train
63,609
hayd/pep8radius
pep8radius/diff.py
get_diff
def get_diff(original, fixed, file_name, original_label='original', fixed_label='fixed'): """Return text of unified diff between original and fixed.""" original, fixed = original.splitlines(True), fixed.splitlines(True) newline = '\n' from difflib import unified_diff diff = unified_dif...
python
def get_diff(original, fixed, file_name, original_label='original', fixed_label='fixed'): """Return text of unified diff between original and fixed.""" original, fixed = original.splitlines(True), fixed.splitlines(True) newline = '\n' from difflib import unified_diff diff = unified_dif...
[ "def", "get_diff", "(", "original", ",", "fixed", ",", "file_name", ",", "original_label", "=", "'original'", ",", "fixed_label", "=", "'fixed'", ")", ":", "original", ",", "fixed", "=", "original", ".", "splitlines", "(", "True", ")", ",", "fixed", ".", ...
Return text of unified diff between original and fixed.
[ "Return", "text", "of", "unified", "diff", "between", "original", "and", "fixed", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/diff.py#L34-L51
train
63,610
fredRos/pypmc
pypmc/sampler/markov_chain.py
MarkovChain.run
def run(self, N=1): '''Run the chain and store the history of visited points into the member variable ``self.samples``. Returns the number of accepted points during the run. .. seealso:: :py:class:`pypmc.tools.History` :param N: An int which defines the...
python
def run(self, N=1): '''Run the chain and store the history of visited points into the member variable ``self.samples``. Returns the number of accepted points during the run. .. seealso:: :py:class:`pypmc.tools.History` :param N: An int which defines the...
[ "def", "run", "(", "self", ",", "N", "=", "1", ")", ":", "if", "N", "==", "0", ":", "return", "0", "# set the accept function", "if", "self", ".", "proposal", ".", "symmetric", ":", "get_log_rho", "=", "self", ".", "_get_log_rho_metropolis", "else", ":",...
Run the chain and store the history of visited points into the member variable ``self.samples``. Returns the number of accepted points during the run. .. seealso:: :py:class:`pypmc.tools.History` :param N: An int which defines the number of steps to run the cha...
[ "Run", "the", "chain", "and", "store", "the", "history", "of", "visited", "points", "into", "the", "member", "variable", "self", ".", "samples", ".", "Returns", "the", "number", "of", "accepted", "points", "during", "the", "run", "." ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/sampler/markov_chain.py#L98-L163
train
63,611
fredRos/pypmc
pypmc/sampler/markov_chain.py
AdaptiveMarkovChain.set_adapt_params
def set_adapt_params(self, *args, **kwargs): r"""Sets variables for covariance adaptation. When :meth:`.adapt` is called, the proposal's covariance matrix is adapted in order to improve the chain's performance. The aim is to improve the efficiency of the chain by making better p...
python
def set_adapt_params(self, *args, **kwargs): r"""Sets variables for covariance adaptation. When :meth:`.adapt` is called, the proposal's covariance matrix is adapted in order to improve the chain's performance. The aim is to improve the efficiency of the chain by making better p...
[ "def", "set_adapt_params", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", "!=", "(", ")", ":", "raise", "TypeError", "(", "'keyword args only; try set_adapt_parameters(keyword = value)'", ")", "self", ".", "covar_scale_multiplier",...
r"""Sets variables for covariance adaptation. When :meth:`.adapt` is called, the proposal's covariance matrix is adapted in order to improve the chain's performance. The aim is to improve the efficiency of the chain by making better proposals and forcing the acceptance rate :math:`\alph...
[ "r", "Sets", "variables", "for", "covariance", "adaptation", "." ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/sampler/markov_chain.py#L215-L340
train
63,612
fredRos/pypmc
pypmc/sampler/markov_chain.py
AdaptiveMarkovChain._update_scale_factor
def _update_scale_factor(self, accept_rate): '''Private function. Updates the covariance scaling factor ``covar_scale_factor`` according to its limits ''' if accept_rate > self.force_acceptance_max and self.covar_scale_factor < self.covar_scale_factor_max: self.covar...
python
def _update_scale_factor(self, accept_rate): '''Private function. Updates the covariance scaling factor ``covar_scale_factor`` according to its limits ''' if accept_rate > self.force_acceptance_max and self.covar_scale_factor < self.covar_scale_factor_max: self.covar...
[ "def", "_update_scale_factor", "(", "self", ",", "accept_rate", ")", ":", "if", "accept_rate", ">", "self", ".", "force_acceptance_max", "and", "self", ".", "covar_scale_factor", "<", "self", ".", "covar_scale_factor_max", ":", "self", ".", "covar_scale_factor", "...
Private function. Updates the covariance scaling factor ``covar_scale_factor`` according to its limits
[ "Private", "function", ".", "Updates", "the", "covariance", "scaling", "factor", "covar_scale_factor", "according", "to", "its", "limits" ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/sampler/markov_chain.py#L391-L400
train
63,613
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.create
def create(self, original, size, crop, options=None): """ Creates a thumbnail. It loads the image, scales it and crops it. :param original: :param size: :param crop: :param options: :return: """ if options is None: options = self.evalu...
python
def create(self, original, size, crop, options=None): """ Creates a thumbnail. It loads the image, scales it and crops it. :param original: :param size: :param crop: :param options: :return: """ if options is None: options = self.evalu...
[ "def", "create", "(", "self", ",", "original", ",", "size", ",", "crop", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "self", ".", "evaluate_options", "(", ")", "image", "=", "self", ".", "engine_load_image...
Creates a thumbnail. It loads the image, scales it and crops it. :param original: :param size: :param crop: :param options: :return:
[ "Creates", "a", "thumbnail", ".", "It", "loads", "the", "image", "scales", "it", "and", "crops", "it", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L43-L60
train
63,614
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.scale
def scale(self, image, size, crop, options): """ Wrapper for ``engine_scale``, checks if the scaling factor is below one or that scale_up option is set to True before calling ``engine_scale``. :param image: :param size: :param crop: :param options: :retur...
python
def scale(self, image, size, crop, options): """ Wrapper for ``engine_scale``, checks if the scaling factor is below one or that scale_up option is set to True before calling ``engine_scale``. :param image: :param size: :param crop: :param options: :retur...
[ "def", "scale", "(", "self", ",", "image", ",", "size", ",", "crop", ",", "options", ")", ":", "original_size", "=", "self", ".", "get_image_size", "(", "image", ")", "factor", "=", "self", ".", "_calculate_scaling_factor", "(", "original_size", ",", "size...
Wrapper for ``engine_scale``, checks if the scaling factor is below one or that scale_up option is set to True before calling ``engine_scale``. :param image: :param size: :param crop: :param options: :return:
[ "Wrapper", "for", "engine_scale", "checks", "if", "the", "scaling", "factor", "is", "below", "one", "or", "that", "scale_up", "option", "is", "set", "to", "True", "before", "calling", "engine_scale", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L62-L81
train
63,615
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.crop
def crop(self, image, size, crop, options): """ Wrapper for ``engine_crop``, will return without calling ``engine_crop`` if crop is None. :param image: :param size: :param crop: :param options: :return: """ if not crop: return image ...
python
def crop(self, image, size, crop, options): """ Wrapper for ``engine_crop``, will return without calling ``engine_crop`` if crop is None. :param image: :param size: :param crop: :param options: :return: """ if not crop: return image ...
[ "def", "crop", "(", "self", ",", "image", ",", "size", ",", "crop", ",", "options", ")", ":", "if", "not", "crop", ":", "return", "image", "return", "self", ".", "engine_crop", "(", "image", ",", "size", ",", "crop", ",", "options", ")" ]
Wrapper for ``engine_crop``, will return without calling ``engine_crop`` if crop is None. :param image: :param size: :param crop: :param options: :return:
[ "Wrapper", "for", "engine_crop", "will", "return", "without", "calling", "engine_crop", "if", "crop", "is", "None", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L83-L95
train
63,616
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.colormode
def colormode(self, image, options): """ Wrapper for ``engine_colormode``. :param image: :param options: :return: """ mode = options['colormode'] return self.engine_colormode(image, mode)
python
def colormode(self, image, options): """ Wrapper for ``engine_colormode``. :param image: :param options: :return: """ mode = options['colormode'] return self.engine_colormode(image, mode)
[ "def", "colormode", "(", "self", ",", "image", ",", "options", ")", ":", "mode", "=", "options", "[", "'colormode'", "]", "return", "self", ".", "engine_colormode", "(", "image", ",", "mode", ")" ]
Wrapper for ``engine_colormode``. :param image: :param options: :return:
[ "Wrapper", "for", "engine_colormode", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L124-L133
train
63,617
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.parse_size
def parse_size(size): """ Parses size string into a tuple :param size: String on the form '100', 'x100 or '100x200' :return: Tuple of two integers for width and height :rtype: tuple """ if size.startswith('x'): return None, int(size.replace('x', '')) ...
python
def parse_size(size): """ Parses size string into a tuple :param size: String on the form '100', 'x100 or '100x200' :return: Tuple of two integers for width and height :rtype: tuple """ if size.startswith('x'): return None, int(size.replace('x', '')) ...
[ "def", "parse_size", "(", "size", ")", ":", "if", "size", ".", "startswith", "(", "'x'", ")", ":", "return", "None", ",", "int", "(", "size", ".", "replace", "(", "'x'", ",", "''", ")", ")", "if", "'x'", "in", "size", ":", "return", "int", "(", ...
Parses size string into a tuple :param size: String on the form '100', 'x100 or '100x200' :return: Tuple of two integers for width and height :rtype: tuple
[ "Parses", "size", "string", "into", "a", "tuple" ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L174-L186
train
63,618
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.parse_crop
def parse_crop(self, crop, original_size, size): """ Parses crop into a tuple usable by the crop function. :param crop: String with the crop settings. :param original_size: A tuple of size of the image that should be cropped. :param size: A tuple of the wanted size. :ret...
python
def parse_crop(self, crop, original_size, size): """ Parses crop into a tuple usable by the crop function. :param crop: String with the crop settings. :param original_size: A tuple of size of the image that should be cropped. :param size: A tuple of the wanted size. :ret...
[ "def", "parse_crop", "(", "self", ",", "crop", ",", "original_size", ",", "size", ")", ":", "if", "crop", "is", "None", ":", "return", "None", "crop", "=", "crop", ".", "split", "(", "' '", ")", "if", "len", "(", "crop", ")", "==", "1", ":", "cro...
Parses crop into a tuple usable by the crop function. :param crop: String with the crop settings. :param original_size: A tuple of size of the image that should be cropped. :param size: A tuple of the wanted size. :return: Tuple of two integers with crop settings :rtype: tuple
[ "Parses", "crop", "into", "a", "tuple", "usable", "by", "the", "crop", "function", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L188-L213
train
63,619
python-thumbnails/python-thumbnails
thumbnails/engines/base.py
BaseThumbnailEngine.calculate_offset
def calculate_offset(percent, original_length, length): """ Calculates crop offset based on percentage. :param percent: A percentage representing the size of the offset. :param original_length: The length the distance that should be cropped. :param length: The desired length. ...
python
def calculate_offset(percent, original_length, length): """ Calculates crop offset based on percentage. :param percent: A percentage representing the size of the offset. :param original_length: The length the distance that should be cropped. :param length: The desired length. ...
[ "def", "calculate_offset", "(", "percent", ",", "original_length", ",", "length", ")", ":", "return", "int", "(", "max", "(", "0", ",", "min", "(", "percent", "*", "original_length", "/", "100.0", ",", "original_length", "-", "length", "/", "2", ")", "-"...
Calculates crop offset based on percentage. :param percent: A percentage representing the size of the offset. :param original_length: The length the distance that should be cropped. :param length: The desired length. :return: The offset in pixels :rtype: int
[ "Calculates", "crop", "offset", "based", "on", "percentage", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/engines/base.py#L216-L230
train
63,620
briandconnelly/pyfttt
pyfttt/cmd_script.py
main
def main(): """Main function for pyfttt command line tool""" args = parse_arguments() if args.key is None: print("Error: Must provide IFTTT secret key.") sys.exit(1) try: res = pyfttt.send_event(api_key=args.key, event=args.event, value1=args.val...
python
def main(): """Main function for pyfttt command line tool""" args = parse_arguments() if args.key is None: print("Error: Must provide IFTTT secret key.") sys.exit(1) try: res = pyfttt.send_event(api_key=args.key, event=args.event, value1=args.val...
[ "def", "main", "(", ")", ":", "args", "=", "parse_arguments", "(", ")", "if", "args", ".", "key", "is", "None", ":", "print", "(", "\"Error: Must provide IFTTT secret key.\"", ")", "sys", ".", "exit", "(", "1", ")", "try", ":", "res", "=", "pyfttt", "....
Main function for pyfttt command line tool
[ "Main", "function", "for", "pyfttt", "command", "line", "tool" ]
fed3d8ec87811cf33c87d9d102845a420204577b
https://github.com/briandconnelly/pyfttt/blob/fed3d8ec87811cf33c87d9d102845a420204577b/pyfttt/cmd_script.py#L37-L75
train
63,621
fredRos/pypmc
pypmc/tools/_plot.py
plot_responsibility
def plot_responsibility(data, responsibility, cmap='nipy_spectral'): '''Classify the 2D ``data`` according to the ``responsibility`` and make a scatter plot of each data point with the color of the component it is most likely from. The ``responsibility`` is normalized internally ...
python
def plot_responsibility(data, responsibility, cmap='nipy_spectral'): '''Classify the 2D ``data`` according to the ``responsibility`` and make a scatter plot of each data point with the color of the component it is most likely from. The ``responsibility`` is normalized internally ...
[ "def", "plot_responsibility", "(", "data", ",", "responsibility", ",", "cmap", "=", "'nipy_spectral'", ")", ":", "import", "numpy", "as", "np", "from", "matplotlib", "import", "pyplot", "as", "plt", "from", "matplotlib", ".", "cm", "import", "get_cmap", "data"...
Classify the 2D ``data`` according to the ``responsibility`` and make a scatter plot of each data point with the color of the component it is most likely from. The ``responsibility`` is normalized internally such that each row sums to unity. :param data: matrix-like; one row = one 2D sample ...
[ "Classify", "the", "2D", "data", "according", "to", "the", "responsibility", "and", "make", "a", "scatter", "plot", "of", "each", "data", "point", "with", "the", "color", "of", "the", "component", "it", "is", "most", "likely", "from", ".", "The", "responsi...
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/tools/_plot.py#L132-L183
train
63,622
thomasw/djproxy
djproxy/util.py
import_string
def import_string(dotted_path): """ Import a dotted module path. Returns the attribute/class designated by the last name in the path. Raises ImportError if the import fails. """ try: module_path, class_name = dotted_path.rsplit('.', 1) except ValueError: raise ImportError(...
python
def import_string(dotted_path): """ Import a dotted module path. Returns the attribute/class designated by the last name in the path. Raises ImportError if the import fails. """ try: module_path, class_name = dotted_path.rsplit('.', 1) except ValueError: raise ImportError(...
[ "def", "import_string", "(", "dotted_path", ")", ":", "try", ":", "module_path", ",", "class_name", "=", "dotted_path", ".", "rsplit", "(", "'.'", ",", "1", ")", "except", "ValueError", ":", "raise", "ImportError", "(", "'%s doesn\\'t look like a valid path'", "...
Import a dotted module path. Returns the attribute/class designated by the last name in the path. Raises ImportError if the import fails.
[ "Import", "a", "dotted", "module", "path", "." ]
c8b3a44e330683f0625b67dfe3d6d995684b6e4a
https://github.com/thomasw/djproxy/blob/c8b3a44e330683f0625b67dfe3d6d995684b6e4a/djproxy/util.py#L6-L27
train
63,623
fredRos/pypmc
pypmc/tools/indicator/_indicator_factory.py
ball
def ball(center, radius=1., bdy=True): '''Returns the indicator function of a ball. :param center: A vector-like numpy array, defining the center of the ball.\n len(center) fixes the dimension. :param radius: Float or int, the radius of the ball :param bdy: Bool, Wh...
python
def ball(center, radius=1., bdy=True): '''Returns the indicator function of a ball. :param center: A vector-like numpy array, defining the center of the ball.\n len(center) fixes the dimension. :param radius: Float or int, the radius of the ball :param bdy: Bool, Wh...
[ "def", "ball", "(", "center", ",", "radius", "=", "1.", ",", "bdy", "=", "True", ")", ":", "center", "=", "_np", ".", "array", "(", "center", ")", "# copy input parameter", "dim", "=", "len", "(", "center", ")", "if", "bdy", ":", "def", "ball_indicat...
Returns the indicator function of a ball. :param center: A vector-like numpy array, defining the center of the ball.\n len(center) fixes the dimension. :param radius: Float or int, the radius of the ball :param bdy: Bool, When ``x`` is at the ball's boundary then ...
[ "Returns", "the", "indicator", "function", "of", "a", "ball", "." ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/tools/indicator/_indicator_factory.py#L5-L48
train
63,624
fredRos/pypmc
pypmc/tools/indicator/_indicator_factory.py
hyperrectangle
def hyperrectangle(lower, upper, bdy=True): '''Returns the indicator function of a hyperrectangle. :param lower: Vector-like numpy array, defining the lower boundary of the hyperrectangle.\n len(lower) fixes the dimension. :param upper: Vector-like numpy array, defining the upper...
python
def hyperrectangle(lower, upper, bdy=True): '''Returns the indicator function of a hyperrectangle. :param lower: Vector-like numpy array, defining the lower boundary of the hyperrectangle.\n len(lower) fixes the dimension. :param upper: Vector-like numpy array, defining the upper...
[ "def", "hyperrectangle", "(", "lower", ",", "upper", ",", "bdy", "=", "True", ")", ":", "# copy input", "lower", "=", "_np", ".", "array", "(", "lower", ")", "upper", "=", "_np", ".", "array", "(", "upper", ")", "dim", "=", "len", "(", "lower", ")"...
Returns the indicator function of a hyperrectangle. :param lower: Vector-like numpy array, defining the lower boundary of the hyperrectangle.\n len(lower) fixes the dimension. :param upper: Vector-like numpy array, defining the upper boundary of the hyperrectangle.\n :param bdy:...
[ "Returns", "the", "indicator", "function", "of", "a", "hyperrectangle", "." ]
9138b67c976f0d58edd080353d16769a47794d09
https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/tools/indicator/_indicator_factory.py#L50-L96
train
63,625
python-thumbnails/python-thumbnails
thumbnails/__init__.py
get_thumbnail
def get_thumbnail(original, size, **options): """ Creates or gets an already created thumbnail for the given image with the given size and options. :param original: File-path, url or base64-encoded string of the image that you want an thumbnail. :param size: String with the wan...
python
def get_thumbnail(original, size, **options): """ Creates or gets an already created thumbnail for the given image with the given size and options. :param original: File-path, url or base64-encoded string of the image that you want an thumbnail. :param size: String with the wan...
[ "def", "get_thumbnail", "(", "original", ",", "size", ",", "*", "*", "options", ")", ":", "engine", "=", "get_engine", "(", ")", "cache", "=", "get_cache_backend", "(", ")", "original", "=", "SourceFile", "(", "original", ")", "crop", "=", "options", "."...
Creates or gets an already created thumbnail for the given image with the given size and options. :param original: File-path, url or base64-encoded string of the image that you want an thumbnail. :param size: String with the wanted thumbnail size. On the form: ``200x200``, ``200`` or ...
[ "Creates", "or", "gets", "an", "already", "created", "thumbnail", "for", "the", "given", "image", "with", "the", "given", "size", "and", "options", "." ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/__init__.py#L11-L65
train
63,626
TheClimateCorporation/properscoring
properscoring/_utils.py
argsort_indices
def argsort_indices(a, axis=-1): """Like argsort, but returns an index suitable for sorting the the original array even if that array is multidimensional """ a = np.asarray(a) ind = list(np.ix_(*[np.arange(d) for d in a.shape])) ind[axis] = a.argsort(axis) return tuple(ind)
python
def argsort_indices(a, axis=-1): """Like argsort, but returns an index suitable for sorting the the original array even if that array is multidimensional """ a = np.asarray(a) ind = list(np.ix_(*[np.arange(d) for d in a.shape])) ind[axis] = a.argsort(axis) return tuple(ind)
[ "def", "argsort_indices", "(", "a", ",", "axis", "=", "-", "1", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "ind", "=", "list", "(", "np", ".", "ix_", "(", "*", "[", "np", ".", "arange", "(", "d", ")", "for", "d", "in", "a", ...
Like argsort, but returns an index suitable for sorting the the original array even if that array is multidimensional
[ "Like", "argsort", "but", "returns", "an", "index", "suitable", "for", "sorting", "the", "the", "original", "array", "even", "if", "that", "array", "is", "multidimensional" ]
1ca13dcbc1abf53d07474b74fbe3567fd4045668
https://github.com/TheClimateCorporation/properscoring/blob/1ca13dcbc1abf53d07474b74fbe3567fd4045668/properscoring/_utils.py#L12-L19
train
63,627
briandconnelly/pyfttt
pyfttt/sending.py
send_event
def send_event(api_key, event, value1=None, value2=None, value3=None): """Send an event to the IFTTT maker channel Parameters: ----------- api_key : string Your IFTTT API key event : string The name of the IFTTT event to trigger value1 : Optional: Extra data sent with th...
python
def send_event(api_key, event, value1=None, value2=None, value3=None): """Send an event to the IFTTT maker channel Parameters: ----------- api_key : string Your IFTTT API key event : string The name of the IFTTT event to trigger value1 : Optional: Extra data sent with th...
[ "def", "send_event", "(", "api_key", ",", "event", ",", "value1", "=", "None", ",", "value2", "=", "None", ",", "value3", "=", "None", ")", ":", "url", "=", "'https://maker.ifttt.com/trigger/{e}/with/key/{k}/'", ".", "format", "(", "e", "=", "event", ",", ...
Send an event to the IFTTT maker channel Parameters: ----------- api_key : string Your IFTTT API key event : string The name of the IFTTT event to trigger value1 : Optional: Extra data sent with the event (default: None) value2 : Optional: Extra data sent with th...
[ "Send", "an", "event", "to", "the", "IFTTT", "maker", "channel" ]
fed3d8ec87811cf33c87d9d102845a420204577b
https://github.com/briandconnelly/pyfttt/blob/fed3d8ec87811cf33c87d9d102845a420204577b/pyfttt/sending.py#L7-L28
train
63,628
zyga/guacamole
guacamole/recipes/cmd.py
get_localized_docstring
def get_localized_docstring(obj, domain): """Get a cleaned-up, localized copy of docstring of this class.""" if obj.__class__.__doc__ is not None: return inspect.cleandoc( gettext.dgettext(domain, obj.__class__.__doc__))
python
def get_localized_docstring(obj, domain): """Get a cleaned-up, localized copy of docstring of this class.""" if obj.__class__.__doc__ is not None: return inspect.cleandoc( gettext.dgettext(domain, obj.__class__.__doc__))
[ "def", "get_localized_docstring", "(", "obj", ",", "domain", ")", ":", "if", "obj", ".", "__class__", ".", "__doc__", "is", "not", "None", ":", "return", "inspect", ".", "cleandoc", "(", "gettext", ".", "dgettext", "(", "domain", ",", "obj", ".", "__clas...
Get a cleaned-up, localized copy of docstring of this class.
[ "Get", "a", "cleaned", "-", "up", "localized", "copy", "of", "docstring", "of", "this", "class", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L396-L400
train
63,629
zyga/guacamole
guacamole/recipes/cmd.py
Command.get_cmd_help
def get_cmd_help(self): """ Get the single-line help of this command. :returns: ``self.help``, if defined :returns: The first line of the docstring, without the trailing dot, if present. :returns: None, otherwise """ ...
python
def get_cmd_help(self): """ Get the single-line help of this command. :returns: ``self.help``, if defined :returns: The first line of the docstring, without the trailing dot, if present. :returns: None, otherwise """ ...
[ "def", "get_cmd_help", "(", "self", ")", ":", "try", ":", "return", "self", ".", "help", "except", "AttributeError", ":", "pass", "try", ":", "return", "get_localized_docstring", "(", "self", ",", "self", ".", "get_gettext_domain", "(", ")", ")", ".", "spl...
Get the single-line help of this command. :returns: ``self.help``, if defined :returns: The first line of the docstring, without the trailing dot, if present. :returns: None, otherwise
[ "Get", "the", "single", "-", "line", "help", "of", "this", "command", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L216-L237
train
63,630
zyga/guacamole
guacamole/recipes/cmd.py
Command.get_cmd_description
def get_cmd_description(self): """ Get the leading, multi-line description of this command. :returns: ``self.description``, if defined :returns: A substring of the class docstring between the first line (which is discarded) and the string ``@EPILOG@``...
python
def get_cmd_description(self): """ Get the leading, multi-line description of this command. :returns: ``self.description``, if defined :returns: A substring of the class docstring between the first line (which is discarded) and the string ``@EPILOG@``...
[ "def", "get_cmd_description", "(", "self", ")", ":", "try", ":", "return", "self", ".", "description", "except", "AttributeError", ":", "pass", "try", ":", "return", "'\\n'", ".", "join", "(", "get_localized_docstring", "(", "self", ",", "self", ".", "get_ge...
Get the leading, multi-line description of this command. :returns: ``self.description``, if defined :returns: A substring of the class docstring between the first line (which is discarded) and the string ``@EPILOG@``, if present, or the end of the docstri...
[ "Get", "the", "leading", "multi", "-", "line", "description", "of", "this", "command", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L239-L272
train
63,631
zyga/guacamole
guacamole/recipes/cmd.py
Command.get_cmd_epilog
def get_cmd_epilog(self): """ Get the trailing, multi-line description of this command. :returns: ``self.epilog``, if defined :returns: A substring of the class docstring between the string ``@EPILOG`` and the end of the docstring, if defined ...
python
def get_cmd_epilog(self): """ Get the trailing, multi-line description of this command. :returns: ``self.epilog``, if defined :returns: A substring of the class docstring between the string ``@EPILOG`` and the end of the docstring, if defined ...
[ "def", "get_cmd_epilog", "(", "self", ")", ":", "try", ":", "return", "self", ".", "source", ".", "epilog", "except", "AttributeError", ":", "pass", "try", ":", "return", "'\\n'", ".", "join", "(", "get_localized_docstring", "(", "self", ",", "self", ".", ...
Get the trailing, multi-line description of this command. :returns: ``self.epilog``, if defined :returns: A substring of the class docstring between the string ``@EPILOG`` and the end of the docstring, if defined :returns: None, otherwise ...
[ "Get", "the", "trailing", "multi", "-", "line", "description", "of", "this", "command", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L274-L305
train
63,632
zyga/guacamole
guacamole/recipes/cmd.py
Command.main
def main(self, argv=None, exit=True): """ Shortcut for running a command. See :meth:`guacamole.recipes.Recipe.main()` for details. """ return CommandRecipe(self).main(argv, exit)
python
def main(self, argv=None, exit=True): """ Shortcut for running a command. See :meth:`guacamole.recipes.Recipe.main()` for details. """ return CommandRecipe(self).main(argv, exit)
[ "def", "main", "(", "self", ",", "argv", "=", "None", ",", "exit", "=", "True", ")", ":", "return", "CommandRecipe", "(", "self", ")", ".", "main", "(", "argv", ",", "exit", ")" ]
Shortcut for running a command. See :meth:`guacamole.recipes.Recipe.main()` for details.
[ "Shortcut", "for", "running", "a", "command", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L387-L393
train
63,633
zyga/guacamole
guacamole/recipes/cmd.py
CommandRecipe.get_ingredients
def get_ingredients(self): """Get a list of ingredients for guacamole.""" return [ cmdtree.CommandTreeBuilder(self.command), cmdtree.CommandTreeDispatcher(), argparse.AutocompleteIngredient(), argparse.ParserIngredient(), crash.VerboseCrashHand...
python
def get_ingredients(self): """Get a list of ingredients for guacamole.""" return [ cmdtree.CommandTreeBuilder(self.command), cmdtree.CommandTreeDispatcher(), argparse.AutocompleteIngredient(), argparse.ParserIngredient(), crash.VerboseCrashHand...
[ "def", "get_ingredients", "(", "self", ")", ":", "return", "[", "cmdtree", ".", "CommandTreeBuilder", "(", "self", ".", "command", ")", ",", "cmdtree", ".", "CommandTreeDispatcher", "(", ")", ",", "argparse", ".", "AutocompleteIngredient", "(", ")", ",", "ar...
Get a list of ingredients for guacamole.
[ "Get", "a", "list", "of", "ingredients", "for", "guacamole", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L411-L421
train
63,634
zyga/guacamole
examples/adder.py
Addder.register_arguments
def register_arguments(self, parser): """ Guacamole method used by the argparse ingredient. :param parser: Argument parser (from :mod:`argparse`) specific to this command. """ parser.add_argument('x', type=int, help='the first value') parser.add_argument('y',...
python
def register_arguments(self, parser): """ Guacamole method used by the argparse ingredient. :param parser: Argument parser (from :mod:`argparse`) specific to this command. """ parser.add_argument('x', type=int, help='the first value') parser.add_argument('y',...
[ "def", "register_arguments", "(", "self", ",", "parser", ")", ":", "parser", ".", "add_argument", "(", "'x'", ",", "type", "=", "int", ",", "help", "=", "'the first value'", ")", "parser", ".", "add_argument", "(", "'y'", ",", "type", "=", "int", ",", ...
Guacamole method used by the argparse ingredient. :param parser: Argument parser (from :mod:`argparse`) specific to this command.
[ "Guacamole", "method", "used", "by", "the", "argparse", "ingredient", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/examples/adder.py#L45-L53
train
63,635
zyga/guacamole
examples/rainbow.py
ANSIDemo.invoked
def invoked(self, ctx): """Method called when the command is invoked.""" if not ctx.ansi.is_enabled: print("You need color support to use this demo") else: print(ctx.ansi.cmd('erase_display')) self._demo_fg_color(ctx) self._demo_bg_color(ctx) ...
python
def invoked(self, ctx): """Method called when the command is invoked.""" if not ctx.ansi.is_enabled: print("You need color support to use this demo") else: print(ctx.ansi.cmd('erase_display')) self._demo_fg_color(ctx) self._demo_bg_color(ctx) ...
[ "def", "invoked", "(", "self", ",", "ctx", ")", ":", "if", "not", "ctx", ".", "ansi", ".", "is_enabled", ":", "print", "(", "\"You need color support to use this demo\"", ")", "else", ":", "print", "(", "ctx", ".", "ansi", ".", "cmd", "(", "'erase_display'...
Method called when the command is invoked.
[ "Method", "called", "when", "the", "command", "is", "invoked", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/examples/rainbow.py#L45-L55
train
63,636
python-thumbnails/python-thumbnails
thumbnails/cache_backends.py
BaseCacheBackend.get
def get(self, thumbnail_name): """ Wrapper for ``_get``, which converts the thumbnail_name to String if necessary before calling ``_get`` :rtype: Thumbnail """ if isinstance(thumbnail_name, list): thumbnail_name = '/'.join(thumbnail_name) return self....
python
def get(self, thumbnail_name): """ Wrapper for ``_get``, which converts the thumbnail_name to String if necessary before calling ``_get`` :rtype: Thumbnail """ if isinstance(thumbnail_name, list): thumbnail_name = '/'.join(thumbnail_name) return self....
[ "def", "get", "(", "self", ",", "thumbnail_name", ")", ":", "if", "isinstance", "(", "thumbnail_name", ",", "list", ")", ":", "thumbnail_name", "=", "'/'", ".", "join", "(", "thumbnail_name", ")", "return", "self", ".", "_get", "(", "thumbnail_name", ")" ]
Wrapper for ``_get``, which converts the thumbnail_name to String if necessary before calling ``_get`` :rtype: Thumbnail
[ "Wrapper", "for", "_get", "which", "converts", "the", "thumbnail_name", "to", "String", "if", "necessary", "before", "calling", "_get" ]
d8dc0ff5410f730de2a0e5759e8a818b19de35b9
https://github.com/python-thumbnails/python-thumbnails/blob/d8dc0ff5410f730de2a0e5759e8a818b19de35b9/thumbnails/cache_backends.py#L17-L26
train
63,637
Jaymon/dsnparse
dsnparse.py
parse
def parse(dsn, parse_class=ParseResult, **defaults): """ parse a dsn to parts similar to parseurl :param dsn: string, the dsn to parse :param parse_class: ParseResult, the class that will be used to hold parsed values :param **defaults: dict, any values you want to have defaults for if they aren't ...
python
def parse(dsn, parse_class=ParseResult, **defaults): """ parse a dsn to parts similar to parseurl :param dsn: string, the dsn to parse :param parse_class: ParseResult, the class that will be used to hold parsed values :param **defaults: dict, any values you want to have defaults for if they aren't ...
[ "def", "parse", "(", "dsn", ",", "parse_class", "=", "ParseResult", ",", "*", "*", "defaults", ")", ":", "r", "=", "parse_class", "(", "dsn", ",", "*", "*", "defaults", ")", "return", "r" ]
parse a dsn to parts similar to parseurl :param dsn: string, the dsn to parse :param parse_class: ParseResult, the class that will be used to hold parsed values :param **defaults: dict, any values you want to have defaults for if they aren't in the dsn :returns: ParseResult() tuple-like instance
[ "parse", "a", "dsn", "to", "parts", "similar", "to", "parseurl" ]
2e4e1be8cc9d2dd0f6138c881b06677a6e80b029
https://github.com/Jaymon/dsnparse/blob/2e4e1be8cc9d2dd0f6138c881b06677a6e80b029/dsnparse.py#L280-L290
train
63,638
Jaymon/dsnparse
dsnparse.py
ParseResult.setdefault
def setdefault(self, key, val): """ set a default value for key this is different than dict's setdefault because it will set default either if the key doesn't exist, or if the value at the key evaluates to False, so an empty string or a None value will also be updated :...
python
def setdefault(self, key, val): """ set a default value for key this is different than dict's setdefault because it will set default either if the key doesn't exist, or if the value at the key evaluates to False, so an empty string or a None value will also be updated :...
[ "def", "setdefault", "(", "self", ",", "key", ",", "val", ")", ":", "if", "not", "getattr", "(", "self", ",", "key", ",", "None", ")", ":", "setattr", "(", "self", ",", "key", ",", "val", ")" ]
set a default value for key this is different than dict's setdefault because it will set default either if the key doesn't exist, or if the value at the key evaluates to False, so an empty string or a None value will also be updated :param key: string, the attribute to update :...
[ "set", "a", "default", "value", "for", "key" ]
2e4e1be8cc9d2dd0f6138c881b06677a6e80b029
https://github.com/Jaymon/dsnparse/blob/2e4e1be8cc9d2dd0f6138c881b06677a6e80b029/dsnparse.py#L197-L210
train
63,639
Jaymon/dsnparse
dsnparse.py
ParseResult.geturl
def geturl(self): """return the dsn back into url form""" return urlparse.urlunparse(( self.scheme, self.netloc, self.path, self.params, self.query_str, self.fragment, ))
python
def geturl(self): """return the dsn back into url form""" return urlparse.urlunparse(( self.scheme, self.netloc, self.path, self.params, self.query_str, self.fragment, ))
[ "def", "geturl", "(", "self", ")", ":", "return", "urlparse", ".", "urlunparse", "(", "(", "self", ".", "scheme", ",", "self", ".", "netloc", ",", "self", ".", "path", ",", "self", ".", "params", ",", "self", ".", "query_str", ",", "self", ".", "fr...
return the dsn back into url form
[ "return", "the", "dsn", "back", "into", "url", "form" ]
2e4e1be8cc9d2dd0f6138c881b06677a6e80b029
https://github.com/Jaymon/dsnparse/blob/2e4e1be8cc9d2dd0f6138c881b06677a6e80b029/dsnparse.py#L212-L221
train
63,640
zyga/guacamole
guacamole/ingredients/argparse.py
ParserIngredient.preparse
def preparse(self, context): """ Parse a portion of command line arguments with the early parser. This method relies on ``context.argv`` and ``context.early_parser`` and produces ``context.early_args``. The ``context.early_args`` object is the return value from argparse. ...
python
def preparse(self, context): """ Parse a portion of command line arguments with the early parser. This method relies on ``context.argv`` and ``context.early_parser`` and produces ``context.early_args``. The ``context.early_args`` object is the return value from argparse. ...
[ "def", "preparse", "(", "self", ",", "context", ")", ":", "context", ".", "early_args", ",", "unused", "=", "(", "context", ".", "early_parser", ".", "parse_known_args", "(", "context", ".", "argv", ")", ")" ]
Parse a portion of command line arguments with the early parser. This method relies on ``context.argv`` and ``context.early_parser`` and produces ``context.early_args``. The ``context.early_args`` object is the return value from argparse. It is the dict/object like namespace object.
[ "Parse", "a", "portion", "of", "command", "line", "arguments", "with", "the", "early", "parser", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/ingredients/argparse.py#L93-L104
train
63,641
zyga/guacamole
guacamole/ingredients/argparse.py
ParserIngredient.build_parser
def build_parser(self, context): """ Create the final argument parser. This method creates the non-early (full) argparse argument parser. Unlike the early counterpart it is expected to have knowledge of the full command tree. This method relies on ``context.cmd_tree`` a...
python
def build_parser(self, context): """ Create the final argument parser. This method creates the non-early (full) argparse argument parser. Unlike the early counterpart it is expected to have knowledge of the full command tree. This method relies on ``context.cmd_tree`` a...
[ "def", "build_parser", "(", "self", ",", "context", ")", ":", "context", ".", "parser", ",", "context", ".", "max_level", "=", "self", ".", "_create_parser", "(", "context", ")" ]
Create the final argument parser. This method creates the non-early (full) argparse argument parser. Unlike the early counterpart it is expected to have knowledge of the full command tree. This method relies on ``context.cmd_tree`` and produces ``context.parser``. Other ingredi...
[ "Create", "the", "final", "argument", "parser", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/ingredients/argparse.py#L106-L118
train
63,642
zyga/guacamole
guacamole/ingredients/argparse.py
AutocompleteIngredient.parse
def parse(self, context): """ Optionally trigger argument completion in the invoking shell. This method is called to see if bash argument completion is requested and to honor the request, if needed. This causes the process to exit (early) without giving other ingredients a chanc...
python
def parse(self, context): """ Optionally trigger argument completion in the invoking shell. This method is called to see if bash argument completion is requested and to honor the request, if needed. This causes the process to exit (early) without giving other ingredients a chanc...
[ "def", "parse", "(", "self", ",", "context", ")", ":", "try", ":", "import", "argcomplete", "except", "ImportError", ":", "return", "try", ":", "parser", "=", "context", ".", "parser", "except", "AttributeError", ":", "raise", "RecipeError", "(", "\"\"\"\n ...
Optionally trigger argument completion in the invoking shell. This method is called to see if bash argument completion is requested and to honor the request, if needed. This causes the process to exit (early) without giving other ingredients a chance to initialize or shut down. ...
[ "Optionally", "trigger", "argument", "completion", "in", "the", "invoking", "shell", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/ingredients/argparse.py#L216-L246
train
63,643
zyga/guacamole
guacamole/ingredients/ansi.py
ansi_cmd
def ansi_cmd(cmd, *args): """Get ANSI command code by name.""" try: obj = getattr(ANSI, str('cmd_{}'.format(cmd))) except AttributeError: raise ValueError( "incorrect command: {!r}".format(cmd)) if isinstance(obj, type("")): return obj else: return obj(*ar...
python
def ansi_cmd(cmd, *args): """Get ANSI command code by name.""" try: obj = getattr(ANSI, str('cmd_{}'.format(cmd))) except AttributeError: raise ValueError( "incorrect command: {!r}".format(cmd)) if isinstance(obj, type("")): return obj else: return obj(*ar...
[ "def", "ansi_cmd", "(", "cmd", ",", "*", "args", ")", ":", "try", ":", "obj", "=", "getattr", "(", "ANSI", ",", "str", "(", "'cmd_{}'", ".", "format", "(", "cmd", ")", ")", ")", "except", "AttributeError", ":", "raise", "ValueError", "(", "\"incorrec...
Get ANSI command code by name.
[ "Get", "ANSI", "command", "code", "by", "name", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/ingredients/ansi.py#L240-L250
train
63,644
zyga/guacamole
guacamole/ingredients/ansi.py
get_visible_color
def get_visible_color(color): """Get the visible counter-color.""" if isinstance(color, (str, type(""))): try: return getattr(_Visible, str('{}'.format(color))) except AttributeError: raise ValueError("incorrect color: {!r}".format(color)) elif isinstance(color, tuple...
python
def get_visible_color(color): """Get the visible counter-color.""" if isinstance(color, (str, type(""))): try: return getattr(_Visible, str('{}'.format(color))) except AttributeError: raise ValueError("incorrect color: {!r}".format(color)) elif isinstance(color, tuple...
[ "def", "get_visible_color", "(", "color", ")", ":", "if", "isinstance", "(", "color", ",", "(", "str", ",", "type", "(", "\"\"", ")", ")", ")", ":", "try", ":", "return", "getattr", "(", "_Visible", ",", "str", "(", "'{}'", ".", "format", "(", "col...
Get the visible counter-color.
[ "Get", "the", "visible", "counter", "-", "color", "." ]
105c10a798144e3b89659b500d7c2b84b0c76546
https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/ingredients/ansi.py#L276-L302
train
63,645
hayd/pep8radius
pep8radius/vcs.py
using_git
def using_git(cwd): """Test whether the directory cwd is contained in a git repository.""" try: git_log = shell_out(["git", "log"], cwd=cwd) return True except (CalledProcessError, OSError): # pragma: no cover return False
python
def using_git(cwd): """Test whether the directory cwd is contained in a git repository.""" try: git_log = shell_out(["git", "log"], cwd=cwd) return True except (CalledProcessError, OSError): # pragma: no cover return False
[ "def", "using_git", "(", "cwd", ")", ":", "try", ":", "git_log", "=", "shell_out", "(", "[", "\"git\"", ",", "\"log\"", "]", ",", "cwd", "=", "cwd", ")", "return", "True", "except", "(", "CalledProcessError", ",", "OSError", ")", ":", "# pragma: no cover...
Test whether the directory cwd is contained in a git repository.
[ "Test", "whether", "the", "directory", "cwd", "is", "contained", "in", "a", "git", "repository", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L21-L27
train
63,646
hayd/pep8radius
pep8radius/vcs.py
using_hg
def using_hg(cwd): """Test whether the directory cwd is contained in a mercurial repository.""" try: hg_log = shell_out(["hg", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
python
def using_hg(cwd): """Test whether the directory cwd is contained in a mercurial repository.""" try: hg_log = shell_out(["hg", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
[ "def", "using_hg", "(", "cwd", ")", ":", "try", ":", "hg_log", "=", "shell_out", "(", "[", "\"hg\"", ",", "\"log\"", "]", ",", "cwd", "=", "cwd", ")", "return", "True", "except", "(", "CalledProcessError", ",", "OSError", ")", ":", "return", "False" ]
Test whether the directory cwd is contained in a mercurial repository.
[ "Test", "whether", "the", "directory", "cwd", "is", "contained", "in", "a", "mercurial", "repository", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L30-L37
train
63,647
hayd/pep8radius
pep8radius/vcs.py
using_bzr
def using_bzr(cwd): """Test whether the directory cwd is contained in a bazaar repository.""" try: bzr_log = shell_out(["bzr", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
python
def using_bzr(cwd): """Test whether the directory cwd is contained in a bazaar repository.""" try: bzr_log = shell_out(["bzr", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
[ "def", "using_bzr", "(", "cwd", ")", ":", "try", ":", "bzr_log", "=", "shell_out", "(", "[", "\"bzr\"", ",", "\"log\"", "]", ",", "cwd", "=", "cwd", ")", "return", "True", "except", "(", "CalledProcessError", ",", "OSError", ")", ":", "return", "False"...
Test whether the directory cwd is contained in a bazaar repository.
[ "Test", "whether", "the", "directory", "cwd", "is", "contained", "in", "a", "bazaar", "repository", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L40-L46
train
63,648
hayd/pep8radius
pep8radius/vcs.py
VersionControl.which
def which(cwd=None): # pragma: no cover """Try to find which version control system contains the cwd directory. Returns the VersionControl superclass e.g. Git, if none were found this will raise a NotImplementedError. """ if cwd is None: cwd = os.getcwd() f...
python
def which(cwd=None): # pragma: no cover """Try to find which version control system contains the cwd directory. Returns the VersionControl superclass e.g. Git, if none were found this will raise a NotImplementedError. """ if cwd is None: cwd = os.getcwd() f...
[ "def", "which", "(", "cwd", "=", "None", ")", ":", "# pragma: no cover", "if", "cwd", "is", "None", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "for", "(", "k", ",", "using_vc", ")", "in", "globals", "(", ")", ".", "items", "(", ")", ":", "...
Try to find which version control system contains the cwd directory. Returns the VersionControl superclass e.g. Git, if none were found this will raise a NotImplementedError.
[ "Try", "to", "find", "which", "version", "control", "system", "contains", "the", "cwd", "directory", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L74-L89
train
63,649
hayd/pep8radius
pep8radius/vcs.py
VersionControl.modified_lines
def modified_lines(self, r, file_name): """Returns the line numbers of a file which have been changed.""" cmd = self.file_diff_cmd(r, file_name) diff = shell_out_ignore_exitcode(cmd, cwd=self.root) return list(self.modified_lines_from_diff(diff))
python
def modified_lines(self, r, file_name): """Returns the line numbers of a file which have been changed.""" cmd = self.file_diff_cmd(r, file_name) diff = shell_out_ignore_exitcode(cmd, cwd=self.root) return list(self.modified_lines_from_diff(diff))
[ "def", "modified_lines", "(", "self", ",", "r", ",", "file_name", ")", ":", "cmd", "=", "self", ".", "file_diff_cmd", "(", "r", ",", "file_name", ")", "diff", "=", "shell_out_ignore_exitcode", "(", "cmd", ",", "cwd", "=", "self", ".", "root", ")", "ret...
Returns the line numbers of a file which have been changed.
[ "Returns", "the", "line", "numbers", "of", "a", "file", "which", "have", "been", "changed", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L122-L126
train
63,650
hayd/pep8radius
pep8radius/vcs.py
VersionControl.modified_lines_from_diff
def modified_lines_from_diff(self, diff): """Returns the changed lines in a diff. - Potentially this is vc specific (if not using udiff). Note: this returns the line numbers in descending order. """ from pep8radius.diff import modified_lines_from_udiff for start, end i...
python
def modified_lines_from_diff(self, diff): """Returns the changed lines in a diff. - Potentially this is vc specific (if not using udiff). Note: this returns the line numbers in descending order. """ from pep8radius.diff import modified_lines_from_udiff for start, end i...
[ "def", "modified_lines_from_diff", "(", "self", ",", "diff", ")", ":", "from", "pep8radius", ".", "diff", "import", "modified_lines_from_udiff", "for", "start", ",", "end", "in", "modified_lines_from_udiff", "(", "diff", ")", ":", "yield", "start", ",", "end" ]
Returns the changed lines in a diff. - Potentially this is vc specific (if not using udiff). Note: this returns the line numbers in descending order.
[ "Returns", "the", "changed", "lines", "in", "a", "diff", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L128-L138
train
63,651
hayd/pep8radius
pep8radius/vcs.py
VersionControl.get_filenames_diff
def get_filenames_diff(self, r): """Get the py files which have been changed since rev.""" cmd = self.filenames_diff_cmd(r) diff_files = shell_out_ignore_exitcode(cmd, cwd=self.root) diff_files = self.parse_diff_filenames(diff_files) return set(f for f in diff_files if f.endswi...
python
def get_filenames_diff(self, r): """Get the py files which have been changed since rev.""" cmd = self.filenames_diff_cmd(r) diff_files = shell_out_ignore_exitcode(cmd, cwd=self.root) diff_files = self.parse_diff_filenames(diff_files) return set(f for f in diff_files if f.endswi...
[ "def", "get_filenames_diff", "(", "self", ",", "r", ")", ":", "cmd", "=", "self", ".", "filenames_diff_cmd", "(", "r", ")", "diff_files", "=", "shell_out_ignore_exitcode", "(", "cmd", ",", "cwd", "=", "self", ".", "root", ")", "diff_files", "=", "self", ...
Get the py files which have been changed since rev.
[ "Get", "the", "py", "files", "which", "have", "been", "changed", "since", "rev", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L140-L147
train
63,652
hayd/pep8radius
pep8radius/vcs.py
Bzr.parse_diff_filenames
def parse_diff_filenames(diff_files): """Parse the output of filenames_diff_cmd.""" # ? .gitignore # M 0.txt files = [] for line in diff_files.splitlines(): line = line.strip() fn = re.findall('[^ ]+\s+(.*.py)', line) if fn and not line.star...
python
def parse_diff_filenames(diff_files): """Parse the output of filenames_diff_cmd.""" # ? .gitignore # M 0.txt files = [] for line in diff_files.splitlines(): line = line.strip() fn = re.findall('[^ ]+\s+(.*.py)', line) if fn and not line.star...
[ "def", "parse_diff_filenames", "(", "diff_files", ")", ":", "# ? .gitignore", "# M 0.txt", "files", "=", "[", "]", "for", "line", "in", "diff_files", ".", "splitlines", "(", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "fn", "=", "re", ".", ...
Parse the output of filenames_diff_cmd.
[ "Parse", "the", "output", "of", "filenames_diff_cmd", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L246-L256
train
63,653
fusionbox/django-argonauts
argonauts/views.py
JsonRequestMixin.data
def data(self): """ Helper class for parsing JSON POST data into a Python object. """ if self.request.method == 'GET': return self.request.GET else: assert self.request.META['CONTENT_TYPE'].startswith('application/json') charset = self.request....
python
def data(self): """ Helper class for parsing JSON POST data into a Python object. """ if self.request.method == 'GET': return self.request.GET else: assert self.request.META['CONTENT_TYPE'].startswith('application/json') charset = self.request....
[ "def", "data", "(", "self", ")", ":", "if", "self", ".", "request", ".", "method", "==", "'GET'", ":", "return", "self", ".", "request", ".", "GET", "else", ":", "assert", "self", ".", "request", ".", "META", "[", "'CONTENT_TYPE'", "]", ".", "startsw...
Helper class for parsing JSON POST data into a Python object.
[ "Helper", "class", "for", "parsing", "JSON", "POST", "data", "into", "a", "Python", "object", "." ]
0f64f9700199e8c70a1cb9a055b8e31f6843933d
https://github.com/fusionbox/django-argonauts/blob/0f64f9700199e8c70a1cb9a055b8e31f6843933d/argonauts/views.py#L52-L61
train
63,654
fusionbox/django-argonauts
argonauts/views.py
RestView.options
def options(self, request, *args, **kwargs): """ Implements a OPTIONS HTTP method function returning all allowed HTTP methods. """ allow = [] for method in self.http_method_names: if hasattr(self, method): allow.append(method.upper()) r...
python
def options(self, request, *args, **kwargs): """ Implements a OPTIONS HTTP method function returning all allowed HTTP methods. """ allow = [] for method in self.http_method_names: if hasattr(self, method): allow.append(method.upper()) r...
[ "def", "options", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "allow", "=", "[", "]", "for", "method", "in", "self", ".", "http_method_names", ":", "if", "hasattr", "(", "self", ",", "method", ")", ":", "allow"...
Implements a OPTIONS HTTP method function returning all allowed HTTP methods.
[ "Implements", "a", "OPTIONS", "HTTP", "method", "function", "returning", "all", "allowed", "HTTP", "methods", "." ]
0f64f9700199e8c70a1cb9a055b8e31f6843933d
https://github.com/fusionbox/django-argonauts/blob/0f64f9700199e8c70a1cb9a055b8e31f6843933d/argonauts/views.py#L107-L118
train
63,655
hayd/pep8radius
pep8radius/main.py
main
def main(args=None, vc=None, cwd=None, apply_config=False): """PEP8 clean only the parts of the files touched since the last commit, a previous commit or branch.""" import signal try: # pragma: no cover # Exit on broken pipe. signal.signal(signal.SIGPIPE, signal.SIG_DFL) except Att...
python
def main(args=None, vc=None, cwd=None, apply_config=False): """PEP8 clean only the parts of the files touched since the last commit, a previous commit or branch.""" import signal try: # pragma: no cover # Exit on broken pipe. signal.signal(signal.SIGPIPE, signal.SIG_DFL) except Att...
[ "def", "main", "(", "args", "=", "None", ",", "vc", "=", "None", ",", "cwd", "=", "None", ",", "apply_config", "=", "False", ")", ":", "import", "signal", "try", ":", "# pragma: no cover", "# Exit on broken pipe.", "signal", ".", "signal", "(", "signal", ...
PEP8 clean only the parts of the files touched since the last commit, a previous commit or branch.
[ "PEP8", "clean", "only", "the", "parts", "of", "the", "files", "touched", "since", "the", "last", "commit", "a", "previous", "commit", "or", "branch", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/main.py#L31-L88
train
63,656
hayd/pep8radius
pep8radius/main.py
parse_args
def parse_args(arguments=None, root=None, apply_config=False): """Parse the arguments from the CLI. If apply_config then we first look up and apply configs using apply_config_defaults. """ if arguments is None: arguments = [] parser = create_parser() args = parser.parse_args(argum...
python
def parse_args(arguments=None, root=None, apply_config=False): """Parse the arguments from the CLI. If apply_config then we first look up and apply configs using apply_config_defaults. """ if arguments is None: arguments = [] parser = create_parser() args = parser.parse_args(argum...
[ "def", "parse_args", "(", "arguments", "=", "None", ",", "root", "=", "None", ",", "apply_config", "=", "False", ")", ":", "if", "arguments", "is", "None", ":", "arguments", "=", "[", "]", "parser", "=", "create_parser", "(", ")", "args", "=", "parser"...
Parse the arguments from the CLI. If apply_config then we first look up and apply configs using apply_config_defaults.
[ "Parse", "the", "arguments", "from", "the", "CLI", "." ]
0c1d14835d390f7feeb602f35a768e52ce306a0a
https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/main.py#L204-L240
train
63,657
andrewsnowden/dota2py
dota2py/parser.py
Reader.read_vint32
def read_vint32(self): """ This seems to be a variable length integer ala utf-8 style """ result = 0 count = 0 while True: if count > 4: raise ValueError("Corrupt VarInt32") b = self.read_byte() result = result | (b & 0...
python
def read_vint32(self): """ This seems to be a variable length integer ala utf-8 style """ result = 0 count = 0 while True: if count > 4: raise ValueError("Corrupt VarInt32") b = self.read_byte() result = result | (b & 0...
[ "def", "read_vint32", "(", "self", ")", ":", "result", "=", "0", "count", "=", "0", "while", "True", ":", "if", "count", ">", "4", ":", "raise", "ValueError", "(", "\"Corrupt VarInt32\"", ")", "b", "=", "self", ".", "read_byte", "(", ")", "result", "...
This seems to be a variable length integer ala utf-8 style
[ "This", "seems", "to", "be", "a", "variable", "length", "integer", "ala", "utf", "-", "8", "style" ]
67637f4b9c160ea90c11b7e81545baf350affa7a
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L100-L115
train
63,658
andrewsnowden/dota2py
dota2py/parser.py
Reader.read_message
def read_message(self, message_type, compressed=False, read_size=True): """ Read a protobuf message """ if read_size: size = self.read_vint32() b = self.read(size) else: b = self.read() if compressed: b = snappy.decompress(...
python
def read_message(self, message_type, compressed=False, read_size=True): """ Read a protobuf message """ if read_size: size = self.read_vint32() b = self.read(size) else: b = self.read() if compressed: b = snappy.decompress(...
[ "def", "read_message", "(", "self", ",", "message_type", ",", "compressed", "=", "False", ",", "read_size", "=", "True", ")", ":", "if", "read_size", ":", "size", "=", "self", ".", "read_vint32", "(", ")", "b", "=", "self", ".", "read", "(", "size", ...
Read a protobuf message
[ "Read", "a", "protobuf", "message" ]
67637f4b9c160ea90c11b7e81545baf350affa7a
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L117-L132
train
63,659
andrewsnowden/dota2py
dota2py/parser.py
DemoParser.run_hooks
def run_hooks(self, packet): """ Run any additional functions that want to process this type of packet. These can be internal parser hooks, or external hooks that process information """ if packet.__class__ in self.internal_hooks: self.internal_hooks[packet._...
python
def run_hooks(self, packet): """ Run any additional functions that want to process this type of packet. These can be internal parser hooks, or external hooks that process information """ if packet.__class__ in self.internal_hooks: self.internal_hooks[packet._...
[ "def", "run_hooks", "(", "self", ",", "packet", ")", ":", "if", "packet", ".", "__class__", "in", "self", ".", "internal_hooks", ":", "self", ".", "internal_hooks", "[", "packet", ".", "__class__", "]", "(", "packet", ")", "if", "packet", ".", "__class__...
Run any additional functions that want to process this type of packet. These can be internal parser hooks, or external hooks that process information
[ "Run", "any", "additional", "functions", "that", "want", "to", "process", "this", "type", "of", "packet", ".", "These", "can", "be", "internal", "parser", "hooks", "or", "external", "hooks", "that", "process", "information" ]
67637f4b9c160ea90c11b7e81545baf350affa7a
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L179-L190
train
63,660
andrewsnowden/dota2py
dota2py/parser.py
DemoParser.parse_string_table
def parse_string_table(self, tables): """ Need to pull out player information from string table """ self.info("String table: %s" % (tables.tables, )) for table in tables.tables: if table.table_name == "userinfo": for item in table.items: ...
python
def parse_string_table(self, tables): """ Need to pull out player information from string table """ self.info("String table: %s" % (tables.tables, )) for table in tables.tables: if table.table_name == "userinfo": for item in table.items: ...
[ "def", "parse_string_table", "(", "self", ",", "tables", ")", ":", "self", ".", "info", "(", "\"String table: %s\"", "%", "(", "tables", ".", "tables", ",", ")", ")", "for", "table", "in", "tables", ".", "tables", ":", "if", "table", ".", "table_name", ...
Need to pull out player information from string table
[ "Need", "to", "pull", "out", "player", "information", "from", "string", "table" ]
67637f4b9c160ea90c11b7e81545baf350affa7a
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L198-L215
train
63,661
andrewsnowden/dota2py
dota2py/parser.py
DemoParser.parse_game_event
def parse_game_event(self, event): """ So CSVCMsg_GameEventList is a list of all events that can happen. A game event has an eventid which maps to a type of event that happened """ if event.eventid in self.event_lookup: #Bash this into a nicer data format to work wit...
python
def parse_game_event(self, event): """ So CSVCMsg_GameEventList is a list of all events that can happen. A game event has an eventid which maps to a type of event that happened """ if event.eventid in self.event_lookup: #Bash this into a nicer data format to work wit...
[ "def", "parse_game_event", "(", "self", ",", "event", ")", ":", "if", "event", ".", "eventid", "in", "self", ".", "event_lookup", ":", "#Bash this into a nicer data format to work with", "event_type", "=", "self", ".", "event_lookup", "[", "event", ".", "eventid",...
So CSVCMsg_GameEventList is a list of all events that can happen. A game event has an eventid which maps to a type of event that happened
[ "So", "CSVCMsg_GameEventList", "is", "a", "list", "of", "all", "events", "that", "can", "happen", ".", "A", "game", "event", "has", "an", "eventid", "which", "maps", "to", "a", "type", "of", "event", "that", "happened" ]
67637f4b9c160ea90c11b7e81545baf350affa7a
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L262-L280
train
63,662
andrewsnowden/dota2py
dota2py/parser.py
DemoParser.parse
def parse(self): """ Parse a replay """ self.important("Parsing demo file '%s'" % (self.filename, )) with open(self.filename, 'rb') as f: reader = Reader(StringIO(f.read())) filestamp = reader.read(8) offset = reader.read_int32() ...
python
def parse(self): """ Parse a replay """ self.important("Parsing demo file '%s'" % (self.filename, )) with open(self.filename, 'rb') as f: reader = Reader(StringIO(f.read())) filestamp = reader.read(8) offset = reader.read_int32() ...
[ "def", "parse", "(", "self", ")", ":", "self", ".", "important", "(", "\"Parsing demo file '%s'\"", "%", "(", "self", ".", "filename", ",", ")", ")", "with", "open", "(", "self", ".", "filename", ",", "'rb'", ")", "as", "f", ":", "reader", "=", "Read...
Parse a replay
[ "Parse", "a", "replay" ]
67637f4b9c160ea90c11b7e81545baf350affa7a
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L282-L327
train
63,663
Arello-Mobile/swagger2rst
swg2rst/swagger/abstract_type_object.py
convert
def convert(data): """ Convert from unicode to native ascii """ try: st = basestring except NameError: st = str if isinstance(data, st): return str(data) elif isinstance(data, Mapping): return dict(map(convert, data.iteritems())) elif isinstance(data, Iter...
python
def convert(data): """ Convert from unicode to native ascii """ try: st = basestring except NameError: st = str if isinstance(data, st): return str(data) elif isinstance(data, Mapping): return dict(map(convert, data.iteritems())) elif isinstance(data, Iter...
[ "def", "convert", "(", "data", ")", ":", "try", ":", "st", "=", "basestring", "except", "NameError", ":", "st", "=", "str", "if", "isinstance", "(", "data", ",", "st", ")", ":", "return", "str", "(", "data", ")", "elif", "isinstance", "(", "data", ...
Convert from unicode to native ascii
[ "Convert", "from", "unicode", "to", "native", "ascii" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/abstract_type_object.py#L103-L118
train
63,664
Arello-Mobile/swagger2rst
swg2rst/swagger/abstract_type_object.py
AbstractTypeObject.set_type_by_schema
def set_type_by_schema(self, schema_obj, schema_type): """ Set property type by schema object Schema will create, if it doesn't exists in collection :param dict schema_obj: raw schema object :param str schema_type: """ schema_id = self._get_object_schema_id(schem...
python
def set_type_by_schema(self, schema_obj, schema_type): """ Set property type by schema object Schema will create, if it doesn't exists in collection :param dict schema_obj: raw schema object :param str schema_type: """ schema_id = self._get_object_schema_id(schem...
[ "def", "set_type_by_schema", "(", "self", ",", "schema_obj", ",", "schema_type", ")", ":", "schema_id", "=", "self", ".", "_get_object_schema_id", "(", "schema_obj", ",", "schema_type", ")", "if", "not", "self", ".", "storage", ".", "contains", "(", "schema_id...
Set property type by schema object Schema will create, if it doesn't exists in collection :param dict schema_obj: raw schema object :param str schema_type:
[ "Set", "property", "type", "by", "schema", "object", "Schema", "will", "create", "if", "it", "doesn", "t", "exists", "in", "collection" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/abstract_type_object.py#L75-L89
train
63,665
joshourisman/django-tablib
django_tablib/admin/actions.py
tablib_export_action
def tablib_export_action(modeladmin, request, queryset, file_type="xls"): """ Allow the user to download the current filtered list of items :param file_type: One of the formats supported by tablib (e.g. "xls", "csv", "html", etc.) """ dataset = SimpleDataset(queryset, headers=None)...
python
def tablib_export_action(modeladmin, request, queryset, file_type="xls"): """ Allow the user to download the current filtered list of items :param file_type: One of the formats supported by tablib (e.g. "xls", "csv", "html", etc.) """ dataset = SimpleDataset(queryset, headers=None)...
[ "def", "tablib_export_action", "(", "modeladmin", ",", "request", ",", "queryset", ",", "file_type", "=", "\"xls\"", ")", ":", "dataset", "=", "SimpleDataset", "(", "queryset", ",", "headers", "=", "None", ")", "filename", "=", "'{0}.{1}'", ".", "format", "(...
Allow the user to download the current filtered list of items :param file_type: One of the formats supported by tablib (e.g. "xls", "csv", "html", etc.)
[ "Allow", "the", "user", "to", "download", "the", "current", "filtered", "list", "of", "items" ]
85b0751fa222a0498aa186714f840b1171a150f9
https://github.com/joshourisman/django-tablib/blob/85b0751fa222a0498aa186714f840b1171a150f9/django_tablib/admin/actions.py#L13-L33
train
63,666
Arello-Mobile/swagger2rst
swg2rst/swagger/schema.py
Schema.get_type_properties
def get_type_properties(self, property_obj, name, additional_prop=False): """ Extend parents 'Get internal properties of property'-method """ property_type, property_format, property_dict = \ super(Schema, self).get_type_properties(property_obj, name, additional_prop=addition...
python
def get_type_properties(self, property_obj, name, additional_prop=False): """ Extend parents 'Get internal properties of property'-method """ property_type, property_format, property_dict = \ super(Schema, self).get_type_properties(property_obj, name, additional_prop=addition...
[ "def", "get_type_properties", "(", "self", ",", "property_obj", ",", "name", ",", "additional_prop", "=", "False", ")", ":", "property_type", ",", "property_format", ",", "property_dict", "=", "super", "(", "Schema", ",", "self", ")", ".", "get_type_properties",...
Extend parents 'Get internal properties of property'-method
[ "Extend", "parents", "Get", "internal", "properties", "of", "property", "-", "method" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/schema.py#L55-L71
train
63,667
joshourisman/django-tablib
django_tablib/views.py
generic_export
def generic_export(request, model_name=None): """ Generic view configured through settings.TABLIB_MODELS Usage: 1. Add the view to ``urlpatterns`` in ``urls.py``:: url(r'export/(?P<model_name>[^/]+)/$', "django_tablib.views.generic_export"), 2. Create the ``setti...
python
def generic_export(request, model_name=None): """ Generic view configured through settings.TABLIB_MODELS Usage: 1. Add the view to ``urlpatterns`` in ``urls.py``:: url(r'export/(?P<model_name>[^/]+)/$', "django_tablib.views.generic_export"), 2. Create the ``setti...
[ "def", "generic_export", "(", "request", ",", "model_name", "=", "None", ")", ":", "if", "model_name", "not", "in", "settings", ".", "TABLIB_MODELS", ":", "raise", "Http404", "(", ")", "model", "=", "get_model", "(", "*", "model_name", ".", "split", "(", ...
Generic view configured through settings.TABLIB_MODELS Usage: 1. Add the view to ``urlpatterns`` in ``urls.py``:: url(r'export/(?P<model_name>[^/]+)/$', "django_tablib.views.generic_export"), 2. Create the ``settings.TABLIB_MODELS`` dictionary using model names ...
[ "Generic", "view", "configured", "through", "settings", ".", "TABLIB_MODELS" ]
85b0751fa222a0498aa186714f840b1171a150f9
https://github.com/joshourisman/django-tablib/blob/85b0751fa222a0498aa186714f840b1171a150f9/django_tablib/views.py#L39-L98
train
63,668
Arello-Mobile/swagger2rst
swg2rst/utils/rst.py
SwaggerObject.sorted
def sorted(collection): """ sorting dict by key, schema-collection by schema-name operations by id """ if len(collection) < 1: return collection if isinstance(collection, dict): return sorted(collection.items(), key=lambda x: x[0]) ...
python
def sorted(collection): """ sorting dict by key, schema-collection by schema-name operations by id """ if len(collection) < 1: return collection if isinstance(collection, dict): return sorted(collection.items(), key=lambda x: x[0]) ...
[ "def", "sorted", "(", "collection", ")", ":", "if", "len", "(", "collection", ")", "<", "1", ":", "return", "collection", "if", "isinstance", "(", "collection", ",", "dict", ")", ":", "return", "sorted", "(", "collection", ".", "items", "(", ")", ",", ...
sorting dict by key, schema-collection by schema-name operations by id
[ "sorting", "dict", "by", "key", "schema", "-", "collection", "by", "schema", "-", "name", "operations", "by", "id" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/utils/rst.py#L24-L42
train
63,669
ixc/python-edtf
edtf/fields.py
EDTFField.pre_save
def pre_save(self, instance, add): """ Updates the edtf value from the value of the display_field. If there's a valid edtf, then set the date values. """ if not self.natural_text_field or self.attname not in instance.__dict__: return edtf = getattr(instance, ...
python
def pre_save(self, instance, add): """ Updates the edtf value from the value of the display_field. If there's a valid edtf, then set the date values. """ if not self.natural_text_field or self.attname not in instance.__dict__: return edtf = getattr(instance, ...
[ "def", "pre_save", "(", "self", ",", "instance", ",", "add", ")", ":", "if", "not", "self", ".", "natural_text_field", "or", "self", ".", "attname", "not", "in", "instance", ".", "__dict__", ":", "return", "edtf", "=", "getattr", "(", "instance", ",", ...
Updates the edtf value from the value of the display_field. If there's a valid edtf, then set the date values.
[ "Updates", "the", "edtf", "value", "from", "the", "value", "of", "the", "display_field", ".", "If", "there", "s", "a", "valid", "edtf", "then", "set", "the", "date", "values", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/fields.py#L87-L138
train
63,670
ixc/python-edtf
edtf/parser/parser_classes.py
apply_delta
def apply_delta(op, time_struct, delta): """ Apply a `relativedelta` to a `struct_time` data structure. `op` is an operator function, probably always `add` or `sub`tract to correspond to `a_date + a_delta` and `a_date - a_delta`. This function is required because we cannot use standard `datetime` ...
python
def apply_delta(op, time_struct, delta): """ Apply a `relativedelta` to a `struct_time` data structure. `op` is an operator function, probably always `add` or `sub`tract to correspond to `a_date + a_delta` and `a_date - a_delta`. This function is required because we cannot use standard `datetime` ...
[ "def", "apply_delta", "(", "op", ",", "time_struct", ",", "delta", ")", ":", "if", "not", "delta", ":", "return", "time_struct", "# No work to do", "try", ":", "dt_result", "=", "op", "(", "datetime", "(", "*", "time_struct", "[", ":", "6", "]", ")", "...
Apply a `relativedelta` to a `struct_time` data structure. `op` is an operator function, probably always `add` or `sub`tract to correspond to `a_date + a_delta` and `a_date - a_delta`. This function is required because we cannot use standard `datetime` module objects for conversion when the date/time ...
[ "Apply", "a", "relativedelta", "to", "a", "struct_time", "data", "structure", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/parser/parser_classes.py#L47-L83
train
63,671
ixc/python-edtf
edtf/parser/parser_classes.py
Date._strict_date
def _strict_date(self, lean): """ Return a `time.struct_time` representation of the date. """ return struct_time( ( self._precise_year(lean), self._precise_month(lean), self._precise_day(lean), ) + tuple(TIME_EMPTY_T...
python
def _strict_date(self, lean): """ Return a `time.struct_time` representation of the date. """ return struct_time( ( self._precise_year(lean), self._precise_month(lean), self._precise_day(lean), ) + tuple(TIME_EMPTY_T...
[ "def", "_strict_date", "(", "self", ",", "lean", ")", ":", "return", "struct_time", "(", "(", "self", ".", "_precise_year", "(", "lean", ")", ",", "self", ".", "_precise_month", "(", "lean", ")", ",", "self", ".", "_precise_day", "(", "lean", ")", ",",...
Return a `time.struct_time` representation of the date.
[ "Return", "a", "time", ".", "struct_time", "representation", "of", "the", "date", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/parser/parser_classes.py#L290-L300
train
63,672
jimjkelly/lambda-deploy
src/lambda_deploy/lambda_deploy.py
LambdaDeploy.package
def package(self): """Packages lambda data for deployment into a zip""" logger.info('Packaging lambda {}'.format(self.lambda_name)) zfh = io.BytesIO() if os.path.exists(os.path.join(self.lambda_dir, '.env')): logger.warn( 'A .env file exists in your Lambda di...
python
def package(self): """Packages lambda data for deployment into a zip""" logger.info('Packaging lambda {}'.format(self.lambda_name)) zfh = io.BytesIO() if os.path.exists(os.path.join(self.lambda_dir, '.env')): logger.warn( 'A .env file exists in your Lambda di...
[ "def", "package", "(", "self", ")", ":", "logger", ".", "info", "(", "'Packaging lambda {}'", ".", "format", "(", "self", ".", "lambda_name", ")", ")", "zfh", "=", "io", ".", "BytesIO", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "os", "...
Packages lambda data for deployment into a zip
[ "Packages", "lambda", "data", "for", "deployment", "into", "a", "zip" ]
012a111189f32d25de23d79fb75411b507b1a5fb
https://github.com/jimjkelly/lambda-deploy/blob/012a111189f32d25de23d79fb75411b507b1a5fb/src/lambda_deploy/lambda_deploy.py#L101-L162
train
63,673
jimjkelly/lambda-deploy
src/lambda_deploy/lambda_deploy.py
LambdaDeploy.deploy
def deploy(self, *lambdas): """Deploys lambdas to AWS""" if not self.role: logger.error('Missing AWS Role') raise ArgumentsError('Role required') logger.debug('Deploying lambda {}'.format(self.lambda_name)) zfh = self.package() if self.lambda_name in se...
python
def deploy(self, *lambdas): """Deploys lambdas to AWS""" if not self.role: logger.error('Missing AWS Role') raise ArgumentsError('Role required') logger.debug('Deploying lambda {}'.format(self.lambda_name)) zfh = self.package() if self.lambda_name in se...
[ "def", "deploy", "(", "self", ",", "*", "lambdas", ")", ":", "if", "not", "self", ".", "role", ":", "logger", ".", "error", "(", "'Missing AWS Role'", ")", "raise", "ArgumentsError", "(", "'Role required'", ")", "logger", ".", "debug", "(", "'Deploying lam...
Deploys lambdas to AWS
[ "Deploys", "lambdas", "to", "AWS" ]
012a111189f32d25de23d79fb75411b507b1a5fb
https://github.com/jimjkelly/lambda-deploy/blob/012a111189f32d25de23d79fb75411b507b1a5fb/src/lambda_deploy/lambda_deploy.py#L164-L231
train
63,674
jimjkelly/lambda-deploy
src/lambda_deploy/lambda_deploy.py
LambdaDeploy.list
def list(self): """Lists already deployed lambdas""" for function in self.client.list_functions().get('Functions', []): lines = json.dumps(function, indent=4, sort_keys=True).split('\n') for line in lines: logger.info(line)
python
def list(self): """Lists already deployed lambdas""" for function in self.client.list_functions().get('Functions', []): lines = json.dumps(function, indent=4, sort_keys=True).split('\n') for line in lines: logger.info(line)
[ "def", "list", "(", "self", ")", ":", "for", "function", "in", "self", ".", "client", ".", "list_functions", "(", ")", ".", "get", "(", "'Functions'", ",", "[", "]", ")", ":", "lines", "=", "json", ".", "dumps", "(", "function", ",", "indent", "=",...
Lists already deployed lambdas
[ "Lists", "already", "deployed", "lambdas" ]
012a111189f32d25de23d79fb75411b507b1a5fb
https://github.com/jimjkelly/lambda-deploy/blob/012a111189f32d25de23d79fb75411b507b1a5fb/src/lambda_deploy/lambda_deploy.py#L233-L238
train
63,675
ixc/python-edtf
edtf/jdutil.py
date_to_jd
def date_to_jd(year,month,day): """ Convert a date to Julian Day. Algorithm from 'Practical Astronomy with your Calculator or Spreadsheet', 4th ed., Duffet-Smith and Zwart, 2011. Parameters ---------- year : int Year as integer. Years preceding 1 A.D. should be 0 or negative. ...
python
def date_to_jd(year,month,day): """ Convert a date to Julian Day. Algorithm from 'Practical Astronomy with your Calculator or Spreadsheet', 4th ed., Duffet-Smith and Zwart, 2011. Parameters ---------- year : int Year as integer. Years preceding 1 A.D. should be 0 or negative. ...
[ "def", "date_to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "if", "month", "==", "1", "or", "month", "==", "2", ":", "yearp", "=", "year", "-", "1", "monthp", "=", "month", "+", "12", "else", ":", "yearp", "=", "year", "monthp", "=", ...
Convert a date to Julian Day. Algorithm from 'Practical Astronomy with your Calculator or Spreadsheet', 4th ed., Duffet-Smith and Zwart, 2011. Parameters ---------- year : int Year as integer. Years preceding 1 A.D. should be 0 or negative. The year before 1 A.D. is 0, 10 B.C....
[ "Convert", "a", "date", "to", "Julian", "Day", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L57-L117
train
63,676
ixc/python-edtf
edtf/jdutil.py
jd_to_date
def jd_to_date(jd): """ Convert Julian Day to date. Algorithm from 'Practical Astronomy with your Calculator or Spreadsheet', 4th ed., Duffet-Smith and Zwart, 2011. Parameters ---------- jd : float Julian Day Returns ------- year : int Year as integer. Yea...
python
def jd_to_date(jd): """ Convert Julian Day to date. Algorithm from 'Practical Astronomy with your Calculator or Spreadsheet', 4th ed., Duffet-Smith and Zwart, 2011. Parameters ---------- jd : float Julian Day Returns ------- year : int Year as integer. Yea...
[ "def", "jd_to_date", "(", "jd", ")", ":", "jd", "=", "jd", "+", "0.5", "F", ",", "I", "=", "math", ".", "modf", "(", "jd", ")", "I", "=", "int", "(", "I", ")", "A", "=", "math", ".", "trunc", "(", "(", "I", "-", "1867216.25", ")", "/", "3...
Convert Julian Day to date. Algorithm from 'Practical Astronomy with your Calculator or Spreadsheet', 4th ed., Duffet-Smith and Zwart, 2011. Parameters ---------- jd : float Julian Day Returns ------- year : int Year as integer. Years preceding 1 A.D. should be 0 ...
[ "Convert", "Julian", "Day", "to", "date", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L120-L184
train
63,677
ixc/python-edtf
edtf/jdutil.py
hmsm_to_days
def hmsm_to_days(hour=0,min=0,sec=0,micro=0): """ Convert hours, minutes, seconds, and microseconds to fractional days. Parameters ---------- hour : int, optional Hour number. Defaults to 0. min : int, optional Minute number. Defaults to 0. sec : int, optional Seco...
python
def hmsm_to_days(hour=0,min=0,sec=0,micro=0): """ Convert hours, minutes, seconds, and microseconds to fractional days. Parameters ---------- hour : int, optional Hour number. Defaults to 0. min : int, optional Minute number. Defaults to 0. sec : int, optional Seco...
[ "def", "hmsm_to_days", "(", "hour", "=", "0", ",", "min", "=", "0", ",", "sec", "=", "0", ",", "micro", "=", "0", ")", ":", "days", "=", "sec", "+", "(", "micro", "/", "1.e6", ")", "days", "=", "min", "+", "(", "days", "/", "60.", ")", "day...
Convert hours, minutes, seconds, and microseconds to fractional days. Parameters ---------- hour : int, optional Hour number. Defaults to 0. min : int, optional Minute number. Defaults to 0. sec : int, optional Second number. Defaults to 0. micro : int, optional ...
[ "Convert", "hours", "minutes", "seconds", "and", "microseconds", "to", "fractional", "days", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L187-L222
train
63,678
ixc/python-edtf
edtf/jdutil.py
days_to_hmsm
def days_to_hmsm(days): """ Convert fractional days to hours, minutes, seconds, and microseconds. Precision beyond microseconds is rounded to the nearest microsecond. Parameters ---------- days : float A fractional number of days. Must be less than 1. Returns ------- hour :...
python
def days_to_hmsm(days): """ Convert fractional days to hours, minutes, seconds, and microseconds. Precision beyond microseconds is rounded to the nearest microsecond. Parameters ---------- days : float A fractional number of days. Must be less than 1. Returns ------- hour :...
[ "def", "days_to_hmsm", "(", "days", ")", ":", "hours", "=", "days", "*", "24.", "hours", ",", "hour", "=", "math", ".", "modf", "(", "hours", ")", "mins", "=", "hours", "*", "60.", "mins", ",", "min", "=", "math", ".", "modf", "(", "mins", ")", ...
Convert fractional days to hours, minutes, seconds, and microseconds. Precision beyond microseconds is rounded to the nearest microsecond. Parameters ---------- days : float A fractional number of days. Must be less than 1. Returns ------- hour : int Hour number. min :...
[ "Convert", "fractional", "days", "to", "hours", "minutes", "seconds", "and", "microseconds", ".", "Precision", "beyond", "microseconds", "is", "rounded", "to", "the", "nearest", "microsecond", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L225-L271
train
63,679
ixc/python-edtf
edtf/jdutil.py
datetime_to_jd
def datetime_to_jd(date): """ Convert a `datetime.datetime` object to Julian Day. Parameters ---------- date : `datetime.datetime` instance Returns ------- jd : float Julian day. Examples -------- >>> d = datetime.datetime(1985,2,17,6) >>> d datetime.date...
python
def datetime_to_jd(date): """ Convert a `datetime.datetime` object to Julian Day. Parameters ---------- date : `datetime.datetime` instance Returns ------- jd : float Julian day. Examples -------- >>> d = datetime.datetime(1985,2,17,6) >>> d datetime.date...
[ "def", "datetime_to_jd", "(", "date", ")", ":", "days", "=", "date", ".", "day", "+", "hmsm_to_days", "(", "date", ".", "hour", ",", "date", ".", "minute", ",", "date", ".", "second", ",", "date", ".", "microsecond", ")", "return", "date_to_jd", "(", ...
Convert a `datetime.datetime` object to Julian Day. Parameters ---------- date : `datetime.datetime` instance Returns ------- jd : float Julian day. Examples -------- >>> d = datetime.datetime(1985,2,17,6) >>> d datetime.datetime(1985, 2, 17, 6, 0) >>> jdutil...
[ "Convert", "a", "datetime", ".", "datetime", "object", "to", "Julian", "Day", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L274-L298
train
63,680
ixc/python-edtf
edtf/jdutil.py
jd_to_datetime
def jd_to_datetime(jd): """ Convert a Julian Day to an `jdutil.datetime` object. Parameters ---------- jd : float Julian day. Returns ------- dt : `jdutil.datetime` object `jdutil.datetime` equivalent of Julian day. Examples -------- >>> jd_to_datetime(2446...
python
def jd_to_datetime(jd): """ Convert a Julian Day to an `jdutil.datetime` object. Parameters ---------- jd : float Julian day. Returns ------- dt : `jdutil.datetime` object `jdutil.datetime` equivalent of Julian day. Examples -------- >>> jd_to_datetime(2446...
[ "def", "jd_to_datetime", "(", "jd", ")", ":", "year", ",", "month", ",", "day", "=", "jd_to_date", "(", "jd", ")", "frac_days", ",", "day", "=", "math", ".", "modf", "(", "day", ")", "day", "=", "int", "(", "day", ")", "hour", ",", "min", ",", ...
Convert a Julian Day to an `jdutil.datetime` object. Parameters ---------- jd : float Julian day. Returns ------- dt : `jdutil.datetime` object `jdutil.datetime` equivalent of Julian day. Examples -------- >>> jd_to_datetime(2446113.75) datetime(1985, 2, 17, 6,...
[ "Convert", "a", "Julian", "Day", "to", "an", "jdutil", ".", "datetime", "object", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L301-L328
train
63,681
ixc/python-edtf
edtf/jdutil.py
timedelta_to_days
def timedelta_to_days(td): """ Convert a `datetime.timedelta` object to a total number of days. Parameters ---------- td : `datetime.timedelta` instance Returns ------- days : float Total number of days in the `datetime.timedelta` object. Examples -------- >>> td =...
python
def timedelta_to_days(td): """ Convert a `datetime.timedelta` object to a total number of days. Parameters ---------- td : `datetime.timedelta` instance Returns ------- days : float Total number of days in the `datetime.timedelta` object. Examples -------- >>> td =...
[ "def", "timedelta_to_days", "(", "td", ")", ":", "seconds_in_day", "=", "24.", "*", "3600.", "days", "=", "td", ".", "days", "+", "(", "td", ".", "seconds", "+", "(", "td", ".", "microseconds", "*", "10.e6", ")", ")", "/", "seconds_in_day", "return", ...
Convert a `datetime.timedelta` object to a total number of days. Parameters ---------- td : `datetime.timedelta` instance Returns ------- days : float Total number of days in the `datetime.timedelta` object. Examples -------- >>> td = datetime.timedelta(4.5) >>> td ...
[ "Convert", "a", "datetime", ".", "timedelta", "object", "to", "a", "total", "number", "of", "days", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/jdutil.py#L331-L357
train
63,682
Arello-Mobile/swagger2rst
swg2rst/swagger/schema_objects.py
SchemaObjects.create_schema
def create_schema(cls, obj, name, schema_type, root): """ Create Schema object :param dict obj: swagger schema object :param str name: schema name :param str schema_type: schema location. Can be ``inline``, ``definition`` or ``mapped`` :param BaseSwaggerObject root: ...
python
def create_schema(cls, obj, name, schema_type, root): """ Create Schema object :param dict obj: swagger schema object :param str name: schema name :param str schema_type: schema location. Can be ``inline``, ``definition`` or ``mapped`` :param BaseSwaggerObject root: ...
[ "def", "create_schema", "(", "cls", ",", "obj", ",", "name", ",", "schema_type", ",", "root", ")", ":", "if", "schema_type", "==", "SchemaTypes", ".", "MAPPED", ":", "schema", "=", "SchemaMapWrapper", "(", "obj", ",", "storage", "=", "cls", ",", "name", ...
Create Schema object :param dict obj: swagger schema object :param str name: schema name :param str schema_type: schema location. Can be ``inline``, ``definition`` or ``mapped`` :param BaseSwaggerObject root: root doc :return: new schema :rtype: Schema
[ "Create", "Schema", "object" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/schema_objects.py#L15-L31
train
63,683
Arello-Mobile/swagger2rst
swg2rst/swagger/schema_objects.py
SchemaObjects.get_schemas
def get_schemas(cls, schema_types=None, sort=True): """ Get schemas by type. If ``schema_type`` is None, return all schemas :param schema_types: list of schema types :type schema_types: list or None :param bool sort: sort by name :return: list of schemas :rtype: ...
python
def get_schemas(cls, schema_types=None, sort=True): """ Get schemas by type. If ``schema_type`` is None, return all schemas :param schema_types: list of schema types :type schema_types: list or None :param bool sort: sort by name :return: list of schemas :rtype: ...
[ "def", "get_schemas", "(", "cls", ",", "schema_types", "=", "None", ",", "sort", "=", "True", ")", ":", "result", "=", "filter", "(", "lambda", "x", ":", "not", "x", ".", "is_inline_array", ",", "cls", ".", "_schemas", ".", "values", "(", ")", ")", ...
Get schemas by type. If ``schema_type`` is None, return all schemas :param schema_types: list of schema types :type schema_types: list or None :param bool sort: sort by name :return: list of schemas :rtype: list
[ "Get", "schemas", "by", "type", ".", "If", "schema_type", "is", "None", "return", "all", "schemas" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/schema_objects.py#L52-L67
train
63,684
ixc/python-edtf
edtf/convert.py
trim_struct_time
def trim_struct_time(st, strip_time=False): """ Return a `struct_time` based on the one provided but with the extra fields `tm_wday`, `tm_yday`, and `tm_isdst` reset to default values. If `strip_time` is set to true the time value are also set to zero: `tm_hour`, `tm_min`, and `tm_sec`. """ ...
python
def trim_struct_time(st, strip_time=False): """ Return a `struct_time` based on the one provided but with the extra fields `tm_wday`, `tm_yday`, and `tm_isdst` reset to default values. If `strip_time` is set to true the time value are also set to zero: `tm_hour`, `tm_min`, and `tm_sec`. """ ...
[ "def", "trim_struct_time", "(", "st", ",", "strip_time", "=", "False", ")", ":", "if", "strip_time", ":", "return", "struct_time", "(", "list", "(", "st", "[", ":", "3", "]", ")", "+", "TIME_EMPTY_TIME", "+", "TIME_EMPTY_EXTRAS", ")", "else", ":", "retur...
Return a `struct_time` based on the one provided but with the extra fields `tm_wday`, `tm_yday`, and `tm_isdst` reset to default values. If `strip_time` is set to true the time value are also set to zero: `tm_hour`, `tm_min`, and `tm_sec`.
[ "Return", "a", "struct_time", "based", "on", "the", "one", "provided", "but", "with", "the", "extra", "fields", "tm_wday", "tm_yday", "and", "tm_isdst", "reset", "to", "default", "values", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/convert.py#L52-L63
train
63,685
ixc/python-edtf
edtf/convert.py
struct_time_to_jd
def struct_time_to_jd(st): """ Return a float number representing the Julian Date for the given `struct_time`. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` are ignored. """ year, month, day = st[:3] hours, minutes, seconds = st[3:6] # Convert time of day to fraction of day ...
python
def struct_time_to_jd(st): """ Return a float number representing the Julian Date for the given `struct_time`. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` are ignored. """ year, month, day = st[:3] hours, minutes, seconds = st[3:6] # Convert time of day to fraction of day ...
[ "def", "struct_time_to_jd", "(", "st", ")", ":", "year", ",", "month", ",", "day", "=", "st", "[", ":", "3", "]", "hours", ",", "minutes", ",", "seconds", "=", "st", "[", "3", ":", "6", "]", "# Convert time of day to fraction of day", "day", "+=", "jdu...
Return a float number representing the Julian Date for the given `struct_time`. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` are ignored.
[ "Return", "a", "float", "number", "representing", "the", "Julian", "Date", "for", "the", "given", "struct_time", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/convert.py#L66-L79
train
63,686
ixc/python-edtf
edtf/convert.py
jd_to_struct_time
def jd_to_struct_time(jd): """ Return a `struct_time` converted from a Julian Date float number. WARNING: Conversion to then from Julian Date value to `struct_time` can be inaccurate and lose or gain time, especially for BC (negative) years. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` ...
python
def jd_to_struct_time(jd): """ Return a `struct_time` converted from a Julian Date float number. WARNING: Conversion to then from Julian Date value to `struct_time` can be inaccurate and lose or gain time, especially for BC (negative) years. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` ...
[ "def", "jd_to_struct_time", "(", "jd", ")", ":", "year", ",", "month", ",", "day", "=", "jdutil", ".", "jd_to_date", "(", "jd", ")", "# Convert time of day from fraction of day", "day_fraction", "=", "day", "-", "int", "(", "day", ")", "hour", ",", "minute",...
Return a `struct_time` converted from a Julian Date float number. WARNING: Conversion to then from Julian Date value to `struct_time` can be inaccurate and lose or gain time, especially for BC (negative) years. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` are set to default values, not real...
[ "Return", "a", "struct_time", "converted", "from", "a", "Julian", "Date", "float", "number", "." ]
ec2124d3df75f8dd72571026380ce8dd16f3dd6b
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/convert.py#L82-L106
train
63,687
Arello-Mobile/swagger2rst
swg2rst/utils/exampilators.py
Exampilator.get_example_by_schema
def get_example_by_schema(cls, schema, ignored_schemas=None, paths=None, name=''): """ Get example by schema object :param Schema schema: current schema :param list ignored_schemas: list of previous schemas for avoid circular references :param list paths: list object paths (...
python
def get_example_by_schema(cls, schema, ignored_schemas=None, paths=None, name=''): """ Get example by schema object :param Schema schema: current schema :param list ignored_schemas: list of previous schemas for avoid circular references :param list paths: list object paths (...
[ "def", "get_example_by_schema", "(", "cls", ",", "schema", ",", "ignored_schemas", "=", "None", ",", "paths", "=", "None", ",", "name", "=", "''", ")", ":", "if", "schema", ".", "schema_example", ":", "return", "schema", ".", "schema_example", "if", "ignor...
Get example by schema object :param Schema schema: current schema :param list ignored_schemas: list of previous schemas for avoid circular references :param list paths: list object paths (ex. #/definitions/Model.property) If nested schemas exists, custom examples checks ...
[ "Get", "example", "by", "schema", "object" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/utils/exampilators.py#L107-L156
train
63,688
Arello-Mobile/swagger2rst
swg2rst/utils/exampilators.py
Exampilator.get_body_example
def get_body_example(cls, operation): """ Get example for body parameter example by operation :param Operation operation: operation object """ path = "#/paths/'{0.path}'/{0.method}/parameters/{name}".format( operation, name=operation.body.name or 'body') return cls.g...
python
def get_body_example(cls, operation): """ Get example for body parameter example by operation :param Operation operation: operation object """ path = "#/paths/'{0.path}'/{0.method}/parameters/{name}".format( operation, name=operation.body.name or 'body') return cls.g...
[ "def", "get_body_example", "(", "cls", ",", "operation", ")", ":", "path", "=", "\"#/paths/'{0.path}'/{0.method}/parameters/{name}\"", ".", "format", "(", "operation", ",", "name", "=", "operation", ".", "body", ".", "name", "or", "'body'", ")", "return", "cls",...
Get example for body parameter example by operation :param Operation operation: operation object
[ "Get", "example", "for", "body", "parameter", "example", "by", "operation" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/utils/exampilators.py#L159-L166
train
63,689
Arello-Mobile/swagger2rst
swg2rst/utils/exampilators.py
Exampilator.get_response_example
def get_response_example(cls, operation, response): """ Get example for response object by operation object :param Operation operation: operation object :param Response response: response object """ path = "#/paths/'{}'/{}/responses/{}".format( operation.path, operat...
python
def get_response_example(cls, operation, response): """ Get example for response object by operation object :param Operation operation: operation object :param Response response: response object """ path = "#/paths/'{}'/{}/responses/{}".format( operation.path, operat...
[ "def", "get_response_example", "(", "cls", ",", "operation", ",", "response", ")", ":", "path", "=", "\"#/paths/'{}'/{}/responses/{}\"", ".", "format", "(", "operation", ".", "path", ",", "operation", ".", "method", ",", "response", ".", "name", ")", "kwargs",...
Get example for response object by operation object :param Operation operation: operation object :param Response response: response object
[ "Get", "example", "for", "response", "object", "by", "operation", "object" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/utils/exampilators.py#L169-L186
train
63,690
Arello-Mobile/swagger2rst
swg2rst/utils/exampilators.py
Exampilator.get_header_example
def get_header_example(cls, header): """ Get example for header object :param Header header: Header object :return: example :rtype: dict """ if header.is_array: result = cls.get_example_for_array(header.item) else: example_method = getattr...
python
def get_header_example(cls, header): """ Get example for header object :param Header header: Header object :return: example :rtype: dict """ if header.is_array: result = cls.get_example_for_array(header.item) else: example_method = getattr...
[ "def", "get_header_example", "(", "cls", ",", "header", ")", ":", "if", "header", ".", "is_array", ":", "result", "=", "cls", ".", "get_example_for_array", "(", "header", ".", "item", ")", "else", ":", "example_method", "=", "getattr", "(", "cls", ",", "...
Get example for header object :param Header header: Header object :return: example :rtype: dict
[ "Get", "example", "for", "header", "object" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/utils/exampilators.py#L189-L201
train
63,691
Arello-Mobile/swagger2rst
swg2rst/utils/exampilators.py
Exampilator.get_property_example
def get_property_example(cls, property_, nested=None, **kw): """ Get example for property :param dict property_: :param set nested: :return: example value """ paths = kw.get('paths', []) name = kw.get('name', '') result = None if name and paths: ...
python
def get_property_example(cls, property_, nested=None, **kw): """ Get example for property :param dict property_: :param set nested: :return: example value """ paths = kw.get('paths', []) name = kw.get('name', '') result = None if name and paths: ...
[ "def", "get_property_example", "(", "cls", ",", "property_", ",", "nested", "=", "None", ",", "*", "*", "kw", ")", ":", "paths", "=", "kw", ".", "get", "(", "'paths'", ",", "[", "]", ")", "name", "=", "kw", ".", "get", "(", "'name'", ",", "''", ...
Get example for property :param dict property_: :param set nested: :return: example value
[ "Get", "example", "for", "property" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/utils/exampilators.py#L204-L253
train
63,692
twaddington/android-asset-resizer
android_asset_resizer/resizer.py
AssetResizer.mkres
def mkres(self): """ Create a directory tree for the resized assets """ for d in DENSITY_TYPES: if d == 'ldpi' and not self.ldpi: continue # skip ldpi if d == 'xxxhdpi' and not self.xxxhdpi: continue # skip xxxhdpi tr...
python
def mkres(self): """ Create a directory tree for the resized assets """ for d in DENSITY_TYPES: if d == 'ldpi' and not self.ldpi: continue # skip ldpi if d == 'xxxhdpi' and not self.xxxhdpi: continue # skip xxxhdpi tr...
[ "def", "mkres", "(", "self", ")", ":", "for", "d", "in", "DENSITY_TYPES", ":", "if", "d", "==", "'ldpi'", "and", "not", "self", ".", "ldpi", ":", "continue", "# skip ldpi", "if", "d", "==", "'xxxhdpi'", "and", "not", "self", ".", "xxxhdpi", ":", "con...
Create a directory tree for the resized assets
[ "Create", "a", "directory", "tree", "for", "the", "resized", "assets" ]
646bbc27ded57c125e7a6bcca11ba367e8f09c18
https://github.com/twaddington/android-asset-resizer/blob/646bbc27ded57c125e7a6bcca11ba367e8f09c18/android_asset_resizer/resizer.py#L31-L45
train
63,693
twaddington/android-asset-resizer
android_asset_resizer/resizer.py
AssetResizer.get_size_for_density
def get_size_for_density(self, size, target_density): """ Return the new image size for the target density """ current_size = size current_density = DENSITY_MAP[self.source_density] target_density = DENSITY_MAP[target_density] return int(current_size * (target_de...
python
def get_size_for_density(self, size, target_density): """ Return the new image size for the target density """ current_size = size current_density = DENSITY_MAP[self.source_density] target_density = DENSITY_MAP[target_density] return int(current_size * (target_de...
[ "def", "get_size_for_density", "(", "self", ",", "size", ",", "target_density", ")", ":", "current_size", "=", "size", "current_density", "=", "DENSITY_MAP", "[", "self", ".", "source_density", "]", "target_density", "=", "DENSITY_MAP", "[", "target_density", "]",...
Return the new image size for the target density
[ "Return", "the", "new", "image", "size", "for", "the", "target", "density" ]
646bbc27ded57c125e7a6bcca11ba367e8f09c18
https://github.com/twaddington/android-asset-resizer/blob/646bbc27ded57c125e7a6bcca11ba367e8f09c18/android_asset_resizer/resizer.py#L53-L61
train
63,694
twaddington/android-asset-resizer
android_asset_resizer/resizer.py
AssetResizer.resize_image
def resize_image(self, path, im): """ Generate assets from the given image and path in case you've already called Image.open """ # Get the original filename _, filename = os.path.split(path) # Generate the new filename filename = self.get_safe_filename(fi...
python
def resize_image(self, path, im): """ Generate assets from the given image and path in case you've already called Image.open """ # Get the original filename _, filename = os.path.split(path) # Generate the new filename filename = self.get_safe_filename(fi...
[ "def", "resize_image", "(", "self", ",", "path", ",", "im", ")", ":", "# Get the original filename", "_", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "path", ")", "# Generate the new filename", "filename", "=", "self", ".", "get_safe_filename",...
Generate assets from the given image and path in case you've already called Image.open
[ "Generate", "assets", "from", "the", "given", "image", "and", "path", "in", "case", "you", "ve", "already", "called", "Image", ".", "open" ]
646bbc27ded57c125e7a6bcca11ba367e8f09c18
https://github.com/twaddington/android-asset-resizer/blob/646bbc27ded57c125e7a6bcca11ba367e8f09c18/android_asset_resizer/resizer.py#L75-L106
train
63,695
stitchdata/python-stitch-client
stitchclient/client.py
Client.push
def push(self, message, callback_arg=None): """message should be a dict recognized by the Stitch Import API. See https://www.stitchdata.com/docs/integrations/import-api. """ if message['action'] == 'upsert': message.setdefault('key_names', self.key_names) message['...
python
def push(self, message, callback_arg=None): """message should be a dict recognized by the Stitch Import API. See https://www.stitchdata.com/docs/integrations/import-api. """ if message['action'] == 'upsert': message.setdefault('key_names', self.key_names) message['...
[ "def", "push", "(", "self", ",", "message", ",", "callback_arg", "=", "None", ")", ":", "if", "message", "[", "'action'", "]", "==", "'upsert'", ":", "message", ".", "setdefault", "(", "'key_names'", ",", "self", ".", "key_names", ")", "message", "[", ...
message should be a dict recognized by the Stitch Import API. See https://www.stitchdata.com/docs/integrations/import-api.
[ "message", "should", "be", "a", "dict", "recognized", "by", "the", "Stitch", "Import", "API", "." ]
de4dfb3db209e5d0a7b0c0dcef625f3e465c787b
https://github.com/stitchdata/python-stitch-client/blob/de4dfb3db209e5d0a7b0c0dcef625f3e465c787b/stitchclient/client.py#L117-L133
train
63,696
stitchdata/python-stitch-client
stitchclient/client.py
Client._take_batch
def _take_batch(self, min_records): '''If we have enough data to build a batch, returns all the data in the buffer and then clears the buffer.''' if not self._buffer: return [] enough_messages = len(self._buffer) >= min_records enough_time = time.time() - self.time_...
python
def _take_batch(self, min_records): '''If we have enough data to build a batch, returns all the data in the buffer and then clears the buffer.''' if not self._buffer: return [] enough_messages = len(self._buffer) >= min_records enough_time = time.time() - self.time_...
[ "def", "_take_batch", "(", "self", ",", "min_records", ")", ":", "if", "not", "self", ".", "_buffer", ":", "return", "[", "]", "enough_messages", "=", "len", "(", "self", ".", "_buffer", ")", ">=", "min_records", "enough_time", "=", "time", ".", "time", ...
If we have enough data to build a batch, returns all the data in the buffer and then clears the buffer.
[ "If", "we", "have", "enough", "data", "to", "build", "a", "batch", "returns", "all", "the", "data", "in", "the", "buffer", "and", "then", "clears", "the", "buffer", "." ]
de4dfb3db209e5d0a7b0c0dcef625f3e465c787b
https://github.com/stitchdata/python-stitch-client/blob/de4dfb3db209e5d0a7b0c0dcef625f3e465c787b/stitchclient/client.py#L136-L152
train
63,697
Arello-Mobile/swagger2rst
swg2rst/swagger/operation.py
Operation.get_parameters_by_location
def get_parameters_by_location(self, locations=None, excludes=None): """ Get parameters list by location :param locations: list of locations :type locations: list or None :param excludes: list of excludes locations :type excludes: list or None :return: list of Parameter ...
python
def get_parameters_by_location(self, locations=None, excludes=None): """ Get parameters list by location :param locations: list of locations :type locations: list or None :param excludes: list of excludes locations :type excludes: list or None :return: list of Parameter ...
[ "def", "get_parameters_by_location", "(", "self", ",", "locations", "=", "None", ",", "excludes", "=", "None", ")", ":", "result", "=", "self", ".", "parameters", "if", "locations", ":", "result", "=", "filter", "(", "lambda", "x", ":", "x", ".", "locati...
Get parameters list by location :param locations: list of locations :type locations: list or None :param excludes: list of excludes locations :type excludes: list or None :return: list of Parameter :rtype: list
[ "Get", "parameters", "list", "by", "location" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/operation.py#L72-L87
train
63,698
Arello-Mobile/swagger2rst
swg2rst/swagger/operation.py
Operation.body
def body(self): """ Return body request parameter :return: Body parameter :rtype: Parameter or None """ body = self.get_parameters_by_location(['body']) return self.root.schemas.get(body[0].type) if body else None
python
def body(self): """ Return body request parameter :return: Body parameter :rtype: Parameter or None """ body = self.get_parameters_by_location(['body']) return self.root.schemas.get(body[0].type) if body else None
[ "def", "body", "(", "self", ")", ":", "body", "=", "self", ".", "get_parameters_by_location", "(", "[", "'body'", "]", ")", "return", "self", ".", "root", ".", "schemas", ".", "get", "(", "body", "[", "0", "]", ".", "type", ")", "if", "body", "else...
Return body request parameter :return: Body parameter :rtype: Parameter or None
[ "Return", "body", "request", "parameter" ]
e519f70701477dcc9f0bb237ee5b8e08e848701b
https://github.com/Arello-Mobile/swagger2rst/blob/e519f70701477dcc9f0bb237ee5b8e08e848701b/swg2rst/swagger/operation.py#L90-L97
train
63,699