partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ClientPool.connected_client
Returns a ContextManagerFuture to be yielded in a with statement. Returns: A ContextManagerFuture object. Examples: >>> with (yield pool.connected_client()) as client: # client is a connected tornadis.Client instance # it will be automati...
tornadis/pool.py
def connected_client(self): """Returns a ContextManagerFuture to be yielded in a with statement. Returns: A ContextManagerFuture object. Examples: >>> with (yield pool.connected_client()) as client: # client is a connected tornadis.Client instance ...
def connected_client(self): """Returns a ContextManagerFuture to be yielded in a with statement. Returns: A ContextManagerFuture object. Examples: >>> with (yield pool.connected_client()) as client: # client is a connected tornadis.Client instance ...
[ "Returns", "a", "ContextManagerFuture", "to", "be", "yielded", "in", "a", "with", "statement", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L132-L147
[ "def", "connected_client", "(", "self", ")", ":", "future", "=", "self", ".", "get_connected_client", "(", ")", "cb", "=", "functools", ".", "partial", "(", "self", ".", "_connected_client_release_cb", ",", "future", ")", "return", "ContextManagerFuture", "(", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
ClientPool.release_client
Releases a client object to the pool. Args: client: Client object.
tornadis/pool.py
def release_client(self, client): """Releases a client object to the pool. Args: client: Client object. """ if isinstance(client, Client): if not self._is_expired_client(client): LOG.debug('Client is not expired. Adding back to pool') ...
def release_client(self, client): """Releases a client object to the pool. Args: client: Client object. """ if isinstance(client, Client): if not self._is_expired_client(client): LOG.debug('Client is not expired. Adding back to pool') ...
[ "Releases", "a", "client", "object", "to", "the", "pool", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L153-L167
[ "def", "release_client", "(", "self", ",", "client", ")", ":", "if", "isinstance", "(", "client", ",", "Client", ")", ":", "if", "not", "self", ".", "_is_expired_client", "(", "client", ")", ":", "LOG", ".", "debug", "(", "'Client is not expired. Adding back...
f9dc883e46eb5971b62eab38346319757e5f900f
train
ClientPool.destroy
Disconnects all pooled client objects.
tornadis/pool.py
def destroy(self): """Disconnects all pooled client objects.""" while True: try: client = self.__pool.popleft() if isinstance(client, Client): client.disconnect() except IndexError: break
def destroy(self): """Disconnects all pooled client objects.""" while True: try: client = self.__pool.popleft() if isinstance(client, Client): client.disconnect() except IndexError: break
[ "Disconnects", "all", "pooled", "client", "objects", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L169-L177
[ "def", "destroy", "(", "self", ")", ":", "while", "True", ":", "try", ":", "client", "=", "self", ".", "__pool", ".", "popleft", "(", ")", "if", "isinstance", "(", "client", ",", "Client", ")", ":", "client", ".", "disconnect", "(", ")", "except", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
ClientPool.preconnect
(pre)Connects some or all redis clients inside the pool. Args: size (int): number of redis clients to build and to connect (-1 means all clients if pool max_size > -1) Raises: ClientError: when size == -1 and pool max_size == -1
tornadis/pool.py
def preconnect(self, size=-1): """(pre)Connects some or all redis clients inside the pool. Args: size (int): number of redis clients to build and to connect (-1 means all clients if pool max_size > -1) Raises: ClientError: when size == -1 and pool max_si...
def preconnect(self, size=-1): """(pre)Connects some or all redis clients inside the pool. Args: size (int): number of redis clients to build and to connect (-1 means all clients if pool max_size > -1) Raises: ClientError: when size == -1 and pool max_si...
[ "(", "pre", ")", "Connects", "some", "or", "all", "redis", "clients", "inside", "the", "pool", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L180-L195
[ "def", "preconnect", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "size", "==", "-", "1", "and", "self", ".", "max_size", "==", "-", "1", ":", "raise", "ClientError", "(", "\"size=-1 not allowed with pool max_size=-1\"", ")", "limit", "=", "m...
f9dc883e46eb5971b62eab38346319757e5f900f
train
setup_path
Setup python search and add ``TASKS_VENDOR_DIR`` (if available).
tasks/_setup.py
def setup_path(invoke_minversion=None): """Setup python search and add ``TASKS_VENDOR_DIR`` (if available).""" # print("INVOKE.tasks: setup_path") if not os.path.isdir(TASKS_VENDOR_DIR): print("SKIP: TASKS_VENDOR_DIR=%s is missing" % TASKS_VENDOR_DIR) return elif os.path.abspath(TASKS_VE...
def setup_path(invoke_minversion=None): """Setup python search and add ``TASKS_VENDOR_DIR`` (if available).""" # print("INVOKE.tasks: setup_path") if not os.path.isdir(TASKS_VENDOR_DIR): print("SKIP: TASKS_VENDOR_DIR=%s is missing" % TASKS_VENDOR_DIR) return elif os.path.abspath(TASKS_VE...
[ "Setup", "python", "search", "and", "add", "TASKS_VENDOR_DIR", "(", "if", "available", ")", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_setup.py#L30-L58
[ "def", "setup_path", "(", "invoke_minversion", "=", "None", ")", ":", "# print(\"INVOKE.tasks: setup_path\")", "if", "not", "os", ".", "path", ".", "isdir", "(", "TASKS_VENDOR_DIR", ")", ":", "print", "(", "\"SKIP: TASKS_VENDOR_DIR=%s is missing\"", "%", "TASKS_VENDOR...
a616204cb9944125fd5051556f27a7ccef611e22
train
require_invoke_minversion
Ensures that :mod:`invoke` has at the least the :param:`min_version`. Otherwise, :param min_version: Minimal acceptable invoke version (as string). :param verbose: Indicates if invoke.version should be shown. :raises: VersionRequirementError=SystemExit if requirement fails.
tasks/_setup.py
def require_invoke_minversion(min_version, verbose=False): """Ensures that :mod:`invoke` has at the least the :param:`min_version`. Otherwise, :param min_version: Minimal acceptable invoke version (as string). :param verbose: Indicates if invoke.version should be shown. :raises: VersionRequirem...
def require_invoke_minversion(min_version, verbose=False): """Ensures that :mod:`invoke` has at the least the :param:`min_version`. Otherwise, :param min_version: Minimal acceptable invoke version (as string). :param verbose: Indicates if invoke.version should be shown. :raises: VersionRequirem...
[ "Ensures", "that", ":", "mod", ":", "invoke", "has", "at", "the", "least", "the", ":", "param", ":", "min_version", ".", "Otherwise" ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_setup.py#L61-L85
[ "def", "require_invoke_minversion", "(", "min_version", ",", "verbose", "=", "False", ")", ":", "# -- REQUIRES: sys.path is setup and contains invoke", "try", ":", "import", "invoke", "invoke_version", "=", "invoke", ".", "__version__", "except", "ImportError", ":", "in...
a616204cb9944125fd5051556f27a7ccef611e22
train
matches_section
Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name(s). .. sourcecode:: @matches_section("foo") class FooSchema(SectionSchema): pass @matches_section(["bar", "baz.*"]) ...
click_configfile.py
def matches_section(section_name): """Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name(s). .. sourcecode:: @matches_section("foo") class FooSchema(SectionSchema): pass ...
def matches_section(section_name): """Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name(s). .. sourcecode:: @matches_section("foo") class FooSchema(SectionSchema): pass ...
[ "Decorator", "for", "SectionSchema", "classes", "to", "define", "the", "mapping", "between", "a", "config", "section", "schema", "class", "and", "one", "or", "more", "config", "sections", "with", "matching", "name", "(", "s", ")", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L30-L78
[ "def", "matches_section", "(", "section_name", ")", ":", "section_names", "=", "section_name", "if", "isinstance", "(", "section_name", ",", "six", ".", "string_types", ")", ":", "section_names", "=", "[", "section_name", "]", "elif", "not", "isinstance", "(", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
assign_param_names
Class decorator to assign parameter name to instances of :class:`Param`. .. sourcecode:: @assign_param_names class ConfigSectionSchema(object): alice = Param(type=str) bob = Param(type=str) assert ConfigSectionSchema.alice.name == "alice" assert ConfigSec...
click_configfile.py
def assign_param_names(cls=None, param_class=None): """Class decorator to assign parameter name to instances of :class:`Param`. .. sourcecode:: @assign_param_names class ConfigSectionSchema(object): alice = Param(type=str) bob = Param(type=str) assert ConfigS...
def assign_param_names(cls=None, param_class=None): """Class decorator to assign parameter name to instances of :class:`Param`. .. sourcecode:: @assign_param_names class ConfigSectionSchema(object): alice = Param(type=str) bob = Param(type=str) assert ConfigS...
[ "Class", "decorator", "to", "assign", "parameter", "name", "to", "instances", "of", ":", "class", ":", "Param", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L81-L126
[ "def", "assign_param_names", "(", "cls", "=", "None", ",", "param_class", "=", "None", ")", ":", "if", "param_class", "is", "None", ":", "param_class", "=", "Param", "def", "decorate_class", "(", "cls", ")", ":", "for", "name", ",", "value", "in", "selec...
a616204cb9944125fd5051556f27a7ccef611e22
train
select_params_from_section_schema
Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params
click_configfile.py
def select_params_from_section_schema(section_schema, param_class=Param, deep=False): """Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params """ # pylint: disable=inva...
def select_params_from_section_schema(section_schema, param_class=Param, deep=False): """Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params """ # pylint: disable=inva...
[ "Selects", "the", "parameters", "of", "a", "config", "section", "schema", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L203-L222
[ "def", "select_params_from_section_schema", "(", "section_schema", ",", "param_class", "=", "Param", ",", "deep", "=", "False", ")", ":", "# pylint: disable=invalid-name", "for", "name", ",", "value", "in", "inspect", ".", "getmembers", "(", "section_schema", ")", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
parse_config_section
Parse a config file section (INI file) by using its schema/description. .. sourcecode:: import configparser # -- NOTE: Use backport for Python2 import click from click_configfile import SectionSchema, Param, parse_config_section class ConfigSectionSchema(object): c...
click_configfile.py
def parse_config_section(config_section, section_schema): """Parse a config file section (INI file) by using its schema/description. .. sourcecode:: import configparser # -- NOTE: Use backport for Python2 import click from click_configfile import SectionSchema, Param, parse_config_...
def parse_config_section(config_section, section_schema): """Parse a config file section (INI file) by using its schema/description. .. sourcecode:: import configparser # -- NOTE: Use backport for Python2 import click from click_configfile import SectionSchema, Param, parse_config_...
[ "Parse", "a", "config", "file", "section", "(", "INI", "file", ")", "by", "using", "its", "schema", "/", "description", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L225-L274
[ "def", "parse_config_section", "(", "config_section", ",", "section_schema", ")", ":", "storage", "=", "{", "}", "for", "name", ",", "param", "in", "select_params_from_section_schema", "(", "section_schema", ")", ":", "value", "=", "config_section", ".", "get", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
generate_configfile_names
Generates all configuration file name combinations to read. .. sourcecode:: # -- ALGORITHM: # First basenames/directories are prefered and override other files. for config_path in reversed(config_searchpath): for config_basename in reversed(config_files): con...
click_configfile.py
def generate_configfile_names(config_files, config_searchpath=None): """Generates all configuration file name combinations to read. .. sourcecode:: # -- ALGORITHM: # First basenames/directories are prefered and override other files. for config_path in reversed(config_searchpath): ...
def generate_configfile_names(config_files, config_searchpath=None): """Generates all configuration file name combinations to read. .. sourcecode:: # -- ALGORITHM: # First basenames/directories are prefered and override other files. for config_path in reversed(config_searchpath): ...
[ "Generates", "all", "configuration", "file", "name", "combinations", "to", "read", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L280-L305
[ "def", "generate_configfile_names", "(", "config_files", ",", "config_searchpath", "=", "None", ")", ":", "if", "config_searchpath", "is", "None", ":", "config_searchpath", "=", "[", "\".\"", "]", "for", "config_path", "in", "reversed", "(", "config_searchpath", "...
a616204cb9944125fd5051556f27a7ccef611e22
train
select_config_sections
Select a subset of the sections in a configuration file by using a list of section names of list of section name patters (supporting :mod:`fnmatch` wildcards). :param configfile_sections: List of config section names (as strings). :param desired_section_patterns: :return: List of selected section n...
click_configfile.py
def select_config_sections(configfile_sections, desired_section_patterns): """Select a subset of the sections in a configuration file by using a list of section names of list of section name patters (supporting :mod:`fnmatch` wildcards). :param configfile_sections: List of config section names (as stri...
def select_config_sections(configfile_sections, desired_section_patterns): """Select a subset of the sections in a configuration file by using a list of section names of list of section name patters (supporting :mod:`fnmatch` wildcards). :param configfile_sections: List of config section names (as stri...
[ "Select", "a", "subset", "of", "the", "sections", "in", "a", "configuration", "file", "by", "using", "a", "list", "of", "section", "names", "of", "list", "of", "section", "name", "patters", "(", "supporting", ":", "mod", ":", "fnmatch", "wildcards", ")", ...
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L308-L320
[ "def", "select_config_sections", "(", "configfile_sections", ",", "desired_section_patterns", ")", ":", "for", "section_name", "in", "configfile_sections", ":", "for", "desired_section_pattern", "in", "desired_section_patterns", ":", "if", "fnmatch", "(", "section_name", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
SectionSchema.matches_section
Indicates if this schema can be used for a config section by using the section name. :param section_name: Config section name to check. :return: True, if this schema can be applied to the config section. :return: Fals, if this schema does not match the config section.
click_configfile.py
def matches_section(cls, section_name, supported_section_names=None): """Indicates if this schema can be used for a config section by using the section name. :param section_name: Config section name to check. :return: True, if this schema can be applied to the config section. ...
def matches_section(cls, section_name, supported_section_names=None): """Indicates if this schema can be used for a config section by using the section name. :param section_name: Config section name to check. :return: True, if this schema can be applied to the config section. ...
[ "Indicates", "if", "this", "schema", "can", "be", "used", "for", "a", "config", "section", "by", "using", "the", "section", "name", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L137-L153
[ "def", "matches_section", "(", "cls", ",", "section_name", ",", "supported_section_names", "=", "None", ")", ":", "if", "supported_section_names", "is", "None", ":", "supported_section_names", "=", "getattr", "(", "cls", ",", "\"section_names\"", ",", "None", ")",...
a616204cb9944125fd5051556f27a7ccef611e22
train
ConfigFileReader.collect_config_sections_from_schemas
Derive support config section names from config section schemas. If no :param:`config_section_schemas` are provided, the schemas from this class are used (normally defined in the DerivedClass). :param config_section_schemas: List of config section schema classes. :return: List of confi...
click_configfile.py
def collect_config_sections_from_schemas(cls, config_section_schemas=None): # pylint: disable=invalid-name """Derive support config section names from config section schemas. If no :param:`config_section_schemas` are provided, the schemas from this class are used (normally defined in the...
def collect_config_sections_from_schemas(cls, config_section_schemas=None): # pylint: disable=invalid-name """Derive support config section names from config section schemas. If no :param:`config_section_schemas` are provided, the schemas from this class are used (normally defined in the...
[ "Derive", "support", "config", "section", "names", "from", "config", "section", "schemas", ".", "If", "no", ":", "param", ":", "config_section_schemas", "are", "provided", "the", "schemas", "from", "this", "class", "are", "used", "(", "normally", "defined", "i...
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L405-L424
[ "def", "collect_config_sections_from_schemas", "(", "cls", ",", "config_section_schemas", "=", "None", ")", ":", "# pylint: disable=invalid-name", "if", "config_section_schemas", "is", "None", ":", "config_section_schemas", "=", "cls", ".", "config_section_schemas", "collec...
a616204cb9944125fd5051556f27a7ccef611e22
train
ConfigFileReader.process_config_section
Process the config section and store the extracted data in the param:`storage` (as outgoing param).
click_configfile.py
def process_config_section(cls, config_section, storage): """Process the config section and store the extracted data in the param:`storage` (as outgoing param). """ # -- CONCEPT: # if not storage: # # -- INIT DATA: With default parts. # storage.update(dict...
def process_config_section(cls, config_section, storage): """Process the config section and store the extracted data in the param:`storage` (as outgoing param). """ # -- CONCEPT: # if not storage: # # -- INIT DATA: With default parts. # storage.update(dict...
[ "Process", "the", "config", "section", "and", "store", "the", "extracted", "data", "in", "the", "param", ":", "storage", "(", "as", "outgoing", "param", ")", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L429-L446
[ "def", "process_config_section", "(", "cls", ",", "config_section", ",", "storage", ")", ":", "# -- CONCEPT:", "# if not storage:", "# # -- INIT DATA: With default parts.", "# storage.update(dict(_PERSONS={}))", "schema", "=", "cls", ".", "select_config_schema_for", "("...
a616204cb9944125fd5051556f27a7ccef611e22
train
ConfigFileReader.select_config_schema_for
Select the config schema that matches the config section (by name). :param section_name: Config section name (as key). :return: Config section schmema to use (subclass of: SectionSchema).
click_configfile.py
def select_config_schema_for(cls, section_name): """Select the config schema that matches the config section (by name). :param section_name: Config section name (as key). :return: Config section schmema to use (subclass of: SectionSchema). """ # pylint: disable=cell-var-from-...
def select_config_schema_for(cls, section_name): """Select the config schema that matches the config section (by name). :param section_name: Config section name (as key). :return: Config section schmema to use (subclass of: SectionSchema). """ # pylint: disable=cell-var-from-...
[ "Select", "the", "config", "schema", "that", "matches", "the", "config", "section", "(", "by", "name", ")", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L449-L465
[ "def", "select_config_schema_for", "(", "cls", ",", "section_name", ")", ":", "# pylint: disable=cell-var-from-loop, redefined-outer-name", "for", "section_schema", "in", "cls", ".", "config_section_schemas", ":", "schema_matches", "=", "getattr", "(", "section_schema", ","...
a616204cb9944125fd5051556f27a7ccef611e22
train
ConfigFileReader.select_storage_for
Selects the data storage for a config section within the :param:`storage`. The primary config section is normally merged into the :param:`storage`. :param section_name: Config section (name) to process. :param storage: Data storage to use. :return: :param:`storage` or...
click_configfile.py
def select_storage_for(cls, section_name, storage): """Selects the data storage for a config section within the :param:`storage`. The primary config section is normally merged into the :param:`storage`. :param section_name: Config section (name) to process. :param storage: ...
def select_storage_for(cls, section_name, storage): """Selects the data storage for a config section within the :param:`storage`. The primary config section is normally merged into the :param:`storage`. :param section_name: Config section (name) to process. :param storage: ...
[ "Selects", "the", "data", "storage", "for", "a", "config", "section", "within", "the", ":", "param", ":", "storage", ".", "The", "primary", "config", "section", "is", "normally", "merged", "into", "the", ":", "param", ":", "storage", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L484-L499
[ "def", "select_storage_for", "(", "cls", ",", "section_name", ",", "storage", ")", ":", "section_storage", "=", "storage", "storage_name", "=", "cls", ".", "get_storage_name_for", "(", "section_name", ")", "if", "storage_name", ":", "section_storage", "=", "storag...
a616204cb9944125fd5051556f27a7ccef611e22
train
clean
Cleanup temporary dirs/files to regain a clean state.
tasks/clean.py
def clean(ctx, dry_run=False): """Cleanup temporary dirs/files to regain a clean state.""" # -- VARIATION-POINT 1: Allow user to override in configuration-file directories = ctx.clean.directories files = ctx.clean.files # -- VARIATION-POINT 2: Allow user to add more files/dirs to be removed. ex...
def clean(ctx, dry_run=False): """Cleanup temporary dirs/files to regain a clean state.""" # -- VARIATION-POINT 1: Allow user to override in configuration-file directories = ctx.clean.directories files = ctx.clean.files # -- VARIATION-POINT 2: Allow user to add more files/dirs to be removed. ex...
[ "Cleanup", "temporary", "dirs", "/", "files", "to", "regain", "a", "clean", "state", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L65-L82
[ "def", "clean", "(", "ctx", ",", "dry_run", "=", "False", ")", ":", "# -- VARIATION-POINT 1: Allow user to override in configuration-file", "directories", "=", "ctx", ".", "clean", ".", "directories", "files", "=", "ctx", ".", "clean", ".", "files", "# -- VARIATION-...
a616204cb9944125fd5051556f27a7ccef611e22
train
clean_all
Clean up everything, even the precious stuff. NOTE: clean task is executed first.
tasks/clean.py
def clean_all(ctx, dry_run=False): """Clean up everything, even the precious stuff. NOTE: clean task is executed first. """ cleanup_dirs(ctx.clean_all.directories or [], dry_run=dry_run) cleanup_dirs(ctx.clean_all.extra_directories or [], dry_run=dry_run) cleanup_files(ctx.clean_all.files or [],...
def clean_all(ctx, dry_run=False): """Clean up everything, even the precious stuff. NOTE: clean task is executed first. """ cleanup_dirs(ctx.clean_all.directories or [], dry_run=dry_run) cleanup_dirs(ctx.clean_all.extra_directories or [], dry_run=dry_run) cleanup_files(ctx.clean_all.files or [],...
[ "Clean", "up", "everything", "even", "the", "precious", "stuff", ".", "NOTE", ":", "clean", "task", "is", "executed", "first", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L86-L95
[ "def", "clean_all", "(", "ctx", ",", "dry_run", "=", "False", ")", ":", "cleanup_dirs", "(", "ctx", ".", "clean_all", ".", "directories", "or", "[", "]", ",", "dry_run", "=", "dry_run", ")", "cleanup_dirs", "(", "ctx", ".", "clean_all", ".", "extra_direc...
a616204cb9944125fd5051556f27a7ccef611e22
train
clean_python
Cleanup python related files/dirs: *.pyc, *.pyo, ...
tasks/clean.py
def clean_python(ctx, dry_run=False): """Cleanup python related files/dirs: *.pyc, *.pyo, ...""" # MAYBE NOT: "**/__pycache__" cleanup_dirs(["build", "dist", "*.egg-info", "**/__pycache__"], dry_run=dry_run) if not dry_run: ctx.run("py.cleanup") cleanup_files(["**/*.pyc", "*...
def clean_python(ctx, dry_run=False): """Cleanup python related files/dirs: *.pyc, *.pyo, ...""" # MAYBE NOT: "**/__pycache__" cleanup_dirs(["build", "dist", "*.egg-info", "**/__pycache__"], dry_run=dry_run) if not dry_run: ctx.run("py.cleanup") cleanup_files(["**/*.pyc", "*...
[ "Cleanup", "python", "related", "files", "/", "dirs", ":", "*", ".", "pyc", "*", ".", "pyo", "..." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L99-L106
[ "def", "clean_python", "(", "ctx", ",", "dry_run", "=", "False", ")", ":", "# MAYBE NOT: \"**/__pycache__\"", "cleanup_dirs", "(", "[", "\"build\"", ",", "\"dist\"", ",", "\"*.egg-info\"", ",", "\"**/__pycache__\"", "]", ",", "dry_run", "=", "dry_run", ")", "if"...
a616204cb9944125fd5051556f27a7ccef611e22
train
cleanup_files
Remove files or files selected by file patterns. Skips removal if file does not exist. :param patterns: File patterns, like "**/*.pyc" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work directory (default=".")
tasks/clean.py
def cleanup_files(patterns, dry_run=False, workdir="."): """Remove files or files selected by file patterns. Skips removal if file does not exist. :param patterns: File patterns, like "**/*.pyc" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work dir...
def cleanup_files(patterns, dry_run=False, workdir="."): """Remove files or files selected by file patterns. Skips removal if file does not exist. :param patterns: File patterns, like "**/*.pyc" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work dir...
[ "Remove", "files", "or", "files", "selected", "by", "file", "patterns", ".", "Skips", "removal", "if", "file", "does", "not", "exist", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L157-L189
[ "def", "cleanup_files", "(", "patterns", ",", "dry_run", "=", "False", ",", "workdir", "=", "\".\"", ")", ":", "current_dir", "=", "Path", "(", "workdir", ")", "python_basedir", "=", "Path", "(", "Path", "(", "sys", ".", "executable", ")", ".", "dirname"...
a616204cb9944125fd5051556f27a7ccef611e22
train
path_glob
Use pathlib for ant-like patterns, like: "**/*.py" :param pattern: File/directory pattern to use (as string). :param current_dir: Current working directory (as Path, pathlib.Path, str) :return Resolved Path (as path.Path).
tasks/clean.py
def path_glob(pattern, current_dir=None): """Use pathlib for ant-like patterns, like: "**/*.py" :param pattern: File/directory pattern to use (as string). :param current_dir: Current working directory (as Path, pathlib.Path, str) :return Resolved Path (as path.Path). """ if not current_di...
def path_glob(pattern, current_dir=None): """Use pathlib for ant-like patterns, like: "**/*.py" :param pattern: File/directory pattern to use (as string). :param current_dir: Current working directory (as Path, pathlib.Path, str) :return Resolved Path (as path.Path). """ if not current_di...
[ "Use", "pathlib", "for", "ant", "-", "like", "patterns", "like", ":", "**", "/", "*", ".", "py" ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L191-L205
[ "def", "path_glob", "(", "pattern", ",", "current_dir", "=", "None", ")", ":", "if", "not", "current_dir", ":", "current_dir", "=", "pathlib", ".", "Path", ".", "cwd", "(", ")", "elif", "not", "isinstance", "(", "current_dir", ",", "pathlib", ".", "Path"...
a616204cb9944125fd5051556f27a7ccef611e22
train
Pipeline.stack_call
Stacks a redis command inside the object. The syntax is the same than the call() method a Client class. Args: *args: full redis command as variable length argument list. Examples: >>> pipeline = Pipeline() >>> pipeline.stack_call("HSET", "key", "field", "va...
tornadis/pipeline.py
def stack_call(self, *args): """Stacks a redis command inside the object. The syntax is the same than the call() method a Client class. Args: *args: full redis command as variable length argument list. Examples: >>> pipeline = Pipeline() >>> pipelin...
def stack_call(self, *args): """Stacks a redis command inside the object. The syntax is the same than the call() method a Client class. Args: *args: full redis command as variable length argument list. Examples: >>> pipeline = Pipeline() >>> pipelin...
[ "Stacks", "a", "redis", "command", "inside", "the", "object", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pipeline.py#L31-L46
[ "def", "stack_call", "(", "self", ",", "*", "args", ")", ":", "self", ".", "pipelined_args", ".", "append", "(", "args", ")", "self", ".", "number_of_stacked_calls", "=", "self", ".", "number_of_stacked_calls", "+", "1" ]
f9dc883e46eb5971b62eab38346319757e5f900f
train
Connection.connect
Connects the object to the host:port. Returns: Future: a Future object with True as result if the connection process was ok.
tornadis/connection.py
def connect(self): """Connects the object to the host:port. Returns: Future: a Future object with True as result if the connection process was ok. """ if self.is_connected() or self.is_connecting(): raise tornado.gen.Return(True) if self.u...
def connect(self): """Connects the object to the host:port. Returns: Future: a Future object with True as result if the connection process was ok. """ if self.is_connected() or self.is_connecting(): raise tornado.gen.Return(True) if self.u...
[ "Connects", "the", "object", "to", "the", "host", ":", "port", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L127-L173
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "is_connected", "(", ")", "or", "self", ".", "is_connecting", "(", ")", ":", "raise", "tornado", ".", "gen", ".", "Return", "(", "True", ")", "if", "self", ".", "unix_domain_socket", "is", "...
f9dc883e46eb5971b62eab38346319757e5f900f
train
Connection.disconnect
Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors).
tornadis/connection.py
def disconnect(self): """Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors). """ if not self.is_connected() and not self.is_connecting(): return LOG.debug("disconnecting from %s...", se...
def disconnect(self): """Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors). """ if not self.is_connected() and not self.is_connecting(): return LOG.debug("disconnecting from %s...", se...
[ "Disconnects", "the", "object", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L208-L230
[ "def", "disconnect", "(", "self", ")", ":", "if", "not", "self", ".", "is_connected", "(", ")", "and", "not", "self", ".", "is_connecting", "(", ")", ":", "return", "LOG", ".", "debug", "(", "\"disconnecting from %s...\"", ",", "self", ".", "_redis_server"...
f9dc883e46eb5971b62eab38346319757e5f900f
train
Connection.write
Buffers some data to be sent to the host:port in a non blocking way. So the data is always buffered and not sent on the socket in a synchronous way. You can give a WriteBuffer as parameter. The internal Connection WriteBuffer will be extended with this one (without copying). A...
tornadis/connection.py
def write(self, data): """Buffers some data to be sent to the host:port in a non blocking way. So the data is always buffered and not sent on the socket in a synchronous way. You can give a WriteBuffer as parameter. The internal Connection WriteBuffer will be extended with this...
def write(self, data): """Buffers some data to be sent to the host:port in a non blocking way. So the data is always buffered and not sent on the socket in a synchronous way. You can give a WriteBuffer as parameter. The internal Connection WriteBuffer will be extended with this...
[ "Buffers", "some", "data", "to", "be", "sent", "to", "the", "host", ":", "port", "in", "a", "non", "blocking", "way", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L302-L323
[ "def", "write", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "WriteBuffer", ")", ":", "self", ".", "_write_buffer", ".", "append", "(", "data", ")", "else", ":", "if", "len", "(", "data", ")", ">", "0", ":", "self", "...
f9dc883e46eb5971b62eab38346319757e5f900f
train
surrogate_escape
Simulate the Python 3 ``surrogateescape`` handler, but for Python 2 only.
tasks/_vendor/path.py
def surrogate_escape(error): """ Simulate the Python 3 ``surrogateescape`` handler, but for Python 2 only. """ chars = error.object[error.start:error.end] assert len(chars) == 1 val = ord(chars) val += 0xdc00 return __builtin__.unichr(val), error.end
def surrogate_escape(error): """ Simulate the Python 3 ``surrogateescape`` handler, but for Python 2 only. """ chars = error.object[error.start:error.end] assert len(chars) == 1 val = ord(chars) val += 0xdc00 return __builtin__.unichr(val), error.end
[ "Simulate", "the", "Python", "3", "surrogateescape", "handler", "but", "for", "Python", "2", "only", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L83-L91
[ "def", "surrogate_escape", "(", "error", ")", ":", "chars", "=", "error", ".", "object", "[", "error", ".", "start", ":", "error", ".", "end", "]", "assert", "len", "(", "chars", ")", "==", "1", "val", "=", "ord", "(", "chars", ")", "val", "+=", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path._always_unicode
Ensure the path as retrieved from a Python API, such as :func:`os.listdir`, is a proper Unicode string.
tasks/_vendor/path.py
def _always_unicode(cls, path): """ Ensure the path as retrieved from a Python API, such as :func:`os.listdir`, is a proper Unicode string. """ if PY3 or isinstance(path, text_type): return path return path.decode(sys.getfilesystemencoding(), 'surrogateescape'...
def _always_unicode(cls, path): """ Ensure the path as retrieved from a Python API, such as :func:`os.listdir`, is a proper Unicode string. """ if PY3 or isinstance(path, text_type): return path return path.decode(sys.getfilesystemencoding(), 'surrogateescape'...
[ "Ensure", "the", "path", "as", "retrieved", "from", "a", "Python", "API", "such", "as", ":", "func", ":", "os", ".", "listdir", "is", "a", "proper", "Unicode", "string", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L221-L228
[ "def", "_always_unicode", "(", "cls", ",", "path", ")", ":", "if", "PY3", "or", "isinstance", "(", "path", ",", "text_type", ")", ":", "return", "path", "return", "path", ".", "decode", "(", "sys", ".", "getfilesystemencoding", "(", ")", ",", "'surrogate...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.namebase
The same as :meth:`name`, but with one file extension stripped off. For example, ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``, but ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``.
tasks/_vendor/path.py
def namebase(self): """ The same as :meth:`name`, but with one file extension stripped off. For example, ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``, but ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``. """ base, ext = self.module...
def namebase(self): """ The same as :meth:`name`, but with one file extension stripped off. For example, ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``, but ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``. """ base, ext = self.module...
[ "The", "same", "as", ":", "meth", ":", "name", "but", "with", "one", "file", "extension", "stripped", "off", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L336-L345
[ "def", "namebase", "(", "self", ")", ":", "base", ",", "ext", "=", "self", ".", "module", ".", "splitext", "(", "self", ".", "name", ")", "return", "base" ]
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.listdir
D.listdir() -> List of items in this directory. Use :meth:`files` or :meth:`dirs` instead if you want a listing of just files or just subdirectories. The elements of the list are Path objects. With the optional `pattern` argument, this only lists items whose names match the gi...
tasks/_vendor/path.py
def listdir(self, pattern=None): """ D.listdir() -> List of items in this directory. Use :meth:`files` or :meth:`dirs` instead if you want a listing of just files or just subdirectories. The elements of the list are Path objects. With the optional `pattern` argument, this only...
def listdir(self, pattern=None): """ D.listdir() -> List of items in this directory. Use :meth:`files` or :meth:`dirs` instead if you want a listing of just files or just subdirectories. The elements of the list are Path objects. With the optional `pattern` argument, this only...
[ "D", ".", "listdir", "()", "-", ">", "List", "of", "items", "in", "this", "directory", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L522-L541
[ "def", "listdir", "(", "self", ",", "pattern", "=", "None", ")", ":", "if", "pattern", "is", "None", ":", "pattern", "=", "'*'", "return", "[", "self", "/", "child", "for", "child", "in", "map", "(", "self", ".", "_always_unicode", ",", "os", ".", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.dirs
D.dirs() -> List of this directory's subdirectories. The elements of the list are Path objects. This does not walk recursively into subdirectories (but see :meth:`walkdirs`). With the optional `pattern` argument, this only lists directories whose names match the given pattern. ...
tasks/_vendor/path.py
def dirs(self, pattern=None): """ D.dirs() -> List of this directory's subdirectories. The elements of the list are Path objects. This does not walk recursively into subdirectories (but see :meth:`walkdirs`). With the optional `pattern` argument, this only lists directo...
def dirs(self, pattern=None): """ D.dirs() -> List of this directory's subdirectories. The elements of the list are Path objects. This does not walk recursively into subdirectories (but see :meth:`walkdirs`). With the optional `pattern` argument, this only lists directo...
[ "D", ".", "dirs", "()", "-", ">", "List", "of", "this", "directory", "s", "subdirectories", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L543-L554
[ "def", "dirs", "(", "self", ",", "pattern", "=", "None", ")", ":", "return", "[", "p", "for", "p", "in", "self", ".", "listdir", "(", "pattern", ")", "if", "p", ".", "isdir", "(", ")", "]" ]
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.files
D.files() -> List of the files in this directory. The elements of the list are Path objects. This does not walk into subdirectories (see :meth:`walkfiles`). With the optional `pattern` argument, this only lists files whose names match the given pattern. For example, ``d.files(...
tasks/_vendor/path.py
def files(self, pattern=None): """ D.files() -> List of the files in this directory. The elements of the list are Path objects. This does not walk into subdirectories (see :meth:`walkfiles`). With the optional `pattern` argument, this only lists files whose names match the give...
def files(self, pattern=None): """ D.files() -> List of the files in this directory. The elements of the list are Path objects. This does not walk into subdirectories (see :meth:`walkfiles`). With the optional `pattern` argument, this only lists files whose names match the give...
[ "D", ".", "files", "()", "-", ">", "List", "of", "the", "files", "in", "this", "directory", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L556-L567
[ "def", "files", "(", "self", ",", "pattern", "=", "None", ")", ":", "return", "[", "p", "for", "p", "in", "self", ".", "listdir", "(", "pattern", ")", "if", "p", ".", "isfile", "(", ")", "]" ]
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.walkdirs
D.walkdirs() -> iterator over subdirs, recursively. With the optional `pattern` argument, this yields only directories whose names match the given pattern. For example, ``mydir.walkdirs('*test')`` yields only directories with names ending in ``'test'``. The `errors=` keyword a...
tasks/_vendor/path.py
def walkdirs(self, pattern=None, errors='strict'): """ D.walkdirs() -> iterator over subdirs, recursively. With the optional `pattern` argument, this yields only directories whose names match the given pattern. For example, ``mydir.walkdirs('*test')`` yields only directories wi...
def walkdirs(self, pattern=None, errors='strict'): """ D.walkdirs() -> iterator over subdirs, recursively. With the optional `pattern` argument, this yields only directories whose names match the given pattern. For example, ``mydir.walkdirs('*test')`` yields only directories wi...
[ "D", ".", "walkdirs", "()", "-", ">", "iterator", "over", "subdirs", "recursively", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L624-L658
[ "def", "walkdirs", "(", "self", ",", "pattern", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "errors", "not", "in", "(", "'strict'", ",", "'warn'", ",", "'ignore'", ")", ":", "raise", "ValueError", "(", "\"invalid errors parameter\"", ")", ...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.walkfiles
D.walkfiles() -> iterator over files in D, recursively. The optional argument `pattern` limits the results to files with names that match the pattern. For example, ``mydir.walkfiles('*.tmp')`` yields only files with the ``.tmp`` extension.
tasks/_vendor/path.py
def walkfiles(self, pattern=None, errors='strict'): """ D.walkfiles() -> iterator over files in D, recursively. The optional argument `pattern` limits the results to files with names that match the pattern. For example, ``mydir.walkfiles('*.tmp')`` yields only files with the ``.tmp`` ...
def walkfiles(self, pattern=None, errors='strict'): """ D.walkfiles() -> iterator over files in D, recursively. The optional argument `pattern` limits the results to files with names that match the pattern. For example, ``mydir.walkfiles('*.tmp')`` yields only files with the ``.tmp`` ...
[ "D", ".", "walkfiles", "()", "-", ">", "iterator", "over", "files", "in", "D", "recursively", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L660-L706
[ "def", "walkfiles", "(", "self", ",", "pattern", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "errors", "not", "in", "(", "'strict'", ",", "'warn'", ",", "'ignore'", ")", ":", "raise", "ValueError", "(", "\"invalid errors parameter\"", ")",...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.open
Open this file and return a corresponding :class:`file` object. Keyword arguments work as in :func:`io.open`. If the file cannot be opened, an :class:`~exceptions.OSError` is raised.
tasks/_vendor/path.py
def open(self, *args, **kwargs): """ Open this file and return a corresponding :class:`file` object. Keyword arguments work as in :func:`io.open`. If the file cannot be opened, an :class:`~exceptions.OSError` is raised. """ with io_error_compat(): return io.open(sel...
def open(self, *args, **kwargs): """ Open this file and return a corresponding :class:`file` object. Keyword arguments work as in :func:`io.open`. If the file cannot be opened, an :class:`~exceptions.OSError` is raised. """ with io_error_compat(): return io.open(sel...
[ "Open", "this", "file", "and", "return", "a", "corresponding", ":", "class", ":", "file", "object", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L743-L750
[ "def", "open", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "io_error_compat", "(", ")", ":", "return", "io", ".", "open", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.write_text
r""" Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the `append=True` keyword argument. There are two differences between :meth:`write_text` and :meth:`write_bytes`: newline handling and Unicode handling. See be...
tasks/_vendor/path.py
def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the `append=True` keyword argument. There are two diff...
def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the `append=True` keyword argument. There are two diff...
[ "r", "Write", "the", "given", "text", "to", "this", "file", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L799-L871
[ "def", "write_text", "(", "self", ",", "text", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "linesep", "=", "os", ".", "linesep", ",", "append", "=", "False", ")", ":", "if", "isinstance", "(", "text", ",", "text_type", ")", ":"...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.write_lines
r""" Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. See `linesep` below. `lines` - A list of strings. `encoding` - A Unicode encoding to use. This ap...
tasks/_vendor/path.py
def write_lines(self, lines, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. ...
def write_lines(self, lines, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. ...
[ "r", "Write", "the", "given", "lines", "of", "text", "to", "this", "file", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L898-L944
[ "def", "write_lines", "(", "self", ",", "lines", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "linesep", "=", "os", ".", "linesep", ",", "append", "=", "False", ")", ":", "with", "self", ".", "open", "(", "'ab'", "if", "append",...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.mkdir_p
Like :meth:`mkdir`, but does not raise an exception if the directory already exists.
tasks/_vendor/path.py
def mkdir_p(self, mode=0o777): """ Like :meth:`mkdir`, but does not raise an exception if the directory already exists. """ try: self.mkdir(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise return ...
def mkdir_p(self, mode=0o777): """ Like :meth:`mkdir`, but does not raise an exception if the directory already exists. """ try: self.mkdir(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise return ...
[ "Like", ":", "meth", ":", "mkdir", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "already", "exists", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1203-L1212
[ "def", "mkdir_p", "(", "self", ",", "mode", "=", "0o777", ")", ":", "try", ":", "self", ".", "mkdir", "(", "mode", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.makedirs_p
Like :meth:`makedirs`, but does not raise an exception if the directory already exists.
tasks/_vendor/path.py
def makedirs_p(self, mode=0o777): """ Like :meth:`makedirs`, but does not raise an exception if the directory already exists. """ try: self.makedirs(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise ...
def makedirs_p(self, mode=0o777): """ Like :meth:`makedirs`, but does not raise an exception if the directory already exists. """ try: self.makedirs(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise ...
[ "Like", ":", "meth", ":", "makedirs", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "already", "exists", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1219-L1228
[ "def", "makedirs_p", "(", "self", ",", "mode", "=", "0o777", ")", ":", "try", ":", "self", ".", "makedirs", "(", "mode", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.rmdir_p
Like :meth:`rmdir`, but does not raise an exception if the directory is not empty or does not exist.
tasks/_vendor/path.py
def rmdir_p(self): """ Like :meth:`rmdir`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.rmdir() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST: ...
def rmdir_p(self): """ Like :meth:`rmdir`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.rmdir() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST: ...
[ "Like", ":", "meth", ":", "rmdir", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "is", "not", "empty", "or", "does", "not", "exist", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1235-L1244
[ "def", "rmdir_p", "(", "self", ")", ":", "try", ":", "self", ".", "rmdir", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOTEMPTY", "and", "e",...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.removedirs_p
Like :meth:`removedirs`, but does not raise an exception if the directory is not empty or does not exist.
tasks/_vendor/path.py
def removedirs_p(self): """ Like :meth:`removedirs`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.removedirs() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno...
def removedirs_p(self): """ Like :meth:`removedirs`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.removedirs() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno...
[ "Like", ":", "meth", ":", "removedirs", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "is", "not", "empty", "or", "does", "not", "exist", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1251-L1260
[ "def", "removedirs_p", "(", "self", ")", ":", "try", ":", "self", ".", "removedirs", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOTEMPTY", "an...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.remove_p
Like :meth:`remove`, but does not raise an exception if the file does not exist.
tasks/_vendor/path.py
def remove_p(self): """ Like :meth:`remove`, but does not raise an exception if the file does not exist. """ try: self.unlink() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
def remove_p(self): """ Like :meth:`remove`, but does not raise an exception if the file does not exist. """ try: self.unlink() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
[ "Like", ":", "meth", ":", "remove", "but", "does", "not", "raise", "an", "exception", "if", "the", "file", "does", "not", "exist", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1278-L1287
[ "def", "remove_p", "(", "self", ")", ":", "try", ":", "self", ".", "unlink", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOENT", ":", "raise"...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.rmtree_p
Like :meth:`rmtree`, but does not raise an exception if the directory does not exist.
tasks/_vendor/path.py
def rmtree_p(self): """ Like :meth:`rmtree`, but does not raise an exception if the directory does not exist. """ try: self.rmtree() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
def rmtree_p(self): """ Like :meth:`rmtree`, but does not raise an exception if the directory does not exist. """ try: self.rmtree() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
[ "Like", ":", "meth", ":", "rmtree", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "does", "not", "exist", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1357-L1366
[ "def", "rmtree_p", "(", "self", ")", ":", "try", ":", "self", ".", "rmtree", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOENT", ":", "raise"...
a616204cb9944125fd5051556f27a7ccef611e22
train
Path.merge_tree
Copy entire contents of self to dst, overwriting existing contents in dst with those in self. If the additional keyword `update` is True, each `src` will only be copied if `dst` does not exist, or `src` is newer than `dst`. Note that the technique employed stages the files in a...
tasks/_vendor/path.py
def merge_tree(self, dst, symlinks=False, *args, **kwargs): """ Copy entire contents of self to dst, overwriting existing contents in dst with those in self. If the additional keyword `update` is True, each `src` will only be copied if `dst` does not exist, or `src` is n...
def merge_tree(self, dst, symlinks=False, *args, **kwargs): """ Copy entire contents of self to dst, overwriting existing contents in dst with those in self. If the additional keyword `update` is True, each `src` will only be copied if `dst` does not exist, or `src` is n...
[ "Copy", "entire", "contents", "of", "self", "to", "dst", "overwriting", "existing", "contents", "in", "dst", "with", "those", "in", "self", "." ]
click-contrib/click-configfile
python
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1374-L1397
[ "def", "merge_tree", "(", "self", ",", "dst", ",", "symlinks", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "update", "=", "kwargs", ".", "pop", "(", "'update'", ",", "False", ")", "with", "tempdir", "(", ")", "as", "_temp_dir...
a616204cb9944125fd5051556f27a7ccef611e22
train
GdalReader.__gdal_dataset_default
DiskReader implementation.
pydem/reader/gdal_reader.py
def __gdal_dataset_default(self): """DiskReader implementation.""" if not os.path.exists(self.file_name): return None if os.path.splitext(self.file_name)[1].lower() not in self.file_types: raise RuntimeError('Filename %s does not have extension type %s.' % (self.file_nam...
def __gdal_dataset_default(self): """DiskReader implementation.""" if not os.path.exists(self.file_name): return None if os.path.splitext(self.file_name)[1].lower() not in self.file_types: raise RuntimeError('Filename %s does not have extension type %s.' % (self.file_nam...
[ "DiskReader", "implementation", "." ]
creare-com/pydem
python
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/gdal_reader.py#L100-L116
[ "def", "__gdal_dataset_default", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "file_name", ")", ":", "return", "None", "if", "os", ".", "path", ".", "splitext", "(", "self", ".", "file_name", ")", "[", "1", ...
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
train
Client.connect
Connects the client object to redis. It's safe to use this method even if you are already connected. Note: this method is useless with autoconnect mode (default). Returns: a Future object with True as result if the connection was ok.
tornadis/client.py
def connect(self): """Connects the client object to redis. It's safe to use this method even if you are already connected. Note: this method is useless with autoconnect mode (default). Returns: a Future object with True as result if the connection was ok. """ ...
def connect(self): """Connects the client object to redis. It's safe to use this method even if you are already connected. Note: this method is useless with autoconnect mode (default). Returns: a Future object with True as result if the connection was ok. """ ...
[ "Connects", "the", "client", "object", "to", "redis", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L84-L118
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "is_connected", "(", ")", ":", "raise", "tornado", ".", "gen", ".", "Return", "(", "True", ")", "cb1", "=", "self", ".", "_read_callback", "cb2", "=", "self", ".", "_close_callback", "self", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
Client._close_callback
Callback called when redis closed the connection. The callback queue is emptied and we call each callback found with None or with an exception object to wake up blocked client.
tornadis/client.py
def _close_callback(self): """Callback called when redis closed the connection. The callback queue is emptied and we call each callback found with None or with an exception object to wake up blocked client. """ while True: try: callback = self.__callb...
def _close_callback(self): """Callback called when redis closed the connection. The callback queue is emptied and we call each callback found with None or with an exception object to wake up blocked client. """ while True: try: callback = self.__callb...
[ "Callback", "called", "when", "redis", "closed", "the", "connection", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L130-L145
[ "def", "_close_callback", "(", "self", ")", ":", "while", "True", ":", "try", ":", "callback", "=", "self", ".", "__callback_queue", ".", "popleft", "(", ")", "callback", "(", "ConnectionError", "(", "\"closed connection\"", ")", ")", "except", "IndexError", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
Client._read_callback
Callback called when some data are read on the socket. The buffer is given to the hiredis parser. If a reply is complete, we put the decoded reply to on the reply queue. Args: data (str): string (buffer) read on the socket.
tornadis/client.py
def _read_callback(self, data=None): """Callback called when some data are read on the socket. The buffer is given to the hiredis parser. If a reply is complete, we put the decoded reply to on the reply queue. Args: data (str): string (buffer) read on the socket. ""...
def _read_callback(self, data=None): """Callback called when some data are read on the socket. The buffer is given to the hiredis parser. If a reply is complete, we put the decoded reply to on the reply queue. Args: data (str): string (buffer) read on the socket. ""...
[ "Callback", "called", "when", "some", "data", "are", "read", "on", "the", "socket", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L147-L175
[ "def", "_read_callback", "(", "self", ",", "data", "=", "None", ")", ":", "try", ":", "if", "data", "is", "not", "None", ":", "self", ".", "__reader", ".", "feed", "(", "data", ")", "while", "True", ":", "reply", "=", "self", ".", "__reader", ".", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
Client.call
Calls a redis command and returns a Future of the reply. Args: *args: full redis command as variable length argument list or a Pipeline object (as a single argument). **kwargs: internal private options (do not use). Returns: a Future with the decoded...
tornadis/client.py
def call(self, *args, **kwargs): """Calls a redis command and returns a Future of the reply. Args: *args: full redis command as variable length argument list or a Pipeline object (as a single argument). **kwargs: internal private options (do not use). Re...
def call(self, *args, **kwargs): """Calls a redis command and returns a Future of the reply. Args: *args: full redis command as variable length argument list or a Pipeline object (as a single argument). **kwargs: internal private options (do not use). Re...
[ "Calls", "a", "redis", "command", "and", "returns", "a", "Future", "of", "the", "reply", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L177-L208
[ "def", "call", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_connected", "(", ")", ":", "if", "self", ".", "autoconnect", ":", "# We use this method only when we are not contected", "# to void performance penaly ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
Client.async_call
Calls a redis command, waits for the reply and call a callback. Following options are available (not part of the redis command itself): - callback Function called (with the result as argument) when the result is available. If not set, the reply is silently discarded. In ...
tornadis/client.py
def async_call(self, *args, **kwargs): """Calls a redis command, waits for the reply and call a callback. Following options are available (not part of the redis command itself): - callback Function called (with the result as argument) when the result is available. If no...
def async_call(self, *args, **kwargs): """Calls a redis command, waits for the reply and call a callback. Following options are available (not part of the redis command itself): - callback Function called (with the result as argument) when the result is available. If no...
[ "Calls", "a", "redis", "command", "waits", "for", "the", "reply", "and", "call", "a", "callback", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L218-L259
[ "def", "async_call", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "after_autoconnect_callback", "(", "future", ")", ":", "if", "self", ".", "is_connected", "(", ")", ":", "self", ".", "_call", "(", "*", "args", ",", "*", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
format_args_in_redis_protocol
Formats arguments into redis protocol... This function makes and returns a string/buffer corresponding to given arguments formated with the redis protocol. integer, text, string or binary types are automatically converted (using utf8 if necessary). More informations about the protocol: http://red...
tornadis/utils.py
def format_args_in_redis_protocol(*args): """Formats arguments into redis protocol... This function makes and returns a string/buffer corresponding to given arguments formated with the redis protocol. integer, text, string or binary types are automatically converted (using utf8 if necessary). ...
def format_args_in_redis_protocol(*args): """Formats arguments into redis protocol... This function makes and returns a string/buffer corresponding to given arguments formated with the redis protocol. integer, text, string or binary types are automatically converted (using utf8 if necessary). ...
[ "Formats", "arguments", "into", "redis", "protocol", "..." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L14-L70
[ "def", "format_args_in_redis_protocol", "(", "*", "args", ")", ":", "buf", "=", "WriteBuffer", "(", ")", "l", "=", "\"*%d\\r\\n\"", "%", "len", "(", "args", ")", "# noqa: E741", "if", "six", ".", "PY2", ":", "buf", ".", "append", "(", "l", ")", "else",...
f9dc883e46eb5971b62eab38346319757e5f900f
train
ContextManagerFuture._done_callback
Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future object
tornadis/utils.py
def _done_callback(self, wrapped): """Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future ob...
def _done_callback(self, wrapped): """Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future ob...
[ "Internal", "done", "callback", "to", "set", "the", "result", "of", "the", "object", "." ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L108-L120
[ "def", "_done_callback", "(", "self", ",", "wrapped", ")", ":", "if", "wrapped", ".", "exception", "(", ")", ":", "self", ".", "set_exception", "(", "wrapped", ".", "exception", "(", ")", ")", "else", ":", "self", ".", "set_result", "(", "wrapped", "."...
f9dc883e46eb5971b62eab38346319757e5f900f
train
ContextManagerFuture.result
The result method which returns a context manager Returns: ContextManager: The corresponding context manager
tornadis/utils.py
def result(self): """The result method which returns a context manager Returns: ContextManager: The corresponding context manager """ if self.exception(): raise self.exception() # Otherwise return a context manager that cleans up after the block. ...
def result(self): """The result method which returns a context manager Returns: ContextManager: The corresponding context manager """ if self.exception(): raise self.exception() # Otherwise return a context manager that cleans up after the block. ...
[ "The", "result", "method", "which", "returns", "a", "context", "manager" ]
thefab/tornadis
python
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L122-L138
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "exception", "(", ")", ":", "raise", "self", ".", "exception", "(", ")", "# Otherwise return a context manager that cleans up after the block.", "@", "contextlib", ".", "contextmanager", "def", "f", "(", ...
f9dc883e46eb5971b62eab38346319757e5f900f
train
create_url
Create the URL in the LyricWikia format
lyricwikia/lyricwikia.py
def create_url(artist, song): """Create the URL in the LyricWikia format""" return (__BASE_URL__ + '/wiki/{artist}:{song}'.format(artist=urlize(artist), song=urlize(song)))
def create_url(artist, song): """Create the URL in the LyricWikia format""" return (__BASE_URL__ + '/wiki/{artist}:{song}'.format(artist=urlize(artist), song=urlize(song)))
[ "Create", "the", "URL", "in", "the", "LyricWikia", "format" ]
enricobacis/lyricwikia
python
https://github.com/enricobacis/lyricwikia/blob/bc6caa7f745f1d54adf3ba1a72df76d593164cfa/lyricwikia/lyricwikia.py#L20-L24
[ "def", "create_url", "(", "artist", ",", "song", ")", ":", "return", "(", "__BASE_URL__", "+", "'/wiki/{artist}:{song}'", ".", "format", "(", "artist", "=", "urlize", "(", "artist", ")", ",", "song", "=", "urlize", "(", "song", ")", ")", ")" ]
bc6caa7f745f1d54adf3ba1a72df76d593164cfa
train
get_lyrics
Retrieve the lyrics of the song and return the first one in case multiple versions are available.
lyricwikia/lyricwikia.py
def get_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve the lyrics of the song and return the first one in case multiple versions are available.""" return get_all_lyrics(artist, song, linesep, timeout)[0]
def get_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve the lyrics of the song and return the first one in case multiple versions are available.""" return get_all_lyrics(artist, song, linesep, timeout)[0]
[ "Retrieve", "the", "lyrics", "of", "the", "song", "and", "return", "the", "first", "one", "in", "case", "multiple", "versions", "are", "available", "." ]
enricobacis/lyricwikia
python
https://github.com/enricobacis/lyricwikia/blob/bc6caa7f745f1d54adf3ba1a72df76d593164cfa/lyricwikia/lyricwikia.py#L27-L30
[ "def", "get_lyrics", "(", "artist", ",", "song", ",", "linesep", "=", "'\\n'", ",", "timeout", "=", "None", ")", ":", "return", "get_all_lyrics", "(", "artist", ",", "song", ",", "linesep", ",", "timeout", ")", "[", "0", "]" ]
bc6caa7f745f1d54adf3ba1a72df76d593164cfa
train
get_all_lyrics
Retrieve a list of all the lyrics versions of a song.
lyricwikia/lyricwikia.py
def get_all_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve a list of all the lyrics versions of a song.""" url = create_url(artist, song) response = _requests.get(url, timeout=timeout) soup = _BeautifulSoup(response.content, "html.parser") lyricboxes = soup.findAll('div', {'class': 'l...
def get_all_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve a list of all the lyrics versions of a song.""" url = create_url(artist, song) response = _requests.get(url, timeout=timeout) soup = _BeautifulSoup(response.content, "html.parser") lyricboxes = soup.findAll('div', {'class': 'l...
[ "Retrieve", "a", "list", "of", "all", "the", "lyrics", "versions", "of", "a", "song", "." ]
enricobacis/lyricwikia
python
https://github.com/enricobacis/lyricwikia/blob/bc6caa7f745f1d54adf3ba1a72df76d593164cfa/lyricwikia/lyricwikia.py#L33-L47
[ "def", "get_all_lyrics", "(", "artist", ",", "song", ",", "linesep", "=", "'\\n'", ",", "timeout", "=", "None", ")", ":", "url", "=", "create_url", "(", "artist", ",", "song", ")", "response", "=", "_requests", ".", "get", "(", "url", ",", "timeout", ...
bc6caa7f745f1d54adf3ba1a72df76d593164cfa
train
open_file
Open an ARF file, creating as necessary. Use this instead of h5py.File to ensure that root-level attributes and group creation property lists are set correctly.
arf.py
def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, **kwargs): """Open an ARF file, creating as necessary. Use this instead of h5py.File to ensure that root-level attributes and group creation property lists are set correctly. """ import sys import os from h5py im...
def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, **kwargs): """Open an ARF file, creating as necessary. Use this instead of h5py.File to ensure that root-level attributes and group creation property lists are set correctly. """ import sys import os from h5py im...
[ "Open", "an", "ARF", "file", "creating", "as", "necessary", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L42-L79
[ "def", "open_file", "(", "name", ",", "mode", "=", "None", ",", "driver", "=", "None", ",", "libver", "=", "None", ",", "userblock_size", "=", "None", ",", "*", "*", "kwargs", ")", ":", "import", "sys", "import", "os", "from", "h5py", "import", "h5p"...
71746d9edbe7993a783d4acaf84b9631f3230283
train
create_entry
Create a new ARF entry under group, setting required attributes. An entry is an abstract collection of data which all refer to the same time frame. Data can include physiological recordings, sound recordings, and derived data such as spike times and labels. See add_data() for information on how data ar...
arf.py
def create_entry(group, name, timestamp, **attributes): """Create a new ARF entry under group, setting required attributes. An entry is an abstract collection of data which all refer to the same time frame. Data can include physiological recordings, sound recordings, and derived data such as spike time...
def create_entry(group, name, timestamp, **attributes): """Create a new ARF entry under group, setting required attributes. An entry is an abstract collection of data which all refer to the same time frame. Data can include physiological recordings, sound recordings, and derived data such as spike time...
[ "Create", "a", "new", "ARF", "entry", "under", "group", "setting", "required", "attributes", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L82-L116
[ "def", "create_entry", "(", "group", ",", "name", ",", "timestamp", ",", "*", "*", "attributes", ")", ":", "# create group using low-level interface to store creation order", "from", "h5py", "import", "h5p", ",", "h5g", ",", "_hl", "try", ":", "gcpl", "=", "h5p"...
71746d9edbe7993a783d4acaf84b9631f3230283
train
create_dataset
Create an ARF dataset under group, setting required attributes Required arguments: name -- the name of dataset in which to store the data data -- the data to store Data can be of the following types: * sampled data: an N-D numerical array of measurements * "simple" event data: a 1-D array...
arf.py
def create_dataset(group, name, data, units='', datatype=DataTypes.UNDEFINED, chunks=True, maxshape=None, compression=None, **attributes): """Create an ARF dataset under group, setting required attributes Required arguments: name -- the name of dataset in which to st...
def create_dataset(group, name, data, units='', datatype=DataTypes.UNDEFINED, chunks=True, maxshape=None, compression=None, **attributes): """Create an ARF dataset under group, setting required attributes Required arguments: name -- the name of dataset in which to st...
[ "Create", "an", "ARF", "dataset", "under", "group", "setting", "required", "attributes" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L119-L181
[ "def", "create_dataset", "(", "group", ",", "name", ",", "data", ",", "units", "=", "''", ",", "datatype", "=", "DataTypes", ".", "UNDEFINED", ",", "chunks", "=", "True", ",", "maxshape", "=", "None", ",", "compression", "=", "None", ",", "*", "*", "...
71746d9edbe7993a783d4acaf84b9631f3230283
train
create_table
Create a new array dataset under group with compound datatype and maxshape=(None,)
arf.py
def create_table(group, name, dtype, **attributes): """Create a new array dataset under group with compound datatype and maxshape=(None,)""" dset = group.create_dataset( name, shape=(0,), dtype=dtype, maxshape=(None,)) set_attributes(dset, **attributes) return dset
def create_table(group, name, dtype, **attributes): """Create a new array dataset under group with compound datatype and maxshape=(None,)""" dset = group.create_dataset( name, shape=(0,), dtype=dtype, maxshape=(None,)) set_attributes(dset, **attributes) return dset
[ "Create", "a", "new", "array", "dataset", "under", "group", "with", "compound", "datatype", "and", "maxshape", "=", "(", "None", ")" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L184-L189
[ "def", "create_table", "(", "group", ",", "name", ",", "dtype", ",", "*", "*", "attributes", ")", ":", "dset", "=", "group", ".", "create_dataset", "(", "name", ",", "shape", "=", "(", "0", ",", ")", ",", "dtype", "=", "dtype", ",", "maxshape", "="...
71746d9edbe7993a783d4acaf84b9631f3230283
train
append_data
Append data to dset along axis 0. Data must be a single element or a 1D array of the same type as the dataset (including compound datatypes).
arf.py
def append_data(dset, data): """Append data to dset along axis 0. Data must be a single element or a 1D array of the same type as the dataset (including compound datatypes).""" N = data.shape[0] if hasattr(data, 'shape') else 1 if N == 0: return oldlen = dset.shape[0] newlen = oldlen + N...
def append_data(dset, data): """Append data to dset along axis 0. Data must be a single element or a 1D array of the same type as the dataset (including compound datatypes).""" N = data.shape[0] if hasattr(data, 'shape') else 1 if N == 0: return oldlen = dset.shape[0] newlen = oldlen + N...
[ "Append", "data", "to", "dset", "along", "axis", "0", ".", "Data", "must", "be", "a", "single", "element", "or", "a", "1D", "array", "of", "the", "same", "type", "as", "the", "dataset", "(", "including", "compound", "datatypes", ")", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L192-L201
[ "def", "append_data", "(", "dset", ",", "data", ")", ":", "N", "=", "data", ".", "shape", "[", "0", "]", "if", "hasattr", "(", "data", ",", "'shape'", ")", "else", "1", "if", "N", "==", "0", ":", "return", "oldlen", "=", "dset", ".", "shape", "...
71746d9edbe7993a783d4acaf84b9631f3230283
train
check_file_version
Check the ARF version attribute of file for compatibility. Raises DeprecationWarning for backwards-incompatible files, FutureWarning for (potentially) forwards-incompatible files, and UserWarning for files that may not have been created by an ARF library. Returns the version for the file
arf.py
def check_file_version(file): """Check the ARF version attribute of file for compatibility. Raises DeprecationWarning for backwards-incompatible files, FutureWarning for (potentially) forwards-incompatible files, and UserWarning for files that may not have been created by an ARF library. Returns t...
def check_file_version(file): """Check the ARF version attribute of file for compatibility. Raises DeprecationWarning for backwards-incompatible files, FutureWarning for (potentially) forwards-incompatible files, and UserWarning for files that may not have been created by an ARF library. Returns t...
[ "Check", "the", "ARF", "version", "attribute", "of", "file", "for", "compatibility", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L204-L238
[ "def", "check_file_version", "(", "file", ")", ":", "from", "distutils", ".", "version", "import", "StrictVersion", "as", "Version", "try", ":", "ver", "=", "file", ".", "attrs", ".", "get", "(", "'arf_version'", ",", "None", ")", "if", "ver", "is", "Non...
71746d9edbe7993a783d4acaf84b9631f3230283
train
set_attributes
Set multiple attributes on node. If overwrite is False, and the attribute already exists, does nothing. If the value for a key is None, the attribute is deleted.
arf.py
def set_attributes(node, overwrite=True, **attributes): """Set multiple attributes on node. If overwrite is False, and the attribute already exists, does nothing. If the value for a key is None, the attribute is deleted. """ aset = node.attrs for k, v in attributes.items(): if not over...
def set_attributes(node, overwrite=True, **attributes): """Set multiple attributes on node. If overwrite is False, and the attribute already exists, does nothing. If the value for a key is None, the attribute is deleted. """ aset = node.attrs for k, v in attributes.items(): if not over...
[ "Set", "multiple", "attributes", "on", "node", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L241-L256
[ "def", "set_attributes", "(", "node", ",", "overwrite", "=", "True", ",", "*", "*", "attributes", ")", ":", "aset", "=", "node", ".", "attrs", "for", "k", ",", "v", "in", "attributes", ".", "items", "(", ")", ":", "if", "not", "overwrite", "and", "...
71746d9edbe7993a783d4acaf84b9631f3230283
train
keys_by_creation
Returns a sequence of links in group in order of creation. Raises an error if the group was not set to track creation order.
arf.py
def keys_by_creation(group): """Returns a sequence of links in group in order of creation. Raises an error if the group was not set to track creation order. """ from h5py import h5 out = [] try: group._id.links.iterate( out.append, idx_type=h5.INDEX_CRT_ORDER, order=h5.ITER...
def keys_by_creation(group): """Returns a sequence of links in group in order of creation. Raises an error if the group was not set to track creation order. """ from h5py import h5 out = [] try: group._id.links.iterate( out.append, idx_type=h5.INDEX_CRT_ORDER, order=h5.ITER...
[ "Returns", "a", "sequence", "of", "links", "in", "group", "in", "order", "of", "creation", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L259-L277
[ "def", "keys_by_creation", "(", "group", ")", ":", "from", "h5py", "import", "h5", "out", "=", "[", "]", "try", ":", "group", ".", "_id", ".", "links", ".", "iterate", "(", "out", ".", "append", ",", "idx_type", "=", "h5", ".", "INDEX_CRT_ORDER", ","...
71746d9edbe7993a783d4acaf84b9631f3230283
train
convert_timestamp
Make an ARF timestamp from an object. Argument can be a datetime.datetime object, a time.struct_time, an integer, a float, or a tuple of integers. The returned value is a numpy array with the integer number of seconds since the Epoch and any additional microseconds. Note that because floating poin...
arf.py
def convert_timestamp(obj): """Make an ARF timestamp from an object. Argument can be a datetime.datetime object, a time.struct_time, an integer, a float, or a tuple of integers. The returned value is a numpy array with the integer number of seconds since the Epoch and any additional microseconds. ...
def convert_timestamp(obj): """Make an ARF timestamp from an object. Argument can be a datetime.datetime object, a time.struct_time, an integer, a float, or a tuple of integers. The returned value is a numpy array with the integer number of seconds since the Epoch and any additional microseconds. ...
[ "Make", "an", "ARF", "timestamp", "from", "an", "object", "." ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L280-L313
[ "def", "convert_timestamp", "(", "obj", ")", ":", "import", "numbers", "from", "datetime", "import", "datetime", "from", "time", "import", "mktime", ",", "struct_time", "from", "numpy", "import", "zeros", "out", "=", "zeros", "(", "2", ",", "dtype", "=", "...
71746d9edbe7993a783d4acaf84b9631f3230283
train
timestamp_to_datetime
Convert an ARF timestamp to a datetime.datetime object (naive local time)
arf.py
def timestamp_to_datetime(timestamp): """Convert an ARF timestamp to a datetime.datetime object (naive local time)""" from datetime import datetime, timedelta obj = datetime.fromtimestamp(timestamp[0]) return obj + timedelta(microseconds=int(timestamp[1]))
def timestamp_to_datetime(timestamp): """Convert an ARF timestamp to a datetime.datetime object (naive local time)""" from datetime import datetime, timedelta obj = datetime.fromtimestamp(timestamp[0]) return obj + timedelta(microseconds=int(timestamp[1]))
[ "Convert", "an", "ARF", "timestamp", "to", "a", "datetime", ".", "datetime", "object", "(", "naive", "local", "time", ")" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L316-L320
[ "def", "timestamp_to_datetime", "(", "timestamp", ")", ":", "from", "datetime", "import", "datetime", ",", "timedelta", "obj", "=", "datetime", ".", "fromtimestamp", "(", "timestamp", "[", "0", "]", ")", "return", "obj", "+", "timedelta", "(", "microseconds", ...
71746d9edbe7993a783d4acaf84b9631f3230283
train
set_uuid
Set the uuid attribute of an HDF5 object. Use this method to ensure correct dtype
arf.py
def set_uuid(obj, uuid=None): """Set the uuid attribute of an HDF5 object. Use this method to ensure correct dtype """ from uuid import uuid4, UUID if uuid is None: uuid = uuid4() elif isinstance(uuid, bytes): if len(uuid) == 16: uuid = UUID(bytes=uuid) else: ...
def set_uuid(obj, uuid=None): """Set the uuid attribute of an HDF5 object. Use this method to ensure correct dtype """ from uuid import uuid4, UUID if uuid is None: uuid = uuid4() elif isinstance(uuid, bytes): if len(uuid) == 16: uuid = UUID(bytes=uuid) else: ...
[ "Set", "the", "uuid", "attribute", "of", "an", "HDF5", "object", ".", "Use", "this", "method", "to", "ensure", "correct", "dtype" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L328-L341
[ "def", "set_uuid", "(", "obj", ",", "uuid", "=", "None", ")", ":", "from", "uuid", "import", "uuid4", ",", "UUID", "if", "uuid", "is", "None", ":", "uuid", "=", "uuid4", "(", ")", "elif", "isinstance", "(", "uuid", ",", "bytes", ")", ":", "if", "...
71746d9edbe7993a783d4acaf84b9631f3230283
train
get_uuid
Return the uuid for obj, or null uuid if none is set
arf.py
def get_uuid(obj): """Return the uuid for obj, or null uuid if none is set""" # TODO: deprecate null uuid ret val from uuid import UUID try: uuid = obj.attrs['uuid'] except KeyError: return UUID(int=0) # convert to unicode for python 3 try: uuid = uuid.decode('ascii')...
def get_uuid(obj): """Return the uuid for obj, or null uuid if none is set""" # TODO: deprecate null uuid ret val from uuid import UUID try: uuid = obj.attrs['uuid'] except KeyError: return UUID(int=0) # convert to unicode for python 3 try: uuid = uuid.decode('ascii')...
[ "Return", "the", "uuid", "for", "obj", "or", "null", "uuid", "if", "none", "is", "set" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L344-L357
[ "def", "get_uuid", "(", "obj", ")", ":", "# TODO: deprecate null uuid ret val", "from", "uuid", "import", "UUID", "try", ":", "uuid", "=", "obj", ".", "attrs", "[", "'uuid'", "]", "except", "KeyError", ":", "return", "UUID", "(", "int", "=", "0", ")", "#...
71746d9edbe7993a783d4acaf84b9631f3230283
train
count_children
Return the number of children of obj, optionally restricting by class
arf.py
def count_children(obj, type=None): """Return the number of children of obj, optionally restricting by class""" if type is None: return len(obj) else: # there doesn't appear to be any hdf5 function for getting this # information without inspecting each child, which makes this somewha...
def count_children(obj, type=None): """Return the number of children of obj, optionally restricting by class""" if type is None: return len(obj) else: # there doesn't appear to be any hdf5 function for getting this # information without inspecting each child, which makes this somewha...
[ "Return", "the", "number", "of", "children", "of", "obj", "optionally", "restricting", "by", "class" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L360-L368
[ "def", "count_children", "(", "obj", ",", "type", "=", "None", ")", ":", "if", "type", "is", "None", ":", "return", "len", "(", "obj", ")", "else", ":", "# there doesn't appear to be any hdf5 function for getting this", "# information without inspecting each child, whic...
71746d9edbe7993a783d4acaf84b9631f3230283
train
DataTypes._todict
generate a dict keyed by value
arf.py
def _todict(cls): """ generate a dict keyed by value """ return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
def _todict(cls): """ generate a dict keyed by value """ return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
[ "generate", "a", "dict", "keyed", "by", "value" ]
melizalab/arf
python
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L32-L34
[ "def", "_todict", "(", "cls", ")", ":", "return", "dict", "(", "(", "getattr", "(", "cls", ",", "attr", ")", ",", "attr", ")", "for", "attr", "in", "dir", "(", "cls", ")", "if", "not", "attr", ".", "startswith", "(", "'_'", ")", ")" ]
71746d9edbe7993a783d4acaf84b9631f3230283
train
get_template
get_template will return a template in the template folder, with some substitutions (eg, {'{{ graph | safe }}':"fill this in!"}
singularity/views/utils.py
def get_template(template_name,fields=None): '''get_template will return a template in the template folder, with some substitutions (eg, {'{{ graph | safe }}':"fill this in!"} ''' template = None if not template_name.endswith('.html'): template_name = "%s.html" %(template_name) here = "%...
def get_template(template_name,fields=None): '''get_template will return a template in the template folder, with some substitutions (eg, {'{{ graph | safe }}':"fill this in!"} ''' template = None if not template_name.endswith('.html'): template_name = "%s.html" %(template_name) here = "%...
[ "get_template", "will", "return", "a", "template", "in", "the", "template", "folder", "with", "some", "substitutions", "(", "eg", "{", "{{", "graph", "|", "safe", "}}", ":", "fill", "this", "in!", "}" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/utils.py#L32-L46
[ "def", "get_template", "(", "template_name", ",", "fields", "=", "None", ")", ":", "template", "=", "None", "if", "not", "template_name", ".", "endswith", "(", "'.html'", ")", ":", "template_name", "=", "\"%s.html\"", "%", "(", "template_name", ")", "here", ...
498c3433724b332f7493fec632d8daf479f47b82
train
container_similarity_vector
container similarity_vector is similar to compare_packages, but intended to compare a container object (singularity image or singularity hub container) to a list of packages. If packages_set is not provided, the default used is 'docker-os'. This can be changed to 'docker-library', or if the user wants a cu...
singularity/analysis/compare.py
def container_similarity_vector(container1=None,packages_set=None,by=None): '''container similarity_vector is similar to compare_packages, but intended to compare a container object (singularity image or singularity hub container) to a list of packages. If packages_set is not provided, the default used is ...
def container_similarity_vector(container1=None,packages_set=None,by=None): '''container similarity_vector is similar to compare_packages, but intended to compare a container object (singularity image or singularity hub container) to a list of packages. If packages_set is not provided, the default used is ...
[ "container", "similarity_vector", "is", "similar", "to", "compare_packages", "but", "intended", "to", "compare", "a", "container", "object", "(", "singularity", "image", "or", "singularity", "hub", "container", ")", "to", "a", "list", "of", "packages", ".", "If"...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L41-L75
[ "def", "container_similarity_vector", "(", "container1", "=", "None", ",", "packages_set", "=", "None", ",", "by", "=", "None", ")", ":", "if", "by", "==", "None", ":", "by", "=", "[", "'files.txt'", "]", "if", "not", "isinstance", "(", "by", ",", "lis...
498c3433724b332f7493fec632d8daf479f47b82
train
compare_singularity_images
compare_singularity_images is a wrapper for compare_containers to compare singularity containers. If image_paths2 is not defined, pairwise comparison is done with image_paths1
singularity/analysis/compare.py
def compare_singularity_images(image_paths1, image_paths2=None): '''compare_singularity_images is a wrapper for compare_containers to compare singularity containers. If image_paths2 is not defined, pairwise comparison is done with image_paths1 ''' repeat = False if image_paths2 is None: ...
def compare_singularity_images(image_paths1, image_paths2=None): '''compare_singularity_images is a wrapper for compare_containers to compare singularity containers. If image_paths2 is not defined, pairwise comparison is done with image_paths1 ''' repeat = False if image_paths2 is None: ...
[ "compare_singularity_images", "is", "a", "wrapper", "for", "compare_containers", "to", "compare", "singularity", "containers", ".", "If", "image_paths2", "is", "not", "defined", "pairwise", "comparison", "is", "done", "with", "image_paths1" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L78-L120
[ "def", "compare_singularity_images", "(", "image_paths1", ",", "image_paths2", "=", "None", ")", ":", "repeat", "=", "False", "if", "image_paths2", "is", "None", ":", "image_paths2", "=", "image_paths1", "repeat", "=", "True", "if", "not", "isinstance", "(", "...
498c3433724b332f7493fec632d8daf479f47b82
train
compare_containers
compare_containers will generate a data structure with common and unique files to two images. If environmental variable SINGULARITY_HUB is set, will use container database objects. :param container1: first container for comparison :param container2: second container for comparison if either not defined ...
singularity/analysis/compare.py
def compare_containers(container1=None, container2=None): '''compare_containers will generate a data structure with common and unique files to two images. If environmental variable SINGULARITY_HUB is set, will use container database objects. :param container1: first container for comparison :param ...
def compare_containers(container1=None, container2=None): '''compare_containers will generate a data structure with common and unique files to two images. If environmental variable SINGULARITY_HUB is set, will use container database objects. :param container1: first container for comparison :param ...
[ "compare_containers", "will", "generate", "a", "data", "structure", "with", "common", "and", "unique", "files", "to", "two", "images", ".", "If", "environmental", "variable", "SINGULARITY_HUB", "is", "set", "will", "use", "container", "database", "objects", ".", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L123-L140
[ "def", "compare_containers", "(", "container1", "=", "None", ",", "container2", "=", "None", ")", ":", "# Get files and folders for each", "container1_guts", "=", "get_container_contents", "(", "split_delim", "=", "\"\\n\"", ",", "container", "=", "container1", ")", ...
498c3433724b332f7493fec632d8daf479f47b82
train
compare_lists
compare lists is the lowest level that drives compare_containers and compare_packages. It returns a comparison object (dict) with the unique, total, and intersecting things between two lists :param list1: the list for container1 :param list2: the list for container2
singularity/analysis/compare.py
def compare_lists(list1,list2): '''compare lists is the lowest level that drives compare_containers and compare_packages. It returns a comparison object (dict) with the unique, total, and intersecting things between two lists :param list1: the list for container1 :param list2: the list for container...
def compare_lists(list1,list2): '''compare lists is the lowest level that drives compare_containers and compare_packages. It returns a comparison object (dict) with the unique, total, and intersecting things between two lists :param list1: the list for container1 :param list2: the list for container...
[ "compare", "lists", "is", "the", "lowest", "level", "that", "drives", "compare_containers", "and", "compare_packages", ".", "It", "returns", "a", "comparison", "object", "(", "dict", ")", "with", "the", "unique", "total", "and", "intersecting", "things", "betwee...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L143-L160
[ "def", "compare_lists", "(", "list1", ",", "list2", ")", ":", "intersect", "=", "list", "(", "set", "(", "list1", ")", ".", "intersection", "(", "list2", ")", ")", "unique1", "=", "list", "(", "set", "(", "list1", ")", ".", "difference", "(", "list2"...
498c3433724b332f7493fec632d8daf479f47b82
train
calculate_similarity
calculate_similarity will calculate similarity of two containers by files content, default will calculate 2.0*len(intersect) / total package1 + total package2 Parameters ========== container1: container 1 container2: container 2 must be defined or metric a function to take a total...
singularity/analysis/compare.py
def calculate_similarity(container1=None, container2=None, comparison=None, metric=None): '''calculate_similarity will calculate similarity of two containers by files content, default will calculate 2.0*len(intersect) / to...
def calculate_similarity(container1=None, container2=None, comparison=None, metric=None): '''calculate_similarity will calculate similarity of two containers by files content, default will calculate 2.0*len(intersect) / to...
[ "calculate_similarity", "will", "calculate", "similarity", "of", "two", "containers", "by", "files", "content", "default", "will", "calculate", "2", ".", "0", "*", "len", "(", "intersect", ")", "/", "total", "package1", "+", "total", "package2" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L163-L193
[ "def", "calculate_similarity", "(", "container1", "=", "None", ",", "container2", "=", "None", ",", "comparison", "=", "None", ",", "metric", "=", "None", ")", ":", "if", "metric", "is", "None", ":", "metric", "=", "information_coefficient", "if", "compariso...
498c3433724b332f7493fec632d8daf479f47b82
train
package_node
package node aims to package a (present working node) for a user into a container. This assumes that the node is a single partition. :param root: the root of the node to package, default is / :param name: the name for the image. If not specified, will use machine's psutil.disk_partitions()
singularity/package/clone.py
def package_node(root=None, name=None): '''package node aims to package a (present working node) for a user into a container. This assumes that the node is a single partition. :param root: the root of the node to package, default is / :param name: the name for the image. If not specified, will use ma...
def package_node(root=None, name=None): '''package node aims to package a (present working node) for a user into a container. This assumes that the node is a single partition. :param root: the root of the node to package, default is / :param name: the name for the image. If not specified, will use ma...
[ "package", "node", "aims", "to", "package", "a", "(", "present", "working", "node", ")", "for", "a", "user", "into", "a", "container", ".", "This", "assumes", "that", "the", "node", "is", "a", "single", "partition", ".", ":", "param", "root", ":", "the...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/clone.py#L30-L53
[ "def", "package_node", "(", "root", "=", "None", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "platform", ".", "node", "(", ")", "if", "root", "is", "None", ":", "root", "=", "\"/\"", "tmpdir", "=", "tempfile", ...
498c3433724b332f7493fec632d8daf479f47b82
train
unpack_node
unpackage node is intended to unpackage a node that was packaged with package_node. The image should be a .tgz file. The general steps are to: 1. Package the node using the package_node function 2. Transfer the package somewhere that Singularity is installed
singularity/package/clone.py
def unpack_node(image_path,name=None,output_folder=None,size=None): '''unpackage node is intended to unpackage a node that was packaged with package_node. The image should be a .tgz file. The general steps are to: 1. Package the node using the package_node function 2. Transfer the package somewhere that...
def unpack_node(image_path,name=None,output_folder=None,size=None): '''unpackage node is intended to unpackage a node that was packaged with package_node. The image should be a .tgz file. The general steps are to: 1. Package the node using the package_node function 2. Transfer the package somewhere that...
[ "unpackage", "node", "is", "intended", "to", "unpackage", "a", "node", "that", "was", "packaged", "with", "package_node", ".", "The", "image", "should", "be", "a", ".", "tgz", "file", ".", "The", "general", "steps", "are", "to", ":", "1", ".", "Package",...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/clone.py#L56-L87
[ "def", "unpack_node", "(", "image_path", ",", "name", "=", "None", ",", "output_folder", "=", "None", ",", "size", "=", "None", ")", ":", "if", "not", "image_path", ".", "endswith", "(", "\".tgz\"", ")", ":", "bot", ".", "error", "(", "\"The image_path s...
498c3433724b332f7493fec632d8daf479f47b82
train
get_build_template
get_build template returns a string or file for a particular build template, which is intended to build a version of a Singularity image on a cloud resource. :param template_name: the name of the template to retrieve in build/scripts :param params: (if needed) a dictionary of parameters to substitute in the...
singularity/build/utils.py
def get_build_template(template_name,params=None,to_file=None): '''get_build template returns a string or file for a particular build template, which is intended to build a version of a Singularity image on a cloud resource. :param template_name: the name of the template to retrieve in build/scripts :pa...
def get_build_template(template_name,params=None,to_file=None): '''get_build template returns a string or file for a particular build template, which is intended to build a version of a Singularity image on a cloud resource. :param template_name: the name of the template to retrieve in build/scripts :pa...
[ "get_build", "template", "returns", "a", "string", "or", "file", "for", "a", "particular", "build", "template", "which", "is", "intended", "to", "build", "a", "version", "of", "a", "Singularity", "image", "on", "a", "cloud", "resource", ".", ":", "param", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/utils.py#L72-L100
[ "def", "get_build_template", "(", "template_name", ",", "params", "=", "None", ",", "to_file", "=", "None", ")", ":", "base", "=", "get_installdir", "(", ")", "template_folder", "=", "\"%s/build/scripts\"", "%", "(", "base", ")", "template_file", "=", "\"%s/%s...
498c3433724b332f7493fec632d8daf479f47b82
train
sniff_extension
sniff_extension will attempt to determine the file type based on the extension, and return the proper mimetype :param file_path: the full path to the file to sniff :param verbose: print stuff out
singularity/build/utils.py
def sniff_extension(file_path,verbose=True): '''sniff_extension will attempt to determine the file type based on the extension, and return the proper mimetype :param file_path: the full path to the file to sniff :param verbose: print stuff out ''' mime_types = { "xls": 'application/vnd.ms-exc...
def sniff_extension(file_path,verbose=True): '''sniff_extension will attempt to determine the file type based on the extension, and return the proper mimetype :param file_path: the full path to the file to sniff :param verbose: print stuff out ''' mime_types = { "xls": 'application/vnd.ms-exc...
[ "sniff_extension", "will", "attempt", "to", "determine", "the", "file", "type", "based", "on", "the", "extension", "and", "return", "the", "proper", "mimetype", ":", "param", "file_path", ":", "the", "full", "path", "to", "the", "file", "to", "sniff", ":", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/utils.py#L140-L185
[ "def", "sniff_extension", "(", "file_path", ",", "verbose", "=", "True", ")", ":", "mime_types", "=", "{", "\"xls\"", ":", "'application/vnd.ms-excel'", ",", "\"xlsx\"", ":", "'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'", ",", "\"xml\"", ":", "'t...
498c3433724b332f7493fec632d8daf479f47b82
train
get_script
get_script will return a build script_name, if it is included in singularity/build/scripts, otherwise will alert the user and return None :param script_name: the name of the script to look for
singularity/build/utils.py
def get_script(script_name): '''get_script will return a build script_name, if it is included in singularity/build/scripts, otherwise will alert the user and return None :param script_name: the name of the script to look for ''' install_dir = get_installdir() script_path = "%s/build/scripts/%s"...
def get_script(script_name): '''get_script will return a build script_name, if it is included in singularity/build/scripts, otherwise will alert the user and return None :param script_name: the name of the script to look for ''' install_dir = get_installdir() script_path = "%s/build/scripts/%s"...
[ "get_script", "will", "return", "a", "build", "script_name", "if", "it", "is", "included", "in", "singularity", "/", "build", "/", "scripts", "otherwise", "will", "alert", "the", "user", "and", "return", "None", ":", "param", "script_name", ":", "the", "name...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/utils.py#L188-L199
[ "def", "get_script", "(", "script_name", ")", ":", "install_dir", "=", "get_installdir", "(", ")", "script_path", "=", "\"%s/build/scripts/%s\"", "%", "(", "install_dir", ",", "script_name", ")", "if", "os", ".", "path", ".", "exists", "(", "script_path", ")",...
498c3433724b332f7493fec632d8daf479f47b82
train
zip_up
zip_up will zip up some list of files into a package (.zip) :param file_list: a list of files to include in the zip. :param output_folder: the output folder to create the zip in. If not :param zip_name: the name of the zipfile to return. specified, a temporary folder will be given.
singularity/package/utils.py
def zip_up(file_list,zip_name,output_folder=None): '''zip_up will zip up some list of files into a package (.zip) :param file_list: a list of files to include in the zip. :param output_folder: the output folder to create the zip in. If not :param zip_name: the name of the zipfile to return. specifi...
def zip_up(file_list,zip_name,output_folder=None): '''zip_up will zip up some list of files into a package (.zip) :param file_list: a list of files to include in the zip. :param output_folder: the output folder to create the zip in. If not :param zip_name: the name of the zipfile to return. specifi...
[ "zip_up", "will", "zip", "up", "some", "list", "of", "files", "into", "a", "package", "(", ".", "zip", ")", ":", "param", "file_list", ":", "a", "list", "of", "files", "to", "include", "in", "the", "zip", ".", ":", "param", "output_folder", ":", "the...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/utils.py#L52-L110
[ "def", "zip_up", "(", "file_list", ",", "zip_name", ",", "output_folder", "=", "None", ")", ":", "tmpdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "# Make a new archive ", "output_zip", "=", "\"%s/%s\"", "%", "(", "tmpdir", ",", "zip_name", ")", "zf", ...
498c3433724b332f7493fec632d8daf479f47b82
train
get_container_contents
get_container_contents will return a list of folders and or files for a container. The environmental variable SINGULARITY_HUB being set means that container objects are referenced instead of packages :param container: the container to get content for :param gets: a list of file names to return, without ...
singularity/package/utils.py
def get_container_contents(container, split_delim=None): '''get_container_contents will return a list of folders and or files for a container. The environmental variable SINGULARITY_HUB being set means that container objects are referenced instead of packages :param container: the container to get conte...
def get_container_contents(container, split_delim=None): '''get_container_contents will return a list of folders and or files for a container. The environmental variable SINGULARITY_HUB being set means that container objects are referenced instead of packages :param container: the container to get conte...
[ "get_container_contents", "will", "return", "a", "list", "of", "folders", "and", "or", "files", "for", "a", "container", ".", "The", "environmental", "variable", "SINGULARITY_HUB", "being", "set", "means", "that", "container", "objects", "are", "referenced", "inst...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/utils.py#L119-L156
[ "def", "get_container_contents", "(", "container", ",", "split_delim", "=", "None", ")", ":", "# We will look for everything in guts, then return it", "guts", "=", "dict", "(", ")", "SINGULARITY_HUB", "=", "os", ".", "environ", ".", "get", "(", "'SINGULARITY_HUB'", ...
498c3433724b332f7493fec632d8daf479f47b82
train
get_image_hashes
get_image_hashes returns the hash for an image across all levels. This is the quickest, easiest way to define a container's reproducibility on each level.
singularity/analysis/reproduce/hash.py
def get_image_hashes(image_path, version=None, levels=None): '''get_image_hashes returns the hash for an image across all levels. This is the quickest, easiest way to define a container's reproducibility on each level. ''' if levels is None: levels = get_levels(version=version) hashes = dict...
def get_image_hashes(image_path, version=None, levels=None): '''get_image_hashes returns the hash for an image across all levels. This is the quickest, easiest way to define a container's reproducibility on each level. ''' if levels is None: levels = get_levels(version=version) hashes = dict...
[ "get_image_hashes", "returns", "the", "hash", "for", "an", "image", "across", "all", "levels", ".", "This", "is", "the", "quickest", "easiest", "way", "to", "define", "a", "container", "s", "reproducibility", "on", "each", "level", "." ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L42-L52
[ "def", "get_image_hashes", "(", "image_path", ",", "version", "=", "None", ",", "levels", "=", "None", ")", ":", "if", "levels", "is", "None", ":", "levels", "=", "get_levels", "(", "version", "=", "version", ")", "hashes", "=", "dict", "(", ")", "for"...
498c3433724b332f7493fec632d8daf479f47b82
train
get_image_hash
get_image_hash will generate a sha1 hash of an image, depending on a level of reproducibility specified by the user. (see function get_levels for descriptions) the user can also provide a level_filter manually with level_filter (for custom levels) :param level: the level of reproducibility to use, which map...
singularity/analysis/reproduce/hash.py
def get_image_hash(image_path, level=None,level_filter=None, include_files=None, skip_files=None, version=None): '''get_image_hash will generate a sha1 hash of an image, depending on a level of reproducibility specified by the user. (s...
def get_image_hash(image_path, level=None,level_filter=None, include_files=None, skip_files=None, version=None): '''get_image_hash will generate a sha1 hash of an image, depending on a level of reproducibility specified by the user. (s...
[ "get_image_hash", "will", "generate", "a", "sha1", "hash", "of", "an", "image", "depending", "on", "a", "level", "of", "reproducibility", "specified", "by", "the", "user", ".", "(", "see", "function", "get_levels", "for", "descriptions", ")", "the", "user", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L56-L121
[ "def", "get_image_hash", "(", "image_path", ",", "level", "=", "None", ",", "level_filter", "=", "None", ",", "include_files", "=", "None", ",", "skip_files", "=", "None", ",", "version", "=", "None", ")", ":", "# First get a level dictionary, with description and...
498c3433724b332f7493fec632d8daf479f47b82
train
get_content_hashes
get_content_hashes is like get_image_hash, but it returns a complete dictionary of file names (keys) and their respective hashes (values). This function is intended for more research purposes and was used to generate the levels in the first place. If include_sizes is True, we include a second data structur...
singularity/analysis/reproduce/hash.py
def get_content_hashes(image_path, level=None, regexp=None, include_files=None, tag_root=True, level_filter=None, skip_files=None, version=None, ...
def get_content_hashes(image_path, level=None, regexp=None, include_files=None, tag_root=True, level_filter=None, skip_files=None, version=None, ...
[ "get_content_hashes", "is", "like", "get_image_hash", "but", "it", "returns", "a", "complete", "dictionary", "of", "file", "names", "(", "keys", ")", "and", "their", "respective", "hashes", "(", "values", ")", ".", "This", "function", "is", "intended", "for", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L124-L162
[ "def", "get_content_hashes", "(", "image_path", ",", "level", "=", "None", ",", "regexp", "=", "None", ",", "include_files", "=", "None", ",", "tag_root", "=", "True", ",", "level_filter", "=", "None", ",", "skip_files", "=", "None", ",", "version", "=", ...
498c3433724b332f7493fec632d8daf479f47b82
train
get_image_file_hash
get_image_hash will return an md5 hash of the file based on a criteria level. :param level: one of LOW, MEDIUM, HIGH :param image_path: full path to the singularity image
singularity/analysis/reproduce/hash.py
def get_image_file_hash(image_path): '''get_image_hash will return an md5 hash of the file based on a criteria level. :param level: one of LOW, MEDIUM, HIGH :param image_path: full path to the singularity image ''' hasher = hashlib.md5() with open(image_path, "rb") as f: for chunk in ite...
def get_image_file_hash(image_path): '''get_image_hash will return an md5 hash of the file based on a criteria level. :param level: one of LOW, MEDIUM, HIGH :param image_path: full path to the singularity image ''' hasher = hashlib.md5() with open(image_path, "rb") as f: for chunk in ite...
[ "get_image_hash", "will", "return", "an", "md5", "hash", "of", "the", "file", "based", "on", "a", "criteria", "level", ".", ":", "param", "level", ":", "one", "of", "LOW", "MEDIUM", "HIGH", ":", "param", "image_path", ":", "full", "path", "to", "the", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L166-L175
[ "def", "get_image_file_hash", "(", "image_path", ")", ":", "hasher", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "image_path", ",", "\"rb\"", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "(",...
498c3433724b332f7493fec632d8daf479f47b82
train
container_difference
container_difference will return a data structure to render an html tree (graph) of the differences between two images or packages. The second container is subtracted from the first :param container: the primary container object (to subtract from) :param container_subtract: the second container object ...
singularity/views/trees.py
def container_difference(container=None,container_subtract=None,image_package=None, image_package_subtract=None,comparison=None): '''container_difference will return a data structure to render an html tree (graph) of the differences between two images or packages. The second contai...
def container_difference(container=None,container_subtract=None,image_package=None, image_package_subtract=None,comparison=None): '''container_difference will return a data structure to render an html tree (graph) of the differences between two images or packages. The second contai...
[ "container_difference", "will", "return", "a", "data", "structure", "to", "render", "an", "html", "tree", "(", "graph", ")", "of", "the", "differences", "between", "two", "images", "or", "packages", ".", "The", "second", "container", "is", "subtracted", "from"...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L55-L78
[ "def", "container_difference", "(", "container", "=", "None", ",", "container_subtract", "=", "None", ",", "image_package", "=", "None", ",", "image_package_subtract", "=", "None", ",", "comparison", "=", "None", ")", ":", "if", "comparison", "==", "None", ":"...
498c3433724b332f7493fec632d8daf479f47b82
train
container_similarity
container_sim will return a data structure to render an html tree (graph) of the intersection (commonalities) between two images or packages :param container1: the first container object :param container2: the second container object if either not defined, need :param image_package1: a packaged contain...
singularity/views/trees.py
def container_similarity(container1=None,container2=None,image_package1=None, image_package2=None,comparison=None): '''container_sim will return a data structure to render an html tree (graph) of the intersection (commonalities) between two images or packages :param container1: the...
def container_similarity(container1=None,container2=None,image_package1=None, image_package2=None,comparison=None): '''container_sim will return a data structure to render an html tree (graph) of the intersection (commonalities) between two images or packages :param container1: the...
[ "container_sim", "will", "return", "a", "data", "structure", "to", "render", "an", "html", "tree", "(", "graph", ")", "of", "the", "intersection", "(", "commonalities", ")", "between", "two", "images", "or", "packages", ":", "param", "container1", ":", "the"...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L82-L103
[ "def", "container_similarity", "(", "container1", "=", "None", ",", "container2", "=", "None", ",", "image_package1", "=", "None", ",", "image_package2", "=", "None", ",", "comparison", "=", "None", ")", ":", "if", "comparison", "==", "None", ":", "compariso...
498c3433724b332f7493fec632d8daf479f47b82
train
container_tree
tree will render an html tree (graph) of a container
singularity/views/trees.py
def container_tree(container=None,image_package=None): '''tree will render an html tree (graph) of a container ''' guts = get_container_contents(container=container, image_package=image_package, split_delim="\n") # Make the tree and r...
def container_tree(container=None,image_package=None): '''tree will render an html tree (graph) of a container ''' guts = get_container_contents(container=container, image_package=image_package, split_delim="\n") # Make the tree and r...
[ "tree", "will", "render", "an", "html", "tree", "(", "graph", ")", "of", "a", "container" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L106-L117
[ "def", "container_tree", "(", "container", "=", "None", ",", "image_package", "=", "None", ")", ":", "guts", "=", "get_container_contents", "(", "container", "=", "container", ",", "image_package", "=", "image_package", ",", "split_delim", "=", "\"\\n\"", ")", ...
498c3433724b332f7493fec632d8daf479f47b82
train
make_container_tree
make_container_tree will convert a list of folders and files into a json structure that represents a graph. :param folders: a list of folders in the image :param files: a list of files in the folder :param parse_files: return 'files' lookup in result, to associate ID of node with files (default True) :p...
singularity/views/trees.py
def make_container_tree(folders,files,path_delim="/",parse_files=True): '''make_container_tree will convert a list of folders and files into a json structure that represents a graph. :param folders: a list of folders in the image :param files: a list of files in the folder :param parse_files: return 'fi...
def make_container_tree(folders,files,path_delim="/",parse_files=True): '''make_container_tree will convert a list of folders and files into a json structure that represents a graph. :param folders: a list of folders in the image :param files: a list of files in the folder :param parse_files: return 'fi...
[ "make_container_tree", "will", "convert", "a", "list", "of", "folders", "and", "files", "into", "a", "json", "structure", "that", "represents", "a", "graph", ".", ":", "param", "folders", ":", "a", "list", "of", "folders", "in", "the", "image", ":", "param...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L120-L197
[ "def", "make_container_tree", "(", "folders", ",", "files", ",", "path_delim", "=", "\"/\"", ",", "parse_files", "=", "True", ")", ":", "nodes", "=", "{", "}", "# first we will make a list of nodes", "lookup", "=", "{", "}", "count", "=", "1", "# count will ho...
498c3433724b332f7493fec632d8daf479f47b82
train
make_package_tree
make package tree will make a dendrogram comparing a matrix of packages :param matrix: a pandas df of packages, with names in index and columns :param labels: a list of labels corresponding to row names, will be pulled from rows if not defined :param title: a title for the plot, if not defined, will be ...
singularity/views/trees.py
def make_package_tree(matrix=None,labels=None,width=25,height=10,title=None,font_size=None): '''make package tree will make a dendrogram comparing a matrix of packages :param matrix: a pandas df of packages, with names in index and columns :param labels: a list of labels corresponding to row names, will be ...
def make_package_tree(matrix=None,labels=None,width=25,height=10,title=None,font_size=None): '''make package tree will make a dendrogram comparing a matrix of packages :param matrix: a pandas df of packages, with names in index and columns :param labels: a list of labels corresponding to row names, will be ...
[ "make", "package", "tree", "will", "make", "a", "dendrogram", "comparing", "a", "matrix", "of", "packages", ":", "param", "matrix", ":", "a", "pandas", "df", "of", "packages", "with", "names", "in", "index", "and", "columns", ":", "param", "labels", ":", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L205-L247
[ "def", "make_package_tree", "(", "matrix", "=", "None", ",", "labels", "=", "None", ",", "width", "=", "25", ",", "height", "=", "10", ",", "title", "=", "None", ",", "font_size", "=", "None", ")", ":", "from", "matplotlib", "import", "pyplot", "as", ...
498c3433724b332f7493fec632d8daf479f47b82
train
make_interactive_tree
make interactive tree will return complete html for an interactive tree :param title: a title for the plot, if not defined, will be left out.
singularity/views/trees.py
def make_interactive_tree(matrix=None,labels=None): '''make interactive tree will return complete html for an interactive tree :param title: a title for the plot, if not defined, will be left out. ''' from scipy.cluster.hierarchy import ( dendrogram, linkage, to_tree ) ...
def make_interactive_tree(matrix=None,labels=None): '''make interactive tree will return complete html for an interactive tree :param title: a title for the plot, if not defined, will be left out. ''' from scipy.cluster.hierarchy import ( dendrogram, linkage, to_tree ) ...
[ "make", "interactive", "tree", "will", "return", "complete", "html", "for", "an", "interactive", "tree", ":", "param", "title", ":", "a", "title", "for", "the", "plot", "if", "not", "defined", "will", "be", "left", "out", "." ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L250-L284
[ "def", "make_interactive_tree", "(", "matrix", "=", "None", ",", "labels", "=", "None", ")", ":", "from", "scipy", ".", "cluster", ".", "hierarchy", "import", "(", "dendrogram", ",", "linkage", ",", "to_tree", ")", "d3", "=", "None", "from", "scipy", "."...
498c3433724b332f7493fec632d8daf479f47b82
train
add_node
add_node will add a node to it's parent
singularity/views/trees.py
def add_node(node, parent): '''add_node will add a node to it's parent ''' newNode = dict(node_id=node.id, children=[]) parent["children"].append(newNode) if node.left: add_node(node.left, newNode) if node.right: add_node(node.right, newNode)
def add_node(node, parent): '''add_node will add a node to it's parent ''' newNode = dict(node_id=node.id, children=[]) parent["children"].append(newNode) if node.left: add_node(node.left, newNode) if node.right: add_node(node.right, newNode)
[ "add_node", "will", "add", "a", "node", "to", "it", "s", "parent" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L287-L293
[ "def", "add_node", "(", "node", ",", "parent", ")", ":", "newNode", "=", "dict", "(", "node_id", "=", "node", ".", "id", ",", "children", "=", "[", "]", ")", "parent", "[", "\"children\"", "]", ".", "append", "(", "newNode", ")", "if", "node", ".",...
498c3433724b332f7493fec632d8daf479f47b82
train
label_tree
label tree will again recursively label the tree :param n: the root node, usually d3['children'][0] :param lookup: the node/id lookup
singularity/views/trees.py
def label_tree(n,lookup): '''label tree will again recursively label the tree :param n: the root node, usually d3['children'][0] :param lookup: the node/id lookup ''' if len(n["children"]) == 0: leaves = [lookup[n["node_id"]]] else: leaves = reduce(lambda ls, c: ls + label_tree(c...
def label_tree(n,lookup): '''label tree will again recursively label the tree :param n: the root node, usually d3['children'][0] :param lookup: the node/id lookup ''' if len(n["children"]) == 0: leaves = [lookup[n["node_id"]]] else: leaves = reduce(lambda ls, c: ls + label_tree(c...
[ "label", "tree", "will", "again", "recursively", "label", "the", "tree", ":", "param", "n", ":", "the", "root", "node", "usually", "d3", "[", "children", "]", "[", "0", "]", ":", "param", "lookup", ":", "the", "node", "/", "id", "lookup" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L296-L307
[ "def", "label_tree", "(", "n", ",", "lookup", ")", ":", "if", "len", "(", "n", "[", "\"children\"", "]", ")", "==", "0", ":", "leaves", "=", "[", "lookup", "[", "n", "[", "\"node_id\"", "]", "]", "]", "else", ":", "leaves", "=", "reduce", "(", ...
498c3433724b332f7493fec632d8daf479f47b82
train
extract_apps
extract app will extract metadata for one or more apps Parameters ========== image: the absolute path to the image app_name: the name of the app under /scif/apps
singularity/analysis/apps.py
def extract_apps(image, app_names): ''' extract app will extract metadata for one or more apps Parameters ========== image: the absolute path to the image app_name: the name of the app under /scif/apps ''' apps = dict() if isinstance(app_names, tuple): app_names...
def extract_apps(image, app_names): ''' extract app will extract metadata for one or more apps Parameters ========== image: the absolute path to the image app_name: the name of the app under /scif/apps ''' apps = dict() if isinstance(app_names, tuple): app_names...
[ "extract", "app", "will", "extract", "metadata", "for", "one", "or", "more", "apps", "Parameters", "==========", "image", ":", "the", "absolute", "path", "to", "the", "image", "app_name", ":", "the", "name", "of", "the", "app", "under", "/", "scif", "/", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/apps.py#L31-L61
[ "def", "extract_apps", "(", "image", ",", "app_names", ")", ":", "apps", "=", "dict", "(", ")", "if", "isinstance", "(", "app_names", ",", "tuple", ")", ":", "app_names", "=", "list", "(", "app_names", ")", "if", "not", "isinstance", "(", "app_names", ...
498c3433724b332f7493fec632d8daf479f47b82
train
run_command
run_command uses subprocess to send a command to the terminal. :param cmd: the command to send, should be a list for subprocess :param error_message: the error message to give to user if fails, if none specified, will alert that command failed. :param sudopw: if specified (not None) command will be run ...
singularity/utils.py
def run_command(cmd, sudo=False): '''run_command uses subprocess to send a command to the terminal. :param cmd: the command to send, should be a list for subprocess :param error_message: the error message to give to user if fails, if none specified, will alert that command failed. :param sudopw: if ...
def run_command(cmd, sudo=False): '''run_command uses subprocess to send a command to the terminal. :param cmd: the command to send, should be a list for subprocess :param error_message: the error message to give to user if fails, if none specified, will alert that command failed. :param sudopw: if ...
[ "run_command", "uses", "subprocess", "to", "send", "a", "command", "to", "the", "terminal", ".", ":", "param", "cmd", ":", "the", "command", "to", "send", "should", "be", "a", "list", "for", "subprocess", ":", "param", "error_message", ":", "the", "error",...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/utils.py#L70-L85
[ "def", "run_command", "(", "cmd", ",", "sudo", "=", "False", ")", ":", "if", "sudo", "is", "True", ":", "cmd", "=", "[", "'sudo'", "]", "+", "cmd", "output", "=", "Popen", "(", "cmd", ",", "stderr", "=", "STDOUT", ",", "stdout", "=", "PIPE", ")",...
498c3433724b332f7493fec632d8daf479f47b82
train
download_repo
download_repo :param repo_url: the url of the repo to clone from :param destination: the full path to the destination for the repo
singularity/utils.py
def download_repo(repo_url, destination, commit=None): '''download_repo :param repo_url: the url of the repo to clone from :param destination: the full path to the destination for the repo ''' command = "git clone %s %s" % (repo_url, destination) os.system(command) return destination
def download_repo(repo_url, destination, commit=None): '''download_repo :param repo_url: the url of the repo to clone from :param destination: the full path to the destination for the repo ''' command = "git clone %s %s" % (repo_url, destination) os.system(command) return destination
[ "download_repo", ":", "param", "repo_url", ":", "the", "url", "of", "the", "repo", "to", "clone", "from", ":", "param", "destination", ":", "the", "full", "path", "to", "the", "destination", "for", "the", "repo" ]
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/utils.py#L190-L197
[ "def", "download_repo", "(", "repo_url", ",", "destination", ",", "commit", "=", "None", ")", ":", "command", "=", "\"git clone %s %s\"", "%", "(", "repo_url", ",", "destination", ")", "os", ".", "system", "(", "command", ")", "return", "destination" ]
498c3433724b332f7493fec632d8daf479f47b82
train
get_tags
get tags will return a list of tags that describe the software in an image, meaning inside of a paricular folder. If search_folder is not defined, uses lib :param container: if provided, will use container as image. Can also provide :param image_package: if provided, can be used instead of container :pa...
singularity/analysis/classify.py
def get_tags(container=None, search_folders=None, file_list=None, return_unique=True): '''get tags will return a list of tags that describe the software in an image, meaning inside of a paricular folder. If search_folder is not defined, uses lib :param container: if p...
def get_tags(container=None, search_folders=None, file_list=None, return_unique=True): '''get tags will return a list of tags that describe the software in an image, meaning inside of a paricular folder. If search_folder is not defined, uses lib :param container: if p...
[ "get", "tags", "will", "return", "a", "list", "of", "tags", "that", "describe", "the", "software", "in", "an", "image", "meaning", "inside", "of", "a", "paricular", "folder", ".", "If", "search_folder", "is", "not", "defined", "uses", "lib", ":", "param", ...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/classify.py#L51-L91
[ "def", "get_tags", "(", "container", "=", "None", ",", "search_folders", "=", "None", ",", "file_list", "=", "None", ",", "return_unique", "=", "True", ")", ":", "if", "file_list", "is", "None", ":", "file_list", "=", "get_container_contents", "(", "containe...
498c3433724b332f7493fec632d8daf479f47b82
train
file_counts
file counts will return a list of files that match one or more regular expressions. if no patterns is defined, a default of readme is used. All patterns and files are made case insensitive. Parameters ========== :param container: if provided, will use container as image. Can also provide :param...
singularity/analysis/classify.py
def file_counts(container=None, patterns=None, image_package=None, file_list=None): '''file counts will return a list of files that match one or more regular expressions. if no patterns is defined, a default of readme is used. All patterns and files are made ...
def file_counts(container=None, patterns=None, image_package=None, file_list=None): '''file counts will return a list of files that match one or more regular expressions. if no patterns is defined, a default of readme is used. All patterns and files are made ...
[ "file", "counts", "will", "return", "a", "list", "of", "files", "that", "match", "one", "or", "more", "regular", "expressions", ".", "if", "no", "patterns", "is", "defined", "a", "default", "of", "readme", "is", "used", ".", "All", "patterns", "and", "fi...
singularityhub/singularity-python
python
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/classify.py#L99-L130
[ "def", "file_counts", "(", "container", "=", "None", ",", "patterns", "=", "None", ",", "image_package", "=", "None", ",", "file_list", "=", "None", ")", ":", "if", "file_list", "is", "None", ":", "file_list", "=", "get_container_contents", "(", "container",...
498c3433724b332f7493fec632d8daf479f47b82