partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
SRegistryMessage.useColor
useColor will determine if color should be added to a print. Will check if being run in a terminal, and if has support for asci
sregistry/logger/message.py
def useColor(self): '''useColor will determine if color should be added to a print. Will check if being run in a terminal, and if has support for asci''' COLORIZE = get_user_color_preference() if COLORIZE is not None: return COLORIZE streams = [self.errorStrea...
def useColor(self): '''useColor will determine if color should be added to a print. Will check if being run in a terminal, and if has support for asci''' COLORIZE = get_user_color_preference() if COLORIZE is not None: return COLORIZE streams = [self.errorStrea...
[ "useColor", "will", "determine", "if", "color", "should", "be", "added", "to", "a", "print", ".", "Will", "check", "if", "being", "run", "in", "a", "terminal", "and", "if", "has", "support", "for", "asci" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L59-L72
[ "def", "useColor", "(", "self", ")", ":", "COLORIZE", "=", "get_user_color_preference", "(", ")", "if", "COLORIZE", "is", "not", "None", ":", "return", "COLORIZE", "streams", "=", "[", "self", ".", "errorStream", ",", "self", ".", "outputStream", "]", "for...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.addColor
addColor to the prompt (usually prefix) if terminal supports, and specified to do so
sregistry/logger/message.py
def addColor(self, level, text): '''addColor to the prompt (usually prefix) if terminal supports, and specified to do so''' if self.colorize: if level in self.colors: text = "%s%s%s" % (self.colors[level], text, ...
def addColor(self, level, text): '''addColor to the prompt (usually prefix) if terminal supports, and specified to do so''' if self.colorize: if level in self.colors: text = "%s%s%s" % (self.colors[level], text, ...
[ "addColor", "to", "the", "prompt", "(", "usually", "prefix", ")", "if", "terminal", "supports", "and", "specified", "to", "do", "so" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L74-L82
[ "def", "addColor", "(", "self", ",", "level", ",", "text", ")", ":", "if", "self", ".", "colorize", ":", "if", "level", "in", "self", ".", "colors", ":", "text", "=", "\"%s%s%s\"", "%", "(", "self", ".", "colors", "[", "level", "]", ",", "text", ...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.emitError
determine if a level should print to stderr, includes all levels but INFO and QUIET
sregistry/logger/message.py
def emitError(self, level): '''determine if a level should print to stderr, includes all levels but INFO and QUIET''' if level in [ABORT, ERROR, WARNING, VERBOSE, VERBOSE1, VERBOSE2, ...
def emitError(self, level): '''determine if a level should print to stderr, includes all levels but INFO and QUIET''' if level in [ABORT, ERROR, WARNING, VERBOSE, VERBOSE1, VERBOSE2, ...
[ "determine", "if", "a", "level", "should", "print", "to", "stderr", "includes", "all", "levels", "but", "INFO", "and", "QUIET" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L84-L96
[ "def", "emitError", "(", "self", ",", "level", ")", ":", "if", "level", "in", "[", "ABORT", ",", "ERROR", ",", "WARNING", ",", "VERBOSE", ",", "VERBOSE1", ",", "VERBOSE2", ",", "VERBOSE3", ",", "DEBUG", "]", ":", "return", "True", "return", "False" ]
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.emit
emit is the main function to print the message optionally with a prefix :param level: the level of the message :param message: the message to print :param prefix: a prefix for the message
sregistry/logger/message.py
def emit(self, level, message, prefix=None, color=None): '''emit is the main function to print the message optionally with a prefix :param level: the level of the message :param message: the message to print :param prefix: a prefix for the message ''' if color is ...
def emit(self, level, message, prefix=None, color=None): '''emit is the main function to print the message optionally with a prefix :param level: the level of the message :param message: the message to print :param prefix: a prefix for the message ''' if color is ...
[ "emit", "is", "the", "main", "function", "to", "print", "the", "message", "optionally", "with", "a", "prefix", ":", "param", "level", ":", "the", "level", "of", "the", "message", ":", "param", "message", ":", "the", "message", "to", "print", ":", "param"...
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L113-L147
[ "def", "emit", "(", "self", ",", "level", ",", "message", ",", "prefix", "=", "None", ",", "color", "=", "None", ")", ":", "if", "color", "is", "None", ":", "color", "=", "level", "if", "prefix", "is", "not", "None", ":", "prefix", "=", "self", "...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.write
write will write a message to a stream, first checking the encoding
sregistry/logger/message.py
def write(self, stream, message): '''write will write a message to a stream, first checking the encoding ''' if isinstance(message, bytes): message = message.decode('utf-8') stream.write(message)
def write(self, stream, message): '''write will write a message to a stream, first checking the encoding ''' if isinstance(message, bytes): message = message.decode('utf-8') stream.write(message)
[ "write", "will", "write", "a", "message", "to", "a", "stream", "first", "checking", "the", "encoding" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L149-L155
[ "def", "write", "(", "self", ",", "stream", ",", "message", ")", ":", "if", "isinstance", "(", "message", ",", "bytes", ")", ":", "message", "=", "message", ".", "decode", "(", "'utf-8'", ")", "stream", ".", "write", "(", "message", ")" ]
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.get_logs
get_logs will return the complete history, joined by newline (default) or as is.
sregistry/logger/message.py
def get_logs(self, join_newline=True): ''''get_logs will return the complete history, joined by newline (default) or as is. ''' if join_newline: return '\n'.join(self.history) return self.history
def get_logs(self, join_newline=True): ''''get_logs will return the complete history, joined by newline (default) or as is. ''' if join_newline: return '\n'.join(self.history) return self.history
[ "get_logs", "will", "return", "the", "complete", "history", "joined", "by", "newline", "(", "default", ")", "or", "as", "is", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L157-L163
[ "def", "get_logs", "(", "self", ",", "join_newline", "=", "True", ")", ":", "if", "join_newline", ":", "return", "'\\n'", ".", "join", "(", "self", ".", "history", ")", "return", "self", ".", "history" ]
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.show_progress
create a terminal progress bar, default bar shows for verbose+ Parameters ========== iteration: current iteration (Int) total: total iterations (Int) length: character length of bar (Int)
sregistry/logger/message.py
def show_progress(self, iteration, total, length=40, min_level=0, prefix=None, carriage_return=True, suffix=None, symbol=None): '''creat...
def show_progress(self, iteration, total, length=40, min_level=0, prefix=None, carriage_return=True, suffix=None, symbol=None): '''creat...
[ "create", "a", "terminal", "progress", "bar", "default", "bar", "shows", "for", "verbose", "+", "Parameters", "==========", "iteration", ":", "current", "iteration", "(", "Int", ")", "total", ":", "total", "iterations", "(", "Int", ")", "length", ":", "chara...
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L166-L216
[ "def", "show_progress", "(", "self", ",", "iteration", ",", "total", ",", "length", "=", "40", ",", "min_level", "=", "0", ",", "prefix", "=", "None", ",", "carriage_return", "=", "True", ",", "suffix", "=", "None", ",", "symbol", "=", "None", ")", "...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
SRegistryMessage.table
table will print a table of entries. If the rows is a dictionary, the keys are interpreted as column names. if not, a numbered list is used.
sregistry/logger/message.py
def table(self, rows, col_width=2): '''table will print a table of entries. If the rows is a dictionary, the keys are interpreted as column names. if not, a numbered list is used. ''' labels = [str(x) for x in range(1,len(rows)+1)] if isinstance(rows, dict): ...
def table(self, rows, col_width=2): '''table will print a table of entries. If the rows is a dictionary, the keys are interpreted as column names. if not, a numbered list is used. ''' labels = [str(x) for x in range(1,len(rows)+1)] if isinstance(rows, dict): ...
[ "table", "will", "print", "a", "table", "of", "entries", ".", "If", "the", "rows", "is", "a", "dictionary", "the", "keys", "are", "interpreted", "as", "column", "names", ".", "if", "not", "a", "numbered", "list", "is", "used", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L274-L290
[ "def", "table", "(", "self", ",", "rows", ",", "col_width", "=", "2", ")", ":", "labels", "=", "[", "str", "(", "x", ")", "for", "x", "in", "range", "(", "1", ",", "len", "(", "rows", ")", "+", "1", ")", "]", "if", "isinstance", "(", "rows", ...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
push
push an image to Singularity Registry path: should correspond to an absolte image path (or derive it) name: should be the complete uri that the user has requested to push. tag: should correspond with an image tag. This is provided to mirror Docker
sregistry/main/__template__/push.py
def push(self, path, name, tag=None): '''push an image to Singularity Registry path: should correspond to an absolte image path (or derive it) name: should be the complete uri that the user has requested to push. tag: should correspond with an image tag. This is provided to mirror Docker ''' ...
def push(self, path, name, tag=None): '''push an image to Singularity Registry path: should correspond to an absolte image path (or derive it) name: should be the complete uri that the user has requested to push. tag: should correspond with an image tag. This is provided to mirror Docker ''' ...
[ "push", "an", "image", "to", "Singularity", "Registry", "path", ":", "should", "correspond", "to", "an", "absolte", "image", "path", "(", "or", "derive", "it", ")", "name", ":", "should", "be", "the", "complete", "uri", "that", "the", "user", "has", "req...
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/__template__/push.py#L28-L52
[ "def", "push", "(", "self", ",", "path", ",", "name", ",", "tag", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "bot", ".", "debug", "(", "\"PUSH %s\"", "%", "path", ")", "if", "not", "os", ".", "path"...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
push
push an image to Globus endpoint. In this case, the name is the globus endpoint id and path. --name <endpointid>:/path/for/image
sregistry/main/globus/push.py
def push(self, path, name, tag=None): '''push an image to Globus endpoint. In this case, the name is the globus endpoint id and path. --name <endpointid>:/path/for/image ''' # Split the name into endpoint and rest endpoint, remote = self._parse_endpoint_name(name) path = os.path.a...
def push(self, path, name, tag=None): '''push an image to Globus endpoint. In this case, the name is the globus endpoint id and path. --name <endpointid>:/path/for/image ''' # Split the name into endpoint and rest endpoint, remote = self._parse_endpoint_name(name) path = os.path.a...
[ "push", "an", "image", "to", "Globus", "endpoint", ".", "In", "this", "case", "the", "name", "is", "the", "globus", "endpoint", "id", "and", "path", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/globus/push.py#L24-L97
[ "def", "push", "(", "self", ",", "path", ",", "name", ",", "tag", "=", "None", ")", ":", "# Split the name into endpoint and rest", "endpoint", ",", "remote", "=", "self", ".", "_parse_endpoint_name", "(", "name", ")", "path", "=", "os", ".", "path", ".", ...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
get_template
return a default template for some function in sregistry If there is no template, None is returned. Parameters ========== name: the name of the template to retrieve
sregistry/utils/templates.py
def get_template(name): '''return a default template for some function in sregistry If there is no template, None is returned. Parameters ========== name: the name of the template to retrieve ''' name = name.lower() templates = dict() templates['tarinfo'] = {"gid": 0, ...
def get_template(name): '''return a default template for some function in sregistry If there is no template, None is returned. Parameters ========== name: the name of the template to retrieve ''' name = name.lower() templates = dict() templates['tarinfo'] = {"gid": 0, ...
[ "return", "a", "default", "template", "for", "some", "function", "in", "sregistry", "If", "there", "is", "no", "template", "None", "is", "returned", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/utils/templates.py#L13-L35
[ "def", "get_template", "(", "name", ")", ":", "name", "=", "name", ".", "lower", "(", ")", "templates", "=", "dict", "(", ")", "templates", "[", "'tarinfo'", "]", "=", "{", "\"gid\"", ":", "0", ",", "\"uid\"", ":", "0", ",", "\"uname\"", ":", "\"ro...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
update_token
update_token uses HTTP basic authentication to get a token for Docker registry API V2 operations. We get here if a 401 is returned for a request. Parameters ========== response: the http request response to parse for the challenge. https://docs.docker.com/registry/spec/auth/token/
sregistry/main/aws/api.py
def update_token(self): '''update_token uses HTTP basic authentication to get a token for Docker registry API V2 operations. We get here if a 401 is returned for a request. Parameters ========== response: the http request response to parse for the challenge. https://docs.docker.com/reg...
def update_token(self): '''update_token uses HTTP basic authentication to get a token for Docker registry API V2 operations. We get here if a 401 is returned for a request. Parameters ========== response: the http request response to parse for the challenge. https://docs.docker.com/reg...
[ "update_token", "uses", "HTTP", "basic", "authentication", "to", "get", "a", "token", "for", "Docker", "registry", "API", "V2", "operations", ".", "We", "get", "here", "if", "a", "401", "is", "returned", "for", "a", "request", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/aws/api.py#L26-L48
[ "def", "update_token", "(", "self", ")", ":", "# Add Amazon headers", "tokens", "=", "self", ".", "aws", ".", "get_authorization_token", "(", ")", "token", "=", "tokens", "[", "'authorizationData'", "]", "[", "0", "]", "[", "'authorizationToken'", "]", "try", ...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
download_layers
download layers is a wrapper to do the following for a client loaded with a manifest for an image: 1. use the manifests to retrieve list of digests (get_digests) 2. atomically download the list to destination (get_layers) This function uses the MultiProcess client to download lay...
sregistry/main/aws/api.py
def download_layers(self, repo_name, digest=None, destination=None): ''' download layers is a wrapper to do the following for a client loaded with a manifest for an image: 1. use the manifests to retrieve list of digests (get_digests) 2. atomically download the list to destination (ge...
def download_layers(self, repo_name, digest=None, destination=None): ''' download layers is a wrapper to do the following for a client loaded with a manifest for an image: 1. use the manifests to retrieve list of digests (get_digests) 2. atomically download the list to destination (ge...
[ "download", "layers", "is", "a", "wrapper", "to", "do", "the", "following", "for", "a", "client", "loaded", "with", "a", "manifest", "for", "an", "image", ":", "1", ".", "use", "the", "manifests", "to", "retrieve", "list", "of", "digests", "(", "get_dige...
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/aws/api.py#L51-L95
[ "def", "download_layers", "(", "self", ",", "repo_name", ",", "digest", "=", "None", ",", "destination", "=", "None", ")", ":", "from", "sregistry", ".", "main", ".", "workers", "import", "Workers", "from", "sregistry", ".", "main", ".", "workers", ".", ...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
get_manifest
return the image manifest via the aws client, saved in self.manifest
sregistry/main/aws/api.py
def get_manifest(self, repo_name, tag): '''return the image manifest via the aws client, saved in self.manifest ''' image = None repo = self.aws.describe_images(repositoryName=repo_name) if 'imageDetails' in repo: for contender in repo.get('imageDetails'): if tag in contender['i...
def get_manifest(self, repo_name, tag): '''return the image manifest via the aws client, saved in self.manifest ''' image = None repo = self.aws.describe_images(repositoryName=repo_name) if 'imageDetails' in repo: for contender in repo.get('imageDetails'): if tag in contender['i...
[ "return", "the", "image", "manifest", "via", "the", "aws", "client", "saved", "in", "self", ".", "manifest" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/aws/api.py#L98-L120
[ "def", "get_manifest", "(", "self", ",", "repo_name", ",", "tag", ")", ":", "image", "=", "None", "repo", "=", "self", ".", "aws", ".", "describe_images", "(", "repositoryName", "=", "repo_name", ")", "if", "'imageDetails'", "in", "repo", ":", "for", "co...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
get_digests
return a list of layers from a manifest. The function is intended to work with both version 1 and 2 of the schema. All layers (including redundant) are returned. By default, we try version 2 first, then fall back to version 1. For version 1 manifests: extraction is reversed P...
sregistry/main/aws/api.py
def get_digests(self, repo_name, tag): ''' return a list of layers from a manifest. The function is intended to work with both version 1 and 2 of the schema. All layers (including redundant) are returned. By default, we try version 2 first, then fall back to version 1. For...
def get_digests(self, repo_name, tag): ''' return a list of layers from a manifest. The function is intended to work with both version 1 and 2 of the schema. All layers (including redundant) are returned. By default, we try version 2 first, then fall back to version 1. For...
[ "return", "a", "list", "of", "layers", "from", "a", "manifest", ".", "The", "function", "is", "intended", "to", "work", "with", "both", "version", "1", "and", "2", "of", "the", "schema", ".", "All", "layers", "(", "including", "redundant", ")", "are", ...
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/aws/api.py#L123-L143
[ "def", "get_digests", "(", "self", ",", "repo_name", ",", "tag", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'manifest'", ")", ":", "bot", ".", "error", "(", "'Please retrieve manifest for the image first.'", ")", "sys", ".", "exit", "(", "1", ")"...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
prepare_metadata
prepare a key/value list of metadata for the request. The metadata object that comes in is only parsed one level.
sregistry/main/google_storage/utils.py
def prepare_metadata(metadata): '''prepare a key/value list of metadata for the request. The metadata object that comes in is only parsed one level. ''' pairs = { 'metadata': { 'items': [{ 'key': 'client', 'value': 'sregistry' } ...
def prepare_metadata(metadata): '''prepare a key/value list of metadata for the request. The metadata object that comes in is only parsed one level. ''' pairs = { 'metadata': { 'items': [{ 'key': 'client', 'value': 'sregistry' } ...
[ "prepare", "a", "key", "/", "value", "list", "of", "metadata", "for", "the", "request", ".", "The", "metadata", "object", "that", "comes", "in", "is", "only", "parsed", "one", "level", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_storage/utils.py#L16-L37
[ "def", "prepare_metadata", "(", "metadata", ")", ":", "pairs", "=", "{", "'metadata'", ":", "{", "'items'", ":", "[", "{", "'key'", ":", "'client'", ",", "'value'", ":", "'sregistry'", "}", "]", "}", "}", "for", "key", ",", "val", "in", "metadata", "...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
get_build_template
get a particular build template, by default we return templates that are based on package managers. Parameters ========== name: the full path of the template file to use. manager: the package manager to use in the template (yum or apt)
sregistry/main/google_storage/utils.py
def get_build_template(name=None, manager='apt'): '''get a particular build template, by default we return templates that are based on package managers. Parameters ========== name: the full path of the template file to use. manager: the package manager to use in the template (yum...
def get_build_template(name=None, manager='apt'): '''get a particular build template, by default we return templates that are based on package managers. Parameters ========== name: the full path of the template file to use. manager: the package manager to use in the template (yum...
[ "get", "a", "particular", "build", "template", "by", "default", "we", "return", "templates", "that", "are", "based", "on", "package", "managers", "." ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_storage/utils.py#L40-L59
[ "def", "get_build_template", "(", "name", "=", "None", ",", "manager", "=", "'apt'", ")", ":", "base", "=", "get_installdir", "(", ")", "if", "name", "is", "None", ":", "name", "=", "\"%s/main/templates/build/singularity-builder-%s.sh\"", "%", "(", "base", ","...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
get_metadata
extract metadata using Singularity inspect, if the executable is found. If not, return a reasonable default (the parsed image name) Parameters ========== image_file: the full path to a Singularity image names: optional, an extracted or otherwise created dictionary of va...
sregistry/main/base/inspect.py
def get_metadata(self, image_file, names={}): '''extract metadata using Singularity inspect, if the executable is found. If not, return a reasonable default (the parsed image name) Parameters ========== image_file: the full path to a Singularity image names: optional, an extracte...
def get_metadata(self, image_file, names={}): '''extract metadata using Singularity inspect, if the executable is found. If not, return a reasonable default (the parsed image name) Parameters ========== image_file: the full path to a Singularity image names: optional, an extracte...
[ "extract", "metadata", "using", "Singularity", "inspect", "if", "the", "executable", "is", "found", ".", "If", "not", "return", "a", "reasonable", "default", "(", "the", "parsed", "image", "name", ")" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/base/inspect.py#L27-L74
[ "def", "get_metadata", "(", "self", ",", "image_file", ",", "names", "=", "{", "}", ")", ":", "metadata", "=", "dict", "(", ")", "# We can't return anything without image_file or names", "if", "image_file", "is", "not", "None", ":", "if", "not", "os", ".", "...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
_pull
pull an image from a docker hub. This is a (less than ideal) workaround that actually does the following: - creates a sandbox folder - adds docker layers, metadata folder, and custom metadata to it - converts to a squashfs image with build the docker manifests are stored with registry ...
sregistry/main/docker/pull.py
def _pull(self, file_name, names, save=True, force=False, uri="docker://", **kwargs): '''pull an image from a docker hub. This is a (less than ideal) workaround that actually does the following: - creates a sandbox folder - add...
def _pull(self, file_name, names, save=True, force=False, uri="docker://", **kwargs): '''pull an image from a docker hub. This is a (less than ideal) workaround that actually does the following: - creates a sandbox folder - add...
[ "pull", "an", "image", "from", "a", "docker", "hub", ".", "This", "is", "a", "(", "less", "than", "ideal", ")", "workaround", "that", "actually", "does", "the", "following", ":" ]
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/docker/pull.py#L84-L185
[ "def", "_pull", "(", "self", ",", "file_name", ",", "names", ",", "save", "=", "True", ",", "force", "=", "False", ",", "uri", "=", "\"docker://\"", ",", "*", "*", "kwargs", ")", ":", "# Use Singularity to build the image, based on user preference", "if", "fil...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
Client._update_secrets
update secrets will take a secrets credential file either located at .sregistry or the environment variable SREGISTRY_CLIENT_SECRETS and update the current client secrets as well as the associated API base. This is where you should do any customization of the secrets flie, o...
sregistry/main/__template__/__init__.py
def _update_secrets(self): '''update secrets will take a secrets credential file either located at .sregistry or the environment variable SREGISTRY_CLIENT_SECRETS and update the current client secrets as well as the associated API base. This is where you should do an...
def _update_secrets(self): '''update secrets will take a secrets credential file either located at .sregistry or the environment variable SREGISTRY_CLIENT_SECRETS and update the current client secrets as well as the associated API base. This is where you should do an...
[ "update", "secrets", "will", "take", "a", "secrets", "credential", "file", "either", "located", "at", ".", "sregistry", "or", "the", "environment", "variable", "SREGISTRY_CLIENT_SECRETS", "and", "update", "the", "current", "client", "secrets", "as", "well", "as", ...
singularityhub/sregistry-cli
python
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/__template__/__init__.py#L38-L65
[ "def", "_update_secrets", "(", "self", ")", ":", "# Get a setting for client myclient and some variable name VAR. ", "# returns None if not set", "setting", "=", "self", ".", "_get_setting", "(", "'SREGISTRY_MYCLIENT_VAR'", ")", "# Get (and if found in environment (1) settings (2) up...
abc96140a1d15b5e96d83432e1e0e1f4f8f36331
test
_make_repr
Generate a repr string. Positional arguments should be the positional arguments used to construct the class. Keyword arguments should consist of tuples of the attribute value and default. If the value is the default, then it won't be rendered in the output. Here's an example:: def __repr_...
fs_s3fs/_s3fs.py
def _make_repr(class_name, *args, **kwargs): """ Generate a repr string. Positional arguments should be the positional arguments used to construct the class. Keyword arguments should consist of tuples of the attribute value and default. If the value is the default, then it won't be rendered in ...
def _make_repr(class_name, *args, **kwargs): """ Generate a repr string. Positional arguments should be the positional arguments used to construct the class. Keyword arguments should consist of tuples of the attribute value and default. If the value is the default, then it won't be rendered in ...
[ "Generate", "a", "repr", "string", "." ]
PyFilesystem/s3fs
python
https://github.com/PyFilesystem/s3fs/blob/1c5e3a1b6abbb9dff91ea7fc4cec7353798cd536/fs_s3fs/_s3fs.py#L34-L58
[ "def", "_make_repr", "(", "class_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "arguments", "=", "[", "repr", "(", "arg", ")", "for", "arg", "in", "args", "]", "arguments", ".", "extend", "(", "\"{}={!r}\"", ".", "format", "(", "name", ...
1c5e3a1b6abbb9dff91ea7fc4cec7353798cd536
test
s3errors
Translate S3 errors to FSErrors.
fs_s3fs/_s3fs.py
def s3errors(path): """Translate S3 errors to FSErrors.""" try: yield except ClientError as error: _error = error.response.get("Error", {}) error_code = _error.get("Code", None) response_meta = error.response.get("ResponseMetadata", {}) http_status = response_meta.get...
def s3errors(path): """Translate S3 errors to FSErrors.""" try: yield except ClientError as error: _error = error.response.get("Error", {}) error_code = _error.get("Code", None) response_meta = error.response.get("ResponseMetadata", {}) http_status = response_meta.get...
[ "Translate", "S3", "errors", "to", "FSErrors", "." ]
PyFilesystem/s3fs
python
https://github.com/PyFilesystem/s3fs/blob/1c5e3a1b6abbb9dff91ea7fc4cec7353798cd536/fs_s3fs/_s3fs.py#L171-L192
[ "def", "s3errors", "(", "path", ")", ":", "try", ":", "yield", "except", "ClientError", "as", "error", ":", "_error", "=", "error", ".", "response", ".", "get", "(", "\"Error\"", ",", "{", "}", ")", "error_code", "=", "_error", ".", "get", "(", "\"Co...
1c5e3a1b6abbb9dff91ea7fc4cec7353798cd536
test
S3File.factory
Create a S3File backed with a temporary file.
fs_s3fs/_s3fs.py
def factory(cls, filename, mode, on_close): """Create a S3File backed with a temporary file.""" _temp_file = tempfile.TemporaryFile() proxy = cls(_temp_file, filename, mode, on_close=on_close) return proxy
def factory(cls, filename, mode, on_close): """Create a S3File backed with a temporary file.""" _temp_file = tempfile.TemporaryFile() proxy = cls(_temp_file, filename, mode, on_close=on_close) return proxy
[ "Create", "a", "S3File", "backed", "with", "a", "temporary", "file", "." ]
PyFilesystem/s3fs
python
https://github.com/PyFilesystem/s3fs/blob/1c5e3a1b6abbb9dff91ea7fc4cec7353798cd536/fs_s3fs/_s3fs.py#L65-L69
[ "def", "factory", "(", "cls", ",", "filename", ",", "mode", ",", "on_close", ")", ":", "_temp_file", "=", "tempfile", ".", "TemporaryFile", "(", ")", "proxy", "=", "cls", "(", "_temp_file", ",", "filename", ",", "mode", ",", "on_close", "=", "on_close", ...
1c5e3a1b6abbb9dff91ea7fc4cec7353798cd536
test
gravatar_url
Builds a gravatar url from an user or email
django_gravatar/templatetags/gravatar.py
def gravatar_url(user_or_email, size=GRAVATAR_DEFAULT_SIZE): """ Builds a gravatar url from an user or email """ if hasattr(user_or_email, 'email'): email = user_or_email.email else: email = user_or_email try: return escape(get_gravatar_url(email=email, size=size)) except: ...
def gravatar_url(user_or_email, size=GRAVATAR_DEFAULT_SIZE): """ Builds a gravatar url from an user or email """ if hasattr(user_or_email, 'email'): email = user_or_email.email else: email = user_or_email try: return escape(get_gravatar_url(email=email, size=size)) except: ...
[ "Builds", "a", "gravatar", "url", "from", "an", "user", "or", "email" ]
twaddington/django-gravatar
python
https://github.com/twaddington/django-gravatar/blob/c4849d93ed43b419eceff0ff2de83d4265597629/django_gravatar/templatetags/gravatar.py#L11-L21
[ "def", "gravatar_url", "(", "user_or_email", ",", "size", "=", "GRAVATAR_DEFAULT_SIZE", ")", ":", "if", "hasattr", "(", "user_or_email", ",", "'email'", ")", ":", "email", "=", "user_or_email", ".", "email", "else", ":", "email", "=", "user_or_email", "try", ...
c4849d93ed43b419eceff0ff2de83d4265597629
test
gravatar
Builds an gravatar <img> tag from an user or email
django_gravatar/templatetags/gravatar.py
def gravatar(user_or_email, size=GRAVATAR_DEFAULT_SIZE, alt_text='', css_class='gravatar'): """ Builds an gravatar <img> tag from an user or email """ if hasattr(user_or_email, 'email'): email = user_or_email.email else: email = user_or_email try: url = escape(get_gravatar_url(e...
def gravatar(user_or_email, size=GRAVATAR_DEFAULT_SIZE, alt_text='', css_class='gravatar'): """ Builds an gravatar <img> tag from an user or email """ if hasattr(user_or_email, 'email'): email = user_or_email.email else: email = user_or_email try: url = escape(get_gravatar_url(e...
[ "Builds", "an", "gravatar", "<img", ">", "tag", "from", "an", "user", "or", "email" ]
twaddington/django-gravatar
python
https://github.com/twaddington/django-gravatar/blob/c4849d93ed43b419eceff0ff2de83d4265597629/django_gravatar/templatetags/gravatar.py#L24-L41
[ "def", "gravatar", "(", "user_or_email", ",", "size", "=", "GRAVATAR_DEFAULT_SIZE", ",", "alt_text", "=", "''", ",", "css_class", "=", "'gravatar'", ")", ":", "if", "hasattr", "(", "user_or_email", ",", "'email'", ")", ":", "email", "=", "user_or_email", "."...
c4849d93ed43b419eceff0ff2de83d4265597629
test
get_gravatar_url
Builds a url to a gravatar from an email address. :param email: The email to fetch the gravatar for :param size: The size (in pixels) of the gravatar to fetch :param default: What type of default image to use if the gravatar does not exist :param rating: Used to filter the allowed gravatar ratings ...
django_gravatar/helpers.py
def get_gravatar_url(email, size=GRAVATAR_DEFAULT_SIZE, default=GRAVATAR_DEFAULT_IMAGE, rating=GRAVATAR_DEFAULT_RATING, secure=GRAVATAR_DEFAULT_SECURE): """ Builds a url to a gravatar from an email address. :param email: The email to fetch the gravatar for :param size: The size (in pixels) of t...
def get_gravatar_url(email, size=GRAVATAR_DEFAULT_SIZE, default=GRAVATAR_DEFAULT_IMAGE, rating=GRAVATAR_DEFAULT_RATING, secure=GRAVATAR_DEFAULT_SECURE): """ Builds a url to a gravatar from an email address. :param email: The email to fetch the gravatar for :param size: The size (in pixels) of t...
[ "Builds", "a", "url", "to", "a", "gravatar", "from", "an", "email", "address", "." ]
twaddington/django-gravatar
python
https://github.com/twaddington/django-gravatar/blob/c4849d93ed43b419eceff0ff2de83d4265597629/django_gravatar/helpers.py#L41-L71
[ "def", "get_gravatar_url", "(", "email", ",", "size", "=", "GRAVATAR_DEFAULT_SIZE", ",", "default", "=", "GRAVATAR_DEFAULT_IMAGE", ",", "rating", "=", "GRAVATAR_DEFAULT_RATING", ",", "secure", "=", "GRAVATAR_DEFAULT_SECURE", ")", ":", "if", "secure", ":", "url_base"...
c4849d93ed43b419eceff0ff2de83d4265597629
test
has_gravatar
Returns True if the user has a gravatar, False if otherwise
django_gravatar/helpers.py
def has_gravatar(email): """ Returns True if the user has a gravatar, False if otherwise """ # Request a 404 response if the gravatar does not exist url = get_gravatar_url(email, default=GRAVATAR_DEFAULT_IMAGE_404) # Verify an OK response was received try: request = Request(url) ...
def has_gravatar(email): """ Returns True if the user has a gravatar, False if otherwise """ # Request a 404 response if the gravatar does not exist url = get_gravatar_url(email, default=GRAVATAR_DEFAULT_IMAGE_404) # Verify an OK response was received try: request = Request(url) ...
[ "Returns", "True", "if", "the", "user", "has", "a", "gravatar", "False", "if", "otherwise" ]
twaddington/django-gravatar
python
https://github.com/twaddington/django-gravatar/blob/c4849d93ed43b419eceff0ff2de83d4265597629/django_gravatar/helpers.py#L74-L87
[ "def", "has_gravatar", "(", "email", ")", ":", "# Request a 404 response if the gravatar does not exist", "url", "=", "get_gravatar_url", "(", "email", ",", "default", "=", "GRAVATAR_DEFAULT_IMAGE_404", ")", "# Verify an OK response was received", "try", ":", "request", "="...
c4849d93ed43b419eceff0ff2de83d4265597629
test
get_gravatar_profile_url
Builds a url to a gravatar profile from an email address. :param email: The email to fetch the gravatar for :param secure: If True use https, otherwise plain http
django_gravatar/helpers.py
def get_gravatar_profile_url(email, secure=GRAVATAR_DEFAULT_SECURE): """ Builds a url to a gravatar profile from an email address. :param email: The email to fetch the gravatar for :param secure: If True use https, otherwise plain http """ if secure: url_base = GRAVATAR_SECURE_URL e...
def get_gravatar_profile_url(email, secure=GRAVATAR_DEFAULT_SECURE): """ Builds a url to a gravatar profile from an email address. :param email: The email to fetch the gravatar for :param secure: If True use https, otherwise plain http """ if secure: url_base = GRAVATAR_SECURE_URL e...
[ "Builds", "a", "url", "to", "a", "gravatar", "profile", "from", "an", "email", "address", "." ]
twaddington/django-gravatar
python
https://github.com/twaddington/django-gravatar/blob/c4849d93ed43b419eceff0ff2de83d4265597629/django_gravatar/helpers.py#L90-L108
[ "def", "get_gravatar_profile_url", "(", "email", ",", "secure", "=", "GRAVATAR_DEFAULT_SECURE", ")", ":", "if", "secure", ":", "url_base", "=", "GRAVATAR_SECURE_URL", "else", ":", "url_base", "=", "GRAVATAR_URL", "# Calculate the email hash", "email_hash", "=", "calcu...
c4849d93ed43b419eceff0ff2de83d4265597629
test
graph_coloring_qubo
the QUBO for k-coloring a graph A is as follows: variables: x_{v,c} = 1 if vertex v of A gets color c; x_{v,c} = 0 otherwise constraints: 1) each v in A gets exactly one color. This constraint is enforced by including the term (\sum_c x_{v,c} - 1)^2 in the QUBO, which is minimized when ...
examples/fourcolor.py
def graph_coloring_qubo(graph, k): """ the QUBO for k-coloring a graph A is as follows: variables: x_{v,c} = 1 if vertex v of A gets color c; x_{v,c} = 0 otherwise constraints: 1) each v in A gets exactly one color. This constraint is enforced by including the term (\sum_c x_{v,c} - 1)...
def graph_coloring_qubo(graph, k): """ the QUBO for k-coloring a graph A is as follows: variables: x_{v,c} = 1 if vertex v of A gets color c; x_{v,c} = 0 otherwise constraints: 1) each v in A gets exactly one color. This constraint is enforced by including the term (\sum_c x_{v,c} - 1)...
[ "the", "QUBO", "for", "k", "-", "coloring", "a", "graph", "A", "is", "as", "follows", ":" ]
dwavesystems/minorminer
python
https://github.com/dwavesystems/minorminer/blob/05cac6db180adf8223a613dff808248e3048b07d/examples/fourcolor.py#L43-L70
[ "def", "graph_coloring_qubo", "(", "graph", ",", "k", ")", ":", "K", "=", "nx", ".", "complete_graph", "(", "k", ")", "g1", "=", "nx", ".", "cartesian_product", "(", "nx", ".", "create_empty_copy", "(", "graph", ")", ",", "K", ")", "g2", "=", "nx", ...
05cac6db180adf8223a613dff808248e3048b07d
test
chimera_blocks
Generator for blocks for a chimera block quotient
examples/fourcolor.py
def chimera_blocks(M=16, N=16, L=4): """ Generator for blocks for a chimera block quotient """ for x in xrange(M): for y in xrange(N): for u in (0, 1): yield tuple((x, y, u, k) for k in xrange(L))
def chimera_blocks(M=16, N=16, L=4): """ Generator for blocks for a chimera block quotient """ for x in xrange(M): for y in xrange(N): for u in (0, 1): yield tuple((x, y, u, k) for k in xrange(L))
[ "Generator", "for", "blocks", "for", "a", "chimera", "block", "quotient" ]
dwavesystems/minorminer
python
https://github.com/dwavesystems/minorminer/blob/05cac6db180adf8223a613dff808248e3048b07d/examples/fourcolor.py#L73-L80
[ "def", "chimera_blocks", "(", "M", "=", "16", ",", "N", "=", "16", ",", "L", "=", "4", ")", ":", "for", "x", "in", "xrange", "(", "M", ")", ":", "for", "y", "in", "xrange", "(", "N", ")", ":", "for", "u", "in", "(", "0", ",", "1", ")", ...
05cac6db180adf8223a613dff808248e3048b07d
test
chimera_block_quotient
Extract the blocks from a graph, and returns a block-quotient graph according to the acceptability functions block_good and eblock_good Inputs: G: a networkx graph blocks: a tuple of tuples
examples/fourcolor.py
def chimera_block_quotient(G, blocks): """ Extract the blocks from a graph, and returns a block-quotient graph according to the acceptability functions block_good and eblock_good Inputs: G: a networkx graph blocks: a tuple of tuples """ from networkx import Graph from i...
def chimera_block_quotient(G, blocks): """ Extract the blocks from a graph, and returns a block-quotient graph according to the acceptability functions block_good and eblock_good Inputs: G: a networkx graph blocks: a tuple of tuples """ from networkx import Graph from i...
[ "Extract", "the", "blocks", "from", "a", "graph", "and", "returns", "a", "block", "-", "quotient", "graph", "according", "to", "the", "acceptability", "functions", "block_good", "and", "eblock_good" ]
dwavesystems/minorminer
python
https://github.com/dwavesystems/minorminer/blob/05cac6db180adf8223a613dff808248e3048b07d/examples/fourcolor.py#L83-L126
[ "def", "chimera_block_quotient", "(", "G", ",", "blocks", ")", ":", "from", "networkx", "import", "Graph", "from", "itertools", "import", "product", "BG", "=", "Graph", "(", ")", "blockid", "=", "{", "}", "for", "i", ",", "b", "in", "enumerate", "(", "...
05cac6db180adf8223a613dff808248e3048b07d
test
embed_with_quotient
Produce an embedding in target_graph suitable to check if source_graph is 4-colorable. More generally, if target_graph is a (M,N,L) Chimera subgraph, the test is for L-colorability. This depends heavily upon the Chimera structure Inputs: source_graph, target_graph: networkx graphs ...
examples/fourcolor.py
def embed_with_quotient(source_graph, target_graph, M=16, N=16, L=4, **args): """ Produce an embedding in target_graph suitable to check if source_graph is 4-colorable. More generally, if target_graph is a (M,N,L) Chimera subgraph, the test is for L-colorability. This depends heavily upon the ...
def embed_with_quotient(source_graph, target_graph, M=16, N=16, L=4, **args): """ Produce an embedding in target_graph suitable to check if source_graph is 4-colorable. More generally, if target_graph is a (M,N,L) Chimera subgraph, the test is for L-colorability. This depends heavily upon the ...
[ "Produce", "an", "embedding", "in", "target_graph", "suitable", "to", "check", "if", "source_graph", "is", "4", "-", "colorable", ".", "More", "generally", "if", "target_graph", "is", "a", "(", "M", "N", "L", ")", "Chimera", "subgraph", "the", "test", "is"...
dwavesystems/minorminer
python
https://github.com/dwavesystems/minorminer/blob/05cac6db180adf8223a613dff808248e3048b07d/examples/fourcolor.py#L129-L202
[ "def", "embed_with_quotient", "(", "source_graph", ",", "target_graph", ",", "M", "=", "16", ",", "N", "=", "16", ",", "L", "=", "4", ",", "*", "*", "args", ")", ":", "from", "random", "import", "sample", "blocks", "=", "list", "(", "chimera_blocks", ...
05cac6db180adf8223a613dff808248e3048b07d
test
enumerate_resonance_smiles
Return a set of resonance forms as SMILES strings, given a SMILES string. :param smiles: A SMILES string. :returns: A set containing SMILES strings for every possible resonance form. :rtype: set of strings.
molvs/resonance.py
def enumerate_resonance_smiles(smiles): """Return a set of resonance forms as SMILES strings, given a SMILES string. :param smiles: A SMILES string. :returns: A set containing SMILES strings for every possible resonance form. :rtype: set of strings. """ mol = Chem.MolFromSmiles(smiles) #Che...
def enumerate_resonance_smiles(smiles): """Return a set of resonance forms as SMILES strings, given a SMILES string. :param smiles: A SMILES string. :returns: A set containing SMILES strings for every possible resonance form. :rtype: set of strings. """ mol = Chem.MolFromSmiles(smiles) #Che...
[ "Return", "a", "set", "of", "resonance", "forms", "as", "SMILES", "strings", "given", "a", "SMILES", "string", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/resonance.py#L81-L91
[ "def", "enumerate_resonance_smiles", "(", "smiles", ")", ":", "mol", "=", "Chem", ".", "MolFromSmiles", "(", "smiles", ")", "#Chem.SanitizeMol(mol) # MolFromSmiles does Sanitize by default", "mesomers", "=", "ResonanceEnumerator", "(", ")", ".", "enumerate", "(", "mol"...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
ResonanceEnumerator.enumerate
Enumerate all possible resonance forms and return them as a list. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: A list of all possible resonance forms of the molecule. :rtype: list of rdkit.Chem.rdchem.Mol
molvs/resonance.py
def enumerate(self, mol): """Enumerate all possible resonance forms and return them as a list. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: A list of all possible resonance forms of the molecule. :rtype: list of rdkit.Chem.rdchem.Mol """ ...
def enumerate(self, mol): """Enumerate all possible resonance forms and return them as a list. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: A list of all possible resonance forms of the molecule. :rtype: list of rdkit.Chem.rdchem.Mol """ ...
[ "Enumerate", "all", "possible", "resonance", "forms", "and", "return", "them", "as", "a", "list", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/resonance.py#L52-L76
[ "def", "enumerate", "(", "self", ",", "mol", ")", ":", "flags", "=", "0", "if", "self", ".", "kekule_all", ":", "flags", "=", "flags", "|", "Chem", ".", "KEKULE_ALL", "if", "self", ".", "allow_incomplete_octets", ":", "flags", "=", "flags", "|", "Chem"...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Normalizer.normalize
Apply a series of Normalization transforms to correct functional groups and recombine charges. A series of transforms are applied to the molecule. For each Normalization, the transform is applied repeatedly until no further changes occur. If any changes occurred, we go back and start from the first Nor...
molvs/normalize.py
def normalize(self, mol): """Apply a series of Normalization transforms to correct functional groups and recombine charges. A series of transforms are applied to the molecule. For each Normalization, the transform is applied repeatedly until no further changes occur. If any changes occurred, we...
def normalize(self, mol): """Apply a series of Normalization transforms to correct functional groups and recombine charges. A series of transforms are applied to the molecule. For each Normalization, the transform is applied repeatedly until no further changes occur. If any changes occurred, we...
[ "Apply", "a", "series", "of", "Normalization", "transforms", "to", "correct", "functional", "groups", "and", "recombine", "charges", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/normalize.py#L114-L137
[ "def", "normalize", "(", "self", ",", "mol", ")", ":", "log", ".", "debug", "(", "'Running Normalizer'", ")", "# Normalize each fragment separately to get around quirky RunReactants behaviour", "fragments", "=", "[", "]", "for", "fragment", "in", "Chem", ".", "GetMolF...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Normalizer._apply_transform
Repeatedly apply normalization transform to molecule until no changes occur. It is possible for multiple products to be produced when a rule is applied. The rule is applied repeatedly to each of the products, until no further changes occur or after 20 attempts. If there are multiple unique products ...
molvs/normalize.py
def _apply_transform(self, mol, rule): """Repeatedly apply normalization transform to molecule until no changes occur. It is possible for multiple products to be produced when a rule is applied. The rule is applied repeatedly to each of the products, until no further changes occur or after 20 a...
def _apply_transform(self, mol, rule): """Repeatedly apply normalization transform to molecule until no changes occur. It is possible for multiple products to be produced when a rule is applied. The rule is applied repeatedly to each of the products, until no further changes occur or after 20 a...
[ "Repeatedly", "apply", "normalization", "transform", "to", "molecule", "until", "no", "changes", "occur", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/normalize.py#L156-L174
[ "def", "_apply_transform", "(", "self", ",", "mol", ",", "rule", ")", ":", "mols", "=", "[", "mol", "]", "for", "n", "in", "six", ".", "moves", ".", "range", "(", "20", ")", ":", "products", "=", "{", "}", "for", "mol", "in", "mols", ":", "for"...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
TautomerCanonicalizer.canonicalize
Return a canonical tautomer by enumerating and scoring all possible tautomers. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: The canonical tautomer. :rtype: rdkit.Chem.rdchem.Mol
molvs/tautomer.py
def canonicalize(self, mol): """Return a canonical tautomer by enumerating and scoring all possible tautomers. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: The canonical tautomer. :rtype: rdkit.Chem.rdchem.Mol """ # TODO: Overload the...
def canonicalize(self, mol): """Return a canonical tautomer by enumerating and scoring all possible tautomers. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: The canonical tautomer. :rtype: rdkit.Chem.rdchem.Mol """ # TODO: Overload the...
[ "Return", "a", "canonical", "tautomer", "by", "enumerating", "and", "scoring", "all", "possible", "tautomers", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/tautomer.py#L170-L215
[ "def", "canonicalize", "(", "self", ",", "mol", ")", ":", "# TODO: Overload the mol parameter to pass a list of pre-enumerated tautomers", "tautomers", "=", "self", ".", "_enumerate_tautomers", "(", "mol", ")", "if", "len", "(", "tautomers", ")", "==", "1", ":", "re...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
TautomerEnumerator.enumerate
Enumerate all possible tautomers and return them as a list. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: A list of all possible tautomers of the molecule. :rtype: list of rdkit.Chem.rdchem.Mol
molvs/tautomer.py
def enumerate(self, mol): """Enumerate all possible tautomers and return them as a list. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: A list of all possible tautomers of the molecule. :rtype: list of rdkit.Chem.rdchem.Mol """ smiles =...
def enumerate(self, mol): """Enumerate all possible tautomers and return them as a list. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :return: A list of all possible tautomers of the molecule. :rtype: list of rdkit.Chem.rdchem.Mol """ smiles =...
[ "Enumerate", "all", "possible", "tautomers", "and", "return", "them", "as", "a", "list", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/tautomer.py#L240-L327
[ "def", "enumerate", "(", "self", ",", "mol", ")", ":", "smiles", "=", "Chem", ".", "MolToSmiles", "(", "mol", ",", "isomericSmiles", "=", "True", ")", "tautomers", "=", "{", "smiles", ":", "copy", ".", "deepcopy", "(", "mol", ")", "}", "# Create a keku...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
validate_smiles
Return log messages for a given SMILES string using the default validations. Note: This is a convenience function for quickly validating a single SMILES string. It is more efficient to use the :class:`~molvs.validate.Validator` class directly when working with many molecules or when custom options are need...
molvs/validate.py
def validate_smiles(smiles): """Return log messages for a given SMILES string using the default validations. Note: This is a convenience function for quickly validating a single SMILES string. It is more efficient to use the :class:`~molvs.validate.Validator` class directly when working with many molecules...
def validate_smiles(smiles): """Return log messages for a given SMILES string using the default validations. Note: This is a convenience function for quickly validating a single SMILES string. It is more efficient to use the :class:`~molvs.validate.Validator` class directly when working with many molecules...
[ "Return", "log", "messages", "for", "a", "given", "SMILES", "string", "using", "the", "default", "validations", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/validate.py#L105-L119
[ "def", "validate_smiles", "(", "smiles", ")", ":", "# Skip sanitize as standardize does this anyway", "mol", "=", "Chem", ".", "MolFromSmiles", "(", "smiles", ")", "logs", "=", "Validator", "(", ")", ".", "validate", "(", "mol", ")", "return", "logs" ]
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
MetalDisconnector.disconnect
Break covalent bonds between metals and organic atoms under certain conditions. The algorithm works as follows: - Disconnect N, O, F from any metal. - Disconnect other non-metals from transition metals + Al (but not Hg, Ga, Ge, In, Sn, As, Tl, Pb, Bi, Po). - For every bond broken, adju...
molvs/metal.py
def disconnect(self, mol): """Break covalent bonds between metals and organic atoms under certain conditions. The algorithm works as follows: - Disconnect N, O, F from any metal. - Disconnect other non-metals from transition metals + Al (but not Hg, Ga, Ge, In, Sn, As, Tl, Pb, Bi, Po)....
def disconnect(self, mol): """Break covalent bonds between metals and organic atoms under certain conditions. The algorithm works as follows: - Disconnect N, O, F from any metal. - Disconnect other non-metals from transition metals + Al (but not Hg, Ga, Ge, In, Sn, As, Tl, Pb, Bi, Po)....
[ "Break", "covalent", "bonds", "between", "metals", "and", "organic", "atoms", "under", "certain", "conditions", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/metal.py#L38-L72
[ "def", "disconnect", "(", "self", ",", "mol", ")", ":", "log", ".", "debug", "(", "'Running MetalDisconnector'", ")", "# Remove bonds that match SMARTS", "for", "smarts", "in", "[", "self", ".", "_metal_nof", ",", "self", ".", "_metal_non", "]", ":", "pairs", ...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
standardize_smiles
Return a standardized canonical SMILES string given a SMILES string. Note: This is a convenience function for quickly standardizing a single SMILES string. It is more efficient to use the :class:`~molvs.standardize.Standardizer` class directly when working with many molecules or when custom options are nee...
molvs/standardize.py
def standardize_smiles(smiles): """Return a standardized canonical SMILES string given a SMILES string. Note: This is a convenience function for quickly standardizing a single SMILES string. It is more efficient to use the :class:`~molvs.standardize.Standardizer` class directly when working with many molec...
def standardize_smiles(smiles): """Return a standardized canonical SMILES string given a SMILES string. Note: This is a convenience function for quickly standardizing a single SMILES string. It is more efficient to use the :class:`~molvs.standardize.Standardizer` class directly when working with many molec...
[ "Return", "a", "standardized", "canonical", "SMILES", "string", "given", "a", "SMILES", "string", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L289-L303
[ "def", "standardize_smiles", "(", "smiles", ")", ":", "# Skip sanitize as standardize does this anyway", "mol", "=", "Chem", ".", "MolFromSmiles", "(", "smiles", ",", "sanitize", "=", "False", ")", "mol", "=", "Standardizer", "(", ")", ".", "standardize", "(", "...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
enumerate_tautomers_smiles
Return a set of tautomers as SMILES strings, given a SMILES string. :param smiles: A SMILES string. :returns: A set containing SMILES strings for every possible tautomer. :rtype: set of strings.
molvs/standardize.py
def enumerate_tautomers_smiles(smiles): """Return a set of tautomers as SMILES strings, given a SMILES string. :param smiles: A SMILES string. :returns: A set containing SMILES strings for every possible tautomer. :rtype: set of strings. """ # Skip sanitize as standardize does this anyway m...
def enumerate_tautomers_smiles(smiles): """Return a set of tautomers as SMILES strings, given a SMILES string. :param smiles: A SMILES string. :returns: A set containing SMILES strings for every possible tautomer. :rtype: set of strings. """ # Skip sanitize as standardize does this anyway m...
[ "Return", "a", "set", "of", "tautomers", "as", "SMILES", "strings", "given", "a", "SMILES", "string", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L306-L317
[ "def", "enumerate_tautomers_smiles", "(", "smiles", ")", ":", "# Skip sanitize as standardize does this anyway", "mol", "=", "Chem", ".", "MolFromSmiles", "(", "smiles", ",", "sanitize", "=", "False", ")", "mol", "=", "Standardizer", "(", ")", ".", "standardize", ...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
canonicalize_tautomer_smiles
Return a standardized canonical tautomer SMILES string given a SMILES string. Note: This is a convenience function for quickly standardizing and finding the canonical tautomer for a single SMILES string. It is more efficient to use the :class:`~molvs.standardize.Standardizer` class directly when working wi...
molvs/standardize.py
def canonicalize_tautomer_smiles(smiles): """Return a standardized canonical tautomer SMILES string given a SMILES string. Note: This is a convenience function for quickly standardizing and finding the canonical tautomer for a single SMILES string. It is more efficient to use the :class:`~molvs.standardize...
def canonicalize_tautomer_smiles(smiles): """Return a standardized canonical tautomer SMILES string given a SMILES string. Note: This is a convenience function for quickly standardizing and finding the canonical tautomer for a single SMILES string. It is more efficient to use the :class:`~molvs.standardize...
[ "Return", "a", "standardized", "canonical", "tautomer", "SMILES", "string", "given", "a", "SMILES", "string", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L320-L335
[ "def", "canonicalize_tautomer_smiles", "(", "smiles", ")", ":", "# Skip sanitize as standardize does this anyway", "mol", "=", "Chem", ".", "MolFromSmiles", "(", "smiles", ",", "sanitize", "=", "False", ")", "mol", "=", "Standardizer", "(", ")", ".", "standardize", ...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.standardize
Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :py:func:`~rdkit.Chem.rdmolops.RemoveHs`, RDKit :py:func:`~rdkit.Chem.rdmolops.SanitizeMol`, :class:`~molvs.metal.MetalDisconnector`, :class:`~molvs.normalize.Normalizer`, ...
molvs/standardize.py
def standardize(self, mol): """Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :py:func:`~rdkit.Chem.rdmolops.RemoveHs`, RDKit :py:func:`~rdkit.Chem.rdmolops.SanitizeMol`, :class:`~molvs.metal.MetalDisconnector`, :cla...
def standardize(self, mol): """Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :py:func:`~rdkit.Chem.rdmolops.RemoveHs`, RDKit :py:func:`~rdkit.Chem.rdmolops.SanitizeMol`, :class:`~molvs.metal.MetalDisconnector`, :cla...
[ "Return", "a", "standardized", "version", "the", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L78-L99
[ "def", "standardize", "(", "self", ",", "mol", ")", ":", "mol", "=", "copy", ".", "deepcopy", "(", "mol", ")", "Chem", ".", "SanitizeMol", "(", "mol", ")", "mol", "=", "Chem", ".", "RemoveHs", "(", "mol", ")", "mol", "=", "self", ".", "disconnect_m...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.tautomer_parent
Return the tautomer parent of a given molecule. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been standardized. :returns: The tautomer parent molecule. :rtype: rdkit.Chem.rdchem.Mol
molvs/standardize.py
def tautomer_parent(self, mol, skip_standardize=False): """Return the tautomer parent of a given molecule. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been standardized. :returns: The tautomer pare...
def tautomer_parent(self, mol, skip_standardize=False): """Return the tautomer parent of a given molecule. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been standardized. :returns: The tautomer pare...
[ "Return", "the", "tautomer", "parent", "of", "a", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L101-L114
[ "def", "tautomer_parent", "(", "self", ",", "mol", ",", "skip_standardize", "=", "False", ")", ":", "if", "not", "skip_standardize", ":", "mol", "=", "self", ".", "standardize", "(", "mol", ")", "tautomer", "=", "self", ".", "canonicalize_tautomer", "(", "...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.fragment_parent
Return the fragment parent of a given molecule. The fragment parent is the largest organic covalent unit in the molecule. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been standardized. :returns: T...
molvs/standardize.py
def fragment_parent(self, mol, skip_standardize=False): """Return the fragment parent of a given molecule. The fragment parent is the largest organic covalent unit in the molecule. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Se...
def fragment_parent(self, mol, skip_standardize=False): """Return the fragment parent of a given molecule. The fragment parent is the largest organic covalent unit in the molecule. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Se...
[ "Return", "the", "fragment", "parent", "of", "a", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L116-L131
[ "def", "fragment_parent", "(", "self", ",", "mol", ",", "skip_standardize", "=", "False", ")", ":", "if", "not", "skip_standardize", ":", "mol", "=", "self", ".", "standardize", "(", "mol", ")", "# TODO: Consider applying FragmentRemover first to remove salts, solvent...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.stereo_parent
Return the stereo parent of a given molecule. The stereo parent has all stereochemistry information removed from tetrahedral centers and double bonds. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been stan...
molvs/standardize.py
def stereo_parent(self, mol, skip_standardize=False): """Return the stereo parent of a given molecule. The stereo parent has all stereochemistry information removed from tetrahedral centers and double bonds. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :para...
def stereo_parent(self, mol, skip_standardize=False): """Return the stereo parent of a given molecule. The stereo parent has all stereochemistry information removed from tetrahedral centers and double bonds. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :para...
[ "Return", "the", "stereo", "parent", "of", "a", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L133-L149
[ "def", "stereo_parent", "(", "self", ",", "mol", ",", "skip_standardize", "=", "False", ")", ":", "if", "not", "skip_standardize", ":", "mol", "=", "self", ".", "standardize", "(", "mol", ")", "else", ":", "mol", "=", "copy", ".", "deepcopy", "(", "mol...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.isotope_parent
Return the isotope parent of a given molecule. The isotope parent has all atoms replaced with the most abundant isotope for that element. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been standardized. ...
molvs/standardize.py
def isotope_parent(self, mol, skip_standardize=False): """Return the isotope parent of a given molecule. The isotope parent has all atoms replaced with the most abundant isotope for that element. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_...
def isotope_parent(self, mol, skip_standardize=False): """Return the isotope parent of a given molecule. The isotope parent has all atoms replaced with the most abundant isotope for that element. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_...
[ "Return", "the", "isotope", "parent", "of", "a", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L151-L169
[ "def", "isotope_parent", "(", "self", ",", "mol", ",", "skip_standardize", "=", "False", ")", ":", "if", "not", "skip_standardize", ":", "mol", "=", "self", ".", "standardize", "(", "mol", ")", "else", ":", "mol", "=", "copy", ".", "deepcopy", "(", "mo...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.charge_parent
Return the charge parent of a given molecule. The charge parent is the uncharged version of the fragment parent. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True if mol has already been standardized. :returns: The charge...
molvs/standardize.py
def charge_parent(self, mol, skip_standardize=False): """Return the charge parent of a given molecule. The charge parent is the uncharged version of the fragment parent. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True i...
def charge_parent(self, mol, skip_standardize=False): """Return the charge parent of a given molecule. The charge parent is the uncharged version of the fragment parent. :param mol: The input molecule. :type mol: rdkit.Chem.rdchem.Mol :param bool skip_standardize: Set to True i...
[ "Return", "the", "charge", "parent", "of", "a", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L171-L190
[ "def", "charge_parent", "(", "self", ",", "mol", ",", "skip_standardize", "=", "False", ")", ":", "# TODO: All ionized acids and bases should be neutralised.", "if", "not", "skip_standardize", ":", "mol", "=", "self", ".", "standardize", "(", "mol", ")", "fragment",...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.super_parent
Return the super parent of a given molecule. THe super parent is fragment, charge, isotope, stereochemistry and tautomer insensitive. From the input molecule, the largest fragment is taken. This is uncharged and then isotope and stereochemistry information is discarded. Finally, the canonical t...
molvs/standardize.py
def super_parent(self, mol, skip_standardize=False): """Return the super parent of a given molecule. THe super parent is fragment, charge, isotope, stereochemistry and tautomer insensitive. From the input molecule, the largest fragment is taken. This is uncharged and then isotope and stereochem...
def super_parent(self, mol, skip_standardize=False): """Return the super parent of a given molecule. THe super parent is fragment, charge, isotope, stereochemistry and tautomer insensitive. From the input molecule, the largest fragment is taken. This is uncharged and then isotope and stereochem...
[ "Return", "the", "super", "parent", "of", "a", "given", "molecule", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L192-L213
[ "def", "super_parent", "(", "self", ",", "mol", ",", "skip_standardize", "=", "False", ")", ":", "if", "not", "skip_standardize", ":", "mol", "=", "self", ".", "standardize", "(", "mol", ")", "# We don't need to get fragment parent, because the charge parent is the la...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Standardizer.canonicalize_tautomer
:returns: A callable :class:`~molvs.tautomer.TautomerCanonicalizer` instance.
molvs/standardize.py
def canonicalize_tautomer(self): """ :returns: A callable :class:`~molvs.tautomer.TautomerCanonicalizer` instance. """ return TautomerCanonicalizer(transforms=self.tautomer_transforms, scores=self.tautomer_scores, max_tautomers=self.max_tautomers)
def canonicalize_tautomer(self): """ :returns: A callable :class:`~molvs.tautomer.TautomerCanonicalizer` instance. """ return TautomerCanonicalizer(transforms=self.tautomer_transforms, scores=self.tautomer_scores, max_tautomers=self.max_tautomers)
[ ":", "returns", ":", "A", "callable", ":", "class", ":", "~molvs", ".", "tautomer", ".", "TautomerCanonicalizer", "instance", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L281-L286
[ "def", "canonicalize_tautomer", "(", "self", ")", ":", "return", "TautomerCanonicalizer", "(", "transforms", "=", "self", ".", "tautomer_transforms", ",", "scores", "=", "self", ".", "tautomer_scores", ",", "max_tautomers", "=", "self", ".", "max_tautomers", ")" ]
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
main
Main function for molvs command line interface.
molvs/cli.py
def main(): """Main function for molvs command line interface.""" # Root options parser = MolvsParser(epilog='use "molvs <command> -h" to show help for a specific command') subparsers = parser.add_subparsers(title='Available commands') # Options common to all commands common_parser = MolvsPar...
def main(): """Main function for molvs command line interface.""" # Root options parser = MolvsParser(epilog='use "molvs <command> -h" to show help for a specific command') subparsers = parser.add_subparsers(title='Available commands') # Options common to all commands common_parser = MolvsPar...
[ "Main", "function", "for", "molvs", "command", "line", "interface", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/cli.py#L35-L65
[ "def", "main", "(", ")", ":", "# Root options", "parser", "=", "MolvsParser", "(", "epilog", "=", "'use \"molvs <command> -h\" to show help for a specific command'", ")", "subparsers", "=", "parser", ".", "add_subparsers", "(", "title", "=", "'Available commands'", ")",...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Reionizer.reionize
Enforce charges on certain atoms, then perform competitive reionization. First, charge corrections are applied to ensure, for example, that free metals are correctly ionized. Then, if a molecule with multiple acid groups is partially ionized, ensure the strongest acids ionize first. The algori...
molvs/charge.py
def reionize(self, mol): """Enforce charges on certain atoms, then perform competitive reionization. First, charge corrections are applied to ensure, for example, that free metals are correctly ionized. Then, if a molecule with multiple acid groups is partially ionized, ensure the strongest aci...
def reionize(self, mol): """Enforce charges on certain atoms, then perform competitive reionization. First, charge corrections are applied to ensure, for example, that free metals are correctly ionized. Then, if a molecule with multiple acid groups is partially ionized, ensure the strongest aci...
[ "Enforce", "charges", "on", "certain", "atoms", "then", "perform", "competitive", "reionization", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/charge.py#L154-L241
[ "def", "reionize", "(", "self", ",", "mol", ")", ":", "log", ".", "debug", "(", "'Running Reionizer'", ")", "start_charge", "=", "Chem", ".", "GetFormalCharge", "(", "mol", ")", "# Apply forced charge corrections", "for", "cc", "in", "self", ".", "charge_corre...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Uncharger.uncharge
Neutralize molecule by adding/removing hydrogens. :param mol: The molecule to uncharge. :type mol: rdkit.Chem.rdchem.Mol :return: The uncharged molecule. :rtype: rdkit.Chem.rdchem.Mol
molvs/charge.py
def uncharge(self, mol): """Neutralize molecule by adding/removing hydrogens. :param mol: The molecule to uncharge. :type mol: rdkit.Chem.rdchem.Mol :return: The uncharged molecule. :rtype: rdkit.Chem.rdchem.Mol """ log.debug('Running Uncharger') mol = co...
def uncharge(self, mol): """Neutralize molecule by adding/removing hydrogens. :param mol: The molecule to uncharge. :type mol: rdkit.Chem.rdchem.Mol :return: The uncharged molecule. :rtype: rdkit.Chem.rdchem.Mol """ log.debug('Running Uncharger') mol = co...
[ "Neutralize", "molecule", "by", "adding", "/", "removing", "hydrogens", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/charge.py#L272-L314
[ "def", "uncharge", "(", "self", ",", "mol", ")", ":", "log", ".", "debug", "(", "'Running Uncharger'", ")", "mol", "=", "copy", ".", "deepcopy", "(", "mol", ")", "# Neutralize positive charges", "pos_remainder", "=", "0", "neg_count", "=", "0", "for", "ato...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
Uncharger._get_neg_skip
Get negatively charged atoms to skip (up to pos_count).
molvs/charge.py
def _get_neg_skip(self, mol, pos_count): """Get negatively charged atoms to skip (up to pos_count).""" neg_skip = set() if pos_count: # Get negative oxygens in charge-separated nitro groups TODO: Any other special cases to skip? for occurrence in mol.GetSubstructMatches(s...
def _get_neg_skip(self, mol, pos_count): """Get negatively charged atoms to skip (up to pos_count).""" neg_skip = set() if pos_count: # Get negative oxygens in charge-separated nitro groups TODO: Any other special cases to skip? for occurrence in mol.GetSubstructMatches(s...
[ "Get", "negatively", "charged", "atoms", "to", "skip", "(", "up", "to", "pos_count", ")", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/charge.py#L316-L331
[ "def", "_get_neg_skip", "(", "self", ",", "mol", ",", "pos_count", ")", ":", "neg_skip", "=", "set", "(", ")", "if", "pos_count", ":", "# Get negative oxygens in charge-separated nitro groups TODO: Any other special cases to skip?", "for", "occurrence", "in", "mol", "."...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
FragmentRemover.remove
Return the molecule with specified fragments removed. :param mol: The molecule to remove fragments from. :type mol: rdkit.Chem.rdchem.Mol :return: The molecule with fragments removed. :rtype: rdkit.Chem.rdchem.Mol
molvs/fragment.py
def remove(self, mol): """Return the molecule with specified fragments removed. :param mol: The molecule to remove fragments from. :type mol: rdkit.Chem.rdchem.Mol :return: The molecule with fragments removed. :rtype: rdkit.Chem.rdchem.Mol """ log.debug('Running ...
def remove(self, mol): """Return the molecule with specified fragments removed. :param mol: The molecule to remove fragments from. :type mol: rdkit.Chem.rdchem.Mol :return: The molecule with fragments removed. :rtype: rdkit.Chem.rdchem.Mol """ log.debug('Running ...
[ "Return", "the", "molecule", "with", "specified", "fragments", "removed", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/fragment.py#L157-L179
[ "def", "remove", "(", "self", ",", "mol", ")", ":", "log", ".", "debug", "(", "'Running FragmentRemover'", ")", "# Iterate FragmentPatterns and remove matching fragments", "for", "frag", "in", "self", ".", "fragments", ":", "# If nothing is left or leave_last and only one...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
LargestFragmentChooser.choose
Return the largest covalent unit. The largest fragment is determined by number of atoms (including hydrogens). Ties are broken by taking the fragment with the higher molecular weight, and then by taking the first alphabetically by SMILES if needed. :param mol: The molecule to choose the larges...
molvs/fragment.py
def choose(self, mol): """Return the largest covalent unit. The largest fragment is determined by number of atoms (including hydrogens). Ties are broken by taking the fragment with the higher molecular weight, and then by taking the first alphabetically by SMILES if needed. :param mol:...
def choose(self, mol): """Return the largest covalent unit. The largest fragment is determined by number of atoms (including hydrogens). Ties are broken by taking the fragment with the higher molecular weight, and then by taking the first alphabetically by SMILES if needed. :param mol:...
[ "Return", "the", "largest", "covalent", "unit", "." ]
mcs07/MolVS
python
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/fragment.py#L200-L243
[ "def", "choose", "(", "self", ",", "mol", ")", ":", "log", ".", "debug", "(", "'Running LargestFragmentChooser'", ")", "# TODO: Alternatively allow a list of fragments to be passed as the mol parameter", "fragments", "=", "Chem", ".", "GetMolFrags", "(", "mol", ",", "as...
d815fe52d160abcecbcbf117e6437bf727dbd8ad
test
integrate_ivp
Example program integrating an IVP problem of van der Pol oscillator
examples/van_der_pol.py
def integrate_ivp(u0=1.0, v0=0.0, mu=1.0, tend=10.0, dt0=1e-8, nt=0, nsteps=600, t0=0.0, atol=1e-8, rtol=1e-8, plot=False, savefig='None', method='bdf', dpi=100, verbose=False): """ Example program integrating an IVP problem of van der Pol oscillator """ f, j = get_f_...
def integrate_ivp(u0=1.0, v0=0.0, mu=1.0, tend=10.0, dt0=1e-8, nt=0, nsteps=600, t0=0.0, atol=1e-8, rtol=1e-8, plot=False, savefig='None', method='bdf', dpi=100, verbose=False): """ Example program integrating an IVP problem of van der Pol oscillator """ f, j = get_f_...
[ "Example", "program", "integrating", "an", "IVP", "problem", "of", "van", "der", "Pol", "oscillator" ]
bjodah/pycvodes
python
https://github.com/bjodah/pycvodes/blob/00637a682d363319bc5c7c73a78f033556fde8a5/examples/van_der_pol.py#L25-L50
[ "def", "integrate_ivp", "(", "u0", "=", "1.0", ",", "v0", "=", "0.0", ",", "mu", "=", "1.0", ",", "tend", "=", "10.0", ",", "dt0", "=", "1e-8", ",", "nt", "=", "0", ",", "nsteps", "=", "600", ",", "t0", "=", "0.0", ",", "atol", "=", "1e-8", ...
00637a682d363319bc5c7c73a78f033556fde8a5
test
integrate_adaptive
Integrates a system of ordinary differential equations. Solves the initial value problem (IVP) defined by the user supplied arguments. The solver chooses at what values of the independent variable results should be reported. Parameters ---------- rhs : callable Function with signature ...
pycvodes/__init__.py
def integrate_adaptive(rhs, jac, y0, x0, xend, atol, rtol, dx0=.0, dx_min=.0, dx_max=.0, nsteps=500, method=None, nderiv=0, roots=None, nroots=0, return_on_root=False, check_callable=False, check_indexing=False, **kwargs): "...
def integrate_adaptive(rhs, jac, y0, x0, xend, atol, rtol, dx0=.0, dx_min=.0, dx_max=.0, nsteps=500, method=None, nderiv=0, roots=None, nroots=0, return_on_root=False, check_callable=False, check_indexing=False, **kwargs): "...
[ "Integrates", "a", "system", "of", "ordinary", "differential", "equations", "." ]
bjodah/pycvodes
python
https://github.com/bjodah/pycvodes/blob/00637a682d363319bc5c7c73a78f033556fde8a5/pycvodes/__init__.py#L21-L147
[ "def", "integrate_adaptive", "(", "rhs", ",", "jac", ",", "y0", ",", "x0", ",", "xend", ",", "atol", ",", "rtol", ",", "dx0", "=", ".0", ",", "dx_min", "=", ".0", ",", "dx_max", "=", ".0", ",", "nsteps", "=", "500", ",", "method", "=", "None", ...
00637a682d363319bc5c7c73a78f033556fde8a5
test
integrate_predefined
Integrates a system of ordinary differential equations. Solves the initial value problem (IVP) defined by the user supplied arguments. The user chooses at what values of the independent variable results should be reported. Parameters ---------- rhs : callable Function with signature f(...
pycvodes/__init__.py
def integrate_predefined(rhs, jac, y0, xout, atol, rtol, jac_type="dense", dx0=.0, dx_min=.0, dx_max=.0, nsteps=500, method=None, nderiv=0, roots=None, nroots=0, check_callable=False, check_indexing=False, **kwargs): """ Integrates a system ...
def integrate_predefined(rhs, jac, y0, xout, atol, rtol, jac_type="dense", dx0=.0, dx_min=.0, dx_max=.0, nsteps=500, method=None, nderiv=0, roots=None, nroots=0, check_callable=False, check_indexing=False, **kwargs): """ Integrates a system ...
[ "Integrates", "a", "system", "of", "ordinary", "differential", "equations", "." ]
bjodah/pycvodes
python
https://github.com/bjodah/pycvodes/blob/00637a682d363319bc5c7c73a78f033556fde8a5/pycvodes/__init__.py#L150-L275
[ "def", "integrate_predefined", "(", "rhs", ",", "jac", ",", "y0", ",", "xout", ",", "atol", ",", "rtol", ",", "jac_type", "=", "\"dense\"", ",", "dx0", "=", ".0", ",", "dx_min", "=", ".0", ",", "dx_max", "=", ".0", ",", "nsteps", "=", "500", ",", ...
00637a682d363319bc5c7c73a78f033556fde8a5
test
GitHub_LLNL_Stats.get_stats
Retrieves the statistics from the given organization with the given credentials. Will not retreive data if file exists and force hasn't been set to True. This is to save GH API requests.
scripts/github_stats.py
def get_stats(self, username='', password='', organization='llnl', force=True, repo_type='public'): """ Retrieves the statistics from the given organization with the given credentials. Will not retreive data if file exists and force hasn't been set to True. This is to save GH API...
def get_stats(self, username='', password='', organization='llnl', force=True, repo_type='public'): """ Retrieves the statistics from the given organization with the given credentials. Will not retreive data if file exists and force hasn't been set to True. This is to save GH API...
[ "Retrieves", "the", "statistics", "from", "the", "given", "organization", "with", "the", "given", "credentials", ".", "Will", "not", "retreive", "data", "if", "file", "exists", "and", "force", "hasn", "t", "been", "set", "to", "True", ".", "This", "is", "t...
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L38-L86
[ "def", "get_stats", "(", "self", ",", "username", "=", "''", ",", "password", "=", "''", ",", "organization", "=", "'llnl'", ",", "force", "=", "True", ",", "repo_type", "=", "'public'", ")", ":", "date", "=", "str", "(", "datetime", ".", "date", "."...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_mems_of_org
Retrieves the number of members of the organization.
scripts/github_stats.py
def get_mems_of_org(self): """ Retrieves the number of members of the organization. """ print 'Getting members.' counter = 0 for member in self.org_retrieved.iter_members(): self.members_json[member.id] = member.to_json() counter += 1 retur...
def get_mems_of_org(self): """ Retrieves the number of members of the organization. """ print 'Getting members.' counter = 0 for member in self.org_retrieved.iter_members(): self.members_json[member.id] = member.to_json() counter += 1 retur...
[ "Retrieves", "the", "number", "of", "members", "of", "the", "organization", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L147-L156
[ "def", "get_mems_of_org", "(", "self", ")", ":", "print", "'Getting members.'", "counter", "=", "0", "for", "member", "in", "self", ".", "org_retrieved", ".", "iter_members", "(", ")", ":", "self", ".", "members_json", "[", "member", ".", "id", "]", "=", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_teams_of_org
Retrieves the number of teams of the organization.
scripts/github_stats.py
def get_teams_of_org(self): """ Retrieves the number of teams of the organization. """ print 'Getting teams.' counter = 0 for team in self.org_retrieved.iter_teams(): self.teams_json[team.id] = team.to_json() counter += 1 return counter
def get_teams_of_org(self): """ Retrieves the number of teams of the organization. """ print 'Getting teams.' counter = 0 for team in self.org_retrieved.iter_teams(): self.teams_json[team.id] = team.to_json() counter += 1 return counter
[ "Retrieves", "the", "number", "of", "teams", "of", "the", "organization", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L158-L167
[ "def", "get_teams_of_org", "(", "self", ")", ":", "print", "'Getting teams.'", "counter", "=", "0", "for", "team", "in", "self", ".", "org_retrieved", ".", "iter_teams", "(", ")", ":", "self", ".", "teams_json", "[", "team", ".", "id", "]", "=", "team", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.repos
Retrieves info about the repos of the current organization.
scripts/github_stats.py
def repos(self, repo_type='public', organization='llnl'): """ Retrieves info about the repos of the current organization. """ print 'Getting repos.' for repo in self.org_retrieved.iter_repos(type=repo_type): #JSON json = repo.to_json() self.rep...
def repos(self, repo_type='public', organization='llnl'): """ Retrieves info about the repos of the current organization. """ print 'Getting repos.' for repo in self.org_retrieved.iter_repos(type=repo_type): #JSON json = repo.to_json() self.rep...
[ "Retrieves", "info", "about", "the", "repos", "of", "the", "current", "organization", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L169-L207
[ "def", "repos", "(", "self", ",", "repo_type", "=", "'public'", ",", "organization", "=", "'llnl'", ")", ":", "print", "'Getting repos.'", "for", "repo", "in", "self", ".", "org_retrieved", ".", "iter_repos", "(", "type", "=", "repo_type", ")", ":", "#JSON...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_total_contributors
Retrieves the number of contributors to a repo in the organization. Also adds to unique contributor list.
scripts/github_stats.py
def get_total_contributors(self, repo): """ Retrieves the number of contributors to a repo in the organization. Also adds to unique contributor list. """ repo_contributors = 0 for contributor in repo.iter_contributors(): repo_contributors += 1 self...
def get_total_contributors(self, repo): """ Retrieves the number of contributors to a repo in the organization. Also adds to unique contributor list. """ repo_contributors = 0 for contributor in repo.iter_contributors(): repo_contributors += 1 self...
[ "Retrieves", "the", "number", "of", "contributors", "to", "a", "repo", "in", "the", "organization", ".", "Also", "adds", "to", "unique", "contributor", "list", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L209-L219
[ "def", "get_total_contributors", "(", "self", ",", "repo", ")", ":", "repo_contributors", "=", "0", "for", "contributor", "in", "repo", ".", "iter_contributors", "(", ")", ":", "repo_contributors", "+=", "1", "self", ".", "unique_contributors", "[", "contributor...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_pull_reqs
Retrieves the number of pull requests on a repo in the organization.
scripts/github_stats.py
def get_pull_reqs(self, repo): """ Retrieves the number of pull requests on a repo in the organization. """ pull_reqs_open = 0 pull_reqs_closed = 0 for pull_request in repo.iter_pulls(state='all'): self.pull_requests_json[repo.name].append(pull_request.to_json...
def get_pull_reqs(self, repo): """ Retrieves the number of pull requests on a repo in the organization. """ pull_reqs_open = 0 pull_reqs_closed = 0 for pull_request in repo.iter_pulls(state='all'): self.pull_requests_json[repo.name].append(pull_request.to_json...
[ "Retrieves", "the", "number", "of", "pull", "requests", "on", "a", "repo", "in", "the", "organization", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L221-L233
[ "def", "get_pull_reqs", "(", "self", ",", "repo", ")", ":", "pull_reqs_open", "=", "0", "pull_reqs_closed", "=", "0", "for", "pull_request", "in", "repo", ".", "iter_pulls", "(", "state", "=", "'all'", ")", ":", "self", ".", "pull_requests_json", "[", "rep...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_issues
Retrieves the number of closed issues.
scripts/github_stats.py
def get_issues(self, repo, organization='llnl'): """ Retrieves the number of closed issues. """ #JSON path = ('../github-data/' + organization + '/' + repo.name + '/issues') is_only_today = False if not os.path.exists(path): #no previous path, get all issues ...
def get_issues(self, repo, organization='llnl'): """ Retrieves the number of closed issues. """ #JSON path = ('../github-data/' + organization + '/' + repo.name + '/issues') is_only_today = False if not os.path.exists(path): #no previous path, get all issues ...
[ "Retrieves", "the", "number", "of", "closed", "issues", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L235-L265
[ "def", "get_issues", "(", "self", ",", "repo", ",", "organization", "=", "'llnl'", ")", ":", "#JSON", "path", "=", "(", "'../github-data/'", "+", "organization", "+", "'/'", "+", "repo", ".", "name", "+", "'/issues'", ")", "is_only_today", "=", "False", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_languages
Retrieves the languages used in the repo and increments the respective counts of those languages. Only increments languages that have names. Anything else is not incremented (i.e. numbers).
scripts/github_stats.py
def get_languages(self, repo, temp_repo): """ Retrieves the languages used in the repo and increments the respective counts of those languages. Only increments languages that have names. Anything else is not incremented (i.e. numbers). """ try: self.languages[...
def get_languages(self, repo, temp_repo): """ Retrieves the languages used in the repo and increments the respective counts of those languages. Only increments languages that have names. Anything else is not incremented (i.e. numbers). """ try: self.languages[...
[ "Retrieves", "the", "languages", "used", "in", "the", "repo", "and", "increments", "the", "respective", "counts", "of", "those", "languages", ".", "Only", "increments", "languages", "that", "have", "names", ".", "Anything", "else", "is", "not", "incremented", ...
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L267-L289
[ "def", "get_languages", "(", "self", ",", "repo", ",", "temp_repo", ")", ":", "try", ":", "self", ".", "languages", "[", "repo", ".", "language", "]", "+=", "1", "except", "KeyError", ":", "count", "=", "self", ".", "languages", "[", "repo", ".", "la...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_readme
Checks to see if the given repo has a ReadMe. MD means it has a correct Readme recognized by GitHub.
scripts/github_stats.py
def get_readme(self, repo): """ Checks to see if the given repo has a ReadMe. MD means it has a correct Readme recognized by GitHub. """ readme_contents = repo.readme() if readme_contents is not None: self.total_readmes += 1 return 'MD' if ...
def get_readme(self, repo): """ Checks to see if the given repo has a ReadMe. MD means it has a correct Readme recognized by GitHub. """ readme_contents = repo.readme() if readme_contents is not None: self.total_readmes += 1 return 'MD' if ...
[ "Checks", "to", "see", "if", "the", "given", "repo", "has", "a", "ReadMe", ".", "MD", "means", "it", "has", "a", "correct", "Readme", "recognized", "by", "GitHub", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L291-L315
[ "def", "get_readme", "(", "self", ",", "repo", ")", ":", "readme_contents", "=", "repo", ".", "readme", "(", ")", "if", "readme_contents", "is", "not", "None", ":", "self", ".", "total_readmes", "+=", "1", "return", "'MD'", "if", "self", ".", "search_lim...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_license
Checks to see if the given repo has a top level LICENSE file.
scripts/github_stats.py
def get_license(self, repo): """ Checks to see if the given repo has a top level LICENSE file. """ if self.search_limit >= 28: print 'Hit search limit. Sleeping for 60 sec.' time.sleep(60) self.search_limit = 0 self.search_limit += 1 se...
def get_license(self, repo): """ Checks to see if the given repo has a top level LICENSE file. """ if self.search_limit >= 28: print 'Hit search limit. Sleeping for 60 sec.' time.sleep(60) self.search_limit = 0 self.search_limit += 1 se...
[ "Checks", "to", "see", "if", "the", "given", "repo", "has", "a", "top", "level", "LICENSE", "file", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L317-L336
[ "def", "get_license", "(", "self", ",", "repo", ")", ":", "if", "self", ".", "search_limit", ">=", "28", ":", "print", "'Hit search limit. Sleeping for 60 sec.'", "time", ".", "sleep", "(", "60", ")", "self", ".", "search_limit", "=", "0", "self", ".", "se...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.get_commits
Retrieves the number of commits to a repo in the organization. If it is the first time getting commits for a repo, it will get all commits and save them to JSON. If there are previous commits saved, it will only get commits that have not been saved to disk since the last date of commits.
scripts/github_stats.py
def get_commits(self, repo, organization='llnl'): """ Retrieves the number of commits to a repo in the organization. If it is the first time getting commits for a repo, it will get all commits and save them to JSON. If there are previous commits saved, it will only get commits th...
def get_commits(self, repo, organization='llnl'): """ Retrieves the number of commits to a repo in the organization. If it is the first time getting commits for a repo, it will get all commits and save them to JSON. If there are previous commits saved, it will only get commits th...
[ "Retrieves", "the", "number", "of", "commits", "to", "a", "repo", "in", "the", "organization", ".", "If", "it", "is", "the", "first", "time", "getting", "commits", "for", "a", "repo", "it", "will", "get", "all", "commits", "and", "save", "them", "to", ...
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L338-L370
[ "def", "get_commits", "(", "self", ",", "repo", ",", "organization", "=", "'llnl'", ")", ":", "#JSON", "path", "=", "(", "'../github-data/'", "+", "organization", "+", "'/'", "+", "repo", ".", "name", "+", "'/commits'", ")", "is_only_today", "=", "False", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.write_org_json
Writes stats from the organization to JSON.
scripts/github_stats.py
def write_org_json(self, date=(datetime.date.today()), organization='llnl',dict_to_write={}, path_ending_type='', is_list=False): """ Writes stats from the organization to JSON. """ path = ('../github-data/' + organization + '-org/' + path_ending_type + '/' + ...
def write_org_json(self, date=(datetime.date.today()), organization='llnl',dict_to_write={}, path_ending_type='', is_list=False): """ Writes stats from the organization to JSON. """ path = ('../github-data/' + organization + '-org/' + path_ending_type + '/' + ...
[ "Writes", "stats", "from", "the", "organization", "to", "JSON", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L372-L393
[ "def", "write_org_json", "(", "self", ",", "date", "=", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ",", "organization", "=", "'llnl'", ",", "dict_to_write", "=", "{", "}", ",", "path_ending_type", "=", "''", ",", "is_list", "=", "False"...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.write_repo_json
#Writes repo specific data to JSON.
scripts/github_stats.py
def write_repo_json(self, date=(datetime.date.today()), organization='llnl', dict_to_write={}, path_ending_type='', is_list=False, is_dict=False): """ #Writes repo specific data to JSON. """ for repo in dict_to_write: path = ('../github-data/' + organization +...
def write_repo_json(self, date=(datetime.date.today()), organization='llnl', dict_to_write={}, path_ending_type='', is_list=False, is_dict=False): """ #Writes repo specific data to JSON. """ for repo in dict_to_write: path = ('../github-data/' + organization +...
[ "#Writes", "repo", "specific", "data", "to", "JSON", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L395-L422
[ "def", "write_repo_json", "(", "self", ",", "date", "=", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ",", "organization", "=", "'llnl'", ",", "dict_to_write", "=", "{", "}", ",", "path_ending_type", "=", "''", ",", "is_list", "=", "False...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.write_to_file
Writes the current organization information to file (csv).
scripts/github_stats.py
def write_to_file(self, file_path='', date=str(datetime.date.today()), organization='N/A', members=0, teams=0): """ Writes the current organization information to file (csv). """ self.checkDir(file_path) with open(file_path, 'w+') as output: output.write('date...
def write_to_file(self, file_path='', date=str(datetime.date.today()), organization='N/A', members=0, teams=0): """ Writes the current organization information to file (csv). """ self.checkDir(file_path) with open(file_path, 'w+') as output: output.write('date...
[ "Writes", "the", "current", "organization", "information", "to", "file", "(", "csv", ")", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L424-L462
[ "def", "write_to_file", "(", "self", ",", "file_path", "=", "''", ",", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ",", "organization", "=", "'N/A'", ",", "members", "=", "0", ",", "teams", "=", "0", ")", ":", "...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.write_totals
Updates the total.csv file with current data.
scripts/github_stats.py
def write_totals(self, file_path='', date=str(datetime.date.today()), organization='N/A', members=0, teams=0): """ Updates the total.csv file with current data. """ total_exists = os.path.isfile(file_path) with open(file_path, 'a') as out_total: if not total_...
def write_totals(self, file_path='', date=str(datetime.date.today()), organization='N/A', members=0, teams=0): """ Updates the total.csv file with current data. """ total_exists = os.path.isfile(file_path) with open(file_path, 'a') as out_total: if not total_...
[ "Updates", "the", "total", ".", "csv", "file", "with", "current", "data", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L464-L496
[ "def", "write_totals", "(", "self", ",", "file_path", "=", "''", ",", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ",", "organization", "=", "'N/A'", ",", "members", "=", "0", ",", "teams", "=", "0", ")", ":", "t...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.write_languages
Updates languages.csv file with current data.
scripts/github_stats.py
def write_languages(self, file_path='',date=str(datetime.date.today())): """ Updates languages.csv file with current data. """ self.remove_date(file_path=file_path, date=date) languages_exists = os.path.isfile(file_path) with open(file_path, 'a') as out_languages: ...
def write_languages(self, file_path='',date=str(datetime.date.today())): """ Updates languages.csv file with current data. """ self.remove_date(file_path=file_path, date=date) languages_exists = os.path.isfile(file_path) with open(file_path, 'a') as out_languages: ...
[ "Updates", "languages", ".", "csv", "file", "with", "current", "data", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L498-L521
[ "def", "write_languages", "(", "self", ",", "file_path", "=", "''", ",", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ")", ":", "self", ".", "remove_date", "(", "file_path", "=", "file_path", ",", "date", "=", "date"...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.checkDir
Checks if a directory exists. If not, it creates one with the specified file_path.
scripts/github_stats.py
def checkDir(self, file_path=''): """ Checks if a directory exists. If not, it creates one with the specified file_path. """ if not os.path.exists(os.path.dirname(file_path)): try: os.makedirs(os.path.dirname(file_path)) except OSError as e...
def checkDir(self, file_path=''): """ Checks if a directory exists. If not, it creates one with the specified file_path. """ if not os.path.exists(os.path.dirname(file_path)): try: os.makedirs(os.path.dirname(file_path)) except OSError as e...
[ "Checks", "if", "a", "directory", "exists", ".", "If", "not", "it", "creates", "one", "with", "the", "specified", "file_path", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L523-L533
[ "def", "checkDir", "(", "self", ",", "file_path", "=", "''", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "dirname", "(", "file_path", ")", ")", ":", "try", ":", "os", ".", "makedirs", "(", "os", ".", "p...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.remove_date
Removes all rows of the associated date from the given csv file. Defaults to today.
scripts/github_stats.py
def remove_date(self, file_path='', date=str(datetime.date.today())): """ Removes all rows of the associated date from the given csv file. Defaults to today. """ languages_exists = os.path.isfile(file_path) if languages_exists: with open(file_path, 'rb') as in...
def remove_date(self, file_path='', date=str(datetime.date.today())): """ Removes all rows of the associated date from the given csv file. Defaults to today. """ languages_exists = os.path.isfile(file_path) if languages_exists: with open(file_path, 'rb') as in...
[ "Removes", "all", "rows", "of", "the", "associated", "date", "from", "the", "given", "csv", "file", ".", "Defaults", "to", "today", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L535-L550
[ "def", "remove_date", "(", "self", ",", "file_path", "=", "''", ",", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ")", ":", "languages_exists", "=", "os", ".", "path", ".", "isfile", "(", "file_path", ")", "if", "l...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_LLNL_Stats.delete_last_line
The following code was modified from http://stackoverflow.com/a/10289740 & http://stackoverflow.com/a/17309010 It essentially will check if the total for the current date already exists in total.csv. If it does, it just removes the last line. This is so the script could be run mo...
scripts/github_stats.py
def delete_last_line(self, file_path='', date=str(datetime.date.today())): """ The following code was modified from http://stackoverflow.com/a/10289740 & http://stackoverflow.com/a/17309010 It essentially will check if the total for the current date already exists in tota...
def delete_last_line(self, file_path='', date=str(datetime.date.today())): """ The following code was modified from http://stackoverflow.com/a/10289740 & http://stackoverflow.com/a/17309010 It essentially will check if the total for the current date already exists in tota...
[ "The", "following", "code", "was", "modified", "from", "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "10289740", "&", "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "17309010", "It", "essentially", "will", "check", "if", ...
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/github_stats.py#L552-L579
[ "def", "delete_last_line", "(", "self", ",", "file_path", "=", "''", ",", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ")", ":", "deleted_line", "=", "False", "if", "os", ".", "path", ".", "isfile", "(", "file_path",...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
gov_orgs
Returns a list of the names of US Government GitHub organizations Based on: https://government.github.com/community/ Exmample return: {'llnl', '18f', 'gsa', 'dhs-ncats', 'spack', ...}
scraper/github/__init__.py
def gov_orgs(): """ Returns a list of the names of US Government GitHub organizations Based on: https://government.github.com/community/ Exmample return: {'llnl', '18f', 'gsa', 'dhs-ncats', 'spack', ...} """ us_gov_github_orgs = set() gov_orgs = requests.get('https://government.gi...
def gov_orgs(): """ Returns a list of the names of US Government GitHub organizations Based on: https://government.github.com/community/ Exmample return: {'llnl', '18f', 'gsa', 'dhs-ncats', 'spack', ...} """ us_gov_github_orgs = set() gov_orgs = requests.get('https://government.gi...
[ "Returns", "a", "list", "of", "the", "names", "of", "US", "Government", "GitHub", "organizations" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/__init__.py#L14-L31
[ "def", "gov_orgs", "(", ")", ":", "us_gov_github_orgs", "=", "set", "(", ")", "gov_orgs", "=", "requests", ".", "get", "(", "'https://government.github.com/organizations.json'", ")", ".", "json", "(", ")", "us_gov_github_orgs", ".", "update", "(", "gov_orgs", "[...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
create_session
Create a github3.py session connected to GitHub.com If token is not provided, will attempt to use the GITHUB_API_TOKEN environment variable if present.
scraper/github/__init__.py
def create_session(token=None): """ Create a github3.py session connected to GitHub.com If token is not provided, will attempt to use the GITHUB_API_TOKEN environment variable if present. """ if token is None: token = os.environ.get('GITHUB_API_TOKEN', None) gh_session = github3.lo...
def create_session(token=None): """ Create a github3.py session connected to GitHub.com If token is not provided, will attempt to use the GITHUB_API_TOKEN environment variable if present. """ if token is None: token = os.environ.get('GITHUB_API_TOKEN', None) gh_session = github3.lo...
[ "Create", "a", "github3", ".", "py", "session", "connected", "to", "GitHub", ".", "com" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/__init__.py#L34-L49
[ "def", "create_session", "(", "token", "=", "None", ")", ":", "if", "token", "is", "None", ":", "token", "=", "os", ".", "environ", ".", "get", "(", "'GITHUB_API_TOKEN'", ",", "None", ")", "gh_session", "=", "github3", ".", "login", "(", "token", "=", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
create_enterprise_session
Create a github3.py session for a GitHub Enterprise instance If token is not provided, will attempt to use the GITHUB_API_TOKEN environment variable if present.
scraper/github/__init__.py
def create_enterprise_session(url, token=None): """ Create a github3.py session for a GitHub Enterprise instance If token is not provided, will attempt to use the GITHUB_API_TOKEN environment variable if present. """ gh_session = github3.enterprise_login(url=url, token=token) if gh_sessio...
def create_enterprise_session(url, token=None): """ Create a github3.py session for a GitHub Enterprise instance If token is not provided, will attempt to use the GITHUB_API_TOKEN environment variable if present. """ gh_session = github3.enterprise_login(url=url, token=token) if gh_sessio...
[ "Create", "a", "github3", ".", "py", "session", "for", "a", "GitHub", "Enterprise", "instance" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/__init__.py#L52-L66
[ "def", "create_enterprise_session", "(", "url", ",", "token", "=", "None", ")", ":", "gh_session", "=", "github3", ".", "enterprise_login", "(", "url", "=", "url", ",", "token", "=", "token", ")", "if", "gh_session", "is", "None", ":", "msg", "=", "'Unab...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
_check_api_limits
Simplified check for API limits If necessary, spin in place waiting for API to reset before returning. See: https://developer.github.com/v3/#rate-limiting
scraper/github/__init__.py
def _check_api_limits(gh_session, api_required=250, sleep_time=15): """ Simplified check for API limits If necessary, spin in place waiting for API to reset before returning. See: https://developer.github.com/v3/#rate-limiting """ api_rates = gh_session.rate_limit() api_remaining = api_ra...
def _check_api_limits(gh_session, api_required=250, sleep_time=15): """ Simplified check for API limits If necessary, spin in place waiting for API to reset before returning. See: https://developer.github.com/v3/#rate-limiting """ api_rates = gh_session.rate_limit() api_remaining = api_ra...
[ "Simplified", "check", "for", "API", "limits" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/__init__.py#L76-L101
[ "def", "_check_api_limits", "(", "gh_session", ",", "api_required", "=", "250", ",", "sleep_time", "=", "15", ")", ":", "api_rates", "=", "gh_session", ".", "rate_limit", "(", ")", "api_remaining", "=", "api_rates", "[", "'rate'", "]", "[", "'remaining'", "]...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
connect
Create a GitHub session for making requests
scraper/github/__init__.py
def connect(url='https://github.com', token=None): """ Create a GitHub session for making requests """ gh_session = None if url == 'https://github.com': gh_session = create_session(token) else: gh_session = create_enterprise_session(url, token) if gh_session is None: ...
def connect(url='https://github.com', token=None): """ Create a GitHub session for making requests """ gh_session = None if url == 'https://github.com': gh_session = create_session(token) else: gh_session = create_enterprise_session(url, token) if gh_session is None: ...
[ "Create", "a", "GitHub", "session", "for", "making", "requests" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/__init__.py#L104-L121
[ "def", "connect", "(", "url", "=", "'https://github.com'", ",", "token", "=", "None", ")", ":", "gh_session", "=", "None", "if", "url", "==", "'https://github.com'", ":", "gh_session", "=", "create_session", "(", "token", ")", "else", ":", "gh_session", "=",...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
query_repos
Yields GitHub3.py repo objects for provided orgs and repo names If orgs and repos are BOTH empty, execute special mode of getting ALL repositories from the GitHub Server. If public_only is True, will return only those repos that are marked as public. Set this to false to return all organizations that ...
scraper/github/__init__.py
def query_repos(gh_session, orgs=None, repos=None, public_only=True): """ Yields GitHub3.py repo objects for provided orgs and repo names If orgs and repos are BOTH empty, execute special mode of getting ALL repositories from the GitHub Server. If public_only is True, will return only those repos ...
def query_repos(gh_session, orgs=None, repos=None, public_only=True): """ Yields GitHub3.py repo objects for provided orgs and repo names If orgs and repos are BOTH empty, execute special mode of getting ALL repositories from the GitHub Server. If public_only is True, will return only those repos ...
[ "Yields", "GitHub3", ".", "py", "repo", "objects", "for", "provided", "orgs", "and", "repo", "names" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/__init__.py#L124-L164
[ "def", "query_repos", "(", "gh_session", ",", "orgs", "=", "None", ",", "repos", "=", "None", ",", "public_only", "=", "True", ")", ":", "if", "orgs", "is", "None", ":", "orgs", "=", "[", "]", "if", "repos", "is", "None", ":", "repos", "=", "[", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Stargazers.get_stats
Retrieves the traffic for the users of the given organization. Requires organization admin credentials token to access the data.
scripts/get_stargazers.py
def get_stats(self, username='', password='', organization='llnl', force=True): """ Retrieves the traffic for the users of the given organization. Requires organization admin credentials token to access the data. """ date = str(datetime.date.today()) stargazers_file_path ...
def get_stats(self, username='', password='', organization='llnl', force=True): """ Retrieves the traffic for the users of the given organization. Requires organization admin credentials token to access the data. """ date = str(datetime.date.today()) stargazers_file_path ...
[ "Retrieves", "the", "traffic", "for", "the", "users", "of", "the", "given", "organization", ".", "Requires", "organization", "admin", "credentials", "token", "to", "access", "the", "data", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_stargazers.py#L11-L29
[ "def", "get_stats", "(", "self", ",", "username", "=", "''", ",", "password", "=", "''", ",", "organization", "=", "'llnl'", ",", "force", "=", "True", ")", ":", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", "starga...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Stargazers.get_org
Retrieves an organization via given org name. If given empty string, prompts user for an org name.
scripts/get_stargazers.py
def get_org(self, organization_name=''): """ Retrieves an organization via given org name. If given empty string, prompts user for an org name. """ self.organization_name = organization_name if(organization_name == ''): self.organization_name = raw_input('Orga...
def get_org(self, organization_name=''): """ Retrieves an organization via given org name. If given empty string, prompts user for an org name. """ self.organization_name = organization_name if(organization_name == ''): self.organization_name = raw_input('Orga...
[ "Retrieves", "an", "organization", "via", "given", "org", "name", ".", "If", "given", "empty", "string", "prompts", "user", "for", "an", "org", "name", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_stargazers.py#L80-L89
[ "def", "get_org", "(", "self", ",", "organization_name", "=", "''", ")", ":", "self", ".", "organization_name", "=", "organization_name", "if", "(", "organization_name", "==", "''", ")", ":", "self", ".", "organization_name", "=", "raw_input", "(", "'Organizat...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Stargazers.get_repos
Gets the repos for the organization and builds the URL/headers for getting timestamps of stargazers.
scripts/get_stargazers.py
def get_repos(self): """ Gets the repos for the organization and builds the URL/headers for getting timestamps of stargazers. """ print 'Getting repos.' #Uses the developer API. Note this could change. headers = {'Accept': 'application/vnd.github.v3.star+json', '...
def get_repos(self): """ Gets the repos for the organization and builds the URL/headers for getting timestamps of stargazers. """ print 'Getting repos.' #Uses the developer API. Note this could change. headers = {'Accept': 'application/vnd.github.v3.star+json', '...
[ "Gets", "the", "repos", "for", "the", "organization", "and", "builds", "the", "URL", "/", "headers", "for", "getting", "timestamps", "of", "stargazers", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_stargazers.py#L91-L107
[ "def", "get_repos", "(", "self", ")", ":", "print", "'Getting repos.'", "#Uses the developer API. Note this could change.", "headers", "=", "{", "'Accept'", ":", "'application/vnd.github.v3.star+json'", ",", "'Authorization'", ":", "'token '", "+", "self", ".", "token", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Stargazers.get_stargazers
Return a list of the stargazers of a GitHub repo Includes both the 'starred_at' and 'user' data. param: url url is the 'stargazers_url' of the form: https://api.github.com/repos/LLNL/spack/stargazers
scripts/get_stargazers.py
def get_stargazers(self, url, headers={}): """ Return a list of the stargazers of a GitHub repo Includes both the 'starred_at' and 'user' data. param: url url is the 'stargazers_url' of the form: https://api.github.com/repos/LLNL/spack/stargazers """...
def get_stargazers(self, url, headers={}): """ Return a list of the stargazers of a GitHub repo Includes both the 'starred_at' and 'user' data. param: url url is the 'stargazers_url' of the form: https://api.github.com/repos/LLNL/spack/stargazers """...
[ "Return", "a", "list", "of", "the", "stargazers", "of", "a", "GitHub", "repo" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_stargazers.py#L109-L128
[ "def", "get_stargazers", "(", "self", ",", "url", ",", "headers", "=", "{", "}", ")", ":", "url", "=", "url", "+", "'/stargazers?per_page=100&page=%s'", "page", "=", "1", "gazers", "=", "[", "]", "json_data", "=", "requests", ".", "get", "(", "url", "%...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Stargazers.write_to_file
Writes stargazers data to file.
scripts/get_stargazers.py
def write_to_file(self, file_path='', date=(datetime.date.today()), organization='llnl'): """ Writes stargazers data to file. """ with open(file_path, 'w+') as out: out.write('date,organization,stargazers\n') sorted_stargazers = sorted(self.stargazers)#sor...
def write_to_file(self, file_path='', date=(datetime.date.today()), organization='llnl'): """ Writes stargazers data to file. """ with open(file_path, 'w+') as out: out.write('date,organization,stargazers\n') sorted_stargazers = sorted(self.stargazers)#sor...
[ "Writes", "stargazers", "data", "to", "file", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_stargazers.py#L147-L157
[ "def", "write_to_file", "(", "self", ",", "file_path", "=", "''", ",", "date", "=", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", ",", "organization", "=", "'llnl'", ")", ":", "with", "open", "(", "file_path", ",", "'w+'", ")", "as", "...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
Project.from_github3
Create CodeGovProject object from github3 Repository object
scraper/code_gov/models.py
def from_github3(klass, repository, labor_hours=True): """ Create CodeGovProject object from github3 Repository object """ if not isinstance(repository, github3.repos.repo._Repository): raise TypeError('Repository must be a github3 Repository object') logger.info('Pr...
def from_github3(klass, repository, labor_hours=True): """ Create CodeGovProject object from github3 Repository object """ if not isinstance(repository, github3.repos.repo._Repository): raise TypeError('Repository must be a github3 Repository object') logger.info('Pr...
[ "Create", "CodeGovProject", "object", "from", "github3", "Repository", "object" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/models.py#L178-L283
[ "def", "from_github3", "(", "klass", ",", "repository", ",", "labor_hours", "=", "True", ")", ":", "if", "not", "isinstance", "(", "repository", ",", "github3", ".", "repos", ".", "repo", ".", "_Repository", ")", ":", "raise", "TypeError", "(", "'Repositor...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
Project.from_gitlab
Create CodeGovProject object from GitLab Repository
scraper/code_gov/models.py
def from_gitlab(klass, repository, labor_hours=True): """ Create CodeGovProject object from GitLab Repository """ if not isinstance(repository, gitlab.v4.objects.Project): raise TypeError('Repository must be a gitlab Repository object') project = klass() log...
def from_gitlab(klass, repository, labor_hours=True): """ Create CodeGovProject object from GitLab Repository """ if not isinstance(repository, gitlab.v4.objects.Project): raise TypeError('Repository must be a gitlab Repository object') project = klass() log...
[ "Create", "CodeGovProject", "object", "from", "GitLab", "Repository" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/models.py#L286-L360
[ "def", "from_gitlab", "(", "klass", ",", "repository", ",", "labor_hours", "=", "True", ")", ":", "if", "not", "isinstance", "(", "repository", ",", "gitlab", ".", "v4", ".", "objects", ".", "Project", ")", ":", "raise", "TypeError", "(", "'Repository must...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
Project.from_stashy
Handles crafting Code.gov Project for Bitbucket Server repositories
scraper/code_gov/models.py
def from_stashy(klass, repository, labor_hours=True): """ Handles crafting Code.gov Project for Bitbucket Server repositories """ # if not isinstance(repository, stashy.repos.Repository): # raise TypeError('Repository must be a stashy Repository object') if not isinst...
def from_stashy(klass, repository, labor_hours=True): """ Handles crafting Code.gov Project for Bitbucket Server repositories """ # if not isinstance(repository, stashy.repos.Repository): # raise TypeError('Repository must be a stashy Repository object') if not isinst...
[ "Handles", "crafting", "Code", ".", "gov", "Project", "for", "Bitbucket", "Server", "repositories" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/models.py#L363-L447
[ "def", "from_stashy", "(", "klass", ",", "repository", ",", "labor_hours", "=", "True", ")", ":", "# if not isinstance(repository, stashy.repos.Repository):", "# raise TypeError('Repository must be a stashy Repository object')", "if", "not", "isinstance", "(", "repository", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
Project.from_doecode
Create CodeGovProject object from DOE CODE record Handles crafting Code.gov Project
scraper/code_gov/models.py
def from_doecode(klass, record): """ Create CodeGovProject object from DOE CODE record Handles crafting Code.gov Project """ if not isinstance(record, dict): raise TypeError('`record` must be a dict') project = klass() # -- REQUIRED FIELDS -- ...
def from_doecode(klass, record): """ Create CodeGovProject object from DOE CODE record Handles crafting Code.gov Project """ if not isinstance(record, dict): raise TypeError('`record` must be a dict') project = klass() # -- REQUIRED FIELDS -- ...
[ "Create", "CodeGovProject", "object", "from", "DOE", "CODE", "record" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/models.py#L450-L573
[ "def", "from_doecode", "(", "klass", ",", "record", ")", ":", "if", "not", "isinstance", "(", "record", ",", "dict", ")", ":", "raise", "TypeError", "(", "'`record` must be a dict'", ")", "project", "=", "klass", "(", ")", "# -- REQUIRED FIELDS --", "project",...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
Project.from_tfs
Creates CodeGovProject object from TFS/VSTS/AzureDevOps Instance
scraper/code_gov/models.py
def from_tfs(klass, tfs_project, labor_hours=True): """ Creates CodeGovProject object from TFS/VSTS/AzureDevOps Instance """ project = klass() project_web_url = '' # -- REQUIRED FIELDS -- project['name'] = tfs_project.projectInfo.name if 'web' in tfs_pro...
def from_tfs(klass, tfs_project, labor_hours=True): """ Creates CodeGovProject object from TFS/VSTS/AzureDevOps Instance """ project = klass() project_web_url = '' # -- REQUIRED FIELDS -- project['name'] = tfs_project.projectInfo.name if 'web' in tfs_pro...
[ "Creates", "CodeGovProject", "object", "from", "TFS", "/", "VSTS", "/", "AzureDevOps", "Instance" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/models.py#L576-L628
[ "def", "from_tfs", "(", "klass", ",", "tfs_project", ",", "labor_hours", "=", "True", ")", ":", "project", "=", "klass", "(", ")", "project_web_url", "=", "''", "# -- REQUIRED FIELDS --", "project", "[", "'name'", "]", "=", "tfs_project", ".", "projectInfo", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
process_config
Master function to process a Scraper config file Returns a Code.gov Metadata file
scraper/code_gov/__init__.py
def process_config(config): """ Master function to process a Scraper config file Returns a Code.gov Metadata file """ agency = config.get('agency', 'UNKNOWN') logger.debug('Agency: %s', agency) method = config.get('method', 'other') logger.debug('Inventory Method: %s', method) co...
def process_config(config): """ Master function to process a Scraper config file Returns a Code.gov Metadata file """ agency = config.get('agency', 'UNKNOWN') logger.debug('Agency: %s', agency) method = config.get('method', 'other') logger.debug('Inventory Method: %s', method) co...
[ "Master", "function", "to", "process", "a", "Scraper", "config", "file" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/__init__.py#L13-L128
[ "def", "process_config", "(", "config", ")", ":", "agency", "=", "config", ".", "get", "(", "'agency'", ",", "'UNKNOWN'", ")", "logger", ".", "debug", "(", "'Agency: %s'", ",", "agency", ")", "method", "=", "config", ".", "get", "(", "'method'", ",", "...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
force_attributes
Forces certain fields in the Code.gov Metadata json
scraper/code_gov/__init__.py
def force_attributes(metadata, config): """ Forces certain fields in the Code.gov Metadata json """ organization = config.get('organization', '') logger.debug('Organization: %s', organization) contact_email = config.get('contact_email') logger.debug('Contact Email: %s', contact_email) ...
def force_attributes(metadata, config): """ Forces certain fields in the Code.gov Metadata json """ organization = config.get('organization', '') logger.debug('Organization: %s', organization) contact_email = config.get('contact_email') logger.debug('Contact Email: %s', contact_email) ...
[ "Forces", "certain", "fields", "in", "the", "Code", ".", "gov", "Metadata", "json" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/__init__.py#L131-L172
[ "def", "force_attributes", "(", "metadata", ",", "config", ")", ":", "organization", "=", "config", ".", "get", "(", "'organization'", ",", "''", ")", "logger", ".", "debug", "(", "'Organization: %s'", ",", "organization", ")", "contact_email", "=", "config", ...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
_license_obj
A helper function to look up license object information Use names from: https://api.github.com/licenses
scraper/github/util.py
def _license_obj(license): """ A helper function to look up license object information Use names from: https://api.github.com/licenses """ obj = None if license in ('MIT', 'MIT License'): obj = { 'URL': 'https://api.github.com/licenses/mit', 'name': 'MIT' ...
def _license_obj(license): """ A helper function to look up license object information Use names from: https://api.github.com/licenses """ obj = None if license in ('MIT', 'MIT License'): obj = { 'URL': 'https://api.github.com/licenses/mit', 'name': 'MIT' ...
[ "A", "helper", "function", "to", "look", "up", "license", "object", "information" ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/util.py#L6-L89
[ "def", "_license_obj", "(", "license", ")", ":", "obj", "=", "None", "if", "license", "in", "(", "'MIT'", ",", "'MIT License'", ")", ":", "obj", "=", "{", "'URL'", ":", "'https://api.github.com/licenses/mit'", ",", "'name'", ":", "'MIT'", "}", "elif", "lic...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Traffic.get_stats
Retrieves the traffic for the users of the given organization. Requires organization admin credentials token to access the data.
scripts/get_traffic.py
def get_stats(self, username='', password='', organization='llnl', force=True): """ Retrieves the traffic for the users of the given organization. Requires organization admin credentials token to access the data. """ date = str(datetime.date.today()) referrers_file_path =...
def get_stats(self, username='', password='', organization='llnl', force=True): """ Retrieves the traffic for the users of the given organization. Requires organization admin credentials token to access the data. """ date = str(datetime.date.today()) referrers_file_path =...
[ "Retrieves", "the", "traffic", "for", "the", "users", "of", "the", "given", "organization", ".", "Requires", "organization", "admin", "credentials", "token", "to", "access", "the", "data", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_traffic.py#L18-L53
[ "def", "get_stats", "(", "self", ",", "username", "=", "''", ",", "password", "=", "''", ",", "organization", "=", "'llnl'", ",", "force", "=", "True", ")", ":", "date", "=", "str", "(", "datetime", ".", "date", ".", "today", "(", ")", ")", "referr...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea
test
GitHub_Traffic.get_traffic
Retrieves the traffic for the repositories of the given organization.
scripts/get_traffic.py
def get_traffic(self): """ Retrieves the traffic for the repositories of the given organization. """ print 'Getting traffic.' #Uses the developer API. Note this could change. headers = {'Accept': 'application/vnd.github.spiderman-preview', 'Authorization': 'token ' + self...
def get_traffic(self): """ Retrieves the traffic for the repositories of the given organization. """ print 'Getting traffic.' #Uses the developer API. Note this could change. headers = {'Accept': 'application/vnd.github.spiderman-preview', 'Authorization': 'token ' + self...
[ "Retrieves", "the", "traffic", "for", "the", "repositories", "of", "the", "given", "organization", "." ]
LLNL/scraper
python
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scripts/get_traffic.py#L115-L132
[ "def", "get_traffic", "(", "self", ")", ":", "print", "'Getting traffic.'", "#Uses the developer API. Note this could change.", "headers", "=", "{", "'Accept'", ":", "'application/vnd.github.spiderman-preview'", ",", "'Authorization'", ":", "'token '", "+", "self", ".", "...
881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea