repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
shazow/unstdlib.py
unstdlib/standard/string_.py
format_int
def format_int(n, singular=_Default, plural=_Default): """ Return `singular.format(n)` if n is 1, or `plural.format(n)` otherwise. If plural is not specified, then it is assumed to be same as singular but suffixed with an 's'. :param n: Integer which determines pluralness. :param singu...
python
def format_int(n, singular=_Default, plural=_Default): """ Return `singular.format(n)` if n is 1, or `plural.format(n)` otherwise. If plural is not specified, then it is assumed to be same as singular but suffixed with an 's'. :param n: Integer which determines pluralness. :param singu...
[ "def", "format_int", "(", "n", ",", "singular", "=", "_Default", ",", "plural", "=", "_Default", ")", ":", "n", "=", "int", "(", "n", ")", "if", "singular", "in", "(", "None", ",", "_Default", ")", ":", "if", "plural", "is", "_Default", ":", "plura...
Return `singular.format(n)` if n is 1, or `plural.format(n)` otherwise. If plural is not specified, then it is assumed to be same as singular but suffixed with an 's'. :param n: Integer which determines pluralness. :param singular: String with a format() placeholder for n. (Default: `u...
[ "Return", "singular", ".", "format", "(", "n", ")", "if", "n", "is", "1", "or", "plural", ".", "format", "(", "n", ")", "otherwise", ".", "If", "plural", "is", "not", "specified", "then", "it", "is", "assumed", "to", "be", "same", "as", "singular", ...
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/string_.py#L332-L375
train
shazow/unstdlib.py
unstdlib/standard/string_.py
dollars_to_cents
def dollars_to_cents(s, allow_negative=False): """ Given a string or integer representing dollars, return an integer of equivalent cents, in an input-resilient way. This works by stripping any non-numeric characters before attempting to cast the value. Examples:: >>> dollars_to_ce...
python
def dollars_to_cents(s, allow_negative=False): """ Given a string or integer representing dollars, return an integer of equivalent cents, in an input-resilient way. This works by stripping any non-numeric characters before attempting to cast the value. Examples:: >>> dollars_to_ce...
[ "def", "dollars_to_cents", "(", "s", ",", "allow_negative", "=", "False", ")", ":", "# TODO: Implement cents_to_dollars", "if", "not", "s", ":", "return", "if", "isinstance", "(", "s", ",", "string_types", ")", ":", "s", "=", "''", ".", "join", "(", "RE_NU...
Given a string or integer representing dollars, return an integer of equivalent cents, in an input-resilient way. This works by stripping any non-numeric characters before attempting to cast the value. Examples:: >>> dollars_to_cents('$1') 100 >>> dollars_to_cents('1') ...
[ "Given", "a", "string", "or", "integer", "representing", "dollars", "return", "an", "integer", "of", "equivalent", "cents", "in", "an", "input", "-", "resilient", "way", ".", "This", "works", "by", "stripping", "any", "non", "-", "numeric", "characters", "be...
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/string_.py#L381-L415
train
shazow/unstdlib.py
unstdlib/standard/string_.py
slugify
def slugify(s, delimiter='-'): """ Normalize `s` into ASCII and replace non-word characters with `delimiter`. """ s = unicodedata.normalize('NFKD', to_unicode(s)).encode('ascii', 'ignore').decode('ascii') return RE_SLUG.sub(delimiter, s).strip(delimiter).lower()
python
def slugify(s, delimiter='-'): """ Normalize `s` into ASCII and replace non-word characters with `delimiter`. """ s = unicodedata.normalize('NFKD', to_unicode(s)).encode('ascii', 'ignore').decode('ascii') return RE_SLUG.sub(delimiter, s).strip(delimiter).lower()
[ "def", "slugify", "(", "s", ",", "delimiter", "=", "'-'", ")", ":", "s", "=", "unicodedata", ".", "normalize", "(", "'NFKD'", ",", "to_unicode", "(", "s", ")", ")", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ".", "decode", "(", "'ascii'", ...
Normalize `s` into ASCII and replace non-word characters with `delimiter`.
[ "Normalize", "s", "into", "ASCII", "and", "replace", "non", "-", "word", "characters", "with", "delimiter", "." ]
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/string_.py#L420-L425
train
shazow/unstdlib.py
unstdlib/html.py
get_cache_buster
def get_cache_buster(src_path, method='importtime'): """ Return a string that can be used as a parameter for cache-busting URLs for this asset. :param src_path: Filesystem path to the file we're generating a cache-busting value for. :param method: Method for cache-busting. Supported va...
python
def get_cache_buster(src_path, method='importtime'): """ Return a string that can be used as a parameter for cache-busting URLs for this asset. :param src_path: Filesystem path to the file we're generating a cache-busting value for. :param method: Method for cache-busting. Supported va...
[ "def", "get_cache_buster", "(", "src_path", ",", "method", "=", "'importtime'", ")", ":", "try", ":", "fn", "=", "_BUST_METHODS", "[", "method", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "'Unsupported busting method value: %s'", "%", "method", ")...
Return a string that can be used as a parameter for cache-busting URLs for this asset. :param src_path: Filesystem path to the file we're generating a cache-busting value for. :param method: Method for cache-busting. Supported values: importtime, mtime, md5 The default is 'importti...
[ "Return", "a", "string", "that", "can", "be", "used", "as", "a", "parameter", "for", "cache", "-", "busting", "URLs", "for", "this", "asset", "." ]
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/html.py#L46-L75
train
shazow/unstdlib.py
unstdlib/html.py
_generate_dom_attrs
def _generate_dom_attrs(attrs, allow_no_value=True): """ Yield compiled DOM attribute key-value strings. If the value is `True`, then it is treated as no-value. If `None`, then it is skipped. """ for attr in iterate_items(attrs): if isinstance(attr, basestring): attr = (attr, Tr...
python
def _generate_dom_attrs(attrs, allow_no_value=True): """ Yield compiled DOM attribute key-value strings. If the value is `True`, then it is treated as no-value. If `None`, then it is skipped. """ for attr in iterate_items(attrs): if isinstance(attr, basestring): attr = (attr, Tr...
[ "def", "_generate_dom_attrs", "(", "attrs", ",", "allow_no_value", "=", "True", ")", ":", "for", "attr", "in", "iterate_items", "(", "attrs", ")", ":", "if", "isinstance", "(", "attr", ",", "basestring", ")", ":", "attr", "=", "(", "attr", ",", "True", ...
Yield compiled DOM attribute key-value strings. If the value is `True`, then it is treated as no-value. If `None`, then it is skipped.
[ "Yield", "compiled", "DOM", "attribute", "key", "-", "value", "strings", "." ]
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/html.py#L78-L95
train
shazow/unstdlib.py
unstdlib/html.py
tag
def tag(tagname, content='', attrs=None): """ Helper for programmatically building HTML tags. Note that this barely does any escaping, and will happily spit out dangerous user input if used as such. :param tagname: Tag name of the DOM element we want to return. :param content: Opt...
python
def tag(tagname, content='', attrs=None): """ Helper for programmatically building HTML tags. Note that this barely does any escaping, and will happily spit out dangerous user input if used as such. :param tagname: Tag name of the DOM element we want to return. :param content: Opt...
[ "def", "tag", "(", "tagname", ",", "content", "=", "''", ",", "attrs", "=", "None", ")", ":", "attrs_str", "=", "attrs", "and", "' '", ".", "join", "(", "_generate_dom_attrs", "(", "attrs", ")", ")", "open_tag", "=", "tagname", "if", "attrs_str", ":", ...
Helper for programmatically building HTML tags. Note that this barely does any escaping, and will happily spit out dangerous user input if used as such. :param tagname: Tag name of the DOM element we want to return. :param content: Optional content of the DOM element. If `None`, then ...
[ "Helper", "for", "programmatically", "building", "HTML", "tags", "." ]
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/html.py#L107-L146
train
shazow/unstdlib.py
unstdlib/html.py
javascript_link
def javascript_link(src_url, src_path=None, cache_bust=None, content='', extra_attrs=None): """ Helper for programmatically building HTML JavaScript source include links, with optional cache busting. :param src_url: Goes into the `src` attribute of the `<script src="...">` tag. :param src_path...
python
def javascript_link(src_url, src_path=None, cache_bust=None, content='', extra_attrs=None): """ Helper for programmatically building HTML JavaScript source include links, with optional cache busting. :param src_url: Goes into the `src` attribute of the `<script src="...">` tag. :param src_path...
[ "def", "javascript_link", "(", "src_url", ",", "src_path", "=", "None", ",", "cache_bust", "=", "None", ",", "content", "=", "''", ",", "extra_attrs", "=", "None", ")", ":", "if", "cache_bust", ":", "append_suffix", "=", "get_cache_buster", "(", "src_path", ...
Helper for programmatically building HTML JavaScript source include links, with optional cache busting. :param src_url: Goes into the `src` attribute of the `<script src="...">` tag. :param src_path: Optional filesystem path to the source file, used when `cache_bust` is enabled. ...
[ "Helper", "for", "programmatically", "building", "HTML", "JavaScript", "source", "include", "links", "with", "optional", "cache", "busting", "." ]
e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/html.py#L164-L202
train
rackerlabs/lambda-uploader
setup.py
package_meta
def package_meta(): """Read __init__.py for global package metadata. Do this without importing the package. """ _version_re = re.compile(r'__version__\s+=\s+(.*)') _url_re = re.compile(r'__url__\s+=\s+(.*)') _license_re = re.compile(r'__license__\s+=\s+(.*)') with open('lambda_uploader/__in...
python
def package_meta(): """Read __init__.py for global package metadata. Do this without importing the package. """ _version_re = re.compile(r'__version__\s+=\s+(.*)') _url_re = re.compile(r'__url__\s+=\s+(.*)') _license_re = re.compile(r'__license__\s+=\s+(.*)') with open('lambda_uploader/__in...
[ "def", "package_meta", "(", ")", ":", "_version_re", "=", "re", ".", "compile", "(", "r'__version__\\s+=\\s+(.*)'", ")", "_url_re", "=", "re", ".", "compile", "(", "r'__url__\\s+=\\s+(.*)'", ")", "_license_re", "=", "re", ".", "compile", "(", "r'__license__\\s+=...
Read __init__.py for global package metadata. Do this without importing the package.
[ "Read", "__init__", ".", "py", "for", "global", "package", "metadata", ".", "Do", "this", "without", "importing", "the", "package", "." ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/setup.py#L37-L57
train
rackerlabs/lambda-uploader
lambda_uploader/subscribers.py
create_subscriptions
def create_subscriptions(config, profile_name): ''' Adds supported subscriptions ''' if 'kinesis' in config.subscription.keys(): data = config.subscription['kinesis'] function_name = config.name stream_name = data['stream'] batch_size = data['batch_size'] starting_positio...
python
def create_subscriptions(config, profile_name): ''' Adds supported subscriptions ''' if 'kinesis' in config.subscription.keys(): data = config.subscription['kinesis'] function_name = config.name stream_name = data['stream'] batch_size = data['batch_size'] starting_positio...
[ "def", "create_subscriptions", "(", "config", ",", "profile_name", ")", ":", "if", "'kinesis'", "in", "config", ".", "subscription", ".", "keys", "(", ")", ":", "data", "=", "config", ".", "subscription", "[", "'kinesis'", "]", "function_name", "=", "config"...
Adds supported subscriptions
[ "Adds", "supported", "subscriptions" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/subscribers.py#L77-L93
train
rackerlabs/lambda-uploader
lambda_uploader/subscribers.py
KinesisSubscriber.subscribe
def subscribe(self): ''' Subscribes the lambda to the Kinesis stream ''' try: LOG.debug('Creating Kinesis subscription') if self.starting_position_ts: self._lambda_client \ .create_event_source_mapping( EventSourceArn=se...
python
def subscribe(self): ''' Subscribes the lambda to the Kinesis stream ''' try: LOG.debug('Creating Kinesis subscription') if self.starting_position_ts: self._lambda_client \ .create_event_source_mapping( EventSourceArn=se...
[ "def", "subscribe", "(", "self", ")", ":", "try", ":", "LOG", ".", "debug", "(", "'Creating Kinesis subscription'", ")", "if", "self", ".", "starting_position_ts", ":", "self", ".", "_lambda_client", ".", "create_event_source_mapping", "(", "EventSourceArn", "=", ...
Subscribes the lambda to the Kinesis stream
[ "Subscribes", "the", "lambda", "to", "the", "Kinesis", "stream" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/subscribers.py#L37-L74
train
rackerlabs/lambda-uploader
lambda_uploader/uploader.py
PackageUploader._format_vpc_config
def _format_vpc_config(self): ''' Returns {} if the VPC config is set to None by Config, returns the formatted config otherwise ''' if self._config.raw['vpc']: return { 'SubnetIds': self._config.raw['vpc']['subnets'], 'SecurityGroupIds'...
python
def _format_vpc_config(self): ''' Returns {} if the VPC config is set to None by Config, returns the formatted config otherwise ''' if self._config.raw['vpc']: return { 'SubnetIds': self._config.raw['vpc']['subnets'], 'SecurityGroupIds'...
[ "def", "_format_vpc_config", "(", "self", ")", ":", "if", "self", ".", "_config", ".", "raw", "[", "'vpc'", "]", ":", "return", "{", "'SubnetIds'", ":", "self", ".", "_config", ".", "raw", "[", "'vpc'", "]", "[", "'subnets'", "]", ",", "'SecurityGroupI...
Returns {} if the VPC config is set to None by Config, returns the formatted config otherwise
[ "Returns", "{}", "if", "the", "VPC", "config", "is", "set", "to", "None", "by", "Config", "returns", "the", "formatted", "config", "otherwise" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/uploader.py#L203-L217
train
rackerlabs/lambda-uploader
lambda_uploader/uploader.py
PackageUploader._upload_s3
def _upload_s3(self, zip_file): ''' Uploads the lambda package to s3 ''' s3_client = self._aws_session.client('s3') transfer = boto3.s3.transfer.S3Transfer(s3_client) transfer.upload_file(zip_file, self._config.s3_bucket, self._config.s3_packa...
python
def _upload_s3(self, zip_file): ''' Uploads the lambda package to s3 ''' s3_client = self._aws_session.client('s3') transfer = boto3.s3.transfer.S3Transfer(s3_client) transfer.upload_file(zip_file, self._config.s3_bucket, self._config.s3_packa...
[ "def", "_upload_s3", "(", "self", ",", "zip_file", ")", ":", "s3_client", "=", "self", ".", "_aws_session", ".", "client", "(", "'s3'", ")", "transfer", "=", "boto3", ".", "s3", ".", "transfer", ".", "S3Transfer", "(", "s3_client", ")", "transfer", ".", ...
Uploads the lambda package to s3
[ "Uploads", "the", "lambda", "package", "to", "s3" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/uploader.py#L219-L226
train
rackerlabs/lambda-uploader
lambda_uploader/shell.py
main
def main(arv=None): """lambda-uploader command line interface.""" # Check for Python 2.7 or later if sys.version_info[0] < 3 and not sys.version_info[1] == 7: raise RuntimeError('lambda-uploader requires Python 2.7 or later') import argparse parser = argparse.ArgumentParser( de...
python
def main(arv=None): """lambda-uploader command line interface.""" # Check for Python 2.7 or later if sys.version_info[0] < 3 and not sys.version_info[1] == 7: raise RuntimeError('lambda-uploader requires Python 2.7 or later') import argparse parser = argparse.ArgumentParser( de...
[ "def", "main", "(", "arv", "=", "None", ")", ":", "# Check for Python 2.7 or later", "if", "sys", ".", "version_info", "[", "0", "]", "<", "3", "and", "not", "sys", ".", "version_info", "[", "1", "]", "==", "7", ":", "raise", "RuntimeError", "(", "'lam...
lambda-uploader command line interface.
[ "lambda", "-", "uploader", "command", "line", "interface", "." ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/shell.py#L117-L203
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
build_package
def build_package(path, requires, virtualenv=None, ignore=None, extra_files=None, zipfile_name=ZIPFILE_NAME, pyexec=None): '''Builds the zip file and creates the package with it''' pkg = Package(path, zipfile_name, pyexec) if extra_files: for fil in extra_files: ...
python
def build_package(path, requires, virtualenv=None, ignore=None, extra_files=None, zipfile_name=ZIPFILE_NAME, pyexec=None): '''Builds the zip file and creates the package with it''' pkg = Package(path, zipfile_name, pyexec) if extra_files: for fil in extra_files: ...
[ "def", "build_package", "(", "path", ",", "requires", ",", "virtualenv", "=", "None", ",", "ignore", "=", "None", ",", "extra_files", "=", "None", ",", "zipfile_name", "=", "ZIPFILE_NAME", ",", "pyexec", "=", "None", ")", ":", "pkg", "=", "Package", "(",...
Builds the zip file and creates the package with it
[ "Builds", "the", "zip", "file", "and", "creates", "the", "package", "with", "it" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L39-L53
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.build
def build(self, ignore=None): '''Calls all necessary methods to build the Lambda Package''' self._prepare_workspace() self.install_dependencies() self.package(ignore)
python
def build(self, ignore=None): '''Calls all necessary methods to build the Lambda Package''' self._prepare_workspace() self.install_dependencies() self.package(ignore)
[ "def", "build", "(", "self", ",", "ignore", "=", "None", ")", ":", "self", ".", "_prepare_workspace", "(", ")", "self", ".", "install_dependencies", "(", ")", "self", ".", "package", "(", "ignore", ")" ]
Calls all necessary methods to build the Lambda Package
[ "Calls", "all", "necessary", "methods", "to", "build", "the", "Lambda", "Package" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L76-L80
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.clean_workspace
def clean_workspace(self): '''Clean up the temporary workspace if one exists''' if os.path.isdir(self._temp_workspace): shutil.rmtree(self._temp_workspace)
python
def clean_workspace(self): '''Clean up the temporary workspace if one exists''' if os.path.isdir(self._temp_workspace): shutil.rmtree(self._temp_workspace)
[ "def", "clean_workspace", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "_temp_workspace", ")", ":", "shutil", ".", "rmtree", "(", "self", ".", "_temp_workspace", ")" ]
Clean up the temporary workspace if one exists
[ "Clean", "up", "the", "temporary", "workspace", "if", "one", "exists" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L82-L85
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.clean_zipfile
def clean_zipfile(self): '''remove existing zipfile''' if os.path.isfile(self.zip_file): os.remove(self.zip_file)
python
def clean_zipfile(self): '''remove existing zipfile''' if os.path.isfile(self.zip_file): os.remove(self.zip_file)
[ "def", "clean_zipfile", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "zip_file", ")", ":", "os", ".", "remove", "(", "self", ".", "zip_file", ")" ]
remove existing zipfile
[ "remove", "existing", "zipfile" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L87-L90
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.requirements
def requirements(self, requires): ''' Sets the requirements for the package. It will take either a valid path to a requirements file or a list of requirements. ''' if requires: if isinstance(requires, basestring) and \ os.path.isfile(os.path.ab...
python
def requirements(self, requires): ''' Sets the requirements for the package. It will take either a valid path to a requirements file or a list of requirements. ''' if requires: if isinstance(requires, basestring) and \ os.path.isfile(os.path.ab...
[ "def", "requirements", "(", "self", ",", "requires", ")", ":", "if", "requires", ":", "if", "isinstance", "(", "requires", ",", "basestring", ")", "and", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "abspath", "(", "requires", ")", ...
Sets the requirements for the package. It will take either a valid path to a requirements file or a list of requirements.
[ "Sets", "the", "requirements", "for", "the", "package", "." ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L92-L112
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.virtualenv
def virtualenv(self, virtualenv): ''' Sets the virtual environment for the lambda package If this is not set then package_dependencies will create a new one. Takes a path to a virtualenv or a boolean if the virtualenv creation should be skipped. ''' # If a boole...
python
def virtualenv(self, virtualenv): ''' Sets the virtual environment for the lambda package If this is not set then package_dependencies will create a new one. Takes a path to a virtualenv or a boolean if the virtualenv creation should be skipped. ''' # If a boole...
[ "def", "virtualenv", "(", "self", ",", "virtualenv", ")", ":", "# If a boolean is passed then set the internal _skip_virtualenv flag", "if", "isinstance", "(", "virtualenv", ",", "bool", ")", ":", "self", ".", "_skip_virtualenv", "=", "virtualenv", "else", ":", "self"...
Sets the virtual environment for the lambda package If this is not set then package_dependencies will create a new one. Takes a path to a virtualenv or a boolean if the virtualenv creation should be skipped.
[ "Sets", "the", "virtual", "environment", "for", "the", "lambda", "package" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L114-L133
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.install_dependencies
def install_dependencies(self): ''' Creates a virtualenv and installs requirements ''' # If virtualenv is set to skip then do nothing if self._skip_virtualenv: LOG.info('Skip Virtualenv set ... nothing to do') return has_reqs = _isfile(self._requirements_file) or...
python
def install_dependencies(self): ''' Creates a virtualenv and installs requirements ''' # If virtualenv is set to skip then do nothing if self._skip_virtualenv: LOG.info('Skip Virtualenv set ... nothing to do') return has_reqs = _isfile(self._requirements_file) or...
[ "def", "install_dependencies", "(", "self", ")", ":", "# If virtualenv is set to skip then do nothing", "if", "self", ".", "_skip_virtualenv", ":", "LOG", ".", "info", "(", "'Skip Virtualenv set ... nothing to do'", ")", "return", "has_reqs", "=", "_isfile", "(", "self"...
Creates a virtualenv and installs requirements
[ "Creates", "a", "virtualenv", "and", "installs", "requirements" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L141-L157
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package._build_new_virtualenv
def _build_new_virtualenv(self): '''Build a new virtualenvironment if self._virtualenv is set to None''' if self._virtualenv is None: # virtualenv was "None" which means "do default" self._pkg_venv = os.path.join(self._temp_workspace, 'venv') self._venv_pip = 'bin/pip...
python
def _build_new_virtualenv(self): '''Build a new virtualenvironment if self._virtualenv is set to None''' if self._virtualenv is None: # virtualenv was "None" which means "do default" self._pkg_venv = os.path.join(self._temp_workspace, 'venv') self._venv_pip = 'bin/pip...
[ "def", "_build_new_virtualenv", "(", "self", ")", ":", "if", "self", ".", "_virtualenv", "is", "None", ":", "# virtualenv was \"None\" which means \"do default\"", "self", ".", "_pkg_venv", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_temp_workspace", ...
Build a new virtualenvironment if self._virtualenv is set to None
[ "Build", "a", "new", "virtualenvironment", "if", "self", ".", "_virtualenv", "is", "set", "to", "None" ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L168-L189
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package._install_requirements
def _install_requirements(self): ''' Create a new virtualenvironment and install requirements if there are any. ''' if not hasattr(self, '_pkg_venv'): err = 'Must call build_new_virtualenv before install_requirements' raise Exception(err) cmd = No...
python
def _install_requirements(self): ''' Create a new virtualenvironment and install requirements if there are any. ''' if not hasattr(self, '_pkg_venv'): err = 'Must call build_new_virtualenv before install_requirements' raise Exception(err) cmd = No...
[ "def", "_install_requirements", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_pkg_venv'", ")", ":", "err", "=", "'Must call build_new_virtualenv before install_requirements'", "raise", "Exception", "(", "err", ")", "cmd", "=", "None", "if", ...
Create a new virtualenvironment and install requirements if there are any.
[ "Create", "a", "new", "virtualenvironment", "and", "install", "requirements", "if", "there", "are", "any", "." ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L207-L237
train
rackerlabs/lambda-uploader
lambda_uploader/package.py
Package.package
def package(self, ignore=None): """ Create a zip file of the lambda script and its dependencies. :param list ignore: a list of regular expression strings to match paths of files in the source of the lambda script against and ignore those files when creating the zip file....
python
def package(self, ignore=None): """ Create a zip file of the lambda script and its dependencies. :param list ignore: a list of regular expression strings to match paths of files in the source of the lambda script against and ignore those files when creating the zip file....
[ "def", "package", "(", "self", ",", "ignore", "=", "None", ")", ":", "ignore", "=", "ignore", "or", "[", "]", "package", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_temp_workspace", ",", "'lambda_package'", ")", "# Copy site packages into pack...
Create a zip file of the lambda script and its dependencies. :param list ignore: a list of regular expression strings to match paths of files in the source of the lambda script against and ignore those files when creating the zip file. The paths to be matched are local to th...
[ "Create", "a", "zip", "file", "of", "the", "lambda", "script", "and", "its", "dependencies", "." ]
a5036e60d45d1a4fdc07df071f5b6e3b113388d4
https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L239-L294
train
Parallels/artifactory
artifactory.py
encode_properties
def encode_properties(parameters): """ Performs encoding of url parameters from dictionary to a string. It does not escape backslash because it is not needed. See: http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-SetItemProperties """ result = [] for para...
python
def encode_properties(parameters): """ Performs encoding of url parameters from dictionary to a string. It does not escape backslash because it is not needed. See: http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-SetItemProperties """ result = [] for para...
[ "def", "encode_properties", "(", "parameters", ")", ":", "result", "=", "[", "]", "for", "param", "in", "iter", "(", "sorted", "(", "parameters", ")", ")", ":", "if", "isinstance", "(", "parameters", "[", "param", "]", ",", "(", "list", ",", "tuple", ...
Performs encoding of url parameters from dictionary to a string. It does not escape backslash because it is not needed. See: http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-SetItemProperties
[ "Performs", "encoding", "of", "url", "parameters", "from", "dictionary", "to", "a", "string", ".", "It", "does", "not", "escape", "backslash", "because", "it", "is", "not", "needed", "." ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L271-L288
train
Parallels/artifactory
artifactory.py
_ArtifactoryFlavour.splitroot
def splitroot(self, part, sep=sep): """ Splits path string into drive, root and relative path Uses '/artifactory/' as a splitting point in URI. Everything before it, including '/artifactory/' itself is treated as drive. The next folder is treated as root, and everything else is ...
python
def splitroot(self, part, sep=sep): """ Splits path string into drive, root and relative path Uses '/artifactory/' as a splitting point in URI. Everything before it, including '/artifactory/' itself is treated as drive. The next folder is treated as root, and everything else is ...
[ "def", "splitroot", "(", "self", ",", "part", ",", "sep", "=", "sep", ")", ":", "drv", "=", "''", "root", "=", "''", "base", "=", "get_global_base_url", "(", "part", ")", "if", "base", "and", "without_http_prefix", "(", "part", ")", ".", "startswith", ...
Splits path string into drive, root and relative path Uses '/artifactory/' as a splitting point in URI. Everything before it, including '/artifactory/' itself is treated as drive. The next folder is treated as root, and everything else is taken for relative path.
[ "Splits", "path", "string", "into", "drive", "root", "and", "relative", "path" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L316-L355
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.rest_get
def rest_get(self, url, params=None, headers=None, auth=None, verify=True, cert=None): """ Perform a GET request to url with optional authentication """ res = requests.get(url, params=params, headers=headers, auth=auth, verify=verify, cert=cert) return ...
python
def rest_get(self, url, params=None, headers=None, auth=None, verify=True, cert=None): """ Perform a GET request to url with optional authentication """ res = requests.get(url, params=params, headers=headers, auth=auth, verify=verify, cert=cert) return ...
[ "def", "rest_get", "(", "self", ",", "url", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "auth", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ")", ":", "res", "=", "requests", ".", "get", "(", "url", ",", ...
Perform a GET request to url with optional authentication
[ "Perform", "a", "GET", "request", "to", "url", "with", "optional", "authentication" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L412-L418
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.rest_put
def rest_put(self, url, params=None, headers=None, auth=None, verify=True, cert=None): """ Perform a PUT request to url with optional authentication """ res = requests.put(url, params=params, headers=headers, auth=auth, verify=verify, cert=cert) return ...
python
def rest_put(self, url, params=None, headers=None, auth=None, verify=True, cert=None): """ Perform a PUT request to url with optional authentication """ res = requests.put(url, params=params, headers=headers, auth=auth, verify=verify, cert=cert) return ...
[ "def", "rest_put", "(", "self", ",", "url", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "auth", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ")", ":", "res", "=", "requests", ".", "put", "(", "url", ",", ...
Perform a PUT request to url with optional authentication
[ "Perform", "a", "PUT", "request", "to", "url", "with", "optional", "authentication" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L420-L426
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.rest_post
def rest_post(self, url, params=None, headers=None, auth=None, verify=True, cert=None): """ Perform a PUT request to url with optional authentication """ res = requests.post(url, params=params, headers=headers, auth=auth, verify=verify, cert=cert) retu...
python
def rest_post(self, url, params=None, headers=None, auth=None, verify=True, cert=None): """ Perform a PUT request to url with optional authentication """ res = requests.post(url, params=params, headers=headers, auth=auth, verify=verify, cert=cert) retu...
[ "def", "rest_post", "(", "self", ",", "url", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "auth", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ")", ":", "res", "=", "requests", ".", "post", "(", "url", ",", ...
Perform a PUT request to url with optional authentication
[ "Perform", "a", "PUT", "request", "to", "url", "with", "optional", "authentication" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L428-L434
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.rest_del
def rest_del(self, url, params=None, auth=None, verify=True, cert=None): """ Perform a DELETE request to url with optional authentication """ res = requests.delete(url, params=params, auth=auth, verify=verify, cert=cert) return res.text, res.status_code
python
def rest_del(self, url, params=None, auth=None, verify=True, cert=None): """ Perform a DELETE request to url with optional authentication """ res = requests.delete(url, params=params, auth=auth, verify=verify, cert=cert) return res.text, res.status_code
[ "def", "rest_del", "(", "self", ",", "url", ",", "params", "=", "None", ",", "auth", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ")", ":", "res", "=", "requests", ".", "delete", "(", "url", ",", "params", "=", "params", ","...
Perform a DELETE request to url with optional authentication
[ "Perform", "a", "DELETE", "request", "to", "url", "with", "optional", "authentication" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L436-L441
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.rest_get_stream
def rest_get_stream(self, url, auth=None, verify=True, cert=None): """ Perform a chunked GET request to url with optional authentication This is specifically to download files. """ res = requests.get(url, auth=auth, stream=True, verify=verify, cert=cert) return res.raw, r...
python
def rest_get_stream(self, url, auth=None, verify=True, cert=None): """ Perform a chunked GET request to url with optional authentication This is specifically to download files. """ res = requests.get(url, auth=auth, stream=True, verify=verify, cert=cert) return res.raw, r...
[ "def", "rest_get_stream", "(", "self", ",", "url", ",", "auth", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ")", ":", "res", "=", "requests", ".", "get", "(", "url", ",", "auth", "=", "auth", ",", "stream", "=", "True", ","...
Perform a chunked GET request to url with optional authentication This is specifically to download files.
[ "Perform", "a", "chunked", "GET", "request", "to", "url", "with", "optional", "authentication", "This", "is", "specifically", "to", "download", "files", "." ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L451-L457
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.get_stat_json
def get_stat_json(self, pathobj): """ Request remote file/directory status info Returns a json object as specified by Artifactory REST API """ url = '/'.join([pathobj.drive, 'api/storage', str(pathobj.relative_to(pathobj.drive)).str...
python
def get_stat_json(self, pathobj): """ Request remote file/directory status info Returns a json object as specified by Artifactory REST API """ url = '/'.join([pathobj.drive, 'api/storage', str(pathobj.relative_to(pathobj.drive)).str...
[ "def", "get_stat_json", "(", "self", ",", "pathobj", ")", ":", "url", "=", "'/'", ".", "join", "(", "[", "pathobj", ".", "drive", ",", "'api/storage'", ",", "str", "(", "pathobj", ".", "relative_to", "(", "pathobj", ".", "drive", ")", ")", ".", "stri...
Request remote file/directory status info Returns a json object as specified by Artifactory REST API
[ "Request", "remote", "file", "/", "directory", "status", "info", "Returns", "a", "json", "object", "as", "specified", "by", "Artifactory", "REST", "API" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L459-L475
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.open
def open(self, pathobj): """ Opens the remote file and returns a file-like object HTTPResponse Given the nature of HTTP streaming, this object doesn't support seek() """ url = str(pathobj) raw, code = self.rest_get_stream(url, auth=pathobj.auth, verify=pathobj.ver...
python
def open(self, pathobj): """ Opens the remote file and returns a file-like object HTTPResponse Given the nature of HTTP streaming, this object doesn't support seek() """ url = str(pathobj) raw, code = self.rest_get_stream(url, auth=pathobj.auth, verify=pathobj.ver...
[ "def", "open", "(", "self", ",", "pathobj", ")", ":", "url", "=", "str", "(", "pathobj", ")", "raw", ",", "code", "=", "self", ".", "rest_get_stream", "(", "url", ",", "auth", "=", "pathobj", ".", "auth", ",", "verify", "=", "pathobj", ".", "verify...
Opens the remote file and returns a file-like object HTTPResponse Given the nature of HTTP streaming, this object doesn't support seek()
[ "Opens", "the", "remote", "file", "and", "returns", "a", "file", "-", "like", "object", "HTTPResponse", "Given", "the", "nature", "of", "HTTP", "streaming", "this", "object", "doesn", "t", "support", "seek", "()" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L649-L662
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.deploy
def deploy(self, pathobj, fobj, md5=None, sha1=None, parameters=None): """ Uploads a given file-like object HTTP chunked encoding will be attempted """ if isinstance(fobj, urllib3.response.HTTPResponse): fobj = HTTPResponseWrapper(fobj) url = str(pathobj) ...
python
def deploy(self, pathobj, fobj, md5=None, sha1=None, parameters=None): """ Uploads a given file-like object HTTP chunked encoding will be attempted """ if isinstance(fobj, urllib3.response.HTTPResponse): fobj = HTTPResponseWrapper(fobj) url = str(pathobj) ...
[ "def", "deploy", "(", "self", ",", "pathobj", ",", "fobj", ",", "md5", "=", "None", ",", "sha1", "=", "None", ",", "parameters", "=", "None", ")", ":", "if", "isinstance", "(", "fobj", ",", "urllib3", ".", "response", ".", "HTTPResponse", ")", ":", ...
Uploads a given file-like object HTTP chunked encoding will be attempted
[ "Uploads", "a", "given", "file", "-", "like", "object", "HTTP", "chunked", "encoding", "will", "be", "attempted" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L664-L692
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.move
def move(self, src, dst): """ Move artifact from src to dst """ url = '/'.join([src.drive, 'api/move', str(src.relative_to(src.drive)).rstrip('/')]) params = {'to': str(dst.relative_to(dst.drive)).rstrip('/')} text, code =...
python
def move(self, src, dst): """ Move artifact from src to dst """ url = '/'.join([src.drive, 'api/move', str(src.relative_to(src.drive)).rstrip('/')]) params = {'to': str(dst.relative_to(dst.drive)).rstrip('/')} text, code =...
[ "def", "move", "(", "self", ",", "src", ",", "dst", ")", ":", "url", "=", "'/'", ".", "join", "(", "[", "src", ".", "drive", ",", "'api/move'", ",", "str", "(", "src", ".", "relative_to", "(", "src", ".", "drive", ")", ")", ".", "rstrip", "(", ...
Move artifact from src to dst
[ "Move", "artifact", "from", "src", "to", "dst" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L714-L731
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.set_properties
def set_properties(self, pathobj, props, recursive): """ Set artifact properties """ url = '/'.join([pathobj.drive, 'api/storage', str(pathobj.relative_to(pathobj.drive)).strip('/')]) params = {'properties': encode_properties(props...
python
def set_properties(self, pathobj, props, recursive): """ Set artifact properties """ url = '/'.join([pathobj.drive, 'api/storage', str(pathobj.relative_to(pathobj.drive)).strip('/')]) params = {'properties': encode_properties(props...
[ "def", "set_properties", "(", "self", ",", "pathobj", ",", "props", ",", "recursive", ")", ":", "url", "=", "'/'", ".", "join", "(", "[", "pathobj", ".", "drive", ",", "'api/storage'", ",", "str", "(", "pathobj", ".", "relative_to", "(", "pathobj", "."...
Set artifact properties
[ "Set", "artifact", "properties" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L758-L780
train
Parallels/artifactory
artifactory.py
_ArtifactoryAccessor.del_properties
def del_properties(self, pathobj, props, recursive): """ Delete artifact properties """ if isinstance(props, str): props = (props,) url = '/'.join([pathobj.drive, 'api/storage', str(pathobj.relative_to(pathobj.drive)).s...
python
def del_properties(self, pathobj, props, recursive): """ Delete artifact properties """ if isinstance(props, str): props = (props,) url = '/'.join([pathobj.drive, 'api/storage', str(pathobj.relative_to(pathobj.drive)).s...
[ "def", "del_properties", "(", "self", ",", "pathobj", ",", "props", ",", "recursive", ")", ":", "if", "isinstance", "(", "props", ",", "str", ")", ":", "props", "=", "(", "props", ",", ")", "url", "=", "'/'", ".", "join", "(", "[", "pathobj", ".", ...
Delete artifact properties
[ "Delete", "artifact", "properties" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L782-L807
train
Parallels/artifactory
artifactory.py
ArtifactoryPath.relative_to
def relative_to(self, *other): """ Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError. """ obj = super(ArtifactoryPath, self).relative_to(*other...
python
def relative_to(self, *other): """ Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError. """ obj = super(ArtifactoryPath, self).relative_to(*other...
[ "def", "relative_to", "(", "self", ",", "*", "other", ")", ":", "obj", "=", "super", "(", "ArtifactoryPath", ",", "self", ")", ".", "relative_to", "(", "*", "other", ")", "obj", ".", "auth", "=", "self", ".", "auth", "obj", ".", "verify", "=", "sel...
Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError.
[ "Return", "the", "relative", "path", "to", "another", "path", "identified", "by", "the", "passed", "arguments", ".", "If", "the", "operation", "is", "not", "possible", "(", "because", "this", "is", "not", "a", "subpath", "of", "the", "other", "path", ")", ...
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L923-L933
train
Parallels/artifactory
artifactory.py
ArtifactoryPath.set_properties
def set_properties(self, properties, recursive=True): """ Adds new or modifies existing properties listed in properties properties - is a dict which contains the property names and values to set. Property values can be a list or tuple to set multiple values ...
python
def set_properties(self, properties, recursive=True): """ Adds new or modifies existing properties listed in properties properties - is a dict which contains the property names and values to set. Property values can be a list or tuple to set multiple values ...
[ "def", "set_properties", "(", "self", ",", "properties", ",", "recursive", "=", "True", ")", ":", "if", "not", "properties", ":", "return", "return", "self", ".", "_accessor", ".", "set_properties", "(", "self", ",", "properties", ",", "recursive", ")" ]
Adds new or modifies existing properties listed in properties properties - is a dict which contains the property names and values to set. Property values can be a list or tuple to set multiple values for a key. recursive - on folders property attachment is rec...
[ "Adds", "new", "or", "modifies", "existing", "properties", "listed", "in", "properties" ]
09ddcc4ae15095eec2347d39774c3f8aca6c4654
https://github.com/Parallels/artifactory/blob/09ddcc4ae15095eec2347d39774c3f8aca6c4654/artifactory.py#L1234-L1247
train
bbitmaster/ale_python_interface
ale_python_interface/ale_python_interface.py
ALEInterface.getScreenDims
def getScreenDims(self): """returns a tuple that contains (screen_width,screen_height) """ width = ale_lib.getScreenWidth(self.obj) height = ale_lib.getScreenHeight(self.obj) return (width,height)
python
def getScreenDims(self): """returns a tuple that contains (screen_width,screen_height) """ width = ale_lib.getScreenWidth(self.obj) height = ale_lib.getScreenHeight(self.obj) return (width,height)
[ "def", "getScreenDims", "(", "self", ")", ":", "width", "=", "ale_lib", ".", "getScreenWidth", "(", "self", ".", "obj", ")", "height", "=", "ale_lib", ".", "getScreenHeight", "(", "self", ".", "obj", ")", "return", "(", "width", ",", "height", ")" ]
returns a tuple that contains (screen_width,screen_height)
[ "returns", "a", "tuple", "that", "contains", "(", "screen_width", "screen_height", ")" ]
253062be8e07fb738ea25982387b20af3712b615
https://github.com/bbitmaster/ale_python_interface/blob/253062be8e07fb738ea25982387b20af3712b615/ale_python_interface/ale_python_interface.py#L67-L72
train
bbitmaster/ale_python_interface
ale_python_interface/ale_python_interface.py
ALEInterface.getScreen
def getScreen(self,screen_data=None): """This function fills screen_data with the RAW Pixel data screen_data MUST be a numpy array of uint8/int8. This could be initialized like so: screen_data = np.array(w*h,dtype=np.uint8) Notice, it must be width*height in size also If it is No...
python
def getScreen(self,screen_data=None): """This function fills screen_data with the RAW Pixel data screen_data MUST be a numpy array of uint8/int8. This could be initialized like so: screen_data = np.array(w*h,dtype=np.uint8) Notice, it must be width*height in size also If it is No...
[ "def", "getScreen", "(", "self", ",", "screen_data", "=", "None", ")", ":", "if", "(", "screen_data", "is", "None", ")", ":", "width", "=", "ale_lib", ".", "getScreenWidth", "(", "self", ".", "obj", ")", "height", "=", "ale_lib", ".", "getScreenWidth", ...
This function fills screen_data with the RAW Pixel data screen_data MUST be a numpy array of uint8/int8. This could be initialized like so: screen_data = np.array(w*h,dtype=np.uint8) Notice, it must be width*height in size also If it is None, then this function will initialize it ...
[ "This", "function", "fills", "screen_data", "with", "the", "RAW", "Pixel", "data", "screen_data", "MUST", "be", "a", "numpy", "array", "of", "uint8", "/", "int8", ".", "This", "could", "be", "initialized", "like", "so", ":", "screen_data", "=", "np", ".", ...
253062be8e07fb738ea25982387b20af3712b615
https://github.com/bbitmaster/ale_python_interface/blob/253062be8e07fb738ea25982387b20af3712b615/ale_python_interface/ale_python_interface.py#L75-L88
train
bbitmaster/ale_python_interface
ale_python_interface/ale_python_interface.py
ALEInterface.getScreenRGB
def getScreenRGB(self,screen_data=None): """This function fills screen_data with the data screen_data MUST be a numpy array of uint32/int32. This can be initialized like so: screen_data = np.array(w*h,dtype=np.uint32) Notice, it must be width*height in size also If it is None, th...
python
def getScreenRGB(self,screen_data=None): """This function fills screen_data with the data screen_data MUST be a numpy array of uint32/int32. This can be initialized like so: screen_data = np.array(w*h,dtype=np.uint32) Notice, it must be width*height in size also If it is None, th...
[ "def", "getScreenRGB", "(", "self", ",", "screen_data", "=", "None", ")", ":", "if", "(", "screen_data", "is", "None", ")", ":", "width", "=", "ale_lib", ".", "getScreenWidth", "(", "self", ".", "obj", ")", "height", "=", "ale_lib", ".", "getScreenWidth"...
This function fills screen_data with the data screen_data MUST be a numpy array of uint32/int32. This can be initialized like so: screen_data = np.array(w*h,dtype=np.uint32) Notice, it must be width*height in size also If it is None, then this function will initialize it
[ "This", "function", "fills", "screen_data", "with", "the", "data", "screen_data", "MUST", "be", "a", "numpy", "array", "of", "uint32", "/", "int32", ".", "This", "can", "be", "initialized", "like", "so", ":", "screen_data", "=", "np", ".", "array", "(", ...
253062be8e07fb738ea25982387b20af3712b615
https://github.com/bbitmaster/ale_python_interface/blob/253062be8e07fb738ea25982387b20af3712b615/ale_python_interface/ale_python_interface.py#L90-L102
train
bbitmaster/ale_python_interface
ale_python_interface/ale_python_interface.py
ALEInterface.getRAM
def getRAM(self,ram=None): """This function grabs the atari RAM. ram MUST be a numpy array of uint8/int8. This can be initialized like so: ram = np.array(ram_size,dtype=uint8) Notice: It must be ram_size where ram_size can be retrieved via the getRAMSize function. If it is None, ...
python
def getRAM(self,ram=None): """This function grabs the atari RAM. ram MUST be a numpy array of uint8/int8. This can be initialized like so: ram = np.array(ram_size,dtype=uint8) Notice: It must be ram_size where ram_size can be retrieved via the getRAMSize function. If it is None, ...
[ "def", "getRAM", "(", "self", ",", "ram", "=", "None", ")", ":", "if", "(", "ram", "is", "None", ")", ":", "ram_size", "=", "ale_lib", ".", "getRAMSize", "(", "self", ".", "obj", ")", "ram", "=", "np", ".", "zeros", "(", "ram_size", ",", "dtype",...
This function grabs the atari RAM. ram MUST be a numpy array of uint8/int8. This can be initialized like so: ram = np.array(ram_size,dtype=uint8) Notice: It must be ram_size where ram_size can be retrieved via the getRAMSize function. If it is None, then this function will initialize it.
[ "This", "function", "grabs", "the", "atari", "RAM", ".", "ram", "MUST", "be", "a", "numpy", "array", "of", "uint8", "/", "int8", ".", "This", "can", "be", "initialized", "like", "so", ":", "ram", "=", "np", ".", "array", "(", "ram_size", "dtype", "="...
253062be8e07fb738ea25982387b20af3712b615
https://github.com/bbitmaster/ale_python_interface/blob/253062be8e07fb738ea25982387b20af3712b615/ale_python_interface/ale_python_interface.py#L107-L117
train
gpoulter/python-ngram
scripts/csvjoin.py
lowstrip
def lowstrip(term): """Convert to lowercase and strip spaces""" term = re.sub('\s+', ' ', term) term = term.lower() return term
python
def lowstrip(term): """Convert to lowercase and strip spaces""" term = re.sub('\s+', ' ', term) term = term.lower() return term
[ "def", "lowstrip", "(", "term", ")", ":", "term", "=", "re", ".", "sub", "(", "'\\s+'", ",", "' '", ",", "term", ")", "term", "=", "term", ".", "lower", "(", ")", "return", "term" ]
Convert to lowercase and strip spaces
[ "Convert", "to", "lowercase", "and", "strip", "spaces" ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/scripts/csvjoin.py#L16-L20
train
gpoulter/python-ngram
scripts/csvjoin.py
main
def main(left_path, left_column, right_path, right_column, outfile, titles, join, minscore, count, warp): """Perform the similarity join""" right_file = csv.reader(open(right_path, 'r')) if titles: right_header = next(right_file) index = NGram((tuple(r) for r in right_file), ...
python
def main(left_path, left_column, right_path, right_column, outfile, titles, join, minscore, count, warp): """Perform the similarity join""" right_file = csv.reader(open(right_path, 'r')) if titles: right_header = next(right_file) index = NGram((tuple(r) for r in right_file), ...
[ "def", "main", "(", "left_path", ",", "left_column", ",", "right_path", ",", "right_column", ",", "outfile", ",", "titles", ",", "join", ",", "minscore", ",", "count", ",", "warp", ")", ":", "right_file", "=", "csv", ".", "reader", "(", "open", "(", "r...
Perform the similarity join
[ "Perform", "the", "similarity", "join" ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/scripts/csvjoin.py#L22-L46
train
gpoulter/python-ngram
scripts/csvjoin.py
console_main
def console_main(): """Process command-line arguments.""" from argparse import ArgumentParser parser = ArgumentParser(description=__doc__) parser.add_argument('-t', '--titles', action='store_true', help='input files have column titles') parser.add_argument( '-j', '--j...
python
def console_main(): """Process command-line arguments.""" from argparse import ArgumentParser parser = ArgumentParser(description=__doc__) parser.add_argument('-t', '--titles', action='store_true', help='input files have column titles') parser.add_argument( '-j', '--j...
[ "def", "console_main", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", "parser", "=", "ArgumentParser", "(", "description", "=", "__doc__", ")", "parser", ".", "add_argument", "(", "'-t'", ",", "'--titles'", ",", "action", "=", "'store_true'", "...
Process command-line arguments.
[ "Process", "command", "-", "line", "arguments", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/scripts/csvjoin.py#L48-L84
train
gpoulter/python-ngram
ngram.py
NGram.copy
def copy(self, items=None): """Return a new NGram object with the same settings, and referencing the same items. Copy is shallow in that each item is not recursively copied. Optionally specify alternate items to populate the copy. >>> from ngram import NGram >>> from ...
python
def copy(self, items=None): """Return a new NGram object with the same settings, and referencing the same items. Copy is shallow in that each item is not recursively copied. Optionally specify alternate items to populate the copy. >>> from ngram import NGram >>> from ...
[ "def", "copy", "(", "self", ",", "items", "=", "None", ")", ":", "return", "NGram", "(", "items", "if", "items", "is", "not", "None", "else", "self", ",", "self", ".", "threshold", ",", "self", ".", "warp", ",", "self", ".", "_key", ",", "self", ...
Return a new NGram object with the same settings, and referencing the same items. Copy is shallow in that each item is not recursively copied. Optionally specify alternate items to populate the copy. >>> from ngram import NGram >>> from copy import deepcopy >>> n = NG...
[ "Return", "a", "new", "NGram", "object", "with", "the", "same", "settings", "and", "referencing", "the", "same", "items", ".", "Copy", "is", "shallow", "in", "that", "each", "item", "is", "not", "recursively", "copied", ".", "Optionally", "specify", "alterna...
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L127-L148
train
gpoulter/python-ngram
ngram.py
NGram._split
def _split(self, string): """Iterates over the ngrams of a string (no padding). >>> from ngram import NGram >>> n = NGram() >>> list(n._split("hamegg")) ['ham', 'ame', 'meg', 'egg'] """ for i in range(len(string) - self.N + 1): yield string[i:i + self...
python
def _split(self, string): """Iterates over the ngrams of a string (no padding). >>> from ngram import NGram >>> n = NGram() >>> list(n._split("hamegg")) ['ham', 'ame', 'meg', 'egg'] """ for i in range(len(string) - self.N + 1): yield string[i:i + self...
[ "def", "_split", "(", "self", ",", "string", ")", ":", "for", "i", "in", "range", "(", "len", "(", "string", ")", "-", "self", ".", "N", "+", "1", ")", ":", "yield", "string", "[", "i", ":", "i", "+", "self", ".", "N", "]" ]
Iterates over the ngrams of a string (no padding). >>> from ngram import NGram >>> n = NGram() >>> list(n._split("hamegg")) ['ham', 'ame', 'meg', 'egg']
[ "Iterates", "over", "the", "ngrams", "of", "a", "string", "(", "no", "padding", ")", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L170-L179
train
gpoulter/python-ngram
ngram.py
NGram.add
def add(self, item): """Add an item to the N-gram index (if it has not already been added). >>> from ngram import NGram >>> n = NGram() >>> n.add("ham") >>> list(n) ['ham'] >>> n.add("spam") >>> sorted(list(n)) ['ham', 'spam'] """ ...
python
def add(self, item): """Add an item to the N-gram index (if it has not already been added). >>> from ngram import NGram >>> n = NGram() >>> n.add("ham") >>> list(n) ['ham'] >>> n.add("spam") >>> sorted(list(n)) ['ham', 'spam'] """ ...
[ "def", "add", "(", "self", ",", "item", ")", ":", "if", "item", "not", "in", "self", ":", "# Add the item to the base set", "super", "(", "NGram", ",", "self", ")", ".", "add", "(", "item", ")", "# Record length of padded string", "padded_item", "=", "self",...
Add an item to the N-gram index (if it has not already been added). >>> from ngram import NGram >>> n = NGram() >>> n.add("ham") >>> list(n) ['ham'] >>> n.add("spam") >>> sorted(list(n)) ['ham', 'spam']
[ "Add", "an", "item", "to", "the", "N", "-", "gram", "index", "(", "if", "it", "has", "not", "already", "been", "added", ")", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L212-L234
train
gpoulter/python-ngram
ngram.py
NGram.items_sharing_ngrams
def items_sharing_ngrams(self, query): """Retrieve the subset of items that share n-grams the query string. :param query: look up items that share N-grams with this string. :return: mapping from matched string to the number of shared N-grams. >>> from ngram import NGram >>> n =...
python
def items_sharing_ngrams(self, query): """Retrieve the subset of items that share n-grams the query string. :param query: look up items that share N-grams with this string. :return: mapping from matched string to the number of shared N-grams. >>> from ngram import NGram >>> n =...
[ "def", "items_sharing_ngrams", "(", "self", ",", "query", ")", ":", "# From matched string to number of N-grams shared with query string", "shared", "=", "{", "}", "# Dictionary mapping n-gram to string to number of occurrences of that", "# ngram in the string that remain to be matched."...
Retrieve the subset of items that share n-grams the query string. :param query: look up items that share N-grams with this string. :return: mapping from matched string to the number of shared N-grams. >>> from ngram import NGram >>> n = NGram(["ham","spam","eggs"]) >>> sorted(n...
[ "Retrieve", "the", "subset", "of", "items", "that", "share", "n", "-", "grams", "the", "query", "string", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L267-L294
train
gpoulter/python-ngram
ngram.py
NGram.searchitem
def searchitem(self, item, threshold=None): """Search the index for items whose key exceeds the threshold similarity to the key of the given item. :return: list of pairs of (item, similarity) by decreasing similarity. >>> from ngram import NGram >>> n = NGram([(0, "SPAM"), (1, ...
python
def searchitem(self, item, threshold=None): """Search the index for items whose key exceeds the threshold similarity to the key of the given item. :return: list of pairs of (item, similarity) by decreasing similarity. >>> from ngram import NGram >>> n = NGram([(0, "SPAM"), (1, ...
[ "def", "searchitem", "(", "self", ",", "item", ",", "threshold", "=", "None", ")", ":", "return", "self", ".", "search", "(", "self", ".", "key", "(", "item", ")", ",", "threshold", ")" ]
Search the index for items whose key exceeds the threshold similarity to the key of the given item. :return: list of pairs of (item, similarity) by decreasing similarity. >>> from ngram import NGram >>> n = NGram([(0, "SPAM"), (1, "SPAN"), (2, "EG"), ... (3, "SPANN")], key=lamb...
[ "Search", "the", "index", "for", "items", "whose", "key", "exceeds", "the", "threshold", "similarity", "to", "the", "key", "of", "the", "given", "item", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L296-L308
train
gpoulter/python-ngram
ngram.py
NGram.search
def search(self, query, threshold=None): """Search the index for items whose key exceeds threshold similarity to the query string. :param query: returned items will have at least `threshold` \ similarity to the query string. :return: list of pairs of (item, similarity) by decre...
python
def search(self, query, threshold=None): """Search the index for items whose key exceeds threshold similarity to the query string. :param query: returned items will have at least `threshold` \ similarity to the query string. :return: list of pairs of (item, similarity) by decre...
[ "def", "search", "(", "self", ",", "query", ",", "threshold", "=", "None", ")", ":", "threshold", "=", "threshold", "if", "threshold", "is", "not", "None", "else", "self", ".", "threshold", "results", "=", "[", "]", "# Identify possible results", "for", "m...
Search the index for items whose key exceeds threshold similarity to the query string. :param query: returned items will have at least `threshold` \ similarity to the query string. :return: list of pairs of (item, similarity) by decreasing similarity. >>> from ngram import NGr...
[ "Search", "the", "index", "for", "items", "whose", "key", "exceeds", "threshold", "similarity", "to", "the", "query", "string", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L310-L339
train
gpoulter/python-ngram
ngram.py
NGram.finditem
def finditem(self, item, threshold=None): """Return most similar item to the provided one, or None if nothing exceeds the threshold. >>> from ngram import NGram >>> n = NGram([(0, "Spam"), (1, "Ham"), (2, "Eggsy"), (3, "Egggsy")], ... key=lambda x:x[1].lower()) >>> n...
python
def finditem(self, item, threshold=None): """Return most similar item to the provided one, or None if nothing exceeds the threshold. >>> from ngram import NGram >>> n = NGram([(0, "Spam"), (1, "Ham"), (2, "Eggsy"), (3, "Egggsy")], ... key=lambda x:x[1].lower()) >>> n...
[ "def", "finditem", "(", "self", ",", "item", ",", "threshold", "=", "None", ")", ":", "results", "=", "self", ".", "searchitem", "(", "item", ",", "threshold", ")", "if", "results", ":", "return", "results", "[", "0", "]", "[", "0", "]", "else", ":...
Return most similar item to the provided one, or None if nothing exceeds the threshold. >>> from ngram import NGram >>> n = NGram([(0, "Spam"), (1, "Ham"), (2, "Eggsy"), (3, "Egggsy")], ... key=lambda x:x[1].lower()) >>> n.finditem((3, 'Hom')) (1, 'Ham') >>> ...
[ "Return", "most", "similar", "item", "to", "the", "provided", "one", "or", "None", "if", "nothing", "exceeds", "the", "threshold", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L341-L358
train
gpoulter/python-ngram
ngram.py
NGram.find
def find(self, query, threshold=None): """Simply return the best match to the query, None on no match. >>> from ngram import NGram >>> n = NGram(["Spam","Eggs","Ham"], key=lambda x:x.lower(), N=1) >>> n.find('Hom') 'Ham' >>> n.find("Spom") 'Spam' >>> n.fi...
python
def find(self, query, threshold=None): """Simply return the best match to the query, None on no match. >>> from ngram import NGram >>> n = NGram(["Spam","Eggs","Ham"], key=lambda x:x.lower(), N=1) >>> n.find('Hom') 'Ham' >>> n.find("Spom") 'Spam' >>> n.fi...
[ "def", "find", "(", "self", ",", "query", ",", "threshold", "=", "None", ")", ":", "results", "=", "self", ".", "search", "(", "query", ",", "threshold", ")", "if", "results", ":", "return", "results", "[", "0", "]", "[", "0", "]", "else", ":", "...
Simply return the best match to the query, None on no match. >>> from ngram import NGram >>> n = NGram(["Spam","Eggs","Ham"], key=lambda x:x.lower(), N=1) >>> n.find('Hom') 'Ham' >>> n.find("Spom") 'Spam' >>> n.find("Spom", 0.8)
[ "Simply", "return", "the", "best", "match", "to", "the", "query", "None", "on", "no", "match", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L360-L375
train
gpoulter/python-ngram
ngram.py
NGram.ngram_similarity
def ngram_similarity(samegrams, allgrams, warp=1.0): """Similarity for two sets of n-grams. :note: ``similarity = (a**e - d**e)/a**e`` where `a` is \ "all n-grams", `d` is "different n-grams" and `e` is the warp. :param samegrams: number of n-grams shared by the two strings. :...
python
def ngram_similarity(samegrams, allgrams, warp=1.0): """Similarity for two sets of n-grams. :note: ``similarity = (a**e - d**e)/a**e`` where `a` is \ "all n-grams", `d` is "different n-grams" and `e` is the warp. :param samegrams: number of n-grams shared by the two strings. :...
[ "def", "ngram_similarity", "(", "samegrams", ",", "allgrams", ",", "warp", "=", "1.0", ")", ":", "if", "abs", "(", "warp", "-", "1.0", ")", "<", "1e-9", ":", "similarity", "=", "float", "(", "samegrams", ")", "/", "allgrams", "else", ":", "diffgrams", ...
Similarity for two sets of n-grams. :note: ``similarity = (a**e - d**e)/a**e`` where `a` is \ "all n-grams", `d` is "different n-grams" and `e` is the warp. :param samegrams: number of n-grams shared by the two strings. :param allgrams: total of the distinct n-grams across the two str...
[ "Similarity", "for", "two", "sets", "of", "n", "-", "grams", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L378-L407
train
gpoulter/python-ngram
ngram.py
NGram.compare
def compare(s1, s2, **kwargs): """Compares two strings and returns their similarity. :param s1: first string :param s2: second string :param kwargs: additional keyword arguments passed to __init__. :return: similarity between 0.0 and 1.0. >>> from ngram import NGram ...
python
def compare(s1, s2, **kwargs): """Compares two strings and returns their similarity. :param s1: first string :param s2: second string :param kwargs: additional keyword arguments passed to __init__. :return: similarity between 0.0 and 1.0. >>> from ngram import NGram ...
[ "def", "compare", "(", "s1", ",", "s2", ",", "*", "*", "kwargs", ")", ":", "if", "s1", "is", "None", "or", "s2", "is", "None", ":", "if", "s1", "==", "s2", ":", "return", "1.0", "return", "0.0", "try", ":", "return", "NGram", "(", "[", "s1", ...
Compares two strings and returns their similarity. :param s1: first string :param s2: second string :param kwargs: additional keyword arguments passed to __init__. :return: similarity between 0.0 and 1.0. >>> from ngram import NGram >>> NGram.compare('spa', 'spam') ...
[ "Compares", "two", "strings", "and", "returns", "their", "similarity", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L410-L435
train
gpoulter/python-ngram
ngram.py
NGram.clear
def clear(self): """Remove all elements from this set. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> sorted(list(n)) ['eggs', 'spam'] >>> n.clear() >>> list(n) [] """ super(NGram, self).clear() self._grams = {} ...
python
def clear(self): """Remove all elements from this set. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> sorted(list(n)) ['eggs', 'spam'] >>> n.clear() >>> list(n) [] """ super(NGram, self).clear() self._grams = {} ...
[ "def", "clear", "(", "self", ")", ":", "super", "(", "NGram", ",", "self", ")", ".", "clear", "(", ")", "self", ".", "_grams", "=", "{", "}", "self", ".", "length", "=", "{", "}" ]
Remove all elements from this set. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> sorted(list(n)) ['eggs', 'spam'] >>> n.clear() >>> list(n) []
[ "Remove", "all", "elements", "from", "this", "set", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L466-L479
train
gpoulter/python-ngram
ngram.py
NGram.union
def union(self, *others): """Return the union of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> sorted(list(a.union(b))) ['eggs', 'ham', 'spam'] """ return self.copy(super(NGra...
python
def union(self, *others): """Return the union of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> sorted(list(a.union(b))) ['eggs', 'ham', 'spam'] """ return self.copy(super(NGra...
[ "def", "union", "(", "self", ",", "*", "others", ")", ":", "return", "self", ".", "copy", "(", "super", "(", "NGram", ",", "self", ")", ".", "union", "(", "*", "others", ")", ")" ]
Return the union of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> sorted(list(a.union(b))) ['eggs', 'ham', 'spam']
[ "Return", "the", "union", "of", "two", "or", "more", "sets", "as", "a", "new", "set", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L481-L490
train
gpoulter/python-ngram
ngram.py
NGram.difference
def difference(self, *others): """Return the difference of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> list(a.difference(b)) ['eggs'] """ return self.copy(super(NGram, self)...
python
def difference(self, *others): """Return the difference of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> list(a.difference(b)) ['eggs'] """ return self.copy(super(NGram, self)...
[ "def", "difference", "(", "self", ",", "*", "others", ")", ":", "return", "self", ".", "copy", "(", "super", "(", "NGram", ",", "self", ")", ".", "difference", "(", "*", "others", ")", ")" ]
Return the difference of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> list(a.difference(b)) ['eggs']
[ "Return", "the", "difference", "of", "two", "or", "more", "sets", "as", "a", "new", "set", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L492-L501
train
gpoulter/python-ngram
ngram.py
NGram.intersection
def intersection(self, *others): """Return the intersection of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> list(a.intersection(b)) ['spam'] """ return self.copy(super(NGram,...
python
def intersection(self, *others): """Return the intersection of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> list(a.intersection(b)) ['spam'] """ return self.copy(super(NGram,...
[ "def", "intersection", "(", "self", ",", "*", "others", ")", ":", "return", "self", ".", "copy", "(", "super", "(", "NGram", ",", "self", ")", ".", "intersection", "(", "*", "others", ")", ")" ]
Return the intersection of two or more sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> list(a.intersection(b)) ['spam']
[ "Return", "the", "intersection", "of", "two", "or", "more", "sets", "as", "a", "new", "set", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L516-L525
train
gpoulter/python-ngram
ngram.py
NGram.intersection_update
def intersection_update(self, *others): """Update the set with the intersection of itself and other sets. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> other = set(['spam', 'ham']) >>> n.intersection_update(other) >>> list(n) ['spam'] ""...
python
def intersection_update(self, *others): """Update the set with the intersection of itself and other sets. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> other = set(['spam', 'ham']) >>> n.intersection_update(other) >>> list(n) ['spam'] ""...
[ "def", "intersection_update", "(", "self", ",", "*", "others", ")", ":", "self", ".", "difference_update", "(", "super", "(", "NGram", ",", "self", ")", ".", "difference", "(", "*", "others", ")", ")" ]
Update the set with the intersection of itself and other sets. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> other = set(['spam', 'ham']) >>> n.intersection_update(other) >>> list(n) ['spam']
[ "Update", "the", "set", "with", "the", "intersection", "of", "itself", "and", "other", "sets", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L527-L537
train
gpoulter/python-ngram
ngram.py
NGram.symmetric_difference
def symmetric_difference(self, other): """Return the symmetric difference of two sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> sorted(list(a.symmetric_difference(b))) ['eggs', 'ham'] """ ...
python
def symmetric_difference(self, other): """Return the symmetric difference of two sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> sorted(list(a.symmetric_difference(b))) ['eggs', 'ham'] """ ...
[ "def", "symmetric_difference", "(", "self", ",", "other", ")", ":", "return", "self", ".", "copy", "(", "super", "(", "NGram", ",", "self", ")", ".", "symmetric_difference", "(", "other", ")", ")" ]
Return the symmetric difference of two sets as a new set. >>> from ngram import NGram >>> a = NGram(['spam', 'eggs']) >>> b = NGram(['spam', 'ham']) >>> sorted(list(a.symmetric_difference(b))) ['eggs', 'ham']
[ "Return", "the", "symmetric", "difference", "of", "two", "sets", "as", "a", "new", "set", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L539-L548
train
gpoulter/python-ngram
ngram.py
NGram.symmetric_difference_update
def symmetric_difference_update(self, other): """Update the set with the symmetric difference of itself and `other`. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> other = set(['spam', 'ham']) >>> n.symmetric_difference_update(other) >>> sorted(list(n)) ...
python
def symmetric_difference_update(self, other): """Update the set with the symmetric difference of itself and `other`. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> other = set(['spam', 'ham']) >>> n.symmetric_difference_update(other) >>> sorted(list(n)) ...
[ "def", "symmetric_difference_update", "(", "self", ",", "other", ")", ":", "intersection", "=", "super", "(", "NGram", ",", "self", ")", ".", "intersection", "(", "other", ")", "self", ".", "update", "(", "other", ")", "# add items present in other", "self", ...
Update the set with the symmetric difference of itself and `other`. >>> from ngram import NGram >>> n = NGram(['spam', 'eggs']) >>> other = set(['spam', 'ham']) >>> n.symmetric_difference_update(other) >>> sorted(list(n)) ['eggs', 'ham']
[ "Update", "the", "set", "with", "the", "symmetric", "difference", "of", "itself", "and", "other", "." ]
f8543bdc84a4d24ac60a48b36c4034f881664491
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L550-L562
train
dbrgn/django-mathfilters
mathfilters/templatetags/mathfilters.py
sub
def sub(value, arg): """Subtract the arg from the value.""" try: nvalue, narg = handle_float_decimal_combinations( valid_numeric(value), valid_numeric(arg), '-') return nvalue - narg except (ValueError, TypeError): try: return value - arg except Except...
python
def sub(value, arg): """Subtract the arg from the value.""" try: nvalue, narg = handle_float_decimal_combinations( valid_numeric(value), valid_numeric(arg), '-') return nvalue - narg except (ValueError, TypeError): try: return value - arg except Except...
[ "def", "sub", "(", "value", ",", "arg", ")", ":", "try", ":", "nvalue", ",", "narg", "=", "handle_float_decimal_combinations", "(", "valid_numeric", "(", "value", ")", ",", "valid_numeric", "(", "arg", ")", ",", "'-'", ")", "return", "nvalue", "-", "narg...
Subtract the arg from the value.
[ "Subtract", "the", "arg", "from", "the", "value", "." ]
7f22f98e906d46bee487ce2d78fb995f74c1d568
https://github.com/dbrgn/django-mathfilters/blob/7f22f98e906d46bee487ce2d78fb995f74c1d568/mathfilters/templatetags/mathfilters.py#L37-L47
train
dbrgn/django-mathfilters
mathfilters/templatetags/mathfilters.py
absolute
def absolute(value): """Return the absolute value.""" try: return abs(valid_numeric(value)) except (ValueError, TypeError): try: return abs(value) except Exception: return ''
python
def absolute(value): """Return the absolute value.""" try: return abs(valid_numeric(value)) except (ValueError, TypeError): try: return abs(value) except Exception: return ''
[ "def", "absolute", "(", "value", ")", ":", "try", ":", "return", "abs", "(", "valid_numeric", "(", "value", ")", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "try", ":", "return", "abs", "(", "value", ")", "except", "Exception", ":", ...
Return the absolute value.
[ "Return", "the", "absolute", "value", "." ]
7f22f98e906d46bee487ce2d78fb995f74c1d568
https://github.com/dbrgn/django-mathfilters/blob/7f22f98e906d46bee487ce2d78fb995f74c1d568/mathfilters/templatetags/mathfilters.py#L97-L105
train
Scifabric/pbs
pbs.py
cli
def cli(config, server, api_key, all, credentials, project): """Create the cli command line.""" # Check first for the pybossa.rc file to configure server and api-key home = expanduser("~") if os.path.isfile(os.path.join(home, '.pybossa.cfg')): config.parser.read(os.path.join(home, '.pybossa.cfg'...
python
def cli(config, server, api_key, all, credentials, project): """Create the cli command line.""" # Check first for the pybossa.rc file to configure server and api-key home = expanduser("~") if os.path.isfile(os.path.join(home, '.pybossa.cfg')): config.parser.read(os.path.join(home, '.pybossa.cfg'...
[ "def", "cli", "(", "config", ",", "server", ",", "api_key", ",", "all", ",", "credentials", ",", "project", ")", ":", "# Check first for the pybossa.rc file to configure server and api-key", "home", "=", "expanduser", "(", "\"~\"", ")", "if", "os", ".", "path", ...
Create the cli command line.
[ "Create", "the", "cli", "command", "line", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L65-L109
train
Scifabric/pbs
pbs.py
version
def version(): """Show pbs version.""" try: import pkg_resources click.echo(pkg_resources.get_distribution('pybossa-pbs').version) except ImportError: click.echo("pybossa-pbs package not found!")
python
def version(): """Show pbs version.""" try: import pkg_resources click.echo(pkg_resources.get_distribution('pybossa-pbs').version) except ImportError: click.echo("pybossa-pbs package not found!")
[ "def", "version", "(", ")", ":", "try", ":", "import", "pkg_resources", "click", ".", "echo", "(", "pkg_resources", ".", "get_distribution", "(", "'pybossa-pbs'", ")", ".", "version", ")", "except", "ImportError", ":", "click", ".", "echo", "(", "\"pybossa-p...
Show pbs version.
[ "Show", "pbs", "version", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L113-L119
train
Scifabric/pbs
pbs.py
update_project
def update_project(config, task_presenter, results, long_description, tutorial, watch): # pragma: no cover """Update project templates and information.""" if watch: res = _update_project_watch(config, task_presenter, results, long_description, tutor...
python
def update_project(config, task_presenter, results, long_description, tutorial, watch): # pragma: no cover """Update project templates and information.""" if watch: res = _update_project_watch(config, task_presenter, results, long_description, tutor...
[ "def", "update_project", "(", "config", ",", "task_presenter", ",", "results", ",", "long_description", ",", "tutorial", ",", "watch", ")", ":", "# pragma: no cover", "if", "watch", ":", "res", "=", "_update_project_watch", "(", "config", ",", "task_presenter", ...
Update project templates and information.
[ "Update", "project", "templates", "and", "information", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L141-L150
train
Scifabric/pbs
pbs.py
add_tasks
def add_tasks(config, tasks_file, tasks_type, priority, redundancy): """Add tasks to a project.""" res = _add_tasks(config, tasks_file, tasks_type, priority, redundancy) click.echo(res)
python
def add_tasks(config, tasks_file, tasks_type, priority, redundancy): """Add tasks to a project.""" res = _add_tasks(config, tasks_file, tasks_type, priority, redundancy) click.echo(res)
[ "def", "add_tasks", "(", "config", ",", "tasks_file", ",", "tasks_type", ",", "priority", ",", "redundancy", ")", ":", "res", "=", "_add_tasks", "(", "config", ",", "tasks_file", ",", "tasks_type", ",", "priority", ",", "redundancy", ")", "click", ".", "ec...
Add tasks to a project.
[ "Add", "tasks", "to", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L162-L165
train
Scifabric/pbs
pbs.py
add_helpingmaterials
def add_helpingmaterials(config, helping_materials_file, helping_type): """Add helping materials to a project.""" res = _add_helpingmaterials(config, helping_materials_file, helping_type) click.echo(res)
python
def add_helpingmaterials(config, helping_materials_file, helping_type): """Add helping materials to a project.""" res = _add_helpingmaterials(config, helping_materials_file, helping_type) click.echo(res)
[ "def", "add_helpingmaterials", "(", "config", ",", "helping_materials_file", ",", "helping_type", ")", ":", "res", "=", "_add_helpingmaterials", "(", "config", ",", "helping_materials_file", ",", "helping_type", ")", "click", ".", "echo", "(", "res", ")" ]
Add helping materials to a project.
[ "Add", "helping", "materials", "to", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L175-L178
train
Scifabric/pbs
pbs.py
delete_tasks
def delete_tasks(config, task_id): """Delete tasks from a project.""" if task_id is None: msg = ("Are you sure you want to delete all the tasks and associated task runs?") if click.confirm(msg): res = _delete_tasks(config, task_id) click.echo(res) else: ...
python
def delete_tasks(config, task_id): """Delete tasks from a project.""" if task_id is None: msg = ("Are you sure you want to delete all the tasks and associated task runs?") if click.confirm(msg): res = _delete_tasks(config, task_id) click.echo(res) else: ...
[ "def", "delete_tasks", "(", "config", ",", "task_id", ")", ":", "if", "task_id", "is", "None", ":", "msg", "=", "(", "\"Are you sure you want to delete all the tasks and associated task runs?\"", ")", "if", "click", ".", "confirm", "(", "msg", ")", ":", "res", "...
Delete tasks from a project.
[ "Delete", "tasks", "from", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L184-L196
train
Scifabric/pbs
pbs.py
update_task_redundancy
def update_task_redundancy(config, task_id, redundancy): """Update task redudancy for a project.""" if task_id is None: msg = ("Are you sure you want to update all the tasks redundancy?") if click.confirm(msg): res = _update_tasks_redundancy(config, task_id, redundancy) c...
python
def update_task_redundancy(config, task_id, redundancy): """Update task redudancy for a project.""" if task_id is None: msg = ("Are you sure you want to update all the tasks redundancy?") if click.confirm(msg): res = _update_tasks_redundancy(config, task_id, redundancy) c...
[ "def", "update_task_redundancy", "(", "config", ",", "task_id", ",", "redundancy", ")", ":", "if", "task_id", "is", "None", ":", "msg", "=", "(", "\"Are you sure you want to update all the tasks redundancy?\"", ")", "if", "click", ".", "confirm", "(", "msg", ")", ...
Update task redudancy for a project.
[ "Update", "task", "redudancy", "for", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/pbs.py#L202-L214
train
Scifabric/pbs
helpers.py
_create_project
def _create_project(config): """Create a project in a PyBossa server.""" try: response = config.pbclient.create_project(config.project['name'], config.project['short_name'], config.project['description'])...
python
def _create_project(config): """Create a project in a PyBossa server.""" try: response = config.pbclient.create_project(config.project['name'], config.project['short_name'], config.project['description'])...
[ "def", "_create_project", "(", "config", ")", ":", "try", ":", "response", "=", "config", ".", "pbclient", ".", "create_project", "(", "config", ".", "project", "[", "'name'", "]", ",", "config", ".", "project", "[", "'short_name'", "]", ",", "config", "...
Create a project in a PyBossa server.
[ "Create", "a", "project", "in", "a", "PyBossa", "server", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L57-L68
train
Scifabric/pbs
helpers.py
_update_project_watch
def _update_project_watch(config, task_presenter, results, long_description, tutorial): # pragma: no cover """Update a project in a loop.""" logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H...
python
def _update_project_watch(config, task_presenter, results, long_description, tutorial): # pragma: no cover """Update a project in a loop.""" logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H...
[ "def", "_update_project_watch", "(", "config", ",", "task_presenter", ",", "results", ",", "long_description", ",", "tutorial", ")", ":", "# pragma: no cover", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", "format", "=", "'%(asct...
Update a project in a loop.
[ "Update", "a", "project", "in", "a", "loop", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L70-L88
train
Scifabric/pbs
helpers.py
_update_task_presenter_bundle_js
def _update_task_presenter_bundle_js(project): """Append to template a distribution bundle js.""" if os.path.isfile ('bundle.min.js'): with open('bundle.min.js') as f: js = f.read() project.info['task_presenter'] += "<script>\n%s\n</script>" % js return if os.path.isfile...
python
def _update_task_presenter_bundle_js(project): """Append to template a distribution bundle js.""" if os.path.isfile ('bundle.min.js'): with open('bundle.min.js') as f: js = f.read() project.info['task_presenter'] += "<script>\n%s\n</script>" % js return if os.path.isfile...
[ "def", "_update_task_presenter_bundle_js", "(", "project", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "'bundle.min.js'", ")", ":", "with", "open", "(", "'bundle.min.js'", ")", "as", "f", ":", "js", "=", "f", ".", "read", "(", ")", "project", ...
Append to template a distribution bundle js.
[ "Append", "to", "template", "a", "distribution", "bundle", "js", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L90-L101
train
Scifabric/pbs
helpers.py
_update_project
def _update_project(config, task_presenter, results, long_description, tutorial): """Update a project.""" try: # Get project project = find_project_by_short_name(config.project['short_name'], config.pbclient, ...
python
def _update_project(config, task_presenter, results, long_description, tutorial): """Update a project.""" try: # Get project project = find_project_by_short_name(config.project['short_name'], config.pbclient, ...
[ "def", "_update_project", "(", "config", ",", "task_presenter", ",", "results", ",", "long_description", ",", "tutorial", ")", ":", "try", ":", "# Get project", "project", "=", "find_project_by_short_name", "(", "config", ".", "project", "[", "'short_name'", "]", ...
Update a project.
[ "Update", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L103-L138
train
Scifabric/pbs
helpers.py
_load_data
def _load_data(data_file, data_type): """Load data from CSV, JSON, Excel, ..., formats.""" raw_data = data_file.read() if data_type is None: data_type = data_file.name.split('.')[-1] # Data list to process data = [] # JSON type if data_type == 'json': data = json.loads(raw_da...
python
def _load_data(data_file, data_type): """Load data from CSV, JSON, Excel, ..., formats.""" raw_data = data_file.read() if data_type is None: data_type = data_file.name.split('.')[-1] # Data list to process data = [] # JSON type if data_type == 'json': data = json.loads(raw_da...
[ "def", "_load_data", "(", "data_file", ",", "data_type", ")", ":", "raw_data", "=", "data_file", ".", "read", "(", ")", "if", "data_type", "is", "None", ":", "data_type", "=", "data_file", ".", "name", ".", "split", "(", "'.'", ")", "[", "-", "1", "]...
Load data from CSV, JSON, Excel, ..., formats.
[ "Load", "data", "from", "CSV", "JSON", "Excel", "...", "formats", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L141-L194
train
Scifabric/pbs
helpers.py
_add_tasks
def _add_tasks(config, tasks_file, tasks_type, priority, redundancy): """Add tasks to a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, config.all) data ...
python
def _add_tasks(config, tasks_file, tasks_type, priority, redundancy): """Add tasks to a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, config.all) data ...
[ "def", "_add_tasks", "(", "config", ",", "tasks_file", ",", "tasks_type", ",", "priority", ",", "redundancy", ")", ":", "try", ":", "project", "=", "find_project_by_short_name", "(", "config", ".", "project", "[", "'short_name'", "]", ",", "config", ".", "pb...
Add tasks to a project.
[ "Add", "tasks", "to", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L197-L230
train
Scifabric/pbs
helpers.py
_add_helpingmaterials
def _add_helpingmaterials(config, helping_file, helping_type): """Add helping materials to a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, config.all) ...
python
def _add_helpingmaterials(config, helping_file, helping_type): """Add helping materials to a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, config.all) ...
[ "def", "_add_helpingmaterials", "(", "config", ",", "helping_file", ",", "helping_type", ")", ":", "try", ":", "project", "=", "find_project_by_short_name", "(", "config", ".", "project", "[", "'short_name'", "]", ",", "config", ".", "pbclient", ",", "config", ...
Add helping materials to a project.
[ "Add", "helping", "materials", "to", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L233-L277
train
Scifabric/pbs
helpers.py
_delete_tasks
def _delete_tasks(config, task_id, limit=100, offset=0): """Delete tasks from a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, config.all) if task_id: ...
python
def _delete_tasks(config, task_id, limit=100, offset=0): """Delete tasks from a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, config.all) if task_id: ...
[ "def", "_delete_tasks", "(", "config", ",", "task_id", ",", "limit", "=", "100", ",", "offset", "=", "0", ")", ":", "try", ":", "project", "=", "find_project_by_short_name", "(", "config", ".", "project", "[", "'short_name'", "]", ",", "config", ".", "pb...
Delete tasks from a project.
[ "Delete", "tasks", "from", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L281-L305
train
Scifabric/pbs
helpers.py
_update_tasks_redundancy
def _update_tasks_redundancy(config, task_id, redundancy, limit=300, offset=0): """Update tasks redundancy from a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, ...
python
def _update_tasks_redundancy(config, task_id, redundancy, limit=300, offset=0): """Update tasks redundancy from a project.""" try: project = find_project_by_short_name(config.project['short_name'], config.pbclient, ...
[ "def", "_update_tasks_redundancy", "(", "config", ",", "task_id", ",", "redundancy", ",", "limit", "=", "300", ",", "offset", "=", "0", ")", ":", "try", ":", "project", "=", "find_project_by_short_name", "(", "config", ".", "project", "[", "'short_name'", "]...
Update tasks redundancy from a project.
[ "Update", "tasks", "redundancy", "from", "a", "project", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L308-L345
train
Scifabric/pbs
helpers.py
find_project_by_short_name
def find_project_by_short_name(short_name, pbclient, all=None): """Return project by short_name.""" try: response = pbclient.find_project(short_name=short_name, all=all) check_api_error(response) if (len(response) == 0): msg = '%s not found! You can use the all=1 argument to ...
python
def find_project_by_short_name(short_name, pbclient, all=None): """Return project by short_name.""" try: response = pbclient.find_project(short_name=short_name, all=all) check_api_error(response) if (len(response) == 0): msg = '%s not found! You can use the all=1 argument to ...
[ "def", "find_project_by_short_name", "(", "short_name", ",", "pbclient", ",", "all", "=", "None", ")", ":", "try", ":", "response", "=", "pbclient", ".", "find_project", "(", "short_name", "=", "short_name", ",", "all", "=", "all", ")", "check_api_error", "(...
Return project by short_name.
[ "Return", "project", "by", "short_name", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L348-L362
train
Scifabric/pbs
helpers.py
check_api_error
def check_api_error(api_response): print(api_response) """Check if returned API response contains an error.""" if type(api_response) == dict and 'code' in api_response and api_response['code'] <> 200: print("Server response code: %s" % api_response['code']) print("Server response: %s...
python
def check_api_error(api_response): print(api_response) """Check if returned API response contains an error.""" if type(api_response) == dict and 'code' in api_response and api_response['code'] <> 200: print("Server response code: %s" % api_response['code']) print("Server response: %s...
[ "def", "check_api_error", "(", "api_response", ")", ":", "print", "(", "api_response", ")", "if", "type", "(", "api_response", ")", "==", "dict", "and", "'code'", "in", "api_response", "and", "api_response", "[", "'code'", "]", "<>", "200", ":", "print", "...
Check if returned API response contains an error.
[ "Check", "if", "returned", "API", "response", "contains", "an", "error", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L365-L388
train
Scifabric/pbs
helpers.py
format_error
def format_error(module, error): """Format the error for the given module.""" logging.error(module) # Beautify JSON error print error.message print json.dumps(error.error, sort_keys=True, indent=4, separators=(',', ': ')) exit(1)
python
def format_error(module, error): """Format the error for the given module.""" logging.error(module) # Beautify JSON error print error.message print json.dumps(error.error, sort_keys=True, indent=4, separators=(',', ': ')) exit(1)
[ "def", "format_error", "(", "module", ",", "error", ")", ":", "logging", ".", "error", "(", "module", ")", "# Beautify JSON error", "print", "error", ".", "message", "print", "json", ".", "dumps", "(", "error", ".", "error", ",", "sort_keys", "=", "True", ...
Format the error for the given module.
[ "Format", "the", "error", "for", "the", "given", "module", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L391-L397
train
Scifabric/pbs
helpers.py
create_task_info
def create_task_info(task): """Create task_info field.""" task_info = None if task.get('info'): task_info = task['info'] else: task_info = task return task_info
python
def create_task_info(task): """Create task_info field.""" task_info = None if task.get('info'): task_info = task['info'] else: task_info = task return task_info
[ "def", "create_task_info", "(", "task", ")", ":", "task_info", "=", "None", "if", "task", ".", "get", "(", "'info'", ")", ":", "task_info", "=", "task", "[", "'info'", "]", "else", ":", "task_info", "=", "task", "return", "task_info" ]
Create task_info field.
[ "Create", "task_info", "field", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L400-L407
train
Scifabric/pbs
helpers.py
create_helping_material_info
def create_helping_material_info(helping): """Create helping_material_info field.""" helping_info = None file_path = None if helping.get('info'): helping_info = helping['info'] else: helping_info = helping if helping_info.get('file_path'): file_path = helping_info.get('fi...
python
def create_helping_material_info(helping): """Create helping_material_info field.""" helping_info = None file_path = None if helping.get('info'): helping_info = helping['info'] else: helping_info = helping if helping_info.get('file_path'): file_path = helping_info.get('fi...
[ "def", "create_helping_material_info", "(", "helping", ")", ":", "helping_info", "=", "None", "file_path", "=", "None", "if", "helping", ".", "get", "(", "'info'", ")", ":", "helping_info", "=", "helping", "[", "'info'", "]", "else", ":", "helping_info", "="...
Create helping_material_info field.
[ "Create", "helping_material_info", "field", "." ]
3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38
https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L410-L421
train
wndhydrnt/python-oauth2
oauth2/store/redisdb.py
TokenStore.fetch_by_code
def fetch_by_code(self, code): """ Returns data belonging to an authorization code from redis or ``None`` if no data was found. See :class:`oauth2.store.AuthCodeStore`. """ code_data = self.read(code) if code_data is None: raise AuthCodeNotFound ...
python
def fetch_by_code(self, code): """ Returns data belonging to an authorization code from redis or ``None`` if no data was found. See :class:`oauth2.store.AuthCodeStore`. """ code_data = self.read(code) if code_data is None: raise AuthCodeNotFound ...
[ "def", "fetch_by_code", "(", "self", ",", "code", ")", ":", "code_data", "=", "self", ".", "read", "(", "code", ")", "if", "code_data", "is", "None", ":", "raise", "AuthCodeNotFound", "return", "AuthorizationCode", "(", "*", "*", "code_data", ")" ]
Returns data belonging to an authorization code from redis or ``None`` if no data was found. See :class:`oauth2.store.AuthCodeStore`.
[ "Returns", "data", "belonging", "to", "an", "authorization", "code", "from", "redis", "or", "None", "if", "no", "data", "was", "found", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/redisdb.py#L61-L74
train
wndhydrnt/python-oauth2
oauth2/store/redisdb.py
TokenStore.save_code
def save_code(self, authorization_code): """ Stores the data belonging to an authorization code token in redis. See :class:`oauth2.store.AuthCodeStore`. """ self.write(authorization_code.code, {"client_id": authorization_code.client_id, "c...
python
def save_code(self, authorization_code): """ Stores the data belonging to an authorization code token in redis. See :class:`oauth2.store.AuthCodeStore`. """ self.write(authorization_code.code, {"client_id": authorization_code.client_id, "c...
[ "def", "save_code", "(", "self", ",", "authorization_code", ")", ":", "self", ".", "write", "(", "authorization_code", ".", "code", ",", "{", "\"client_id\"", ":", "authorization_code", ".", "client_id", ",", "\"code\"", ":", "authorization_code", ".", "code", ...
Stores the data belonging to an authorization code token in redis. See :class:`oauth2.store.AuthCodeStore`.
[ "Stores", "the", "data", "belonging", "to", "an", "authorization", "code", "token", "in", "redis", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/redisdb.py#L76-L90
train
wndhydrnt/python-oauth2
oauth2/store/redisdb.py
TokenStore.save_token
def save_token(self, access_token): """ Stores the access token and additional data in redis. See :class:`oauth2.store.AccessTokenStore`. """ self.write(access_token.token, access_token.__dict__) unique_token_key = self._unique_token_key(access_token.client_id, ...
python
def save_token(self, access_token): """ Stores the access token and additional data in redis. See :class:`oauth2.store.AccessTokenStore`. """ self.write(access_token.token, access_token.__dict__) unique_token_key = self._unique_token_key(access_token.client_id, ...
[ "def", "save_token", "(", "self", ",", "access_token", ")", ":", "self", ".", "write", "(", "access_token", ".", "token", ",", "access_token", ".", "__dict__", ")", "unique_token_key", "=", "self", ".", "_unique_token_key", "(", "access_token", ".", "client_id...
Stores the access token and additional data in redis. See :class:`oauth2.store.AccessTokenStore`.
[ "Stores", "the", "access", "token", "and", "additional", "data", "in", "redis", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/redisdb.py#L99-L114
train
wndhydrnt/python-oauth2
oauth2/store/redisdb.py
TokenStore.delete_refresh_token
def delete_refresh_token(self, refresh_token): """ Deletes a refresh token after use :param refresh_token: The refresh token to delete. """ access_token = self.fetch_by_refresh_token(refresh_token) self.delete(access_token.token)
python
def delete_refresh_token(self, refresh_token): """ Deletes a refresh token after use :param refresh_token: The refresh token to delete. """ access_token = self.fetch_by_refresh_token(refresh_token) self.delete(access_token.token)
[ "def", "delete_refresh_token", "(", "self", ",", "refresh_token", ")", ":", "access_token", "=", "self", ".", "fetch_by_refresh_token", "(", "refresh_token", ")", "self", ".", "delete", "(", "access_token", ".", "token", ")" ]
Deletes a refresh token after use :param refresh_token: The refresh token to delete.
[ "Deletes", "a", "refresh", "token", "after", "use", ":", "param", "refresh_token", ":", "The", "refresh", "token", "to", "delete", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/redisdb.py#L116-L123
train
wndhydrnt/python-oauth2
oauth2/store/redisdb.py
ClientStore.add_client
def add_client(self, client_id, client_secret, redirect_uris, authorized_grants=None, authorized_response_types=None): """ Add a client app. :param client_id: Identifier of the client app. :param client_secret: Secret the client app uses for authentication ...
python
def add_client(self, client_id, client_secret, redirect_uris, authorized_grants=None, authorized_response_types=None): """ Add a client app. :param client_id: Identifier of the client app. :param client_secret: Secret the client app uses for authentication ...
[ "def", "add_client", "(", "self", ",", "client_id", ",", "client_secret", ",", "redirect_uris", ",", "authorized_grants", "=", "None", ",", "authorized_response_types", "=", "None", ")", ":", "self", ".", "write", "(", "client_id", ",", "{", "\"identifier\"", ...
Add a client app. :param client_id: Identifier of the client app. :param client_secret: Secret the client app uses for authentication against the OAuth 2.0 provider. :param redirect_uris: A ``list`` of URIs to redirect to.
[ "Add", "a", "client", "app", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/redisdb.py#L149-L167
train
wndhydrnt/python-oauth2
oauth2/tokengenerator.py
TokenGenerator.create_access_token_data
def create_access_token_data(self, grant_type): """ Create data needed by an access token. :param grant_type: :type grant_type: str :return: A ``dict`` containing he ``access_token`` and the ``token_type``. If the value of ``TokenGenerator.expires_in`` ...
python
def create_access_token_data(self, grant_type): """ Create data needed by an access token. :param grant_type: :type grant_type: str :return: A ``dict`` containing he ``access_token`` and the ``token_type``. If the value of ``TokenGenerator.expires_in`` ...
[ "def", "create_access_token_data", "(", "self", ",", "grant_type", ")", ":", "result", "=", "{", "\"access_token\"", ":", "self", ".", "generate", "(", ")", ",", "\"token_type\"", ":", "\"Bearer\"", "}", "if", "self", ".", "expires_in", ".", "get", "(", "g...
Create data needed by an access token. :param grant_type: :type grant_type: str :return: A ``dict`` containing he ``access_token`` and the ``token_type``. If the value of ``TokenGenerator.expires_in`` is larger than 0, a ``refresh_token`` will be generated too...
[ "Create", "data", "needed", "by", "an", "access", "token", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/tokengenerator.py#L22-L41
train
wndhydrnt/python-oauth2
oauth2/tokengenerator.py
URandomTokenGenerator.generate
def generate(self): """ :return: A new token :rtype: str """ random_data = os.urandom(100) hash_gen = hashlib.new("sha512") hash_gen.update(random_data) return hash_gen.hexdigest()[:self.token_length]
python
def generate(self): """ :return: A new token :rtype: str """ random_data = os.urandom(100) hash_gen = hashlib.new("sha512") hash_gen.update(random_data) return hash_gen.hexdigest()[:self.token_length]
[ "def", "generate", "(", "self", ")", ":", "random_data", "=", "os", ".", "urandom", "(", "100", ")", "hash_gen", "=", "hashlib", ".", "new", "(", "\"sha512\"", ")", "hash_gen", ".", "update", "(", "random_data", ")", "return", "hash_gen", ".", "hexdigest...
:return: A new token :rtype: str
[ ":", "return", ":", "A", "new", "token", ":", "rtype", ":", "str" ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/tokengenerator.py#L60-L70
train
wndhydrnt/python-oauth2
docs/examples/resource_owner_grant.py
ClientApplication._display_token
def _display_token(self): """ Display token information or redirect to login prompt if none is available. """ if self.token is None: return "301 Moved", "", {"Location": "/login"} return ("200 OK", self.TOKEN_TEMPLATE.format( ...
python
def _display_token(self): """ Display token information or redirect to login prompt if none is available. """ if self.token is None: return "301 Moved", "", {"Location": "/login"} return ("200 OK", self.TOKEN_TEMPLATE.format( ...
[ "def", "_display_token", "(", "self", ")", ":", "if", "self", ".", "token", "is", "None", ":", "return", "\"301 Moved\"", ",", "\"\"", ",", "{", "\"Location\"", ":", "\"/login\"", "}", "return", "(", "\"200 OK\"", ",", "self", ".", "TOKEN_TEMPLATE", ".", ...
Display token information or redirect to login prompt if none is available.
[ "Display", "token", "information", "or", "redirect", "to", "login", "prompt", "if", "none", "is", "available", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/docs/examples/resource_owner_grant.py#L95-L106
train
wndhydrnt/python-oauth2
docs/examples/resource_owner_grant.py
ClientApplication._login
def _login(self, failed=False): """ Login prompt """ if failed: content = self.LOGIN_TEMPLATE.format(failed_message="Login failed") else: content = self.LOGIN_TEMPLATE.format(failed_message="") return "200 OK", content, {"Content-Type": "text/html"...
python
def _login(self, failed=False): """ Login prompt """ if failed: content = self.LOGIN_TEMPLATE.format(failed_message="Login failed") else: content = self.LOGIN_TEMPLATE.format(failed_message="") return "200 OK", content, {"Content-Type": "text/html"...
[ "def", "_login", "(", "self", ",", "failed", "=", "False", ")", ":", "if", "failed", ":", "content", "=", "self", ".", "LOGIN_TEMPLATE", ".", "format", "(", "failed_message", "=", "\"Login failed\"", ")", "else", ":", "content", "=", "self", ".", "LOGIN_...
Login prompt
[ "Login", "prompt" ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/docs/examples/resource_owner_grant.py#L108-L116
train
wndhydrnt/python-oauth2
docs/examples/resource_owner_grant.py
ClientApplication._request_token
def _request_token(self, env): """ Retrieves a new access token from the OAuth2 server. """ params = {} content = env['wsgi.input'].read(int(env['CONTENT_LENGTH'])) post_params = parse_qs(content) # Convert to dict for easier access for param, value in po...
python
def _request_token(self, env): """ Retrieves a new access token from the OAuth2 server. """ params = {} content = env['wsgi.input'].read(int(env['CONTENT_LENGTH'])) post_params = parse_qs(content) # Convert to dict for easier access for param, value in po...
[ "def", "_request_token", "(", "self", ",", "env", ")", ":", "params", "=", "{", "}", "content", "=", "env", "[", "'wsgi.input'", "]", ".", "read", "(", "int", "(", "env", "[", "'CONTENT_LENGTH'", "]", ")", ")", "post_params", "=", "parse_qs", "(", "c...
Retrieves a new access token from the OAuth2 server.
[ "Retrieves", "a", "new", "access", "token", "from", "the", "OAuth2", "server", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/docs/examples/resource_owner_grant.py#L118-L151
train
wndhydrnt/python-oauth2
oauth2/store/memory.py
ClientStore.add_client
def add_client(self, client_id, client_secret, redirect_uris, authorized_grants=None, authorized_response_types=None): """ Add a client app. :param client_id: Identifier of the client app. :param client_secret: Secret the client app uses for authentication ...
python
def add_client(self, client_id, client_secret, redirect_uris, authorized_grants=None, authorized_response_types=None): """ Add a client app. :param client_id: Identifier of the client app. :param client_secret: Secret the client app uses for authentication ...
[ "def", "add_client", "(", "self", ",", "client_id", ",", "client_secret", ",", "redirect_uris", ",", "authorized_grants", "=", "None", ",", "authorized_response_types", "=", "None", ")", ":", "self", ".", "clients", "[", "client_id", "]", "=", "Client", "(", ...
Add a client app. :param client_id: Identifier of the client app. :param client_secret: Secret the client app uses for authentication against the OAuth 2.0 provider. :param redirect_uris: A ``list`` of URIs to redirect to.
[ "Add", "a", "client", "app", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/memory.py#L21-L39
train
wndhydrnt/python-oauth2
oauth2/store/memory.py
ClientStore.fetch_by_client_id
def fetch_by_client_id(self, client_id): """ Retrieve a client by its identifier. :param client_id: Identifier of a client app. :return: An instance of :class:`oauth2.Client`. :raises: ClientNotFoundError """ if client_id not in self.clients: raise C...
python
def fetch_by_client_id(self, client_id): """ Retrieve a client by its identifier. :param client_id: Identifier of a client app. :return: An instance of :class:`oauth2.Client`. :raises: ClientNotFoundError """ if client_id not in self.clients: raise C...
[ "def", "fetch_by_client_id", "(", "self", ",", "client_id", ")", ":", "if", "client_id", "not", "in", "self", ".", "clients", ":", "raise", "ClientNotFoundError", "return", "self", ".", "clients", "[", "client_id", "]" ]
Retrieve a client by its identifier. :param client_id: Identifier of a client app. :return: An instance of :class:`oauth2.Client`. :raises: ClientNotFoundError
[ "Retrieve", "a", "client", "by", "its", "identifier", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/memory.py#L41-L53
train
wndhydrnt/python-oauth2
oauth2/store/memory.py
TokenStore.fetch_by_code
def fetch_by_code(self, code): """ Returns an AuthorizationCode. :param code: The authorization code. :return: An instance of :class:`oauth2.datatype.AuthorizationCode`. :raises: :class:`AuthCodeNotFound` if no data could be retrieved for given code. ""...
python
def fetch_by_code(self, code): """ Returns an AuthorizationCode. :param code: The authorization code. :return: An instance of :class:`oauth2.datatype.AuthorizationCode`. :raises: :class:`AuthCodeNotFound` if no data could be retrieved for given code. ""...
[ "def", "fetch_by_code", "(", "self", ",", "code", ")", ":", "if", "code", "not", "in", "self", ".", "auth_codes", ":", "raise", "AuthCodeNotFound", "return", "self", ".", "auth_codes", "[", "code", "]" ]
Returns an AuthorizationCode. :param code: The authorization code. :return: An instance of :class:`oauth2.datatype.AuthorizationCode`. :raises: :class:`AuthCodeNotFound` if no data could be retrieved for given code.
[ "Returns", "an", "AuthorizationCode", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/memory.py#L69-L82
train
wndhydrnt/python-oauth2
oauth2/store/memory.py
TokenStore.save_token
def save_token(self, access_token): """ Stores an access token and additional data in memory. :param access_token: An instance of :class:`oauth2.datatype.AccessToken`. """ self.access_tokens[access_token.token] = access_token unique_token_key = self._unique_token_key(ac...
python
def save_token(self, access_token): """ Stores an access token and additional data in memory. :param access_token: An instance of :class:`oauth2.datatype.AccessToken`. """ self.access_tokens[access_token.token] = access_token unique_token_key = self._unique_token_key(ac...
[ "def", "save_token", "(", "self", ",", "access_token", ")", ":", "self", ".", "access_tokens", "[", "access_token", ".", "token", "]", "=", "access_token", "unique_token_key", "=", "self", ".", "_unique_token_key", "(", "access_token", ".", "client_id", ",", "...
Stores an access token and additional data in memory. :param access_token: An instance of :class:`oauth2.datatype.AccessToken`.
[ "Stores", "an", "access", "token", "and", "additional", "data", "in", "memory", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/memory.py#L96-L113
train
wndhydrnt/python-oauth2
oauth2/store/memory.py
TokenStore.fetch_by_refresh_token
def fetch_by_refresh_token(self, refresh_token): """ Find an access token by its refresh token. :param refresh_token: The refresh token that was assigned to an ``AccessToken``. :return: The :class:`oauth2.datatype.AccessToken`. :raises: :class:`oaut...
python
def fetch_by_refresh_token(self, refresh_token): """ Find an access token by its refresh token. :param refresh_token: The refresh token that was assigned to an ``AccessToken``. :return: The :class:`oauth2.datatype.AccessToken`. :raises: :class:`oaut...
[ "def", "fetch_by_refresh_token", "(", "self", ",", "refresh_token", ")", ":", "if", "refresh_token", "not", "in", "self", ".", "refresh_tokens", ":", "raise", "AccessTokenNotFound", "return", "self", ".", "refresh_tokens", "[", "refresh_token", "]" ]
Find an access token by its refresh token. :param refresh_token: The refresh token that was assigned to an ``AccessToken``. :return: The :class:`oauth2.datatype.AccessToken`. :raises: :class:`oauth2.error.AccessTokenNotFound`
[ "Find", "an", "access", "token", "by", "its", "refresh", "token", "." ]
abe3bf5f27bda2ff737cab387b040e2e6e85c2e2
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/memory.py#L131-L143
train