repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Apitax/Apitax
apitax/api/controllers/api_controller.py
get_driver_api_catalog
def get_driver_api_catalog(driver): # noqa: E501 """Retrieve the api catalog Retrieve the api catalog # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized(role='developer') if response: ...
python
def get_driver_api_catalog(driver): # noqa: E501 """Retrieve the api catalog Retrieve the api catalog # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized(role='developer') if response: ...
[ "def", "get_driver_api_catalog", "(", "driver", ")", ":", "# noqa: E501", "response", "=", "errorIfUnauthorized", "(", "role", "=", "'developer'", ")", "if", "response", ":", "return", "response", "else", ":", "response", "=", "ApitaxResponse", "(", ")", "driver...
Retrieve the api catalog Retrieve the api catalog # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response
[ "Retrieve", "the", "api", "catalog" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/api_controller.py#L17-L36
Apitax/Apitax
apitax/api/controllers/api_controller.py
get_driver_api_status
def get_driver_api_status(driver): # noqa: E501 """Retrieve the status of an api backing a driver Retrieve the status of an api backing a driver # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized...
python
def get_driver_api_status(driver): # noqa: E501 """Retrieve the status of an api backing a driver Retrieve the status of an api backing a driver # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized...
[ "def", "get_driver_api_status", "(", "driver", ")", ":", "# noqa: E501", "response", "=", "errorIfUnauthorized", "(", "role", "=", "'developer'", ")", "if", "response", ":", "return", "response", "else", ":", "response", "=", "ApitaxResponse", "(", ")", "driver"...
Retrieve the status of an api backing a driver Retrieve the status of an api backing a driver # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response
[ "Retrieve", "the", "status", "of", "an", "api", "backing", "a", "driver" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/api_controller.py#L40-L75
kejbaly2/idid
idid/logg.py
Logg._parse_engine
def _parse_engine(engine): """ Parse the engine uri to determine where to store loggs """ engine = (engine or '').strip() backend, path = URI_RE.match(engine).groups() if backend not in SUPPORTED_BACKENDS: raise NotImplementedError( "Logg supports only {0} fo...
python
def _parse_engine(engine): """ Parse the engine uri to determine where to store loggs """ engine = (engine or '').strip() backend, path = URI_RE.match(engine).groups() if backend not in SUPPORTED_BACKENDS: raise NotImplementedError( "Logg supports only {0} fo...
[ "def", "_parse_engine", "(", "engine", ")", ":", "engine", "=", "(", "engine", "or", "''", ")", ".", "strip", "(", ")", "backend", ",", "path", "=", "URI_RE", ".", "match", "(", "engine", ")", ".", "groups", "(", ")", "if", "backend", "not", "in", ...
Parse the engine uri to determine where to store loggs
[ "Parse", "the", "engine", "uri", "to", "determine", "where", "to", "store", "loggs" ]
train
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L199-L208
kejbaly2/idid
idid/logg.py
GitLogg._logg_record
def _logg_record(self, record, date): """ # %> idid work 2015-01-01 '... bla bla #tag @mention ...' # results in a logg entry in the 'work' datastore for $DATE (by user) # author_date = '2015-01-01T01:01:01' # record = 'Did something AMAZING! [#id] #did' # info about sp...
python
def _logg_record(self, record, date): """ # %> idid work 2015-01-01 '... bla bla #tag @mention ...' # results in a logg entry in the 'work' datastore for $DATE (by user) # author_date = '2015-01-01T01:01:01' # record = 'Did something AMAZING! [#id] #did' # info about sp...
[ "def", "_logg_record", "(", "self", ",", "record", ",", "date", ")", ":", "# FIXME: take emails from config (extracted in CLI already)", "# FIXME: extract out the possible dates and other tokens", "# FIXME: check that we're using the write dates here...", "# FIXME: check if it isn't a dupl...
# %> idid work 2015-01-01 '... bla bla #tag @mention ...' # results in a logg entry in the 'work' datastore for $DATE (by user) # author_date = '2015-01-01T01:01:01' # record = 'Did something AMAZING! [#id] #did' # info about specifying a specific date for the committ # http://...
[ "#", "%", ">", "idid", "work", "2015", "-", "01", "-", "01", "...", "bla", "bla", "#tag", "@mention", "...", "#", "results", "in", "a", "logg", "entry", "in", "the", "work", "datastore", "for", "$DATE", "(", "by", "user", ")" ]
train
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L245-L298
kejbaly2/idid
idid/logg.py
GitLogg._init_repo
def _init_repo(self): """ create and initialize a new Git Repo """ log.debug("initializing new Git Repo: {0}".format(self._engine_path)) if os.path.exists(self._engine_path): log.error("Path already exists! Aborting!") raise RuntimeError else: # create...
python
def _init_repo(self): """ create and initialize a new Git Repo """ log.debug("initializing new Git Repo: {0}".format(self._engine_path)) if os.path.exists(self._engine_path): log.error("Path already exists! Aborting!") raise RuntimeError else: # create...
[ "def", "_init_repo", "(", "self", ")", ":", "log", ".", "debug", "(", "\"initializing new Git Repo: {0}\"", ".", "format", "(", "self", ".", "_engine_path", ")", ")", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "_engine_path", ")", ":", "lo...
create and initialize a new Git Repo
[ "create", "and", "initialize", "a", "new", "Git", "Repo" ]
train
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L366-L379
kejbaly2/idid
idid/logg.py
GitLogg._load_repo
def _load_repo(self): """ Load git repo using GitPython """ if self._logg_repo: return self._logg_repo try: _logg_repo = git.Repo(self._engine_path) log.debug('Loaded git repo [{0}]'.format(self._engine_path)) except Exception: # FIXME: sh...
python
def _load_repo(self): """ Load git repo using GitPython """ if self._logg_repo: return self._logg_repo try: _logg_repo = git.Repo(self._engine_path) log.debug('Loaded git repo [{0}]'.format(self._engine_path)) except Exception: # FIXME: sh...
[ "def", "_load_repo", "(", "self", ")", ":", "if", "self", ".", "_logg_repo", ":", "return", "self", ".", "_logg_repo", "try", ":", "_logg_repo", "=", "git", ".", "Repo", "(", "self", ".", "_engine_path", ")", "log", ".", "debug", "(", "'Loaded git repo [...
Load git repo using GitPython
[ "Load", "git", "repo", "using", "GitPython" ]
train
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L381-L393
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.add_arguments
def add_arguments(self, parser): '''Add generic command-line arguments to a top-level argparse parser. After running this, the results from ``argparse.parse_args()`` can be passed to :meth:`main`. ''' commands = set(name[3:] for name in dir(self) if name.startswith('do_')) ...
python
def add_arguments(self, parser): '''Add generic command-line arguments to a top-level argparse parser. After running this, the results from ``argparse.parse_args()`` can be passed to :meth:`main`. ''' commands = set(name[3:] for name in dir(self) if name.startswith('do_')) ...
[ "def", "add_arguments", "(", "self", ",", "parser", ")", ":", "commands", "=", "set", "(", "name", "[", "3", ":", "]", "for", "name", "in", "dir", "(", "self", ")", "if", "name", ".", "startswith", "(", "'do_'", ")", ")", "parser", ".", "add_argume...
Add generic command-line arguments to a top-level argparse parser. After running this, the results from ``argparse.parse_args()`` can be passed to :meth:`main`.
[ "Add", "generic", "command", "-", "line", "arguments", "to", "a", "top", "-", "level", "argparse", "parser", "." ]
train
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L84-L95
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.main
def main(self, args): '''Run a single command, or else the main shell loop. `args` should be the :class:`argparse.Namespace` object after being set up via :meth:`add_arguments`. ''' if args.action: self.runcmd(args.action, args.arguments) else: s...
python
def main(self, args): '''Run a single command, or else the main shell loop. `args` should be the :class:`argparse.Namespace` object after being set up via :meth:`add_arguments`. ''' if args.action: self.runcmd(args.action, args.arguments) else: s...
[ "def", "main", "(", "self", ",", "args", ")", ":", "if", "args", ".", "action", ":", "self", ".", "runcmd", "(", "args", ".", "action", ",", "args", ".", "arguments", ")", "else", ":", "self", ".", "cmdloop", "(", ")" ]
Run a single command, or else the main shell loop. `args` should be the :class:`argparse.Namespace` object after being set up via :meth:`add_arguments`.
[ "Run", "a", "single", "command", "or", "else", "the", "main", "shell", "loop", "." ]
train
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L97-L107
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.runcmd
def runcmd(self, cmd, args): '''Run a single command from pre-parsed arguments. This is intended to be run from :meth:`main` or somewhere else "at the top level" of the program. It may raise :exc:`exceptions.SystemExit` if an argument such as ``--help`` that normally causes exe...
python
def runcmd(self, cmd, args): '''Run a single command from pre-parsed arguments. This is intended to be run from :meth:`main` or somewhere else "at the top level" of the program. It may raise :exc:`exceptions.SystemExit` if an argument such as ``--help`` that normally causes exe...
[ "def", "runcmd", "(", "self", ",", "cmd", ",", "args", ")", ":", "dof", "=", "getattr", "(", "self", ",", "'do_'", "+", "cmd", ",", "None", ")", "if", "dof", "is", "None", ":", "return", "self", ".", "default", "(", "' '", ".", "join", "(", "["...
Run a single command from pre-parsed arguments. This is intended to be run from :meth:`main` or somewhere else "at the top level" of the program. It may raise :exc:`exceptions.SystemExit` if an argument such as ``--help`` that normally causes execution to stop is encountered.
[ "Run", "a", "single", "command", "from", "pre", "-", "parsed", "arguments", "." ]
train
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L109-L130
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.do_help
def do_help(self, args): '''print help on a command''' if args.command: f = getattr(self, 'help_' + args.command, None) if f: f() return f = getattr(self, 'do_' + args.command, None) if not f: msg = self.noh...
python
def do_help(self, args): '''print help on a command''' if args.command: f = getattr(self, 'help_' + args.command, None) if f: f() return f = getattr(self, 'do_' + args.command, None) if not f: msg = self.noh...
[ "def", "do_help", "(", "self", ",", "args", ")", ":", "if", "args", ".", "command", ":", "f", "=", "getattr", "(", "self", ",", "'help_'", "+", "args", ".", "command", ",", "None", ")", "if", "f", ":", "f", "(", ")", "return", "f", "=", "getatt...
print help on a command
[ "print", "help", "on", "a", "command" ]
train
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L156-L183
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/utils.py
load_kb_mappings_file
def load_kb_mappings_file(kbname, kbfile, separator): """Add KB values from file to given KB returning rows added.""" num_added = 0 with open(kbfile) as kb_fd: for line in kb_fd: if not line.strip(): continue try: key, value = line.split(separa...
python
def load_kb_mappings_file(kbname, kbfile, separator): """Add KB values from file to given KB returning rows added.""" num_added = 0 with open(kbfile) as kb_fd: for line in kb_fd: if not line.strip(): continue try: key, value = line.split(separa...
[ "def", "load_kb_mappings_file", "(", "kbname", ",", "kbfile", ",", "separator", ")", ":", "num_added", "=", "0", "with", "open", "(", "kbfile", ")", "as", "kb_fd", ":", "for", "line", "in", "kb_fd", ":", "if", "not", "line", ".", "strip", "(", ")", "...
Add KB values from file to given KB returning rows added.
[ "Add", "KB", "values", "from", "file", "to", "given", "KB", "returning", "rows", "added", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/utils.py#L27-L42
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.by_id
def by_id(cls, semantictag_id, autoflush=True): '''Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantic...
python
def by_id(cls, semantictag_id, autoflush=True): '''Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantic...
[ "def", "by_id", "(", "cls", ",", "semantictag_id", ",", "autoflush", "=", "True", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", ".", "filter", "(", "SemanticTag", ".", "id", "==", "semantictag_id", ")", "query", ...
Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantictag.SemanticTag # TODO check this
[ "Return", "the", "semantic", "tag", "with", "the", "given", "id", "or", "None", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L60-L74
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.by_URI
def by_URI(cls, URI, label=None, autoflush=True): '''Return the semantic ag with the given URI, or None. :param URI: the URI of the semantic tag to return :type URI: string (URI format) :param label: URI's label (optional, default: None) :type label: string :returns: the semantic tag object with the given...
python
def by_URI(cls, URI, label=None, autoflush=True): '''Return the semantic ag with the given URI, or None. :param URI: the URI of the semantic tag to return :type URI: string (URI format) :param label: URI's label (optional, default: None) :type label: string :returns: the semantic tag object with the given...
[ "def", "by_URI", "(", "cls", ",", "URI", ",", "label", "=", "None", ",", "autoflush", "=", "True", ")", ":", "if", "label", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", ".", "filter", "(", "SemanticTag", ".", "l...
Return the semantic ag with the given URI, or None. :param URI: the URI of the semantic tag to return :type URI: string (URI format) :param label: URI's label (optional, default: None) :type label: string :returns: the semantic tag object with the given id or URI, or None if there is no tag with that id ...
[ "Return", "the", "semantic", "ag", "with", "the", "given", "URI", "or", "None", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L77-L96
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.get
def get(cls, tag_id_or_URI, label=None): '''Return the tag with the given id or URI, or None. :param tag_id_or_name: the id or name of the tag to return :type tag_id_or_name: string :returns: the tag object with the given id or name, or None if there is no tag with that id or name :rtype: ckan.model.tag....
python
def get(cls, tag_id_or_URI, label=None): '''Return the tag with the given id or URI, or None. :param tag_id_or_name: the id or name of the tag to return :type tag_id_or_name: string :returns: the tag object with the given id or name, or None if there is no tag with that id or name :rtype: ckan.model.tag....
[ "def", "get", "(", "cls", ",", "tag_id_or_URI", ",", "label", "=", "None", ")", ":", "# First try to get the tag by ID.", "semantictag", "=", "SemanticTag", ".", "by_id", "(", "tag_id_or_URI", ")", "if", "semantictag", ":", "return", "semantictag", "else", ":", ...
Return the tag with the given id or URI, or None. :param tag_id_or_name: the id or name of the tag to return :type tag_id_or_name: string :returns: the tag object with the given id or name, or None if there is no tag with that id or name :rtype: ckan.model.tag.Tag
[ "Return", "the", "tag", "with", "the", "given", "id", "or", "URI", "or", "None", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L99-L117
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.search_by_URI
def search_by_URI(cls, search_term): '''Return all tags whose URI or label contain a given string. :param search_term: the string to search for in the URI or label names :type search_term: string :returns: a list of semantictags that match the search term :rtype: list of ckan.model.semantictag.SemanticTag o...
python
def search_by_URI(cls, search_term): '''Return all tags whose URI or label contain a given string. :param search_term: the string to search for in the URI or label names :type search_term: string :returns: a list of semantictags that match the search term :rtype: list of ckan.model.semantictag.SemanticTag o...
[ "def", "search_by_URI", "(", "cls", ",", "search_term", ")", ":", "#TODO include label search", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", "search_term", "=", "search_term", ".", "strip", "(", ")", ".", "lower", "(", ")", ...
Return all tags whose URI or label contain a given string. :param search_term: the string to search for in the URI or label names :type search_term: string :returns: a list of semantictags that match the search term :rtype: list of ckan.model.semantictag.SemanticTag objects
[ "Return", "all", "tags", "whose", "URI", "or", "label", "contain", "a", "given", "string", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L121-L136
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.all
def all(cls): '''Return all tags that are currently applied to any dataset. :returns: a list of all tags that are currently applied to any dataset :rtype: list of ckan.model.tag.Tag objects ''' # if vocab_id_or_name: # vocab = vocabulary.Vocabulary.get(vocab_id_or_name) # if vocab is None: # # The use...
python
def all(cls): '''Return all tags that are currently applied to any dataset. :returns: a list of all tags that are currently applied to any dataset :rtype: list of ckan.model.tag.Tag objects ''' # if vocab_id_or_name: # vocab = vocabulary.Vocabulary.get(vocab_id_or_name) # if vocab is None: # # The use...
[ "def", "all", "(", "cls", ")", ":", "#\t\tif vocab_id_or_name:", "#\t\t\tvocab = vocabulary.Vocabulary.get(vocab_id_or_name)", "#\t\t\tif vocab is None:", "#\t\t\t\t# The user specified an invalid vocab.", "#\t\t\t\traise ckan.logic.NotFound(\"could not find vocabulary '%s'\"", "#\t\t\t\t\t\t%...
Return all tags that are currently applied to any dataset. :returns: a list of all tags that are currently applied to any dataset :rtype: list of ckan.model.tag.Tag objects
[ "Return", "all", "tags", "that", "are", "currently", "applied", "to", "any", "dataset", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L150-L168
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.tags
def tags(self): '''Return a list of all tags that have this semantic tag, sorted by name. :rtype: list of ckan.model.tag.Tag objects ''' q = meta.Session.query(_tag.Tag) q = q.join(TagSemanticTag) q = q.filter_by(tag_id=self.id) # q = q.filter_by(state='active') q = q.order_by(_tag.Tag.name) tags = q...
python
def tags(self): '''Return a list of all tags that have this semantic tag, sorted by name. :rtype: list of ckan.model.tag.Tag objects ''' q = meta.Session.query(_tag.Tag) q = q.join(TagSemanticTag) q = q.filter_by(tag_id=self.id) # q = q.filter_by(state='active') q = q.order_by(_tag.Tag.name) tags = q...
[ "def", "tags", "(", "self", ")", ":", "q", "=", "meta", ".", "Session", ".", "query", "(", "_tag", ".", "Tag", ")", "q", "=", "q", ".", "join", "(", "TagSemanticTag", ")", "q", "=", "q", ".", "filter_by", "(", "tag_id", "=", "self", ".", "id", ...
Return a list of all tags that have this semantic tag, sorted by name. :rtype: list of ckan.model.tag.Tag objects
[ "Return", "a", "list", "of", "all", "tags", "that", "have", "this", "semantic", "tag", "sorted", "by", "name", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L171-L183
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
Predicate.by_id
def by_id(cls, predicate_id, autoflush=True): '''Return the predicate with the given id, or None. :param predicate_id: the id of the predicate to return :type predicate_id: string :returns: the predicate with the given id, or None if there is no predicate with that id :rtype: ckan.model.semantictag.Predi...
python
def by_id(cls, predicate_id, autoflush=True): '''Return the predicate with the given id, or None. :param predicate_id: the id of the predicate to return :type predicate_id: string :returns: the predicate with the given id, or None if there is no predicate with that id :rtype: ckan.model.semantictag.Predi...
[ "def", "by_id", "(", "cls", ",", "predicate_id", ",", "autoflush", "=", "True", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "Predicate", ")", ".", "filter", "(", "Predicate", ".", "id", "==", "predicate_id", ")", "query", "=", ...
Return the predicate with the given id, or None. :param predicate_id: the id of the predicate to return :type predicate_id: string :returns: the predicate with the given id, or None if there is no predicate with that id :rtype: ckan.model.semantictag.Predicate
[ "Return", "the", "predicate", "with", "the", "given", "id", "or", "None", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L204-L217
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
Predicate.list_unique
def list_unique(cls): '''Return all unique namespaces :returns: a list of all predicates :rtype: list of ckan.model.semantictag.Predicate objects ''' query = meta.Session.query(Predicate).distinct(Predicate.namespace) return query.all()
python
def list_unique(cls): '''Return all unique namespaces :returns: a list of all predicates :rtype: list of ckan.model.semantictag.Predicate objects ''' query = meta.Session.query(Predicate).distinct(Predicate.namespace) return query.all()
[ "def", "list_unique", "(", "cls", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "Predicate", ")", ".", "distinct", "(", "Predicate", ".", "namespace", ")", "return", "query", ".", "all", "(", ")" ]
Return all unique namespaces :returns: a list of all predicates :rtype: list of ckan.model.semantictag.Predicate objects
[ "Return", "all", "unique", "namespaces" ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L252-L260
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
TagSemanticTag.by_name
def by_name(self, tag_name, semantictag_URI, autoflush=True): '''Return the TagSemanticTag for the given tag name and semantic tag URI, or None. :param tag_name: the name of the tag to look for :type tag_name: string :param tag_URI: the name of the tag to look for :type tag_URI: string :returns: the Ta...
python
def by_name(self, tag_name, semantictag_URI, autoflush=True): '''Return the TagSemanticTag for the given tag name and semantic tag URI, or None. :param tag_name: the name of the tag to look for :type tag_name: string :param tag_URI: the name of the tag to look for :type tag_URI: string :returns: the Ta...
[ "def", "by_name", "(", "self", ",", "tag_name", ",", "semantictag_URI", ",", "autoflush", "=", "True", ")", ":", "query", "=", "(", "meta", ".", "Session", ".", "query", "(", "TagSemanticTag", ")", ".", "filter", "(", "_tag", ".", "Tag", ".", "name", ...
Return the TagSemanticTag for the given tag name and semantic tag URI, or None. :param tag_name: the name of the tag to look for :type tag_name: string :param tag_URI: the name of the tag to look for :type tag_URI: string :returns: the TagSemanticTag for the given tag name and semantic tag URI, or None i...
[ "Return", "the", "TagSemanticTag", "for", "the", "given", "tag", "name", "and", "semantic", "tag", "URI", "or", "None", "." ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L305-L324
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
TagSemanticTag.by_tag_id
def by_tag_id(self,tag_id): '''Return all the semantic tag related to the given tag id :returns: a semantic tag or None :rtype: list of ckan.model.semantictag.SemanticTag object ''' query = meta.Session.query(TagSemanticTag).filter(TagSemanticTag.tag_id==tag_id) return query.first()
python
def by_tag_id(self,tag_id): '''Return all the semantic tag related to the given tag id :returns: a semantic tag or None :rtype: list of ckan.model.semantictag.SemanticTag object ''' query = meta.Session.query(TagSemanticTag).filter(TagSemanticTag.tag_id==tag_id) return query.first()
[ "def", "by_tag_id", "(", "self", ",", "tag_id", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "TagSemanticTag", ")", ".", "filter", "(", "TagSemanticTag", ".", "tag_id", "==", "tag_id", ")", "return", "query", ".", "first", "(", ")...
Return all the semantic tag related to the given tag id :returns: a semantic tag or None :rtype: list of ckan.model.semantictag.SemanticTag object
[ "Return", "all", "the", "semantic", "tag", "related", "to", "the", "given", "tag", "id" ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L341-L349
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
TagSemanticTag.get
def get(self,id): '''Return all the semantic tag related to the given tag id :returns: a semantic tag or None :rtype: list of ckan.model.semantictag.SemanticTag object ''' query = meta.Session.query(TagSemanticTag).filter(TagSemanticTag.id==id) return query.first()
python
def get(self,id): '''Return all the semantic tag related to the given tag id :returns: a semantic tag or None :rtype: list of ckan.model.semantictag.SemanticTag object ''' query = meta.Session.query(TagSemanticTag).filter(TagSemanticTag.id==id) return query.first()
[ "def", "get", "(", "self", ",", "id", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "TagSemanticTag", ")", ".", "filter", "(", "TagSemanticTag", ".", "id", "==", "id", ")", "return", "query", ".", "first", "(", ")" ]
Return all the semantic tag related to the given tag id :returns: a semantic tag or None :rtype: list of ckan.model.semantictag.SemanticTag object
[ "Return", "all", "the", "semantic", "tag", "related", "to", "the", "given", "tag", "id" ]
train
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L352-L360
cabalgata/cabalgata-silla-de-montar
cabalgata/silla/util/disk.py
temp_directory
def temp_directory(*args, **kwargs): """ Context manager returns a path created by mkdtemp and cleans it up afterwards. """ path = tempfile.mkdtemp(*args, **kwargs) try: yield path finally: shutil.rmtree(path)
python
def temp_directory(*args, **kwargs): """ Context manager returns a path created by mkdtemp and cleans it up afterwards. """ path = tempfile.mkdtemp(*args, **kwargs) try: yield path finally: shutil.rmtree(path)
[ "def", "temp_directory", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "path", "=", "tempfile", ".", "mkdtemp", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "yield", "path", "finally", ":", "shutil", ".", "rmtree", "(", "path"...
Context manager returns a path created by mkdtemp and cleans it up afterwards.
[ "Context", "manager", "returns", "a", "path", "created", "by", "mkdtemp", "and", "cleans", "it", "up", "afterwards", "." ]
train
https://github.com/cabalgata/cabalgata-silla-de-montar/blob/6f1de56f207e55d788d56636f623c0e3ce1aa750/cabalgata/silla/util/disk.py#L27-L36
AliGhahraei/verarandom
verarandom/random_org_v1.py
RandomOrg.random
def random(self, n: Optional[int] = None) -> Union[List[float], float]: """ Generate random float(s) by using integers as fractional part. random.org's API doesn't offer floats, but a sequence of integers can emulate this: [06357, 114, 0210] => 0.06357_00114_00210 """ randoms =...
python
def random(self, n: Optional[int] = None) -> Union[List[float], float]: """ Generate random float(s) by using integers as fractional part. random.org's API doesn't offer floats, but a sequence of integers can emulate this: [06357, 114, 0210] => 0.06357_00114_00210 """ randoms =...
[ "def", "random", "(", "self", ",", "n", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "Union", "[", "List", "[", "float", "]", ",", "float", "]", ":", "randoms", "=", "[", "]", "n_or_default", "=", "1", "if", "n", "is", "None", "els...
Generate random float(s) by using integers as fractional part. random.org's API doesn't offer floats, but a sequence of integers can emulate this: [06357, 114, 0210] => 0.06357_00114_00210
[ "Generate", "random", "float", "(", "s", ")", "by", "using", "integers", "as", "fractional", "part", "." ]
train
https://github.com/AliGhahraei/verarandom/blob/63d9a5bd2776e40368933f54e58c3f4b4f333f03/verarandom/random_org_v1.py#L50-L69
mjalas/messaging-client
messaging_client/option_parser.py
DefaultOptionParser.parse
def parse(self): """Parse command line arguments and options. Returns: Dictionary containing all given command line arguments and options. """ (options, args) = self.parser.parse_args() self._set_attributes(args, options) return self._create_dictionary()
python
def parse(self): """Parse command line arguments and options. Returns: Dictionary containing all given command line arguments and options. """ (options, args) = self.parser.parse_args() self._set_attributes(args, options) return self._create_dictionary()
[ "def", "parse", "(", "self", ")", ":", "(", "options", ",", "args", ")", "=", "self", ".", "parser", ".", "parse_args", "(", ")", "self", ".", "_set_attributes", "(", "args", ",", "options", ")", "return", "self", ".", "_create_dictionary", "(", ")" ]
Parse command line arguments and options. Returns: Dictionary containing all given command line arguments and options.
[ "Parse", "command", "line", "arguments", "and", "options", "." ]
train
https://github.com/mjalas/messaging-client/blob/b72ad622d9c94a879fe1085f0dbb52349892cd15/messaging_client/option_parser.py#L58-L66
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
md5file
def md5file(abspath, nbytes=0): """Return md5 hash value of a piece of a file Estimate processing time on: :param abspath: the absolute path to the file :param nbytes: only has first N bytes of the file. if 0, hash all file CPU = i7-4600U 2.10GHz - 2.70GHz, RAM = 8.00 GB 1 second ...
python
def md5file(abspath, nbytes=0): """Return md5 hash value of a piece of a file Estimate processing time on: :param abspath: the absolute path to the file :param nbytes: only has first N bytes of the file. if 0, hash all file CPU = i7-4600U 2.10GHz - 2.70GHz, RAM = 8.00 GB 1 second ...
[ "def", "md5file", "(", "abspath", ",", "nbytes", "=", "0", ")", ":", "m", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "abspath", ",", "\"rb\"", ")", "as", "f", ":", "if", "nbytes", ":", "data", "=", "f", ".", "read", "(", "nbytes...
Return md5 hash value of a piece of a file Estimate processing time on: :param abspath: the absolute path to the file :param nbytes: only has first N bytes of the file. if 0, hash all file CPU = i7-4600U 2.10GHz - 2.70GHz, RAM = 8.00 GB 1 second can process 0.25GB data - 0.59...
[ "Return", "md5", "hash", "value", "of", "a", "piece", "of", "a", "file", "Estimate", "processing", "time", "on", ":", ":", "param", "abspath", ":", "the", "absolute", "path", "to", "the", "file", ":", "param", "nbytes", ":", "only", "has", "first", "N"...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L85-L119
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinFile.set_initialize_mode
def set_initialize_mode(complexity=2): """Set initialization mode. Default is slow mode. **中文文档** 设置WinFile类的全局变量, 指定WinFile.initialize方法所绑定的初始化方式。 """ if complexity == 3: WinFile.initialize = WinFile.level3_initialize WinFile.init_mode =...
python
def set_initialize_mode(complexity=2): """Set initialization mode. Default is slow mode. **中文文档** 设置WinFile类的全局变量, 指定WinFile.initialize方法所绑定的初始化方式。 """ if complexity == 3: WinFile.initialize = WinFile.level3_initialize WinFile.init_mode =...
[ "def", "set_initialize_mode", "(", "complexity", "=", "2", ")", ":", "if", "complexity", "==", "3", ":", "WinFile", ".", "initialize", "=", "WinFile", ".", "level3_initialize", "WinFile", ".", "init_mode", "=", "3", "elif", "complexity", "==", "2", ":", "W...
Set initialization mode. Default is slow mode. **中文文档** 设置WinFile类的全局变量, 指定WinFile.initialize方法所绑定的初始化方式。
[ "Set", "initialization", "mode", ".", "Default", "is", "slow", "mode", ".", "**", "中文文档", "**", "设置WinFile类的全局变量", "指定WinFile", ".", "initialize方法所绑定的初始化方式。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L198-L215
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinFile.level3_initialize
def level3_initialize(self): """Load abspath, dirname, basename, fname, ext, atime, ctime, mtime, size_on_disk attributes in initialization. **中文文档** 比较全面但稍慢的WinFile对象初始化方法, 从绝对路径中取得: - 绝对路径 - 父目录路径 - 文件全名 - 纯文件名 - 文件扩展名 ...
python
def level3_initialize(self): """Load abspath, dirname, basename, fname, ext, atime, ctime, mtime, size_on_disk attributes in initialization. **中文文档** 比较全面但稍慢的WinFile对象初始化方法, 从绝对路径中取得: - 绝对路径 - 父目录路径 - 文件全名 - 纯文件名 - 文件扩展名 ...
[ "def", "level3_initialize", "(", "self", ")", ":", "self", ".", "dirname", ",", "self", ".", "basename", "=", "os", ".", "path", ".", "split", "(", "self", ".", "abspath", ")", "# 目录名, 文件名", "self", ".", "fname", ",", "self", ".", "ext", "=", "os", ...
Load abspath, dirname, basename, fname, ext, atime, ctime, mtime, size_on_disk attributes in initialization. **中文文档** 比较全面但稍慢的WinFile对象初始化方法, 从绝对路径中取得: - 绝对路径 - 父目录路径 - 文件全名 - 纯文件名 - 文件扩展名 - access time - create t...
[ "Load", "abspath", "dirname", "basename", "fname", "ext", "atime", "ctime", "mtime", "size_on_disk", "attributes", "in", "initialization", ".", "**", "中文文档", "**", "比较全面但稍慢的WinFile对象初始化方法", "从绝对路径中取得", ":", "-", "绝对路径", "-", "父目录路径", "-", "文件全名", "-", "纯文件名", ...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L217-L244
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinFile.level2_initialize
def level2_initialize(self): """Load abspath, dirname, basename, fname, ext, atime, ctime, mtime, size_on_disk attributes in initialization. **中文文档** 比较全面但稍慢的WinFile对象初始化方法, 从绝对路径中取得: - 绝对路径 - 父目录路径 - 文件全名 - 纯文件名 - 文件扩展名 ...
python
def level2_initialize(self): """Load abspath, dirname, basename, fname, ext, atime, ctime, mtime, size_on_disk attributes in initialization. **中文文档** 比较全面但稍慢的WinFile对象初始化方法, 从绝对路径中取得: - 绝对路径 - 父目录路径 - 文件全名 - 纯文件名 - 文件扩展名 ...
[ "def", "level2_initialize", "(", "self", ")", ":", "self", ".", "dirname", ",", "self", ".", "basename", "=", "os", ".", "path", ".", "split", "(", "self", ".", "abspath", ")", "# 目录名, 文件名", "self", ".", "fname", ",", "self", ".", "ext", "=", "os", ...
Load abspath, dirname, basename, fname, ext, atime, ctime, mtime, size_on_disk attributes in initialization. **中文文档** 比较全面但稍慢的WinFile对象初始化方法, 从绝对路径中取得: - 绝对路径 - 父目录路径 - 文件全名 - 纯文件名 - 文件扩展名 - access time - create t...
[ "Load", "abspath", "dirname", "basename", "fname", "ext", "atime", "ctime", "mtime", "size_on_disk", "attributes", "in", "initialization", ".", "**", "中文文档", "**", "比较全面但稍慢的WinFile对象初始化方法", "从绝对路径中取得", ":", "-", "绝对路径", "-", "父目录路径", "-", "文件全名", "-", "纯文件名", ...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L246-L271
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinFile.level1_initialize
def level1_initialize(self): """Load abspath, dirname, basename, fname, ext attributes in initialization. **中文文档** 快速的WinFile对象初始化方法, 只从绝对路径中取得: - 绝对路径 - 目录路径 - 文件全名 - 纯文件名 - 文件扩展名 """ self.dirname, self.basename...
python
def level1_initialize(self): """Load abspath, dirname, basename, fname, ext attributes in initialization. **中文文档** 快速的WinFile对象初始化方法, 只从绝对路径中取得: - 绝对路径 - 目录路径 - 文件全名 - 纯文件名 - 文件扩展名 """ self.dirname, self.basename...
[ "def", "level1_initialize", "(", "self", ")", ":", "self", ".", "dirname", ",", "self", ".", "basename", "=", "os", ".", "path", ".", "split", "(", "self", ".", "abspath", ")", "self", ".", "fname", ",", "self", ".", "ext", "=", "os", ".", "path", ...
Load abspath, dirname, basename, fname, ext attributes in initialization. **中文文档** 快速的WinFile对象初始化方法, 只从绝对路径中取得: - 绝对路径 - 目录路径 - 文件全名 - 纯文件名 - 文件扩展名
[ "Load", "abspath", "dirname", "basename", "fname", "ext", "attributes", "in", "initialization", ".", "**", "中文文档", "**", "快速的WinFile对象初始化方法", "只从绝对路径中取得", ":" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L273-L289
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinFile.rename
def rename(self, new_dirname=None, new_fname=None, new_ext=None): """Rename the dirname, fname, extension or their combinations. **中文文档** 对文件的父目录名, 纯文件名, 扩展名, 或它们的组合进行修改。 """ if not new_dirname: new_dirname = self.dirname else: ne...
python
def rename(self, new_dirname=None, new_fname=None, new_ext=None): """Rename the dirname, fname, extension or their combinations. **中文文档** 对文件的父目录名, 纯文件名, 扩展名, 或它们的组合进行修改。 """ if not new_dirname: new_dirname = self.dirname else: ne...
[ "def", "rename", "(", "self", ",", "new_dirname", "=", "None", ",", "new_fname", "=", "None", ",", "new_ext", "=", "None", ")", ":", "if", "not", "new_dirname", ":", "new_dirname", "=", "self", ".", "dirname", "else", ":", "new_dirname", "=", "os", "."...
Rename the dirname, fname, extension or their combinations. **中文文档** 对文件的父目录名, 纯文件名, 扩展名, 或它们的组合进行修改。
[ "Rename", "the", "dirname", "fname", "extension", "or", "their", "combinations", ".", "**", "中文文档", "**", "对文件的父目录名", "纯文件名", "扩展名", "或它们的组合进行修改。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L313-L341
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinDir.get_detail
def get_detail(self): """Get general stats information. Includes: - size_total: total size on disk - num_folder_total: how many subfolders - num_file_total: how many files - size_current: total size of files on this folder. file in subfolders ...
python
def get_detail(self): """Get general stats information. Includes: - size_total: total size on disk - num_folder_total: how many subfolders - num_file_total: how many files - size_current: total size of files on this folder. file in subfolders ...
[ "def", "get_detail", "(", "self", ")", ":", "self", ".", "size_total", "=", "0", "self", ".", "num_folder_total", "=", "0", "self", ".", "num_file_total", "=", "0", "self", ".", "size_current", "=", "0", "self", ".", "num_folder_current", "=", "0", "self...
Get general stats information. Includes: - size_total: total size on disk - num_folder_total: how many subfolders - num_file_total: how many files - size_current: total size of files on this folder. file in subfolders doesn't count - num_fol...
[ "Get", "general", "stats", "information", ".", "Includes", ":", "-", "size_total", ":", "total", "size", "on", "disk", "-", "num_folder_total", ":", "how", "many", "subfolders", "-", "num_file_total", ":", "how", "many", "files", "-", "size_current", ":", "t...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L378-L409
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinDir.prt_detail
def prt_detail(self): """Nicely print stats information. """ screen = [ "Detail info of %s: " % self.abspath, "total size = %s" % string_SizeInBytes(self.size_total), "number of sub folders = %s" % self.num_folder_total, "number of total files = %s...
python
def prt_detail(self): """Nicely print stats information. """ screen = [ "Detail info of %s: " % self.abspath, "total size = %s" % string_SizeInBytes(self.size_total), "number of sub folders = %s" % self.num_folder_total, "number of total files = %s...
[ "def", "prt_detail", "(", "self", ")", ":", "screen", "=", "[", "\"Detail info of %s: \"", "%", "self", ".", "abspath", ",", "\"total size = %s\"", "%", "string_SizeInBytes", "(", "self", ".", "size_total", ")", ",", "\"number of sub folders = %s\"", "%", "self", ...
Nicely print stats information.
[ "Nicely", "print", "stats", "information", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L411-L423
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinDir.rename
def rename(self, new_dirname=None, new_basename=None): """Rename the dirname, basename or their combinations. **中文文档** 对文件的目录名, 文件夹名, 或它们的组合进行修改。 """ if not new_basename: new_basename = self.new_basename if not new_dirname: new_di...
python
def rename(self, new_dirname=None, new_basename=None): """Rename the dirname, basename or their combinations. **中文文档** 对文件的目录名, 文件夹名, 或它们的组合进行修改。 """ if not new_basename: new_basename = self.new_basename if not new_dirname: new_di...
[ "def", "rename", "(", "self", ",", "new_dirname", "=", "None", ",", "new_basename", "=", "None", ")", ":", "if", "not", "new_basename", ":", "new_basename", "=", "self", ".", "new_basename", "if", "not", "new_dirname", ":", "new_dirname", "=", "self", ".",...
Rename the dirname, basename or their combinations. **中文文档** 对文件的目录名, 文件夹名, 或它们的组合进行修改。
[ "Rename", "the", "dirname", "basename", "or", "their", "combinations", ".", "**", "中文文档", "**", "对文件的目录名", "文件夹名", "或它们的组合进行修改。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L425-L444
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.add
def add(self, abspath_or_winfile, enable_verbose=True): """Add absolute path or WinFile to FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath if abspath_or_winfile in self.files: if enable_verbose: print("'%s' already in this col...
python
def add(self, abspath_or_winfile, enable_verbose=True): """Add absolute path or WinFile to FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath if abspath_or_winfile in self.files: if enable_verbose: print("'%s' already in this col...
[ "def", "add", "(", "self", ",", "abspath_or_winfile", ",", "enable_verbose", "=", "True", ")", ":", "if", "isinstance", "(", "abspath_or_winfile", ",", "str", ")", ":", "# abspath", "if", "abspath_or_winfile", "in", "self", ".", "files", ":", "if", "enable_v...
Add absolute path or WinFile to FileCollection.
[ "Add", "absolute", "path", "or", "WinFile", "to", "FileCollection", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L505-L523
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.remove
def remove(self, abspath_or_winfile, enable_verbose=True): """Remove absolute path or WinFile from FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath try: del self.files[abspath_or_winfile] except KeyError: if enable_verb...
python
def remove(self, abspath_or_winfile, enable_verbose=True): """Remove absolute path or WinFile from FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath try: del self.files[abspath_or_winfile] except KeyError: if enable_verb...
[ "def", "remove", "(", "self", ",", "abspath_or_winfile", ",", "enable_verbose", "=", "True", ")", ":", "if", "isinstance", "(", "abspath_or_winfile", ",", "str", ")", ":", "# abspath", "try", ":", "del", "self", ".", "files", "[", "abspath_or_winfile", "]", ...
Remove absolute path or WinFile from FileCollection.
[ "Remove", "absolute", "path", "or", "WinFile", "from", "FileCollection", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L525-L543
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.iterfiles
def iterfiles(self): """Yield all WinFile object. """ try: for path in self.order: yield self.files[path] except: for winfile in self.files.values(): yield winfile
python
def iterfiles(self): """Yield all WinFile object. """ try: for path in self.order: yield self.files[path] except: for winfile in self.files.values(): yield winfile
[ "def", "iterfiles", "(", "self", ")", ":", "try", ":", "for", "path", "in", "self", ".", "order", ":", "yield", "self", ".", "files", "[", "path", "]", "except", ":", "for", "winfile", "in", "self", ".", "files", ".", "values", "(", ")", ":", "yi...
Yield all WinFile object.
[ "Yield", "all", "WinFile", "object", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L551-L559
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.iterpaths
def iterpaths(self): """Yield all WinFile's absolute path. """ try: for path in self.order: yield path except: for path in self.files: yield path
python
def iterpaths(self): """Yield all WinFile's absolute path. """ try: for path in self.order: yield path except: for path in self.files: yield path
[ "def", "iterpaths", "(", "self", ")", ":", "try", ":", "for", "path", "in", "self", ".", "order", ":", "yield", "path", "except", ":", "for", "path", "in", "self", ".", "files", ":", "yield", "path" ]
Yield all WinFile's absolute path.
[ "Yield", "all", "WinFile", "s", "absolute", "path", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L561-L569
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.yield_all_file_path
def yield_all_file_path(dir_abspath): """ **中文文档** 遍历path目录下的所有文件, 返回绝对路径。 """ if os.path.isdir(dir_abspath): dir_abspath = os.path.abspath(dir_abspath) for current_folder, _, fnamelist in os.walk(dir_abspath): for fname i...
python
def yield_all_file_path(dir_abspath): """ **中文文档** 遍历path目录下的所有文件, 返回绝对路径。 """ if os.path.isdir(dir_abspath): dir_abspath = os.path.abspath(dir_abspath) for current_folder, _, fnamelist in os.walk(dir_abspath): for fname i...
[ "def", "yield_all_file_path", "(", "dir_abspath", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "dir_abspath", ")", ":", "dir_abspath", "=", "os", ".", "path", ".", "abspath", "(", "dir_abspath", ")", "for", "current_folder", ",", "_", ",", "fnam...
**中文文档** 遍历path目录下的所有文件, 返回绝对路径。
[ "**", "中文文档", "**", "遍历path目录下的所有文件", "返回绝对路径。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L578-L592
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.yield_all_dir_path
def yield_all_dir_path(dir_abspath): """ **中文文档** 遍历dir_abspath目录下的所有子目录, 返回绝对路径。 """ if os.path.isdir(dir_abspath): for current_folder, folderlist, _ in os.walk(dir_abspath): for folder in folderlist: yield os.pat...
python
def yield_all_dir_path(dir_abspath): """ **中文文档** 遍历dir_abspath目录下的所有子目录, 返回绝对路径。 """ if os.path.isdir(dir_abspath): for current_folder, folderlist, _ in os.walk(dir_abspath): for folder in folderlist: yield os.pat...
[ "def", "yield_all_dir_path", "(", "dir_abspath", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "dir_abspath", ")", ":", "for", "current_folder", ",", "folderlist", ",", "_", "in", "os", ".", "walk", "(", "dir_abspath", ")", ":", "for", "folder", ...
**中文文档** 遍历dir_abspath目录下的所有子目录, 返回绝对路径。
[ "**", "中文文档", "**", "遍历dir_abspath目录下的所有子目录", "返回绝对路径。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L635-L648
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.remove_children
def remove_children(list_of_abspath): """Remove all dir path that being children path of other dir path. **中文文档** 去除list_of_abspath中所有目录的子目录, 保证其中的所有元素不可能为另一个 元素的子目录。 """ sorted_list_of_abspath = list(list_of_abspath) sorted_list_of_abspath.sort(...
python
def remove_children(list_of_abspath): """Remove all dir path that being children path of other dir path. **中文文档** 去除list_of_abspath中所有目录的子目录, 保证其中的所有元素不可能为另一个 元素的子目录。 """ sorted_list_of_abspath = list(list_of_abspath) sorted_list_of_abspath.sort(...
[ "def", "remove_children", "(", "list_of_abspath", ")", ":", "sorted_list_of_abspath", "=", "list", "(", "list_of_abspath", ")", "sorted_list_of_abspath", ".", "sort", "(", ")", "sorted_list_of_abspath", ".", "append", "(", "\"\"", ")", "res", "=", "list", "(", "...
Remove all dir path that being children path of other dir path. **中文文档** 去除list_of_abspath中所有目录的子目录, 保证其中的所有元素不可能为另一个 元素的子目录。
[ "Remove", "all", "dir", "path", "that", "being", "children", "path", "of", "other", "dir", "path", ".", "**", "中文文档", "**", "去除list_of_abspath中所有目录的子目录", "保证其中的所有元素不可能为另一个", "元素的子目录。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L691-L708
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path
def from_path(list_of_dir): """Create a new FileCollection and add all files from ``dir_path``. :param list_of_dir: absolute dir path, WinDir instance, list of absolute dir path or list of WinDir instance. **中文文档** 添加dir_path目录下的所有文件到一个新的FileCollec...
python
def from_path(list_of_dir): """Create a new FileCollection and add all files from ``dir_path``. :param list_of_dir: absolute dir path, WinDir instance, list of absolute dir path or list of WinDir instance. **中文文档** 添加dir_path目录下的所有文件到一个新的FileCollec...
[ "def", "from_path", "(", "list_of_dir", ")", ":", "if", "isinstance", "(", "list_of_dir", ",", "str", ")", ":", "list_of_dir", "=", "[", "list_of_dir", ",", "]", "elif", "isinstance", "(", "list_of_dir", ",", "WinDir", ")", ":", "list_of_dir", "=", "[", ...
Create a new FileCollection and add all files from ``dir_path``. :param list_of_dir: absolute dir path, WinDir instance, list of absolute dir path or list of WinDir instance. **中文文档** 添加dir_path目录下的所有文件到一个新的FileCollection中.
[ "Create", "a", "new", "FileCollection", "and", "add", "all", "files", "from", "dir_path", ".", ":", "param", "list_of_dir", ":", "absolute", "dir", "path", "WinDir", "instance", "list", "of", "absolute", "dir", "path", "or", "list", "of", "WinDir", "instance...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L711-L732
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path_by_criterion
def from_path_by_criterion(dir_path, criterion, keepboth=False): """Create a new FileCollection, and select some files from ``dir_path``. How to construct your own criterion function:: def filter_image(winfile): if winfile.ext in [".jpg", ".png", ".bmp"]: ...
python
def from_path_by_criterion(dir_path, criterion, keepboth=False): """Create a new FileCollection, and select some files from ``dir_path``. How to construct your own criterion function:: def filter_image(winfile): if winfile.ext in [".jpg", ".png", ".bmp"]: ...
[ "def", "from_path_by_criterion", "(", "dir_path", ",", "criterion", ",", "keepboth", "=", "False", ")", ":", "if", "keepboth", ":", "fc_yes", ",", "fc_no", "=", "FileCollection", "(", ")", ",", "FileCollection", "(", ")", "for", "winfile", "in", "FileCollect...
Create a new FileCollection, and select some files from ``dir_path``. How to construct your own criterion function:: def filter_image(winfile): if winfile.ext in [".jpg", ".png", ".bmp"]: return True else: retu...
[ "Create", "a", "new", "FileCollection", "and", "select", "some", "files", "from", "dir_path", ".", "How", "to", "construct", "your", "own", "criterion", "function", "::", "def", "filter_image", "(", "winfile", ")", ":", "if", "winfile", ".", "ext", "in", "...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L735-L774
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path_except
def from_path_except(dir_path, ignore=list(), ignore_ext=list(), ignore_pattern=list()): """Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_except( ...
python
def from_path_except(dir_path, ignore=list(), ignore_ext=list(), ignore_pattern=list()): """Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_except( ...
[ "def", "from_path_except", "(", "dir_path", ",", "ignore", "=", "list", "(", ")", ",", "ignore_ext", "=", "list", "(", ")", ",", "ignore_pattern", "=", "list", "(", ")", ")", ":", "ignore", "=", "[", "i", ".", "lower", "(", ")", "for", "i", "in", ...
Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_except( dir_path, ignore=["test"], ignore_ext=[".log", ".tmp"] ignore_pattern=["some_pattern"]) ...
[ "Create", "a", "new", "FileCollection", "and", "select", "all", "files", "except", "file", "matching", "ignore", "-", "rule", "::", "dir_path", "=", "your", "/", "path", "fc", "=", "FileCollection", ".", "from_path_except", "(", "dir_path", "ignore", "=", "[...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L777-L821
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path_by_pattern
def from_path_by_pattern(dir_path, pattern=list()): """Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_by_pattern( dir_path, pattern=["log"]) :p...
python
def from_path_by_pattern(dir_path, pattern=list()): """Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_by_pattern( dir_path, pattern=["log"]) :p...
[ "def", "from_path_by_pattern", "(", "dir_path", ",", "pattern", "=", "list", "(", ")", ")", ":", "pattern", "=", "[", "i", ".", "lower", "(", ")", "for", "i", "in", "pattern", "]", "def", "filter", "(", "winfile", ")", ":", "relpath", "=", "os", "....
Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_by_pattern( dir_path, pattern=["log"]) :param dir_path: the root directory you want to start with ...
[ "Create", "a", "new", "FileCollection", "and", "select", "all", "files", "except", "file", "matching", "ignore", "-", "rule", "::", "dir_path", "=", "your", "/", "path", "fc", "=", "FileCollection", ".", "from_path_by_pattern", "(", "dir_path", "pattern", "=",...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L824-L849
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path_by_size
def from_path_by_size(dir_path, min_size=0, max_size=1 << 40): """Create a new FileCollection, and select all files that size in a range:: dir_path = "your/path" # select by file size larger than 100MB fc = FileCollection.from_path_by_size( ...
python
def from_path_by_size(dir_path, min_size=0, max_size=1 << 40): """Create a new FileCollection, and select all files that size in a range:: dir_path = "your/path" # select by file size larger than 100MB fc = FileCollection.from_path_by_size( ...
[ "def", "from_path_by_size", "(", "dir_path", ",", "min_size", "=", "0", ",", "max_size", "=", "1", "<<", "40", ")", ":", "def", "filter", "(", "winfile", ")", ":", "if", "(", "winfile", ".", "size_on_disk", ">=", "min_size", ")", "and", "(", "winfile",...
Create a new FileCollection, and select all files that size in a range:: dir_path = "your/path" # select by file size larger than 100MB fc = FileCollection.from_path_by_size( dir_path, min_size=100*1024*1024) ...
[ "Create", "a", "new", "FileCollection", "and", "select", "all", "files", "that", "size", "in", "a", "range", "::", "dir_path", "=", "your", "/", "path", "#", "select", "by", "file", "size", "larger", "than", "100MB", "fc", "=", "FileCollection", ".", "fr...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L852-L878
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path_by_ext
def from_path_by_ext(dir_path, ext): """Create a new FileCollection, and select all files that extension matching ``ext``:: dir_path = "your/path" fc = FileCollection.from_path_by_ext(dir_path, ext=[".jpg", ".png"]) """ if isinstance(ext, (l...
python
def from_path_by_ext(dir_path, ext): """Create a new FileCollection, and select all files that extension matching ``ext``:: dir_path = "your/path" fc = FileCollection.from_path_by_ext(dir_path, ext=[".jpg", ".png"]) """ if isinstance(ext, (l...
[ "def", "from_path_by_ext", "(", "dir_path", ",", "ext", ")", ":", "if", "isinstance", "(", "ext", ",", "(", "list", ",", "set", ",", "dict", ")", ")", ":", "# collection of extension", "def", "filter", "(", "winfile", ")", ":", "if", "winfile", ".", "e...
Create a new FileCollection, and select all files that extension matching ``ext``:: dir_path = "your/path" fc = FileCollection.from_path_by_ext(dir_path, ext=[".jpg", ".png"])
[ "Create", "a", "new", "FileCollection", "and", "select", "all", "files", "that", "extension", "matching", "ext", "::", "dir_path", "=", "your", "/", "path", "fc", "=", "FileCollection", ".", "from_path_by_ext", "(", "dir_path", "ext", "=", "[", ".", "jpg", ...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L881-L903
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.from_path_by_md5
def from_path_by_md5(md5_value, list_of_dir): """Create a new FileCollection, and select all files' that md5 is matching. **中文文档** 给定一个文件使用WinFile模块获得的md5值, 在list_of_dir中的文件里, 找到与之相同的文件。 """ def filter(winfile): if winfile.md...
python
def from_path_by_md5(md5_value, list_of_dir): """Create a new FileCollection, and select all files' that md5 is matching. **中文文档** 给定一个文件使用WinFile模块获得的md5值, 在list_of_dir中的文件里, 找到与之相同的文件。 """ def filter(winfile): if winfile.md...
[ "def", "from_path_by_md5", "(", "md5_value", ",", "list_of_dir", ")", ":", "def", "filter", "(", "winfile", ")", ":", "if", "winfile", ".", "md5", "==", "md5_value", ":", "return", "True", "else", ":", "return", "False", "if", "not", "isinstance", "(", "...
Create a new FileCollection, and select all files' that md5 is matching. **中文文档** 给定一个文件使用WinFile模块获得的md5值, 在list_of_dir中的文件里, 找到与之相同的文件。
[ "Create", "a", "new", "FileCollection", "and", "select", "all", "files", "that", "md5", "is", "matching", ".", "**", "中文文档", "**", "给定一个文件使用WinFile模块获得的md5值", "在list_of_dir中的文件里", "找到与之相同的文件。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L906-L940
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.sort_by
def sort_by(self, attr_name, reverse=False): """Sort files by one of it's attributes. **中文文档** 对容器内的WinFile根据其某一个属性升序或者降序排序。 """ try: d = dict() for abspath, winfile in self.files.items(): d[abspath] = getattr(winfile, att...
python
def sort_by(self, attr_name, reverse=False): """Sort files by one of it's attributes. **中文文档** 对容器内的WinFile根据其某一个属性升序或者降序排序。 """ try: d = dict() for abspath, winfile in self.files.items(): d[abspath] = getattr(winfile, att...
[ "def", "sort_by", "(", "self", ",", "attr_name", ",", "reverse", "=", "False", ")", ":", "try", ":", "d", "=", "dict", "(", ")", "for", "abspath", ",", "winfile", "in", "self", ".", "files", ".", "items", "(", ")", ":", "d", "[", "abspath", "]", ...
Sort files by one of it's attributes. **中文文档** 对容器内的WinFile根据其某一个属性升序或者降序排序。
[ "Sort", "files", "by", "one", "of", "it", "s", "attributes", ".", "**", "中文文档", "**", "对容器内的WinFile根据其某一个属性升序或者降序排序。" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L942-L958
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.select
def select(self, criterion, keepboth=False): """Filter current file collections, create another file collections contains all winfile with criterion=True. How to construct your own criterion function, see :meth:`FileCollection.from_path_by_criterion`. :param criterion...
python
def select(self, criterion, keepboth=False): """Filter current file collections, create another file collections contains all winfile with criterion=True. How to construct your own criterion function, see :meth:`FileCollection.from_path_by_criterion`. :param criterion...
[ "def", "select", "(", "self", ",", "criterion", ",", "keepboth", "=", "False", ")", ":", "if", "keepboth", ":", "fcs_yes", ",", "fcs_no", "=", "FileCollection", "(", ")", ",", "FileCollection", "(", ")", "for", "winfile", "in", "self", ".", "files", "....
Filter current file collections, create another file collections contains all winfile with criterion=True. How to construct your own criterion function, see :meth:`FileCollection.from_path_by_criterion`. :param criterion: customize filter function :type criterion: fun...
[ "Filter", "current", "file", "collections", "create", "another", "file", "collections", "contains", "all", "winfile", "with", "criterion", "=", "True", ".", "How", "to", "construct", "your", "own", "criterion", "function", "see", ":", "meth", ":", "FileCollectio...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L1032-L1065
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.show_big_file
def show_big_file(dir_path, threshold): """Print all file path that file size greater and equal than ``#threshold``. """ fc = FileCollection.from_path_by_size(dir_path, min_size=threshold) fc.sort_by("size_on_disk") lines = list() lines.append("Results:"...
python
def show_big_file(dir_path, threshold): """Print all file path that file size greater and equal than ``#threshold``. """ fc = FileCollection.from_path_by_size(dir_path, min_size=threshold) fc.sort_by("size_on_disk") lines = list() lines.append("Results:"...
[ "def", "show_big_file", "(", "dir_path", ",", "threshold", ")", ":", "fc", "=", "FileCollection", ".", "from_path_by_size", "(", "dir_path", ",", "min_size", "=", "threshold", ")", "fc", ".", "sort_by", "(", "\"size_on_disk\"", ")", "lines", "=", "list", "("...
Print all file path that file size greater and equal than ``#threshold``.
[ "Print", "all", "file", "path", "that", "file", "size", "greater", "and", "equal", "than", "#threshold", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L1105-L1122
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.show_patterned_file
def show_patterned_file(dir_path, pattern=list(), filename_only=True): """Print all file that file name contains ``pattern``. """ pattern = [i.lower() for i in pattern] if filename_only: def filter(winfile): for p in pattern: if p in winfil...
python
def show_patterned_file(dir_path, pattern=list(), filename_only=True): """Print all file that file name contains ``pattern``. """ pattern = [i.lower() for i in pattern] if filename_only: def filter(winfile): for p in pattern: if p in winfil...
[ "def", "show_patterned_file", "(", "dir_path", ",", "pattern", "=", "list", "(", ")", ",", "filename_only", "=", "True", ")", ":", "pattern", "=", "[", "i", ".", "lower", "(", ")", "for", "i", "in", "pattern", "]", "if", "filename_only", ":", "def", ...
Print all file that file name contains ``pattern``.
[ "Print", "all", "file", "that", "file", "name", "contains", "pattern", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L1125-L1163
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.create_fake_mirror
def create_fake_mirror(src, dst): """Copy all dir, files from ``src`` to ``dst``. But only create a empty file with same file name. Of course, the tree structure doesn't change. A recipe gadget to create some test data set. Make sure to use absolute path. ...
python
def create_fake_mirror(src, dst): """Copy all dir, files from ``src`` to ``dst``. But only create a empty file with same file name. Of course, the tree structure doesn't change. A recipe gadget to create some test data set. Make sure to use absolute path. ...
[ "def", "create_fake_mirror", "(", "src", ",", "dst", ")", ":", "src", "=", "os", ".", "path", ".", "abspath", "(", "src", ")", "if", "not", "(", "os", ".", "path", ".", "exists", "(", "src", ")", "and", "(", "not", "os", ".", "path", ".", "exis...
Copy all dir, files from ``src`` to ``dst``. But only create a empty file with same file name. Of course, the tree structure doesn't change. A recipe gadget to create some test data set. Make sure to use absolute path. **中文文档** 复制整个src目录下的文件树结...
[ "Copy", "all", "dir", "files", "from", "src", "to", "dst", ".", "But", "only", "create", "a", "empty", "file", "with", "same", "file", "name", ".", "Of", "course", "the", "tree", "structure", "doesn", "t", "change", ".", "A", "recipe", "gadget", "to", ...
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L1166-L1197
Naught0/lolrune
lolrune/aioruneclient.py
AioRuneClient._get
async def _get(self, url: str) -> str: """A small wrapper method which makes a quick GET request Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ ...
python
async def _get(self, url: str) -> str: """A small wrapper method which makes a quick GET request Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ ...
[ "async", "def", "_get", "(", "self", ",", "url", ":", "str", ")", "->", "str", ":", "async", "with", "self", ".", "session", ".", "get", "(", "url", ",", "headers", "=", "self", ".", "HEADERS", ")", "as", "r", ":", "if", "r", ".", "status", "==...
A small wrapper method which makes a quick GET request Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ RuneConnectionError If the GET respo...
[ "A", "small", "wrapper", "method", "which", "makes", "a", "quick", "GET", "request" ]
train
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/aioruneclient.py#L59-L81
Naught0/lolrune
lolrune/aioruneclient.py
AioRuneClient.update_champs
async def update_champs(self): """A method which updates ``self.rune_links``. This is useful because runeforge.gg is frequently updating. Raises ------ RuneConnectionError If the request does not return with a status of 200. """ html = await self._get...
python
async def update_champs(self): """A method which updates ``self.rune_links``. This is useful because runeforge.gg is frequently updating. Raises ------ RuneConnectionError If the request does not return with a status of 200. """ html = await self._get...
[ "async", "def", "update_champs", "(", "self", ")", ":", "html", "=", "await", "self", ".", "_get", "(", "self", ".", "URL", ")", "self", ".", "rune_links", "=", "utils", ".", "parse_rune_links", "(", "html", ")" ]
A method which updates ``self.rune_links``. This is useful because runeforge.gg is frequently updating. Raises ------ RuneConnectionError If the request does not return with a status of 200.
[ "A", "method", "which", "updates", "self", ".", "rune_links", ".", "This", "is", "useful", "because", "runeforge", ".", "gg", "is", "frequently", "updating", "." ]
train
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/aioruneclient.py#L83-L93
Naught0/lolrune
lolrune/aioruneclient.py
AioRuneClient.get_raw
async def get_raw(self, champion_name: str) -> Tuple[dict]: """A method to retrieve **raw** optimal runes for a given champion. Parameters ---------- champion_name : str Case insensitive name of the champion to get runes for. Returns ------- Tuple[di...
python
async def get_raw(self, champion_name: str) -> Tuple[dict]: """A method to retrieve **raw** optimal runes for a given champion. Parameters ---------- champion_name : str Case insensitive name of the champion to get runes for. Returns ------- Tuple[di...
[ "async", "def", "get_raw", "(", "self", ",", "champion_name", ":", "str", ")", "->", "Tuple", "[", "dict", "]", ":", "champion_lower", "=", "champion_name", ".", "lower", "(", ")", "if", "champion_lower", "not", "in", "self", ".", "rune_links", ":", "rai...
A method to retrieve **raw** optimal runes for a given champion. Parameters ---------- champion_name : str Case insensitive name of the champion to get runes for. Returns ------- Tuple[dict] A tuple of dicts which contain the rune information. ...
[ "A", "method", "to", "retrieve", "**", "raw", "**", "optimal", "runes", "for", "a", "given", "champion", "." ]
train
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/aioruneclient.py#L95-L126
Naught0/lolrune
lolrune/aioruneclient.py
AioRuneClient.get_runes
async def get_runes(self, champion_name: str) -> Tuple[Champion]: """A method to retrieve a champion's runepage objects. Parameters ---------- champion_name : str Case insensitive name of the champion to get runes for. Returns ------- ...
python
async def get_runes(self, champion_name: str) -> Tuple[Champion]: """A method to retrieve a champion's runepage objects. Parameters ---------- champion_name : str Case insensitive name of the champion to get runes for. Returns ------- ...
[ "async", "def", "get_runes", "(", "self", ",", "champion_name", ":", "str", ")", "->", "Tuple", "[", "Champion", "]", ":", "champion_lower", "=", "champion_name", ".", "lower", "(", ")", "if", "champion_lower", "not", "in", "self", ".", "rune_links", ":", ...
A method to retrieve a champion's runepage objects. Parameters ---------- champion_name : str Case insensitive name of the champion to get runes for. Returns ------- Tuple[:class:`Champion`] A tuple of :class:`Champion`\s. ...
[ "A", "method", "to", "retrieve", "a", "champion", "s", "runepage", "objects", ".", "Parameters", "----------", "champion_name", ":", "str", "Case", "insensitive", "name", "of", "the", "champion", "to", "get", "runes", "for", ".", "Returns", "-------", "Tuple",...
train
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/aioruneclient.py#L128-L154
redbridge/molnctrl
molnctrl/csobjects.py
Virtualmachine.update
def update(self): """ Update the state """ vm = self._cs_api.list_virtualmachines(id=self.id)[0] self.is_running = self._is_running(vm.state)
python
def update(self): """ Update the state """ vm = self._cs_api.list_virtualmachines(id=self.id)[0] self.is_running = self._is_running(vm.state)
[ "def", "update", "(", "self", ")", ":", "vm", "=", "self", ".", "_cs_api", ".", "list_virtualmachines", "(", "id", "=", "self", ".", "id", ")", "[", "0", "]", "self", ".", "is_running", "=", "self", ".", "_is_running", "(", "vm", ".", "state", ")" ...
Update the state
[ "Update", "the", "state" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/csobjects.py#L155-L158
proversity-org/bibblio-api-python
bibbliothon/authorization.py
get_access_token
def get_access_token(client_id, client_secret): ''' Name: token Parameters: client_id, client_secret Return: dictionary ''' headers = {'Content-Type': 'application/x-www-form-urlencoded'} payload = { 'client_id': client_id, 'client_secret': client_secret } request = requests.post(token_url, data=payload,...
python
def get_access_token(client_id, client_secret): ''' Name: token Parameters: client_id, client_secret Return: dictionary ''' headers = {'Content-Type': 'application/x-www-form-urlencoded'} payload = { 'client_id': client_id, 'client_secret': client_secret } request = requests.post(token_url, data=payload,...
[ "def", "get_access_token", "(", "client_id", ",", "client_secret", ")", ":", "headers", "=", "{", "'Content-Type'", ":", "'application/x-www-form-urlencoded'", "}", "payload", "=", "{", "'client_id'", ":", "client_id", ",", "'client_secret'", ":", "client_secret", "...
Name: token Parameters: client_id, client_secret Return: dictionary
[ "Name", ":", "token", "Parameters", ":", "client_id", "client_secret", "Return", ":", "dictionary" ]
train
https://github.com/proversity-org/bibblio-api-python/blob/d619223ad80a4bcd32f90ba64d93370260601b60/bibbliothon/authorization.py#L12-L30
ewiger/tree_output
tree_output/houtput.py
NullOutput.emit
def emit(self, record, closed=False): '''Do nothing''' HierarchicalOutput.emit(self, record, closed)
python
def emit(self, record, closed=False): '''Do nothing''' HierarchicalOutput.emit(self, record, closed)
[ "def", "emit", "(", "self", ",", "record", ",", "closed", "=", "False", ")", ":", "HierarchicalOutput", ".", "emit", "(", "self", ",", "record", ",", "closed", ")" ]
Do nothing
[ "Do", "nothing" ]
train
https://github.com/ewiger/tree_output/blob/29bc8bb5b2cdbe127d266c2d9e7384923dbdb526/tree_output/houtput.py#L95-L97
litters/shrew
shrew/utils/auth.py
unlock_keychain
def unlock_keychain(username): """ If the user is running via SSH, their Keychain must be unlocked first. """ if 'SSH_TTY' not in os.environ: return # Don't unlock if we've already seen this user. if username in _unlocked: return _unlocked.add(username) if sys.platform == 'da...
python
def unlock_keychain(username): """ If the user is running via SSH, their Keychain must be unlocked first. """ if 'SSH_TTY' not in os.environ: return # Don't unlock if we've already seen this user. if username in _unlocked: return _unlocked.add(username) if sys.platform == 'da...
[ "def", "unlock_keychain", "(", "username", ")", ":", "if", "'SSH_TTY'", "not", "in", "os", ".", "environ", ":", "return", "# Don't unlock if we've already seen this user.", "if", "username", "in", "_unlocked", ":", "return", "_unlocked", ".", "add", "(", "username...
If the user is running via SSH, their Keychain must be unlocked first.
[ "If", "the", "user", "is", "running", "via", "SSH", "their", "Keychain", "must", "be", "unlocked", "first", "." ]
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L133-L147
litters/shrew
shrew/utils/auth.py
save_password
def save_password(entry, password, username=None): """ Saves the given password in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param password: The password to save in the keychain. :param username: The username to get the password for. Defau...
python
def save_password(entry, password, username=None): """ Saves the given password in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param password: The password to save in the keychain. :param username: The username to get the password for. Defau...
[ "def", "save_password", "(", "entry", ",", "password", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", ")", "has_keychain", "=", "initialize_keychain", "(", ")", "if", "has_keychain", ":", ...
Saves the given password in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param password: The password to save in the keychain. :param username: The username to get the password for. Default is the current user.
[ "Saves", "the", "given", "password", "in", "the", "user", "s", "keychain", "." ]
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L150-L169
litters/shrew
shrew/utils/auth.py
remove_password
def remove_password(entry, username=None): """ Removes the password for the specific user in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param username: The username whose password is to be removed. Default is the current user. """ if use...
python
def remove_password(entry, username=None): """ Removes the password for the specific user in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param username: The username whose password is to be removed. Default is the current user. """ if use...
[ "def", "remove_password", "(", "entry", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", ")", "has_keychain", "=", "initialize_keychain", "(", ")", "if", "has_keychain", ":", "try", ":", "ke...
Removes the password for the specific user in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param username: The username whose password is to be removed. Default is the current user.
[ "Removes", "the", "password", "for", "the", "specific", "user", "in", "the", "user", "s", "keychain", "." ]
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L172-L191
litters/shrew
shrew/utils/auth.py
get_password
def get_password(entry=None, username=None, prompt=None, always_ask=False): """ Prompt the user for a password on stdin. :param username: The username to get the password for. Default is the current user. :param entry: The entry in the keychain. This is a caller specific key. :param prompt:...
python
def get_password(entry=None, username=None, prompt=None, always_ask=False): """ Prompt the user for a password on stdin. :param username: The username to get the password for. Default is the current user. :param entry: The entry in the keychain. This is a caller specific key. :param prompt:...
[ "def", "get_password", "(", "entry", "=", "None", ",", "username", "=", "None", ",", "prompt", "=", "None", ",", "always_ask", "=", "False", ")", ":", "password", "=", "None", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", "...
Prompt the user for a password on stdin. :param username: The username to get the password for. Default is the current user. :param entry: The entry in the keychain. This is a caller specific key. :param prompt: The entry in the keychain. This is a caller specific key. :param always_ask: Force ...
[ "Prompt", "the", "user", "for", "a", "password", "on", "stdin", "." ]
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L194-L223
litters/shrew
shrew/utils/auth.py
get_password_from_keyring
def get_password_from_keyring(entry=None, username=None): """ :param entry: The entry in the keychain. This is a caller specific key. :param username: The username to get the password for. Default is the current user. """ if username is None: username = get_username() has_keychain ...
python
def get_password_from_keyring(entry=None, username=None): """ :param entry: The entry in the keychain. This is a caller specific key. :param username: The username to get the password for. Default is the current user. """ if username is None: username = get_username() has_keychain ...
[ "def", "get_password_from_keyring", "(", "entry", "=", "None", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", ")", "has_keychain", "=", "initialize_keychain", "(", ")", "# Unlock the user's keyc...
:param entry: The entry in the keychain. This is a caller specific key. :param username: The username to get the password for. Default is the current user.
[ ":", "param", "entry", ":", "The", "entry", "in", "the", "keychain", ".", "This", "is", "a", "caller", "specific", "key", ".", ":", "param", "username", ":", "The", "username", "to", "get", "the", "password", "for", ".", "Default", "is", "the", "curren...
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L226-L247
litters/shrew
shrew/utils/auth.py
validate_password
def validate_password(entry, username, check_function, password=None, retries=1, save_on_success=True, prompt=None, **check_args): """ Validate a password with a check function & retry if the password is incorrect. Useful for after a user has changed their password in LDAP, but their local keychain ent...
python
def validate_password(entry, username, check_function, password=None, retries=1, save_on_success=True, prompt=None, **check_args): """ Validate a password with a check function & retry if the password is incorrect. Useful for after a user has changed their password in LDAP, but their local keychain ent...
[ "def", "validate_password", "(", "entry", ",", "username", ",", "check_function", ",", "password", "=", "None", ",", "retries", "=", "1", ",", "save_on_success", "=", "True", ",", "prompt", "=", "None", ",", "*", "*", "check_args", ")", ":", "if", "passw...
Validate a password with a check function & retry if the password is incorrect. Useful for after a user has changed their password in LDAP, but their local keychain entry is then out of sync. :param str entry: The keychain entry to fetch a password from. :param str username: The username to authenti...
[ "Validate", "a", "password", "with", "a", "check", "function", "&", "retry", "if", "the", "password", "is", "incorrect", "." ]
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L250-L283
litters/shrew
shrew/utils/auth.py
get_stored_credentials
def get_stored_credentials(): """ Gets the credentials, username and password, that have been stored in ~/.shrew/config.ini and the secure keychain respectively without bothering to prompt the user if either credential cannot be found. :returns: username and password :rtype:...
python
def get_stored_credentials(): """ Gets the credentials, username and password, that have been stored in ~/.shrew/config.ini and the secure keychain respectively without bothering to prompt the user if either credential cannot be found. :returns: username and password :rtype:...
[ "def", "get_stored_credentials", "(", ")", ":", "with", "load_config", "(", "sections", "=", "AUTH_SECTIONS", ",", "defaults", "=", "AUTH_CONFIG_DEFAULTS", ")", "as", "config", ":", "username", "=", "config", ".", "get", "(", "AUTH_SECTION", ",", "'username'", ...
Gets the credentials, username and password, that have been stored in ~/.shrew/config.ini and the secure keychain respectively without bothering to prompt the user if either credential cannot be found. :returns: username and password :rtype: tuple of str
[ "Gets", "the", "credentials", "username", "and", "password", "that", "have", "been", "stored", "in", "~", "/", ".", "shrew", "/", "config", ".", "ini", "and", "the", "secure", "keychain", "respectively", "without", "bothering", "to", "prompt", "the", "user",...
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L286-L313
litters/shrew
shrew/utils/auth.py
FixedOSXKeychain.delete_password
def delete_password(service, username): """Delete the password for the username of the service. """ try: # set up the call for security. call = subprocess.Popen(['security', 'delete-generic-password', ...
python
def delete_password(service, username): """Delete the password for the username of the service. """ try: # set up the call for security. call = subprocess.Popen(['security', 'delete-generic-password', ...
[ "def", "delete_password", "(", "service", ",", "username", ")", ":", "try", ":", "# set up the call for security.", "call", "=", "subprocess", ".", "Popen", "(", "[", "'security'", ",", "'delete-generic-password'", ",", "'-a'", ",", "username", ",", "'-s'", ",",...
Delete the password for the username of the service.
[ "Delete", "the", "password", "for", "the", "username", "of", "the", "service", "." ]
train
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L60-L79
mayfield/shellish
shellish/rendering/traceback.py
format_exception
def format_exception(exc, indent=0, pad=' '): """ Take an exception object and return a generator with vtml formatted exception traceback lines. """ from_msg = None if exc.__cause__ is not None: indent += yield from format_exception(exc.__cause__, indent) from_msg = traceback._cause_mes...
python
def format_exception(exc, indent=0, pad=' '): """ Take an exception object and return a generator with vtml formatted exception traceback lines. """ from_msg = None if exc.__cause__ is not None: indent += yield from format_exception(exc.__cause__, indent) from_msg = traceback._cause_mes...
[ "def", "format_exception", "(", "exc", ",", "indent", "=", "0", ",", "pad", "=", "' '", ")", ":", "from_msg", "=", "None", "if", "exc", ".", "__cause__", "is", "not", "None", ":", "indent", "+=", "yield", "from", "format_exception", "(", "exc", ".", ...
Take an exception object and return a generator with vtml formatted exception traceback lines.
[ "Take", "an", "exception", "object", "and", "return", "a", "generator", "with", "vtml", "formatted", "exception", "traceback", "lines", "." ]
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/traceback.py#L12-L36
mayfield/shellish
shellish/rendering/traceback.py
print_exception
def print_exception(*args, file=None, **kwargs): """ Print the formatted output of an exception object. """ for line in format_exception(*args, **kwargs): vtml.vtmlprint(line, file=file)
python
def print_exception(*args, file=None, **kwargs): """ Print the formatted output of an exception object. """ for line in format_exception(*args, **kwargs): vtml.vtmlprint(line, file=file)
[ "def", "print_exception", "(", "*", "args", ",", "file", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "line", "in", "format_exception", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "vtml", ".", "vtmlprint", "(", "line", ",", "file...
Print the formatted output of an exception object.
[ "Print", "the", "formatted", "output", "of", "an", "exception", "object", "." ]
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/traceback.py#L39-L42
1and1/infrascope
src/infrascope/configuration.py
Configuration.create
def create(cls, config_file=None): """ Return the default configuration. """ if cls.instance is None: cls.instance = cls(config_file) # Load config file, possibly overwriting the defaults cls.instance.load_ini() if config_file and config_file != cls....
python
def create(cls, config_file=None): """ Return the default configuration. """ if cls.instance is None: cls.instance = cls(config_file) # Load config file, possibly overwriting the defaults cls.instance.load_ini() if config_file and config_file != cls....
[ "def", "create", "(", "cls", ",", "config_file", "=", "None", ")", ":", "if", "cls", ".", "instance", "is", "None", ":", "cls", ".", "instance", "=", "cls", "(", "config_file", ")", "# Load config file, possibly overwriting the defaults", "cls", ".", "instance...
Return the default configuration.
[ "Return", "the", "default", "configuration", "." ]
train
https://github.com/1and1/infrascope/blob/d7e291917e618a0a3cd6d5bfc20c6b5defd7550c/src/infrascope/configuration.py#L38-L50
1and1/infrascope
src/infrascope/configuration.py
Configuration.load_ini
def load_ini(self): """ Load the given .INI file. """ if not self.config_file: return # Load INI file ini_file = ConfigParser.SafeConfigParser() if not ini_file.read(self.config_file): raise ConfigParser.ParsingError("Global configuration file %r ...
python
def load_ini(self): """ Load the given .INI file. """ if not self.config_file: return # Load INI file ini_file = ConfigParser.SafeConfigParser() if not ini_file.read(self.config_file): raise ConfigParser.ParsingError("Global configuration file %r ...
[ "def", "load_ini", "(", "self", ")", ":", "if", "not", "self", ".", "config_file", ":", "return", "# Load INI file", "ini_file", "=", "ConfigParser", ".", "SafeConfigParser", "(", ")", "if", "not", "ini_file", ".", "read", "(", "self", ".", "config_file", ...
Load the given .INI file.
[ "Load", "the", "given", ".", "INI", "file", "." ]
train
https://github.com/1and1/infrascope/blob/d7e291917e618a0a3cd6d5bfc20c6b5defd7550c/src/infrascope/configuration.py#L74-L109
logston/py3s3
py3s3/files.py
File.chunks
def chunks(self, chunk_size=None): """ Read the file and yield chucks of ``chunk_size`` bytes (defaults to ``UploadedFile.DEFAULT_CHUNK_SIZE``). """ if not chunk_size: chunk_size = self.DEFAULT_CHUNK_SIZE try: self.seek(0) except (Attribut...
python
def chunks(self, chunk_size=None): """ Read the file and yield chucks of ``chunk_size`` bytes (defaults to ``UploadedFile.DEFAULT_CHUNK_SIZE``). """ if not chunk_size: chunk_size = self.DEFAULT_CHUNK_SIZE try: self.seek(0) except (Attribut...
[ "def", "chunks", "(", "self", ",", "chunk_size", "=", "None", ")", ":", "if", "not", "chunk_size", ":", "chunk_size", "=", "self", ".", "DEFAULT_CHUNK_SIZE", "try", ":", "self", ".", "seek", "(", "0", ")", "except", "(", "AttributeError", ",", "Unsupport...
Read the file and yield chucks of ``chunk_size`` bytes (defaults to ``UploadedFile.DEFAULT_CHUNK_SIZE``).
[ "Read", "the", "file", "and", "yield", "chucks", "of", "chunk_size", "bytes", "(", "defaults", "to", "UploadedFile", ".", "DEFAULT_CHUNK_SIZE", ")", "." ]
train
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L94-L111
logston/py3s3
py3s3/files.py
File.multiple_chunks
def multiple_chunks(self, chunk_size=None): """ Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks. """ if not...
python
def multiple_chunks(self, chunk_size=None): """ Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks. """ if not...
[ "def", "multiple_chunks", "(", "self", ",", "chunk_size", "=", "None", ")", ":", "if", "not", "chunk_size", ":", "chunk_size", "=", "self", ".", "DEFAULT_CHUNK_SIZE", "return", "self", ".", "size", ">", "chunk_size" ]
Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks.
[ "Returns", "True", "if", "you", "can", "expect", "multiple", "chunks", "." ]
train
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L113-L123
logston/py3s3
py3s3/files.py
S3ContentFile.content
def content(self, value): """ Set content to byte string, encoding if necessary """ if isinstance(value, bytes): self._content = value else: self._content = value.encode(ENCODING) self.size = len(value)
python
def content(self, value): """ Set content to byte string, encoding if necessary """ if isinstance(value, bytes): self._content = value else: self._content = value.encode(ENCODING) self.size = len(value)
[ "def", "content", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "self", ".", "_content", "=", "value", "else", ":", "self", ".", "_content", "=", "value", ".", "encode", "(", "ENCODING", ")", "self", ...
Set content to byte string, encoding if necessary
[ "Set", "content", "to", "byte", "string", "encoding", "if", "necessary" ]
train
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L208-L216
logston/py3s3
py3s3/files.py
S3ContentFile.md5hash
def md5hash(self): """Return the MD5 hash string of the file content""" digest = hashlib.md5(self.content).digest() return b64_string(digest)
python
def md5hash(self): """Return the MD5 hash string of the file content""" digest = hashlib.md5(self.content).digest() return b64_string(digest)
[ "def", "md5hash", "(", "self", ")", ":", "digest", "=", "hashlib", ".", "md5", "(", "self", ".", "content", ")", ".", "digest", "(", ")", "return", "b64_string", "(", "digest", ")" ]
Return the MD5 hash string of the file content
[ "Return", "the", "MD5", "hash", "string", "of", "the", "file", "content" ]
train
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L218-L221
logston/py3s3
py3s3/files.py
S3ContentFile.read
def read(self, chunk_size=None): """ Return chunk_size of bytes, starting from self.pos, from self.content. """ if chunk_size: data = self.content[self.pos:self.pos + chunk_size] self.pos += len(data) return data else: return self.c...
python
def read(self, chunk_size=None): """ Return chunk_size of bytes, starting from self.pos, from self.content. """ if chunk_size: data = self.content[self.pos:self.pos + chunk_size] self.pos += len(data) return data else: return self.c...
[ "def", "read", "(", "self", ",", "chunk_size", "=", "None", ")", ":", "if", "chunk_size", ":", "data", "=", "self", ".", "content", "[", "self", ".", "pos", ":", "self", ".", "pos", "+", "chunk_size", "]", "self", ".", "pos", "+=", "len", "(", "d...
Return chunk_size of bytes, starting from self.pos, from self.content.
[ "Return", "chunk_size", "of", "bytes", "starting", "from", "self", ".", "pos", "from", "self", ".", "content", "." ]
train
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L226-L235
klmitch/appathy
appathy/utils.py
norm_path
def norm_path(path, allow_trailing=True): """ Normalize a route path. Ensures that the path begins with a '/'. If `allow_trailing` is False, strips off any trailing '/'. Any repeated '/' characters in the path will be collapsed into a single one. """ # Collapse slashes path = _path_re...
python
def norm_path(path, allow_trailing=True): """ Normalize a route path. Ensures that the path begins with a '/'. If `allow_trailing` is False, strips off any trailing '/'. Any repeated '/' characters in the path will be collapsed into a single one. """ # Collapse slashes path = _path_re...
[ "def", "norm_path", "(", "path", ",", "allow_trailing", "=", "True", ")", ":", "# Collapse slashes", "path", "=", "_path_re", ".", "sub", "(", "'/'", ",", "path", ")", "# Force a leading slash", "if", "path", "[", "0", "]", "!=", "'/'", ":", "path", "=",...
Normalize a route path. Ensures that the path begins with a '/'. If `allow_trailing` is False, strips off any trailing '/'. Any repeated '/' characters in the path will be collapsed into a single one.
[ "Normalize", "a", "route", "path", ".", "Ensures", "that", "the", "path", "begins", "with", "a", "/", ".", "If", "allow_trailing", "is", "False", "strips", "off", "any", "trailing", "/", ".", "Any", "repeated", "/", "characters", "in", "the", "path", "wi...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/utils.py#L27-L46
klmitch/appathy
appathy/utils.py
import_egg
def import_egg(string): """ Import a controller class from an egg. Uses the entry point group "appathy.controller". """ # Split the string into a distribution and a name dist, _sep, name = string.partition('#') return pkg_resources.load_entry_point(dist, 'appathy.controller', name)
python
def import_egg(string): """ Import a controller class from an egg. Uses the entry point group "appathy.controller". """ # Split the string into a distribution and a name dist, _sep, name = string.partition('#') return pkg_resources.load_entry_point(dist, 'appathy.controller', name)
[ "def", "import_egg", "(", "string", ")", ":", "# Split the string into a distribution and a name", "dist", ",", "_sep", ",", "name", "=", "string", ".", "partition", "(", "'#'", ")", "return", "pkg_resources", ".", "load_entry_point", "(", "dist", ",", "'appathy.c...
Import a controller class from an egg. Uses the entry point group "appathy.controller".
[ "Import", "a", "controller", "class", "from", "an", "egg", ".", "Uses", "the", "entry", "point", "group", "appathy", ".", "controller", "." ]
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/utils.py#L57-L66
klmitch/appathy
appathy/utils.py
import_controller
def import_controller(string): """ Imports the requested controller. Controllers are specified in a URI-like manner; the scheme is looked up using the entry point group "appathy.loader". Appathy supports the "call:" and "egg:" schemes by default. """ # Split out the scheme and the control...
python
def import_controller(string): """ Imports the requested controller. Controllers are specified in a URI-like manner; the scheme is looked up using the entry point group "appathy.loader". Appathy supports the "call:" and "egg:" schemes by default. """ # Split out the scheme and the control...
[ "def", "import_controller", "(", "string", ")", ":", "# Split out the scheme and the controller descriptor", "scheme", ",", "sep", ",", "controller", "=", "string", ".", "partition", "(", "':'", ")", "if", "sep", "!=", "':'", ":", "raise", "ImportError", "(", "\...
Imports the requested controller. Controllers are specified in a URI-like manner; the scheme is looked up using the entry point group "appathy.loader". Appathy supports the "call:" and "egg:" schemes by default.
[ "Imports", "the", "requested", "controller", ".", "Controllers", "are", "specified", "in", "a", "URI", "-", "like", "manner", ";", "the", "scheme", "is", "looked", "up", "using", "the", "entry", "point", "group", "appathy", ".", "loader", ".", "Appathy", "...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/utils.py#L69-L93
jalanb/pysyte
pysyte/iteration.py
first
def first(sequence, message=None): """The first item in that sequence If there aren't any, raise a ValueError with that message """ try: return next(iter(sequence)) except StopIteration: raise ValueError(message or ('Sequence is empty: %s' % sequence))
python
def first(sequence, message=None): """The first item in that sequence If there aren't any, raise a ValueError with that message """ try: return next(iter(sequence)) except StopIteration: raise ValueError(message or ('Sequence is empty: %s' % sequence))
[ "def", "first", "(", "sequence", ",", "message", "=", "None", ")", ":", "try", ":", "return", "next", "(", "iter", "(", "sequence", ")", ")", "except", "StopIteration", ":", "raise", "ValueError", "(", "message", "or", "(", "'Sequence is empty: %s'", "%", ...
The first item in that sequence If there aren't any, raise a ValueError with that message
[ "The", "first", "item", "in", "that", "sequence" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/iteration.py#L7-L15
jalanb/pysyte
pysyte/iteration.py
last
def last(sequence, message=None): """The last item in that sequence If there aren't any, raise a ValueError with that message """ try: return sequence.pop() except AttributeError: return list(sequence).pop() except IndexError: raise ValueError(message or f'Sequence is em...
python
def last(sequence, message=None): """The last item in that sequence If there aren't any, raise a ValueError with that message """ try: return sequence.pop() except AttributeError: return list(sequence).pop() except IndexError: raise ValueError(message or f'Sequence is em...
[ "def", "last", "(", "sequence", ",", "message", "=", "None", ")", ":", "try", ":", "return", "sequence", ".", "pop", "(", ")", "except", "AttributeError", ":", "return", "list", "(", "sequence", ")", ".", "pop", "(", ")", "except", "IndexError", ":", ...
The last item in that sequence If there aren't any, raise a ValueError with that message
[ "The", "last", "item", "in", "that", "sequence" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/iteration.py#L18-L28
jalanb/pysyte
pysyte/iteration.py
first_that
def first_that(predicate, sequence, message=None): """The first item in that sequence that matches that predicate If none matches raise a KeyError with that message """ try: return next(ifilter(predicate, sequence)) except StopIteration: raise KeyError(message or 'Not Found')
python
def first_that(predicate, sequence, message=None): """The first item in that sequence that matches that predicate If none matches raise a KeyError with that message """ try: return next(ifilter(predicate, sequence)) except StopIteration: raise KeyError(message or 'Not Found')
[ "def", "first_that", "(", "predicate", ",", "sequence", ",", "message", "=", "None", ")", ":", "try", ":", "return", "next", "(", "ifilter", "(", "predicate", ",", "sequence", ")", ")", "except", "StopIteration", ":", "raise", "KeyError", "(", "message", ...
The first item in that sequence that matches that predicate If none matches raise a KeyError with that message
[ "The", "first", "item", "in", "that", "sequence", "that", "matches", "that", "predicate" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/iteration.py#L38-L46
MacHu-GWU/angora-project
angora/math/img2waveform.py
expand_window
def expand_window(center, window_size, array_size): """Generate a bounded windows. maxlength = 2 * window_size + 1, lower bound is 0 and upper bound is ``array_size - 1``. Example:: >>> expand_window(center=50, window_size=3, max=100) [47, 48, 49, 50, 51, 52, 53] >>> expand...
python
def expand_window(center, window_size, array_size): """Generate a bounded windows. maxlength = 2 * window_size + 1, lower bound is 0 and upper bound is ``array_size - 1``. Example:: >>> expand_window(center=50, window_size=3, max=100) [47, 48, 49, 50, 51, 52, 53] >>> expand...
[ "def", "expand_window", "(", "center", ",", "window_size", ",", "array_size", ")", ":", "if", "center", "-", "window_size", "<", "0", ":", "lower", "=", "0", "else", ":", "lower", "=", "center", "-", "window_size", "if", "center", "+", "window_size", "+"...
Generate a bounded windows. maxlength = 2 * window_size + 1, lower bound is 0 and upper bound is ``array_size - 1``. Example:: >>> expand_window(center=50, window_size=3, max=100) [47, 48, 49, 50, 51, 52, 53] >>> expand_window(center=2, window_size=3, max=100) [0, 1, 2,...
[ "Generate", "a", "bounded", "windows", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/img2waveform.py#L44-L69
MacHu-GWU/angora-project
angora/math/img2waveform.py
img2ascii
def img2ascii(img_path, ascii_path, ascii_char="*", pad=0): """Convert an image to ascii art text. Suppose we have an image like that: .. image:: images/rabbit.png :align: left Put some codes:: >>> from weatherlab.math.img2waveform import img2ascii >>> img2ascii(r"testdata\im...
python
def img2ascii(img_path, ascii_path, ascii_char="*", pad=0): """Convert an image to ascii art text. Suppose we have an image like that: .. image:: images/rabbit.png :align: left Put some codes:: >>> from weatherlab.math.img2waveform import img2ascii >>> img2ascii(r"testdata\im...
[ "def", "img2ascii", "(", "img_path", ",", "ascii_path", ",", "ascii_char", "=", "\"*\"", ",", "pad", "=", "0", ")", ":", "if", "len", "(", "ascii_char", ")", "!=", "1", ":", "raise", "Exception", "(", "\"ascii_char has to be single character.\"", ")", "image...
Convert an image to ascii art text. Suppose we have an image like that: .. image:: images/rabbit.png :align: left Put some codes:: >>> from weatherlab.math.img2waveform import img2ascii >>> img2ascii(r"testdata\img2waveform\rabbit.png", ... r"testdata\img2wavef...
[ "Convert", "an", "image", "to", "ascii", "art", "text", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/img2waveform.py#L72-L261
MacHu-GWU/angora-project
angora/math/img2waveform.py
img2wav
def img2wav(path, min_x, max_x, min_y, max_y, window_size=3): """Generate 1-D data ``y=f(x)`` from a black/white image. Suppose we have an image like that: .. image:: images/waveform.png :align: center Put some codes:: >>> from weatherlab.math.img2waveform import img2wav >>> ...
python
def img2wav(path, min_x, max_x, min_y, max_y, window_size=3): """Generate 1-D data ``y=f(x)`` from a black/white image. Suppose we have an image like that: .. image:: images/waveform.png :align: center Put some codes:: >>> from weatherlab.math.img2waveform import img2wav >>> ...
[ "def", "img2wav", "(", "path", ",", "min_x", ",", "max_x", ",", "min_y", ",", "max_y", ",", "window_size", "=", "3", ")", ":", "image", "=", "Image", ".", "open", "(", "path", ")", ".", "convert", "(", "\"L\"", ")", "matrix", "=", "np", ".", "arr...
Generate 1-D data ``y=f(x)`` from a black/white image. Suppose we have an image like that: .. image:: images/waveform.png :align: center Put some codes:: >>> from weatherlab.math.img2waveform import img2wav >>> import matplotlib.pyplot as plt >>> x, y = img2wav(r"testdata...
[ "Generate", "1", "-", "D", "data", "y", "=", "f", "(", "x", ")", "from", "a", "black", "/", "white", "image", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/img2waveform.py#L264-L327
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
ConfigObject.initial_populate
def initial_populate(self, data): """ Populate a newly created config object with data. If it was populated, this returns True. If it wasn't, this returns False. It is recommended to run a .dump() and .reload() after running this. """ if self.config.parsed: ...
python
def initial_populate(self, data): """ Populate a newly created config object with data. If it was populated, this returns True. If it wasn't, this returns False. It is recommended to run a .dump() and .reload() after running this. """ if self.config.parsed: ...
[ "def", "initial_populate", "(", "self", ",", "data", ")", ":", "if", "self", ".", "config", ".", "parsed", ":", "return", "False", "# Otherwise, create a new ConfigKey.", "self", ".", "config", ".", "load_from_dict", "(", "data", ")", "return", "True" ]
Populate a newly created config object with data. If it was populated, this returns True. If it wasn't, this returns False. It is recommended to run a .dump() and .reload() after running this.
[ "Populate", "a", "newly", "created", "config", "object", "with", "data", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L67-L79
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
ConfigObject.apply_defaults
def apply_defaults(self, other_config): """ Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject. If there are any values in this object that are also in the default object, it will use the values from this object. """ if isinstance(other...
python
def apply_defaults(self, other_config): """ Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject. If there are any values in this object that are also in the default object, it will use the values from this object. """ if isinstance(other...
[ "def", "apply_defaults", "(", "self", ",", "other_config", ")", ":", "if", "isinstance", "(", "other_config", ",", "self", ".", "__class__", ")", ":", "self", ".", "config", ".", "load_from_dict", "(", "other_config", ".", "config", ",", "overwrite", "=", ...
Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject. If there are any values in this object that are also in the default object, it will use the values from this object.
[ "Applies", "default", "values", "from", "a", "different", "ConfigObject", "or", "ConfigKey", "object", "to", "this", "ConfigObject", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L81-L90
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
ConfigFile.reload
def reload(self): """ Automatically reloads the config file. This is just an alias for self.load().""" if not self.fd.closed: self.fd.close() self.fd = open(self.fd.name, 'r') self.load()
python
def reload(self): """ Automatically reloads the config file. This is just an alias for self.load().""" if not self.fd.closed: self.fd.close() self.fd = open(self.fd.name, 'r') self.load()
[ "def", "reload", "(", "self", ")", ":", "if", "not", "self", ".", "fd", ".", "closed", ":", "self", ".", "fd", ".", "close", "(", ")", "self", ".", "fd", "=", "open", "(", "self", ".", "fd", ".", "name", ",", "'r'", ")", "self", ".", "load", ...
Automatically reloads the config file. This is just an alias for self.load().
[ "Automatically", "reloads", "the", "config", "file", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L155-L164
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
NetworkedConfigObject.save_to_file
def save_to_file(self, filename: str) -> ConfigFile: """ This converts the NetworkedConfigFile into a normal ConfigFile object. This requires the normal class hooks to be provided. """ newclass = ConfigFile(fd=filename, load_hook=self.normal_class_hook[0], ...
python
def save_to_file(self, filename: str) -> ConfigFile: """ This converts the NetworkedConfigFile into a normal ConfigFile object. This requires the normal class hooks to be provided. """ newclass = ConfigFile(fd=filename, load_hook=self.normal_class_hook[0], ...
[ "def", "save_to_file", "(", "self", ",", "filename", ":", "str", ")", "->", "ConfigFile", ":", "newclass", "=", "ConfigFile", "(", "fd", "=", "filename", ",", "load_hook", "=", "self", ".", "normal_class_hook", "[", "0", "]", ",", "dump_hook", "=", "self...
This converts the NetworkedConfigFile into a normal ConfigFile object. This requires the normal class hooks to be provided.
[ "This", "converts", "the", "NetworkedConfigFile", "into", "a", "normal", "ConfigFile", "object", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L203-L211
robertchase/ergaleia
ergaleia/to_args.py
to_args
def to_args(s): """ parse a string into args and kwargs the input is a blank-delimited set of tokens, which may be grouped as strings (tick or double tick delimited) with embedded blanks. a non-string equal (=) acts as a delimiter between key-value pairs. the initial tokens are tre...
python
def to_args(s): """ parse a string into args and kwargs the input is a blank-delimited set of tokens, which may be grouped as strings (tick or double tick delimited) with embedded blanks. a non-string equal (=) acts as a delimiter between key-value pairs. the initial tokens are tre...
[ "def", "to_args", "(", "s", ")", ":", "args", "=", "[", "]", "kwargs", "=", "{", "}", "state", "=", "'arg'", "for", "token", "in", "to_tokens", "(", "s", ")", ":", "if", "state", "==", "'arg'", ":", "if", "token", ".", "is_key", ":", "key", "="...
parse a string into args and kwargs the input is a blank-delimited set of tokens, which may be grouped as strings (tick or double tick delimited) with embedded blanks. a non-string equal (=) acts as a delimiter between key-value pairs. the initial tokens are treated as args, followed b...
[ "parse", "a", "string", "into", "args", "and", "kwargs" ]
train
https://github.com/robertchase/ergaleia/blob/df8e9a4b18c563022a503faa27e822c9a5755490/ergaleia/to_args.py#L8-L70
klmitch/appathy
appathy/application.py
Application.dispatch
def dispatch(self, req): """ Called by the Routes middleware to dispatch the request to the appropriate controller. If a webob exception is raised, it is returned; if some other exception is raised, the webob `HTTPInternalServerError` exception is raised. Otherwise, the ...
python
def dispatch(self, req): """ Called by the Routes middleware to dispatch the request to the appropriate controller. If a webob exception is raised, it is returned; if some other exception is raised, the webob `HTTPInternalServerError` exception is raised. Otherwise, the ...
[ "def", "dispatch", "(", "self", ",", "req", ")", ":", "# Grab the request parameters", "params", "=", "req", ".", "environ", "[", "'wsgiorg.routing_args'", "]", "[", "1", "]", "# What controller is authoritative?", "controller", "=", "params", ".", "pop", "(", "...
Called by the Routes middleware to dispatch the request to the appropriate controller. If a webob exception is raised, it is returned; if some other exception is raised, the webob `HTTPInternalServerError` exception is raised. Otherwise, the return value of the controller is returned.
[ "Called", "by", "the", "Routes", "middleware", "to", "dispatch", "the", "request", "to", "the", "appropriate", "controller", ".", "If", "a", "webob", "exception", "is", "raised", "it", "is", "returned", ";", "if", "some", "other", "exception", "is", "raised"...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/application.py#L110-L154
francois-vincent/clingon
examples/example2.py
my_func
def my_func(p1, p2, first_option='default_value', second_option=5, third_option=[4, 3], last_option=False): """Help docstring. v{VERSION} {message} """ if last_option: raise RuntimeError("Test of DEBUG") print('%s %s %s %s %s %s' % (p1, p2, ...
python
def my_func(p1, p2, first_option='default_value', second_option=5, third_option=[4, 3], last_option=False): """Help docstring. v{VERSION} {message} """ if last_option: raise RuntimeError("Test of DEBUG") print('%s %s %s %s %s %s' % (p1, p2, ...
[ "def", "my_func", "(", "p1", ",", "p2", ",", "first_option", "=", "'default_value'", ",", "second_option", "=", "5", ",", "third_option", "=", "[", "4", ",", "3", "]", ",", "last_option", "=", "False", ")", ":", "if", "last_option", ":", "raise", "Runt...
Help docstring. v{VERSION} {message}
[ "Help", "docstring", ".", "v", "{", "VERSION", "}", "{", "message", "}" ]
train
https://github.com/francois-vincent/clingon/blob/afc9db073dbc72b2562ce3e444152986a555dcbf/examples/example2.py#L28-L38
wtsi-hgi/gitlab-build-variables
gitlabbuildvariables/update/_single_project_updaters.py
ProjectVariablesUpdater._get_variables
def _get_variables(self) -> Dict[str, str]: """ Gets the variables that should be set for this project. :return: the variables """ variables = {} # type: Dict[str, str] for group in self.groups: setting_variables = self._read_group_variables(group) ...
python
def _get_variables(self) -> Dict[str, str]: """ Gets the variables that should be set for this project. :return: the variables """ variables = {} # type: Dict[str, str] for group in self.groups: setting_variables = self._read_group_variables(group) ...
[ "def", "_get_variables", "(", "self", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "variables", "=", "{", "}", "# type: Dict[str, str]", "for", "group", "in", "self", ".", "groups", ":", "setting_variables", "=", "self", ".", "_read_group_variables",...
Gets the variables that should be set for this project. :return: the variables
[ "Gets", "the", "variables", "that", "should", "be", "set", "for", "this", "project", ".", ":", "return", ":", "the", "variables" ]
train
https://github.com/wtsi-hgi/gitlab-build-variables/blob/ed1afe50bc41fa20ffb29cacba5ff6dbc2446808/gitlabbuildvariables/update/_single_project_updaters.py#L46-L55
wtsi-hgi/gitlab-build-variables
gitlabbuildvariables/update/_single_project_updaters.py
FileBasedProjectVariablesUpdater._resolve_group_location
def _resolve_group_location(self, group: str) -> str: """ Resolves the location of a setting file based on the given identifier. :param group: the identifier for the group's settings file (~its location) :return: the absolute path of the settings location """ if os.path.i...
python
def _resolve_group_location(self, group: str) -> str: """ Resolves the location of a setting file based on the given identifier. :param group: the identifier for the group's settings file (~its location) :return: the absolute path of the settings location """ if os.path.i...
[ "def", "_resolve_group_location", "(", "self", ",", "group", ":", "str", ")", "->", "str", ":", "if", "os", ".", "path", ".", "isabs", "(", "group", ")", ":", "possible_paths", "=", "[", "group", "]", "else", ":", "possible_paths", "=", "[", "]", "fo...
Resolves the location of a setting file based on the given identifier. :param group: the identifier for the group's settings file (~its location) :return: the absolute path of the settings location
[ "Resolves", "the", "location", "of", "a", "setting", "file", "based", "on", "the", "given", "identifier", ".", ":", "param", "group", ":", "the", "identifier", "for", "the", "group", "s", "settings", "file", "(", "~its", "location", ")", ":", "return", "...
train
https://github.com/wtsi-hgi/gitlab-build-variables/blob/ed1afe50bc41fa20ffb29cacba5ff6dbc2446808/gitlabbuildvariables/update/_single_project_updaters.py#L78-L100
shaded-enmity/docker-hica
base/hica_base.py
HicaLabelStore.query
def query(self, ns, selector='*'): """ Query the label store for labels :param ns: Label namespace (`bind_pwd` for example) :type ns: str :param selector: Target selector (`test` or `test.guest` for example) :type selector: str """ q, r = HicaLabelStore.PREFIX + '.' + ns, [] for (k...
python
def query(self, ns, selector='*'): """ Query the label store for labels :param ns: Label namespace (`bind_pwd` for example) :type ns: str :param selector: Target selector (`test` or `test.guest` for example) :type selector: str """ q, r = HicaLabelStore.PREFIX + '.' + ns, [] for (k...
[ "def", "query", "(", "self", ",", "ns", ",", "selector", "=", "'*'", ")", ":", "q", ",", "r", "=", "HicaLabelStore", ".", "PREFIX", "+", "'.'", "+", "ns", ",", "[", "]", "for", "(", "key", ",", "value", ")", "in", "self", ".", "items", ":", "...
Query the label store for labels :param ns: Label namespace (`bind_pwd` for example) :type ns: str :param selector: Target selector (`test` or `test.guest` for example) :type selector: str
[ "Query", "the", "label", "store", "for", "labels" ]
train
https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/base/hica_base.py#L63-L81
shaded-enmity/docker-hica
base/hica_base.py
HicaLabelStore.get_value
def get_value(self, label): """ Get value from a single fully-qualified name """ for (key, value) in self.items: if key == label: return value
python
def get_value(self, label): """ Get value from a single fully-qualified name """ for (key, value) in self.items: if key == label: return value
[ "def", "get_value", "(", "self", ",", "label", ")", ":", "for", "(", "key", ",", "value", ")", "in", "self", ".", "items", ":", "if", "key", "==", "label", ":", "return", "value" ]
Get value from a single fully-qualified name
[ "Get", "value", "from", "a", "single", "fully", "-", "qualified", "name" ]
train
https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/base/hica_base.py#L87-L91
vilmibm/done
parsedatetime/parsedatetime_consts.py
_initLocale
def _initLocale(ptc): """ Helper function to initialize the different lists and strings from either PyICU or one of the internal pdt Locales and store them into ptc. """ def lcase(x): return x.lower() if pyicu and ptc.usePyICU: ptc.icuLocale = None if ptc.localeID ...
python
def _initLocale(ptc): """ Helper function to initialize the different lists and strings from either PyICU or one of the internal pdt Locales and store them into ptc. """ def lcase(x): return x.lower() if pyicu and ptc.usePyICU: ptc.icuLocale = None if ptc.localeID ...
[ "def", "_initLocale", "(", "ptc", ")", ":", "def", "lcase", "(", "x", ")", ":", "return", "x", ".", "lower", "(", ")", "if", "pyicu", "and", "ptc", ".", "usePyICU", ":", "ptc", ".", "icuLocale", "=", "None", "if", "ptc", ".", "localeID", "is", "n...
Helper function to initialize the different lists and strings from either PyICU or one of the internal pdt Locales and store them into ptc.
[ "Helper", "function", "to", "initialize", "the", "different", "lists", "and", "strings", "from", "either", "PyICU", "or", "one", "of", "the", "internal", "pdt", "Locales", "and", "store", "them", "into", "ptc", "." ]
train
https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime_consts.py#L479-L598
vilmibm/done
parsedatetime/parsedatetime_consts.py
_initSymbols
def _initSymbols(ptc): """ Helper function to initialize the single character constants and other symbols needed. """ ptc.timeSep = [ u':' ] ptc.dateSep = [ u'/' ] ptc.meridian = [ u'AM', u'PM' ] ptc.usesMeridian = True ptc.uses24 = False if pyicu and ptc.usePyICU: ...
python
def _initSymbols(ptc): """ Helper function to initialize the single character constants and other symbols needed. """ ptc.timeSep = [ u':' ] ptc.dateSep = [ u'/' ] ptc.meridian = [ u'AM', u'PM' ] ptc.usesMeridian = True ptc.uses24 = False if pyicu and ptc.usePyICU: ...
[ "def", "_initSymbols", "(", "ptc", ")", ":", "ptc", ".", "timeSep", "=", "[", "u':'", "]", "ptc", ".", "dateSep", "=", "[", "u'/'", "]", "ptc", ".", "meridian", "=", "[", "u'AM'", ",", "u'PM'", "]", "ptc", ".", "usesMeridian", "=", "True", "ptc", ...
Helper function to initialize the single character constants and other symbols needed.
[ "Helper", "function", "to", "initialize", "the", "single", "character", "constants", "and", "other", "symbols", "needed", "." ]
train
https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime_consts.py#L601-L707
vilmibm/done
parsedatetime/parsedatetime_consts.py
_initPatterns
def _initPatterns(ptc): """ Helper function to take the different localized bits from ptc and create the regex strings. """ # TODO add code to parse the date formats and build the regexes up from sub-parts # TODO find all hard-coded uses of date/time seperators ptc.RE_DATE4 = r'''(?P<da...
python
def _initPatterns(ptc): """ Helper function to take the different localized bits from ptc and create the regex strings. """ # TODO add code to parse the date formats and build the regexes up from sub-parts # TODO find all hard-coded uses of date/time seperators ptc.RE_DATE4 = r'''(?P<da...
[ "def", "_initPatterns", "(", "ptc", ")", ":", "# TODO add code to parse the date formats and build the regexes up from sub-parts", "# TODO find all hard-coded uses of date/time seperators", "ptc", ".", "RE_DATE4", "=", "r'''(?P<date>(((?P<day>\\d\\d?)(?P<suffix>%(daysuffix)s)?(,)?(\\s)?)\n ...
Helper function to take the different localized bits from ptc and create the regex strings.
[ "Helper", "function", "to", "take", "the", "different", "localized", "bits", "from", "ptc", "and", "create", "the", "regex", "strings", "." ]
train
https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime_consts.py#L710-L838