hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | log | <not_specific> | def log(self, revs=None, path=None, exclude=None, id_only=True, **kw):
"""
Returns a generator that returns information about commits reachable
by revs which modify path.
revs can either be a single revision identifier or a list or tuple
of identifiers, each of which can be anyt... |
Returns a generator that returns information about commits reachable
by revs which modify path.
revs can either be a single revision identifier or a list or tuple
of identifiers, each of which can be anything parsable by self.commit().
If revs is None, the default branch head w... | Returns a generator that returns information about commits reachable
by revs which modify path.
revs can either be a single revision identifier or a list or tuple
of identifiers, each of which can be anything parsable by self.commit().
If revs is None, the default branch head will be used.
If path is not None, then o... | [
"Returns",
"a",
"generator",
"that",
"returns",
"information",
"about",
"commits",
"reachable",
"by",
"revs",
"which",
"modify",
"path",
".",
"revs",
"can",
"either",
"be",
"a",
"single",
"revision",
"identifier",
"or",
"a",
"list",
"or",
"tuple",
"of",
"ide... | def log(self, revs=None, path=None, exclude=None, id_only=True, **kw):
if revs is not None and not isinstance(revs, (list, tuple)):
revs = [revs]
if exclude is not None and not isinstance(exclude, (list, tuple)):
exclude = [exclude]
return self._impl.log(revs, path, exclu... | [
"def",
"log",
"(",
"self",
",",
"revs",
"=",
"None",
",",
"path",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"id_only",
"=",
"True",
",",
"**",
"kw",
")",
":",
"if",
"revs",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"revs",
",",
... | Returns a generator that returns information about commits reachable
by revs which modify path. | [
"Returns",
"a",
"generator",
"that",
"returns",
"information",
"about",
"commits",
"reachable",
"by",
"revs",
"which",
"modify",
"path",
"."
] | [
"\"\"\"\n Returns a generator that returns information about commits reachable\n by revs which modify path.\n\n revs can either be a single revision identifier or a list or tuple\n of identifiers, each of which can be anything parsable by self.commit().\n If revs is None, the defa... | [
{
"param": "self",
"type": null
},
{
"param": "revs",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "exclude",
"type": null
},
{
"param": "id_only",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "revs",
"type": null,
"docstring": null,
"docstring_tokens": [... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | clone_url | <not_specific> | def clone_url(self, category, username=''):
'''Return a URL string suitable for copy/paste that describes _this_ repo,
e.g., for use in a clone/checkout command
'''
if self.app.config.options.get('external_checkout_url', None):
tpl = string.Template(self.app.config.options... | Return a URL string suitable for copy/paste that describes _this_ repo,
e.g., for use in a clone/checkout command
| Return a URL string suitable for copy/paste that describes _this_ repo,
e.g., for use in a clone/checkout command | [
"Return",
"a",
"URL",
"string",
"suitable",
"for",
"copy",
"/",
"paste",
"that",
"describes",
"_this_",
"repo",
"e",
".",
"g",
".",
"for",
"use",
"in",
"a",
"clone",
"/",
"checkout",
"command"
] | def clone_url(self, category, username=''):
if self.app.config.options.get('external_checkout_url', None):
tpl = string.Template(self.app.config.options.external_checkout_url)
else:
tpl = string.Template(
tg.config.get('scm.host.%s.%s' % (category, self.tool)))
... | [
"def",
"clone_url",
"(",
"self",
",",
"category",
",",
"username",
"=",
"''",
")",
":",
"if",
"self",
".",
"app",
".",
"config",
".",
"options",
".",
"get",
"(",
"'external_checkout_url'",
",",
"None",
")",
":",
"tpl",
"=",
"string",
".",
"Template",
... | Return a URL string suitable for copy/paste that describes _this_ repo,
e.g., for use in a clone/checkout command | [
"Return",
"a",
"URL",
"string",
"suitable",
"for",
"copy",
"/",
"paste",
"that",
"describes",
"_this_",
"repo",
"e",
".",
"g",
".",
"for",
"use",
"in",
"a",
"clone",
"/",
"checkout",
"command"
] | [
"'''Return a URL string suitable for copy/paste that describes _this_ repo,\n e.g., for use in a clone/checkout command\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "category",
"type": null
},
{
"param": "username",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "category",
"type": null,
"docstring": null,
"docstring_tokens... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | refresh | null | def refresh(self, all_commits=False, notify=True, new_clone=False):
'''Find any new commits in the repository and update'''
try:
from allura.model.repo_refresh import refresh_repo
log.info('... %r analyzing', self)
self.set_status('analyzing')
refresh_repo... | Find any new commits in the repository and update | Find any new commits in the repository and update | [
"Find",
"any",
"new",
"commits",
"in",
"the",
"repository",
"and",
"update"
] | def refresh(self, all_commits=False, notify=True, new_clone=False):
try:
from allura.model.repo_refresh import refresh_repo
log.info('... %r analyzing', self)
self.set_status('analyzing')
refresh_repo(self, all_commits, notify, new_clone)
finally:
... | [
"def",
"refresh",
"(",
"self",
",",
"all_commits",
"=",
"False",
",",
"notify",
"=",
"True",
",",
"new_clone",
"=",
"False",
")",
":",
"try",
":",
"from",
"allura",
".",
"model",
".",
"repo_refresh",
"import",
"refresh_repo",
"log",
".",
"info",
"(",
"... | Find any new commits in the repository and update | [
"Find",
"any",
"new",
"commits",
"in",
"the",
"repository",
"and",
"update"
] | [
"'''Find any new commits in the repository and update'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "all_commits",
"type": null
},
{
"param": "notify",
"type": null
},
{
"param": "new_clone",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "all_commits",
"type": null,
"docstring": null,
"docstring_tok... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | climb_commit_tree | null | def climb_commit_tree(self, predicate=None):
'''
Returns a generator that walks up the commit tree along
the first-parent ancestory, starting with this commit,
optionally filtering by a predicate.'''
ancestor = self
while ancestor:
if predicate is None or pred... |
Returns a generator that walks up the commit tree along
the first-parent ancestory, starting with this commit,
optionally filtering by a predicate. | Returns a generator that walks up the commit tree along
the first-parent ancestory, starting with this commit,
optionally filtering by a predicate. | [
"Returns",
"a",
"generator",
"that",
"walks",
"up",
"the",
"commit",
"tree",
"along",
"the",
"first",
"-",
"parent",
"ancestory",
"starting",
"with",
"this",
"commit",
"optionally",
"filtering",
"by",
"a",
"predicate",
"."
] | def climb_commit_tree(self, predicate=None):
ancestor = self
while ancestor:
if predicate is None or predicate(ancestor):
yield ancestor
ancestor = ancestor.get_parent() | [
"def",
"climb_commit_tree",
"(",
"self",
",",
"predicate",
"=",
"None",
")",
":",
"ancestor",
"=",
"self",
"while",
"ancestor",
":",
"if",
"predicate",
"is",
"None",
"or",
"predicate",
"(",
"ancestor",
")",
":",
"yield",
"ancestor",
"ancestor",
"=",
"ances... | Returns a generator that walks up the commit tree along
the first-parent ancestory, starting with this commit,
optionally filtering by a predicate. | [
"Returns",
"a",
"generator",
"that",
"walks",
"up",
"the",
"commit",
"tree",
"along",
"the",
"first",
"-",
"parent",
"ancestory",
"starting",
"with",
"this",
"commit",
"optionally",
"filtering",
"by",
"a",
"predicate",
"."
] | [
"'''\n Returns a generator that walks up the commit tree along\n the first-parent ancestory, starting with this commit,\n optionally filtering by a predicate.'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "predicate",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "predicate",
"type": null,
"docstring": null,
"docstring_token... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | changed_paths | <not_specific> | def changed_paths(self):
'''
Returns a list of paths changed in this commit.
Leading and trailing slashes are removed, and
the list is complete, meaning that if a sub-path
is changed, all of the parent paths are included
(including '' to represent the root path).
... |
Returns a list of paths changed in this commit.
Leading and trailing slashes are removed, and
the list is complete, meaning that if a sub-path
is changed, all of the parent paths are included
(including '' to represent the root path).
Example:
If the file /... | Returns a list of paths changed in this commit.
Leading and trailing slashes are removed, and
the list is complete, meaning that if a sub-path
is changed, all of the parent paths are included
(including '' to represent the root path). | [
"Returns",
"a",
"list",
"of",
"paths",
"changed",
"in",
"this",
"commit",
".",
"Leading",
"and",
"trailing",
"slashes",
"are",
"removed",
"and",
"the",
"list",
"is",
"complete",
"meaning",
"that",
"if",
"a",
"sub",
"-",
"path",
"is",
"changed",
"all",
"o... | def changed_paths(self):
changes = self.repo.get_changes(self._id)
changed_paths = set()
for change in changes:
node = change.strip('/')
changed_paths.add(node)
node_path = os.path.dirname(node)
while node_path:
changed_paths.add(no... | [
"def",
"changed_paths",
"(",
"self",
")",
":",
"changes",
"=",
"self",
".",
"repo",
".",
"get_changes",
"(",
"self",
".",
"_id",
")",
"changed_paths",
"=",
"set",
"(",
")",
"for",
"change",
"in",
"changes",
":",
"node",
"=",
"change",
".",
"strip",
"... | Returns a list of paths changed in this commit. | [
"Returns",
"a",
"list",
"of",
"paths",
"changed",
"in",
"this",
"commit",
"."
] | [
"'''\n Returns a list of paths changed in this commit.\n Leading and trailing slashes are removed, and\n the list is complete, meaning that if a sub-path\n is changed, all of the parent paths are included\n (including '' to represent the root path).\n\n Example:\n\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": [
{
"identifier": "examples",
"docstring": "If the... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | compute_hash | <not_specific> | def compute_hash(self):
'''Compute a hash based on the contents of the tree. Note that this
hash does not necessarily correspond to any actual DVCS hash.
'''
lines = (
['tree' + x.name + x.id for x in self.tree_ids]
+ ['blob' + x.name + x.id for x in self.blob_id... | Compute a hash based on the contents of the tree. Note that this
hash does not necessarily correspond to any actual DVCS hash.
| Compute a hash based on the contents of the tree. Note that this
hash does not necessarily correspond to any actual DVCS hash. | [
"Compute",
"a",
"hash",
"based",
"on",
"the",
"contents",
"of",
"the",
"tree",
".",
"Note",
"that",
"this",
"hash",
"does",
"not",
"necessarily",
"correspond",
"to",
"any",
"actual",
"DVCS",
"hash",
"."
] | def compute_hash(self):
lines = (
['tree' + x.name + x.id for x in self.tree_ids]
+ ['blob' + x.name + x.id for x in self.blob_ids]
+ [x.type + x.name + x.id for x in self.other_ids])
sha_obj = sha1()
for line in sorted(lines):
sha_obj.update(line)... | [
"def",
"compute_hash",
"(",
"self",
")",
":",
"lines",
"=",
"(",
"[",
"'tree'",
"+",
"x",
".",
"name",
"+",
"x",
".",
"id",
"for",
"x",
"in",
"self",
".",
"tree_ids",
"]",
"+",
"[",
"'blob'",
"+",
"x",
".",
"name",
"+",
"x",
".",
"id",
"for",... | Compute a hash based on the contents of the tree. | [
"Compute",
"a",
"hash",
"based",
"on",
"the",
"contents",
"of",
"the",
"tree",
"."
] | [
"'''Compute a hash based on the contents of the tree. Note that this\n hash does not necessarily correspond to any actual DVCS hash.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | has_html_view | <not_specific> | def has_html_view(self):
'''
Return true if file is a text file that can be displayed.
:return: boolean
'''
if self.extension in BINARY_EXTENSIONS:
return False
if (self.content_type.startswith('text/') or
self.extension in VIEWABLE_EXTENSIONS ... |
Return true if file is a text file that can be displayed.
:return: boolean
| Return true if file is a text file that can be displayed. | [
"Return",
"true",
"if",
"file",
"is",
"a",
"text",
"file",
"that",
"can",
"be",
"displayed",
"."
] | def has_html_view(self):
if self.extension in BINARY_EXTENSIONS:
return False
if (self.content_type.startswith('text/') or
self.extension in VIEWABLE_EXTENSIONS or
self.extension in PYPELINE_EXTENSIONS or
self.extension in self.repo._additional... | [
"def",
"has_html_view",
"(",
"self",
")",
":",
"if",
"self",
".",
"extension",
"in",
"BINARY_EXTENSIONS",
":",
"return",
"False",
"if",
"(",
"self",
".",
"content_type",
".",
"startswith",
"(",
"'text/'",
")",
"or",
"self",
".",
"extension",
"in",
"VIEWABL... | Return true if file is a text file that can be displayed. | [
"Return",
"true",
"if",
"file",
"is",
"a",
"text",
"file",
"that",
"can",
"be",
"displayed",
"."
] | [
"'''\n Return true if file is a text file that can be displayed.\n :return: boolean\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | _build | <not_specific> | def _build(cls, tree):
'''
Build the LCD record, presuming that this tree is where it was most
recently changed.
'''
model_cache = getattr(c, 'model_cache', '') or ModelCache()
path = tree.path().strip('/')
entries = []
prev_lcd = None
prev_lcd... |
Build the LCD record, presuming that this tree is where it was most
recently changed.
| Build the LCD record, presuming that this tree is where it was most
recently changed. | [
"Build",
"the",
"LCD",
"record",
"presuming",
"that",
"this",
"tree",
"is",
"where",
"it",
"was",
"most",
"recently",
"changed",
"."
] | def _build(cls, tree):
model_cache = getattr(c, 'model_cache', '') or ModelCache()
path = tree.path().strip('/')
entries = []
prev_lcd = None
prev_lcd_cid = cls._prev_commit_id(tree.commit, path)
if prev_lcd_cid:
prev_lcd = model_cache.get(
cls... | [
"def",
"_build",
"(",
"cls",
",",
"tree",
")",
":",
"model_cache",
"=",
"getattr",
"(",
"c",
",",
"'model_cache'",
",",
"''",
")",
"or",
"ModelCache",
"(",
")",
"path",
"=",
"tree",
".",
"path",
"(",
")",
".",
"strip",
"(",
"'/'",
")",
"entries",
... | Build the LCD record, presuming that this tree is where it was most
recently changed. | [
"Build",
"the",
"LCD",
"record",
"presuming",
"that",
"this",
"tree",
"is",
"where",
"it",
"was",
"most",
"recently",
"changed",
"."
] | [
"'''\n Build the LCD record, presuming that this tree is where it was most\n recently changed.\n '''",
"# get unchanged entries from previously computed LCD",
"# no previously computed LCD, so get unchanged entries from SCM",
"# (but only ask for the ones that we know we need)",
"# ... | [
{
"param": "cls",
"type": null
},
{
"param": "tree",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tree",
"type": null,
"docstring": null,
"docstring_tokens": []... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | expire_new_instances | null | def expire_new_instances(self, cls):
'''
Expire any instances that were "new" or had no _id value.
If a lot of new instances of a class are being created, it's possible
for a query to pull a copy from mongo when a copy keyed by the synthetic
ID is still in the cache, potentially... |
Expire any instances that were "new" or had no _id value.
If a lot of new instances of a class are being created, it's possible
for a query to pull a copy from mongo when a copy keyed by the synthetic
ID is still in the cache, potentially causing de-sync between the copies
lead... | Expire any instances that were "new" or had no _id value.
If a lot of new instances of a class are being created, it's possible
for a query to pull a copy from mongo when a copy keyed by the synthetic
ID is still in the cache, potentially causing de-sync between the copies
leading to one with missing data overwriting t... | [
"Expire",
"any",
"instances",
"that",
"were",
"\"",
"new",
"\"",
"or",
"had",
"no",
"_id",
"value",
".",
"If",
"a",
"lot",
"of",
"new",
"instances",
"of",
"a",
"class",
"are",
"being",
"created",
"it",
"'",
"s",
"possible",
"for",
"a",
"query",
"to",... | def expire_new_instances(self, cls):
for _query in self._synthetic_id_queries[cls]:
self._query_cache[cls].pop(_query)
self._synthetic_id_queries[cls] = set()
for _id in self._synthetic_ids[cls]:
instance = self._instance_cache[cls].pop(_id)
self._try_flush(in... | [
"def",
"expire_new_instances",
"(",
"self",
",",
"cls",
")",
":",
"for",
"_query",
"in",
"self",
".",
"_synthetic_id_queries",
"[",
"cls",
"]",
":",
"self",
".",
"_query_cache",
"[",
"cls",
"]",
".",
"pop",
"(",
"_query",
")",
"self",
".",
"_synthetic_id... | Expire any instances that were "new" or had no _id value. | [
"Expire",
"any",
"instances",
"that",
"were",
"\"",
"new",
"\"",
"or",
"had",
"no",
"_id",
"value",
"."
] | [
"'''\n Expire any instances that were \"new\" or had no _id value.\n\n If a lot of new instances of a class are being created, it's possible\n for a query to pull a copy from mongo when a copy keyed by the synthetic\n ID is still in the cache, potentially causing de-sync between the copi... | [
{
"param": "self",
"type": null
},
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": []... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | batch_load | null | def batch_load(self, cls, query, attrs=None):
'''
Load multiple results given a query.
Optionally takes a list of attribute names to use
as the cache key. If not given, uses the keys of
the given query.
'''
if attrs is None:
attrs = query.keys()
... |
Load multiple results given a query.
Optionally takes a list of attribute names to use
as the cache key. If not given, uses the keys of
the given query.
| Load multiple results given a query.
Optionally takes a list of attribute names to use
as the cache key. If not given, uses the keys of
the given query. | [
"Load",
"multiple",
"results",
"given",
"a",
"query",
".",
"Optionally",
"takes",
"a",
"list",
"of",
"attribute",
"names",
"to",
"use",
"as",
"the",
"cache",
"key",
".",
"If",
"not",
"given",
"uses",
"the",
"keys",
"of",
"the",
"given",
"query",
"."
] | def batch_load(self, cls, query, attrs=None):
if attrs is None:
attrs = query.keys()
for result in self._model_query(cls).find(query):
keys = {a: getattr(result, a) for a in attrs}
self.set(cls, keys, result) | [
"def",
"batch_load",
"(",
"self",
",",
"cls",
",",
"query",
",",
"attrs",
"=",
"None",
")",
":",
"if",
"attrs",
"is",
"None",
":",
"attrs",
"=",
"query",
".",
"keys",
"(",
")",
"for",
"result",
"in",
"self",
".",
"_model_query",
"(",
"cls",
")",
... | Load multiple results given a query. | [
"Load",
"multiple",
"results",
"given",
"a",
"query",
"."
] | [
"'''\n Load multiple results given a query.\n\n Optionally takes a list of attribute names to use\n as the cache key. If not given, uses the keys of\n the given query.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "cls",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "attrs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": []... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | hex | <not_specific> | def hex(self):
'''Compute a recursive sha1 hash on the tree'''
# dependent on __repr__ below
if self._hex is None:
sha_obj = sha1('tree\n' + repr(self))
self._hex = sha_obj.hexdigest()
return self._hex | Compute a recursive sha1 hash on the tree | Compute a recursive sha1 hash on the tree | [
"Compute",
"a",
"recursive",
"sha1",
"hash",
"on",
"the",
"tree"
] | def hex(self):
if self._hex is None:
sha_obj = sha1('tree\n' + repr(self))
self._hex = sha_obj.hexdigest()
return self._hex | [
"def",
"hex",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hex",
"is",
"None",
":",
"sha_obj",
"=",
"sha1",
"(",
"'tree\\n'",
"+",
"repr",
"(",
"self",
")",
")",
"self",
".",
"_hex",
"=",
"sha_obj",
".",
"hexdigest",
"(",
")",
"return",
"self",
".... | Compute a recursive sha1 hash on the tree | [
"Compute",
"a",
"recursive",
"sha1",
"hash",
"on",
"the",
"tree"
] | [
"'''Compute a recursive sha1 hash on the tree'''",
"# dependent on __repr__ below"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | pretty_tree | <not_specific> | def pretty_tree(self, indent=0, recurse=True, show_id=True):
'''For debugging, show a nice tree representation'''
lines = [' ' * indent + 't %s %s' %
(name, '\n' + t.unicode_full_tree(indent + 2, show_id=show_id)
if recurse else t.hex())
for name, t in... | For debugging, show a nice tree representation | For debugging, show a nice tree representation | [
"For",
"debugging",
"show",
"a",
"nice",
"tree",
"representation"
] | def pretty_tree(self, indent=0, recurse=True, show_id=True):
lines = [' ' * indent + 't %s %s' %
(name, '\n' + t.unicode_full_tree(indent + 2, show_id=show_id)
if recurse else t.hex())
for name, t in sorted(self.trees.iteritems())]
lines += [' ' * inde... | [
"def",
"pretty_tree",
"(",
"self",
",",
"indent",
"=",
"0",
",",
"recurse",
"=",
"True",
",",
"show_id",
"=",
"True",
")",
":",
"lines",
"=",
"[",
"' '",
"*",
"indent",
"+",
"'t %s %s'",
"%",
"(",
"name",
",",
"'\\n'",
"+",
"t",
".",
"unicode_full_... | For debugging, show a nice tree representation | [
"For",
"debugging",
"show",
"a",
"nice",
"tree",
"representation"
] | [
"'''For debugging, show a nice tree representation'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "indent",
"type": null
},
{
"param": "recurse",
"type": null
},
{
"param": "show_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "indent",
"type": null,
"docstring": null,
"docstring_tokens":... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | topological_sort | null | def topological_sort(graph):
'''Return the topological sort of a graph.
The graph is a dict with each entry representing
a node (the key is the node ID) and its parent(s) (a
set of node IDs). Result is an iterator over the topo-sorted
node IDs.
The algorithm is based on one seen in
http://... | Return the topological sort of a graph.
The graph is a dict with each entry representing
a node (the key is the node ID) and its parent(s) (a
set of node IDs). Result is an iterator over the topo-sorted
node IDs.
The algorithm is based on one seen in
http://en.wikipedia.org/wiki/Topological_so... | Return the topological sort of a graph.
The graph is a dict with each entry representing
a node (the key is the node ID) and its parent(s) (a
set of node IDs). Result is an iterator over the topo-sorted
node IDs.
| [
"Return",
"the",
"topological",
"sort",
"of",
"a",
"graph",
".",
"The",
"graph",
"is",
"a",
"dict",
"with",
"each",
"entry",
"representing",
"a",
"node",
"(",
"the",
"key",
"is",
"the",
"node",
"ID",
")",
"and",
"its",
"parent",
"(",
"s",
")",
"(",
... | def topological_sort(graph):
children = defaultdict(list)
roots = []
for nid, parents in graph.items():
if not parents:
graph.pop(nid)
roots.append(nid)
for p_nid in parents:
children[p_nid].append(nid)
while roots:
n = roots.pop()
yiel... | [
"def",
"topological_sort",
"(",
"graph",
")",
":",
"children",
"=",
"defaultdict",
"(",
"list",
")",
"roots",
"=",
"[",
"]",
"for",
"nid",
",",
"parents",
"in",
"graph",
".",
"items",
"(",
")",
":",
"if",
"not",
"parents",
":",
"graph",
".",
"pop",
... | Return the topological sort of a graph. | [
"Return",
"the",
"topological",
"sort",
"of",
"a",
"graph",
"."
] | [
"'''Return the topological sort of a graph.\n\n The graph is a dict with each entry representing\n a node (the key is the node ID) and its parent(s) (a\n set of node IDs). Result is an iterator over the topo-sorted\n node IDs.\n\n The algorithm is based on one seen in\n http://en.wikipedia.org/wik... | [
{
"param": "graph",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | zipdir | null | def zipdir(source, zipfile, exclude=None):
"""Create zip archive using zip binary."""
zipbin = tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')
source = source.rstrip('/')
# this is needed to get proper prefixes inside zip-file
working_dir = os.path.dirname(source)
source_fn = os.pa... | Create zip archive using zip binary. | Create zip archive using zip binary. | [
"Create",
"zip",
"archive",
"using",
"zip",
"binary",
"."
] | def zipdir(source, zipfile, exclude=None):
zipbin = tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')
source = source.rstrip('/')
working_dir = os.path.dirname(source)
source_fn = os.path.basename(source)
command = [zipbin, '-y', '-q', '-r', zipfile, source_fn]
if exclude:
co... | [
"def",
"zipdir",
"(",
"source",
",",
"zipfile",
",",
"exclude",
"=",
"None",
")",
":",
"zipbin",
"=",
"tg",
".",
"config",
".",
"get",
"(",
"'scm.repos.tarball.zip_binary'",
",",
"'/usr/bin/zip'",
")",
"source",
"=",
"source",
".",
"rstrip",
"(",
"'/'",
... | Create zip archive using zip binary. | [
"Create",
"zip",
"archive",
"using",
"zip",
"binary",
"."
] | [
"\"\"\"Create zip archive using zip binary.\"\"\"",
"# this is needed to get proper prefixes inside zip-file"
] | [
{
"param": "source",
"type": null
},
{
"param": "zipfile",
"type": null
},
{
"param": "exclude",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "zipfile",
"type": null,
"docstring": null,
"docstring_token... |
eb273d25e4d791e6d0ec35ac1166d55aefb8ffcd | lym/allura-git | Allura/allura/lib/utils.py | [
"Apache-2.0"
] | Python | validate | <not_specific> | def validate(cls, error_msg):
'''Controller decorator to raise Invalid errors if bot protection is engaged'''
def antispam_hook(remainder, params):
'''Converts various errors in validate_request to a single Invalid message'''
try:
new_params = cls.validate_request... | Controller decorator to raise Invalid errors if bot protection is engaged | Controller decorator to raise Invalid errors if bot protection is engaged | [
"Controller",
"decorator",
"to",
"raise",
"Invalid",
"errors",
"if",
"bot",
"protection",
"is",
"engaged"
] | def validate(cls, error_msg):
def antispam_hook(remainder, params):
try:
new_params = cls.validate_request(params=params)
params.update(new_params)
except (ValueError, TypeError, binascii.Error):
raise Invalid(error_msg, params, None)
... | [
"def",
"validate",
"(",
"cls",
",",
"error_msg",
")",
":",
"def",
"antispam_hook",
"(",
"remainder",
",",
"params",
")",
":",
"'''Converts various errors in validate_request to a single Invalid message'''",
"try",
":",
"new_params",
"=",
"cls",
".",
"validate_request",
... | Controller decorator to raise Invalid errors if bot protection is engaged | [
"Controller",
"decorator",
"to",
"raise",
"Invalid",
"errors",
"if",
"bot",
"protection",
"is",
"engaged"
] | [
"'''Controller decorator to raise Invalid errors if bot protection is engaged'''",
"'''Converts various errors in validate_request to a single Invalid message'''"
] | [
{
"param": "cls",
"type": null
},
{
"param": "error_msg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "error_msg",
"type": null,
"docstring": null,
"docstring_tokens... |
eb273d25e4d791e6d0ec35ac1166d55aefb8ffcd | lym/allura-git | Allura/allura/lib/utils.py | [
"Apache-2.0"
] | Python | antispam_hook | null | def antispam_hook(remainder, params):
'''Converts various errors in validate_request to a single Invalid message'''
try:
new_params = cls.validate_request(params=params)
params.update(new_params)
except (ValueError, TypeError, binascii.Error):
... | Converts various errors in validate_request to a single Invalid message | Converts various errors in validate_request to a single Invalid message | [
"Converts",
"various",
"errors",
"in",
"validate_request",
"to",
"a",
"single",
"Invalid",
"message"
] | def antispam_hook(remainder, params):
try:
new_params = cls.validate_request(params=params)
params.update(new_params)
except (ValueError, TypeError, binascii.Error):
raise Invalid(error_msg, params, None) | [
"def",
"antispam_hook",
"(",
"remainder",
",",
"params",
")",
":",
"try",
":",
"new_params",
"=",
"cls",
".",
"validate_request",
"(",
"params",
"=",
"params",
")",
"params",
".",
"update",
"(",
"new_params",
")",
"except",
"(",
"ValueError",
",",
"TypeErr... | Converts various errors in validate_request to a single Invalid message | [
"Converts",
"various",
"errors",
"in",
"validate_request",
"to",
"a",
"single",
"Invalid",
"message"
] | [
"'''Converts various errors in validate_request to a single Invalid message'''"
] | [
{
"param": "remainder",
"type": null
},
{
"param": "params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "remainder",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "params",
"type": null,
"docstring": null,
"docstring_tok... |
eb273d25e4d791e6d0ec35ac1166d55aefb8ffcd | lym/allura-git | Allura/allura/lib/utils.py | [
"Apache-2.0"
] | Python | serve_file | <not_specific> | def serve_file(fp, filename, content_type, last_modified=None,
cache_expires=None, size=None, embed=True, etag=None):
'''Sets the response headers and serves as a wsgi iter'''
if not etag and filename and last_modified:
etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
if eta... | Sets the response headers and serves as a wsgi iter | Sets the response headers and serves as a wsgi iter | [
"Sets",
"the",
"response",
"headers",
"and",
"serves",
"as",
"a",
"wsgi",
"iter"
] | def serve_file(fp, filename, content_type, last_modified=None,
cache_expires=None, size=None, embed=True, etag=None):
if not etag and filename and last_modified:
etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
if etag:
etag_cache(etag)
pylons.response.headers['Conte... | [
"def",
"serve_file",
"(",
"fp",
",",
"filename",
",",
"content_type",
",",
"last_modified",
"=",
"None",
",",
"cache_expires",
"=",
"None",
",",
"size",
"=",
"None",
",",
"embed",
"=",
"True",
",",
"etag",
"=",
"None",
")",
":",
"if",
"not",
"etag",
... | Sets the response headers and serves as a wsgi iter | [
"Sets",
"the",
"response",
"headers",
"and",
"serves",
"as",
"a",
"wsgi",
"iter"
] | [
"'''Sets the response headers and serves as a wsgi iter'''",
"# http://code.google.com/p/modwsgi/wiki/FileWrapperExtension"
] | [
{
"param": "fp",
"type": null
},
{
"param": "filename",
"type": null
},
{
"param": "content_type",
"type": null
},
{
"param": "last_modified",
"type": null
},
{
"param": "cache_expires",
"type": null
},
{
"param": "size",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fp",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens":... |
5d35788db3b4f66a9dbb0baa9b47a5aebf2bfad0 | lym/allura-git | Allura/allura/lib/widgets/forms.py | [
"Apache-2.0"
] | Python | to_python | <not_specific> | def to_python(self, value, state=None, check_allowed=True, neighborhood=None):
"""
Validate a project shortname.
If check_allowed is False, the shortname will only be checked for
correctness. Otherwise, it will be rejected if already in use or
otherwise disallowed.
"""
... |
Validate a project shortname.
If check_allowed is False, the shortname will only be checked for
correctness. Otherwise, it will be rejected if already in use or
otherwise disallowed.
| Validate a project shortname.
If check_allowed is False, the shortname will only be checked for
correctness. Otherwise, it will be rejected if already in use or
otherwise disallowed. | [
"Validate",
"a",
"project",
"shortname",
".",
"If",
"check_allowed",
"is",
"False",
"the",
"shortname",
"will",
"only",
"be",
"checked",
"for",
"correctness",
".",
"Otherwise",
"it",
"will",
"be",
"rejected",
"if",
"already",
"in",
"use",
"or",
"otherwise",
... | def to_python(self, value, state=None, check_allowed=True, neighborhood=None):
if neighborhood is None:
neighborhood = M.Neighborhood.query.get(
name=state.full_dict['neighborhood'])
value = h.really_unicode(value or '').encode('utf-8').lower()
self._validate_shortnam... | [
"def",
"to_python",
"(",
"self",
",",
"value",
",",
"state",
"=",
"None",
",",
"check_allowed",
"=",
"True",
",",
"neighborhood",
"=",
"None",
")",
":",
"if",
"neighborhood",
"is",
"None",
":",
"neighborhood",
"=",
"M",
".",
"Neighborhood",
".",
"query",... | Validate a project shortname. | [
"Validate",
"a",
"project",
"shortname",
"."
] | [
"\"\"\"\n Validate a project shortname.\n\n If check_allowed is False, the shortname will only be checked for\n correctness. Otherwise, it will be rejected if already in use or\n otherwise disallowed.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "state",
"type": null
},
{
"param": "check_allowed",
"type": null
},
{
"param": "neighborhood",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
eb9ff4dc04c69a2fa496cf4f01957a0dbd7cace2 | lym/allura-git | Allura/allura/tasks/export_tasks.py | [
"Apache-2.0"
] | Python | bulk_export | <not_specific> | def bulk_export(tools, filename=None, send_email=True):
'''
Export the current project data. Send notification to current user.
:param list tools: list of mount_points to export
:param str filename: optional filename to use
'''
# it's very handy to use c.* within a @task,
# but let's be ex... |
Export the current project data. Send notification to current user.
:param list tools: list of mount_points to export
:param str filename: optional filename to use
| Export the current project data. Send notification to current user. | [
"Export",
"the",
"current",
"project",
"data",
".",
"Send",
"notification",
"to",
"current",
"user",
"."
] | def bulk_export(tools, filename=None, send_email=True):
return BulkExport().process(c.project, tools, c.user, filename, send_email) | [
"def",
"bulk_export",
"(",
"tools",
",",
"filename",
"=",
"None",
",",
"send_email",
"=",
"True",
")",
":",
"return",
"BulkExport",
"(",
")",
".",
"process",
"(",
"c",
".",
"project",
",",
"tools",
",",
"c",
".",
"user",
",",
"filename",
",",
"send_e... | Export the current project data. | [
"Export",
"the",
"current",
"project",
"data",
"."
] | [
"'''\n Export the current project data. Send notification to current user.\n\n :param list tools: list of mount_points to export\n :param str filename: optional filename to use\n '''",
"# it's very handy to use c.* within a @task,",
"# but let's be explicit and keep it separate from the main code"
... | [
{
"param": "tools",
"type": null
},
{
"param": "filename",
"type": null
},
{
"param": "send_email",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tools",
"type": null,
"docstring": "list of mount_points to export",
"docstring_tokens": [
"list",
"of",
"mount_points",
"to",
"export"
],
"default": null,
"is_optional... |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | user_project_of | <not_specific> | def user_project_of(self):
'''
If this is a user-project, return the User, else None
'''
user = None
if self.is_user_project:
user = plugin.AuthenticationProvider.get(
request).user_by_project_shortname(self.shortname[2:])
return user |
If this is a user-project, return the User, else None
| If this is a user-project, return the User, else None | [
"If",
"this",
"is",
"a",
"user",
"-",
"project",
"return",
"the",
"User",
"else",
"None"
] | def user_project_of(self):
user = None
if self.is_user_project:
user = plugin.AuthenticationProvider.get(
request).user_by_project_shortname(self.shortname[2:])
return user | [
"def",
"user_project_of",
"(",
"self",
")",
":",
"user",
"=",
"None",
"if",
"self",
".",
"is_user_project",
":",
"user",
"=",
"plugin",
".",
"AuthenticationProvider",
".",
"get",
"(",
"request",
")",
".",
"user_by_project_shortname",
"(",
"self",
".",
"short... | If this is a user-project, return the User, else None | [
"If",
"this",
"is",
"a",
"user",
"-",
"project",
"return",
"the",
"User",
"else",
"None"
] | [
"'''\n If this is a user-project, return the User, else None\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | menus | <not_specific> | def menus(cls, projects):
'''Return a dict[project_id] = sitemap of sitemaps, efficiently'''
from allura.app import SitemapEntry
pids = [p._id for p in projects]
project_index = dict((p._id, p) for p in projects)
entry_index = dict((pid, []) for pid in pids)
q_subprojects... | Return a dict[project_id] = sitemap of sitemaps, efficiently | Return a dict[project_id] = sitemap of sitemaps, efficiently | [
"Return",
"a",
"dict",
"[",
"project_id",
"]",
"=",
"sitemap",
"of",
"sitemaps",
"efficiently"
] | def menus(cls, projects):
from allura.app import SitemapEntry
pids = [p._id for p in projects]
project_index = dict((p._id, p) for p in projects)
entry_index = dict((pid, []) for pid in pids)
q_subprojects = cls.query.find(dict(
parent_id={'$in': pids},
de... | [
"def",
"menus",
"(",
"cls",
",",
"projects",
")",
":",
"from",
"allura",
".",
"app",
"import",
"SitemapEntry",
"pids",
"=",
"[",
"p",
".",
"_id",
"for",
"p",
"in",
"projects",
"]",
"project_index",
"=",
"dict",
"(",
"(",
"p",
".",
"_id",
",",
"p",
... | Return a dict[project_id] = sitemap of sitemaps, efficiently | [
"Return",
"a",
"dict",
"[",
"project_id",
"]",
"=",
"sitemap",
"of",
"sitemaps",
"efficiently"
] | [
"'''Return a dict[project_id] = sitemap of sitemaps, efficiently'''"
] | [
{
"param": "cls",
"type": null
},
{
"param": "projects",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "projects",
"type": null,
"docstring": null,
"docstring_tokens"... |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | accolades_index | <not_specific> | def accolades_index(cls, projects):
'''Return a dict[project_id] = list of accolades, efficiently'''
from .artifact import AwardGrant
result = dict((p._id, []) for p in projects)
for award in AwardGrant.query.find(dict(
granted_to_project_id={'$in': result.keys()})):
... | Return a dict[project_id] = list of accolades, efficiently | Return a dict[project_id] = list of accolades, efficiently | [
"Return",
"a",
"dict",
"[",
"project_id",
"]",
"=",
"list",
"of",
"accolades",
"efficiently"
] | def accolades_index(cls, projects):
from .artifact import AwardGrant
result = dict((p._id, []) for p in projects)
for award in AwardGrant.query.find(dict(
granted_to_project_id={'$in': result.keys()})):
result[award.granted_to_project_id].append(award)
return ... | [
"def",
"accolades_index",
"(",
"cls",
",",
"projects",
")",
":",
"from",
".",
"artifact",
"import",
"AwardGrant",
"result",
"=",
"dict",
"(",
"(",
"p",
".",
"_id",
",",
"[",
"]",
")",
"for",
"p",
"in",
"projects",
")",
"for",
"award",
"in",
"AwardGra... | Return a dict[project_id] = list of accolades, efficiently | [
"Return",
"a",
"dict",
"[",
"project_id",
"]",
"=",
"list",
"of",
"accolades",
"efficiently"
] | [
"'''Return a dict[project_id] = list of accolades, efficiently'''"
] | [
{
"param": "cls",
"type": null
},
{
"param": "projects",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "projects",
"type": null,
"docstring": null,
"docstring_tokens"... |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | grouped_navbar_entries | <not_specific> | def grouped_navbar_entries(self):
"""Return a :class:`~allura.app.SitemapEntry` list suitable for rendering
the project navbar with tools grouped together by tool type.
"""
# get orginal (non-grouped) navbar entries
sitemap = self.sitemap()
# ordered dict to preserve the ... | Return a :class:`~allura.app.SitemapEntry` list suitable for rendering
the project navbar with tools grouped together by tool type.
| Return a :class:`~allura.app.SitemapEntry` list suitable for rendering
the project navbar with tools grouped together by tool type. | [
"Return",
"a",
":",
"class",
":",
"`",
"~allura",
".",
"app",
".",
"SitemapEntry",
"`",
"list",
"suitable",
"for",
"rendering",
"the",
"project",
"navbar",
"with",
"tools",
"grouped",
"together",
"by",
"tool",
"type",
"."
] | def grouped_navbar_entries(self):
sitemap = self.sitemap()
grouped_nav = OrderedDict()
counts = Counter([e.tool_name.lower() for e in sitemap if e.tool_name])
grouping_threshold = self.get_tool_data(
'allura', 'grouping_threshold', 1)
for e in sitemap:
if ... | [
"def",
"grouped_navbar_entries",
"(",
"self",
")",
":",
"sitemap",
"=",
"self",
".",
"sitemap",
"(",
")",
"grouped_nav",
"=",
"OrderedDict",
"(",
")",
"counts",
"=",
"Counter",
"(",
"[",
"e",
".",
"tool_name",
".",
"lower",
"(",
")",
"for",
"e",
"in",
... | Return a :class:`~allura.app.SitemapEntry` list suitable for rendering
the project navbar with tools grouped together by tool type. | [
"Return",
"a",
":",
"class",
":",
"`",
"~allura",
".",
"app",
".",
"SitemapEntry",
"`",
"list",
"suitable",
"for",
"rendering",
"the",
"project",
"navbar",
"with",
"tools",
"grouped",
"together",
"by",
"tool",
"type",
"."
] | [
"\"\"\"Return a :class:`~allura.app.SitemapEntry` list suitable for rendering\n the project navbar with tools grouped together by tool type.\n \"\"\"",
"# get orginal (non-grouped) navbar entries",
"# ordered dict to preserve the orginal ordering of tools",
"# count how many tools of each type w... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | install_apps | null | def install_apps(self, apps_params):
""" Install many apps at once.
Better than doing individually if you expect
default name conflicts (e.g. "code" for both git & svn), by using the
tool_label value.
:param list apps_params: list of dicts, where each dict is the args used in i... | Install many apps at once.
Better than doing individually if you expect
default name conflicts (e.g. "code" for both git & svn), by using the
tool_label value.
:param list apps_params: list of dicts, where each dict is the args used in install_app()
| Install many apps at once.
Better than doing individually if you expect
default name conflicts , by using the
tool_label value. | [
"Install",
"many",
"apps",
"at",
"once",
".",
"Better",
"than",
"doing",
"individually",
"if",
"you",
"expect",
"default",
"name",
"conflicts",
"by",
"using",
"the",
"tool_label",
"value",
"."
] | def install_apps(self, apps_params):
mount_points = dict()
for app_params in apps_params:
App = g.entry_points['tool'][app_params['ep_name']]
mount_point = self._mount_point_for_install(App, app_params.get('mount_point'))
mount_points[App] = mount_point
mount_... | [
"def",
"install_apps",
"(",
"self",
",",
"apps_params",
")",
":",
"mount_points",
"=",
"dict",
"(",
")",
"for",
"app_params",
"in",
"apps_params",
":",
"App",
"=",
"g",
".",
"entry_points",
"[",
"'tool'",
"]",
"[",
"app_params",
"[",
"'ep_name'",
"]",
"]... | Install many apps at once. | [
"Install",
"many",
"apps",
"at",
"once",
"."
] | [
"\"\"\" Install many apps at once.\n\n Better than doing individually if you expect\n default name conflicts (e.g. \"code\" for both git & svn), by using the\n tool_label value.\n\n :param list apps_params: list of dicts, where each dict is the args used in install_app()\n \"\"\""... | [
{
"param": "self",
"type": null
},
{
"param": "apps_params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "apps_params",
"type": null,
"docstring": "list of dicts, where each... |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | ordered_mounts | <not_specific> | def ordered_mounts(self, include_hidden=False):
'''Returns an array of a projects mounts (tools and sub-projects) in
toolbar order.'''
result = []
anchored_tools = self.neighborhood.get_anchored_tools()
i = len(anchored_tools)
self.install_anchored_tools()
for su... | Returns an array of a projects mounts (tools and sub-projects) in
toolbar order. | Returns an array of a projects mounts (tools and sub-projects) in
toolbar order. | [
"Returns",
"an",
"array",
"of",
"a",
"projects",
"mounts",
"(",
"tools",
"and",
"sub",
"-",
"projects",
")",
"in",
"toolbar",
"order",
"."
] | def ordered_mounts(self, include_hidden=False):
result = []
anchored_tools = self.neighborhood.get_anchored_tools()
i = len(anchored_tools)
self.install_anchored_tools()
for sub in self.direct_subprojects:
result.append(
{'ordinal': int(sub.ordinal + i... | [
"def",
"ordered_mounts",
"(",
"self",
",",
"include_hidden",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"anchored_tools",
"=",
"self",
".",
"neighborhood",
".",
"get_anchored_tools",
"(",
")",
"i",
"=",
"len",
"(",
"anchored_tools",
")",
"self",
".",... | Returns an array of a projects mounts (tools and sub-projects) in
toolbar order. | [
"Returns",
"an",
"array",
"of",
"a",
"projects",
"mounts",
"(",
"tools",
"and",
"sub",
"-",
"projects",
")",
"in",
"toolbar",
"order",
"."
] | [
"'''Returns an array of a projects mounts (tools and sub-projects) in\n toolbar order.'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "include_hidden",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_hidden",
"type": null,
"docstring": null,
"docstring_... |
7d917f16643c1f551bfd067e4d795d6ee7a589b0 | lym/allura-git | Allura/allura/model/project.py | [
"Apache-2.0"
] | Python | bulk_export_filename | <not_specific> | def bulk_export_filename(self):
'''
Return a filename (configurable) for this project export. The current timestamp
may be included, so only run this method once per export.
'''
shortname = self.shortname
if self.is_nbhd_project:
shortname = self.url().strip(... |
Return a filename (configurable) for this project export. The current timestamp
may be included, so only run this method once per export.
| Return a filename (configurable) for this project export. The current timestamp
may be included, so only run this method once per export. | [
"Return",
"a",
"filename",
"(",
"configurable",
")",
"for",
"this",
"project",
"export",
".",
"The",
"current",
"timestamp",
"may",
"be",
"included",
"so",
"only",
"run",
"this",
"method",
"once",
"per",
"export",
"."
] | def bulk_export_filename(self):
shortname = self.shortname
if self.is_nbhd_project:
shortname = self.url().strip('/')
elif self.is_user_project:
shortname = self.shortname.split('/')[1]
elif not self.is_root:
shortname = self.shortname.split('/')[1]
... | [
"def",
"bulk_export_filename",
"(",
"self",
")",
":",
"shortname",
"=",
"self",
".",
"shortname",
"if",
"self",
".",
"is_nbhd_project",
":",
"shortname",
"=",
"self",
".",
"url",
"(",
")",
".",
"strip",
"(",
"'/'",
")",
"elif",
"self",
".",
"is_user_proj... | Return a filename (configurable) for this project export. | [
"Return",
"a",
"filename",
"(",
"configurable",
")",
"for",
"this",
"project",
"export",
"."
] | [
"'''\n Return a filename (configurable) for this project export. The current timestamp\n may be included, so only run this method once per export.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46369d179665542d7fa95bad6fc2fc65df8122d2 | lym/allura-git | Allura/allura/tests/decorators.py | [
"Apache-2.0"
] | Python | audits | null | def audits(*messages, **kwargs):
"""
Asserts all the messages exist in audit log
:param messages: regex strings
:param bool user: if this is a user log
"""
M.AuditLog.query.remove()
yield
if kwargs.get('user'):
actor = kwargs.get('actor', '.*')
ip_addr = kwargs.get('ip_... |
Asserts all the messages exist in audit log
:param messages: regex strings
:param bool user: if this is a user log
| Asserts all the messages exist in audit log | [
"Asserts",
"all",
"the",
"messages",
"exist",
"in",
"audit",
"log"
] | def audits(*messages, **kwargs):
M.AuditLog.query.remove()
yield
if kwargs.get('user'):
actor = kwargs.get('actor', '.*')
ip_addr = kwargs.get('ip_addr', '.*')
preamble = '(Done by user: {}\n)?IP Address: {}\n'.format(actor, ip_addr)
else:
preamble = ''
for message in... | [
"def",
"audits",
"(",
"*",
"messages",
",",
"**",
"kwargs",
")",
":",
"M",
".",
"AuditLog",
".",
"query",
".",
"remove",
"(",
")",
"yield",
"if",
"kwargs",
".",
"get",
"(",
"'user'",
")",
":",
"actor",
"=",
"kwargs",
".",
"get",
"(",
"'actor'",
"... | Asserts all the messages exist in audit log | [
"Asserts",
"all",
"the",
"messages",
"exist",
"in",
"audit",
"log"
] | [
"\"\"\"\n Asserts all the messages exist in audit log\n\n :param messages: regex strings\n :param bool user: if this is a user log\n\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [
{
"identifier": "messages",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
... |
46369d179665542d7fa95bad6fc2fc65df8122d2 | lym/allura-git | Allura/allura/tests/decorators.py | [
"Apache-2.0"
] | Python | out_audits | null | def out_audits(*messages, **kwargs):
"""
Asserts none the messages exist in audit log. "without audits"
:param messages: list of regex strings
:param bool user: if this is a user log
"""
M.AuditLog.query.remove()
yield
if kwargs.get('user'):
actor = kwargs.get('actor', '.*')
... |
Asserts none the messages exist in audit log. "without audits"
:param messages: list of regex strings
:param bool user: if this is a user log
| Asserts none the messages exist in audit log. "without audits" | [
"Asserts",
"none",
"the",
"messages",
"exist",
"in",
"audit",
"log",
".",
"\"",
"without",
"audits",
"\""
] | def out_audits(*messages, **kwargs):
M.AuditLog.query.remove()
yield
if kwargs.get('user'):
actor = kwargs.get('actor', '.*')
ip_addr = kwargs.get('ip_addr', '.*')
preamble = '(Done by user: {}\n)?IP Address: {}\n'.format(actor, ip_addr)
else:
preamble = ''
for messag... | [
"def",
"out_audits",
"(",
"*",
"messages",
",",
"**",
"kwargs",
")",
":",
"M",
".",
"AuditLog",
".",
"query",
".",
"remove",
"(",
")",
"yield",
"if",
"kwargs",
".",
"get",
"(",
"'user'",
")",
":",
"actor",
"=",
"kwargs",
".",
"get",
"(",
"'actor'",... | Asserts none the messages exist in audit log. | [
"Asserts",
"none",
"the",
"messages",
"exist",
"in",
"audit",
"log",
"."
] | [
"\"\"\"\n Asserts none the messages exist in audit log. \"without audits\"\n\n :param messages: list of regex strings\n :param bool user: if this is a user log\n\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [
{
"identifier": "messages",
"type": null,
"docstring": "list of regex strings",
"docstring_tokens": [
"list",
"of",
"regex",
"strings"
],
"default": null,
"is_optional":... |
30d28d944bcc4f7af084b5f8b77e60c50d30a18b | lym/allura-git | Allura/allura/controllers/rest.py | [
"Apache-2.0"
] | Python | index | <not_specific> | def index(self, **kw):
"""Return site summary information as JSON.
Currently, the only summary information returned are any site_stats
whose providers are defined as entry points under the
'allura.site_stats' group in a package or tool's setup.py, e.g.::
[allura.site_stats]... | Return site summary information as JSON.
Currently, the only summary information returned are any site_stats
whose providers are defined as entry points under the
'allura.site_stats' group in a package or tool's setup.py, e.g.::
[allura.site_stats]
new_users_24hr = allu... | Return site summary information as JSON.
Currently, the only summary information returned are any site_stats
whose providers are defined as entry points under the
'allura.site_stats' group in a package or tool's setup.py, e.g.:.
The stat provider will be called with no arguments to generate the
stat, which will be i... | [
"Return",
"site",
"summary",
"information",
"as",
"JSON",
".",
"Currently",
"the",
"only",
"summary",
"information",
"returned",
"are",
"any",
"site_stats",
"whose",
"providers",
"are",
"defined",
"as",
"entry",
"points",
"under",
"the",
"'",
"allura",
".",
"s... | def index(self, **kw):
summary = dict()
stats = dict()
for stat, provider in g.entry_points['site_stats'].iteritems():
stats[stat] = provider()
if stats:
summary['site_stats'] = stats
return summary | [
"def",
"index",
"(",
"self",
",",
"**",
"kw",
")",
":",
"summary",
"=",
"dict",
"(",
")",
"stats",
"=",
"dict",
"(",
")",
"for",
"stat",
",",
"provider",
"in",
"g",
".",
"entry_points",
"[",
"'site_stats'",
"]",
".",
"iteritems",
"(",
")",
":",
"... | Return site summary information as JSON. | [
"Return",
"site",
"summary",
"information",
"as",
"JSON",
"."
] | [
"\"\"\"Return site summary information as JSON.\n\n Currently, the only summary information returned are any site_stats\n whose providers are defined as entry points under the\n 'allura.site_stats' group in a package or tool's setup.py, e.g.::\n\n [allura.site_stats]\n new... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
302544e4d77bcde7c4ec511deb322c1fbdc22bd4 | lym/allura-git | ForgeImporters/forgeimporters/google/__init__.py | [
"Apache-2.0"
] | Python | _as_text | <not_specific> | def _as_text(node, chunks=None):
"""
Similar to node.text, but preserves whitespace around tags,
and converts <br/>s to \n.
"""
if chunks is None:
chunks = []
for n in node:
if isinstance(n, basestring):
chunks.append(n)
elif n.name == 'br':
chunks... |
Similar to node.text, but preserves whitespace around tags,
and converts <br/>s to \n.
| Similar to node.text, but preserves whitespace around tags,
and converts s to \n. | [
"Similar",
"to",
"node",
".",
"text",
"but",
"preserves",
"whitespace",
"around",
"tags",
"and",
"converts",
"s",
"to",
"\\",
"n",
"."
] | def _as_text(node, chunks=None):
if chunks is None:
chunks = []
for n in node:
if isinstance(n, basestring):
chunks.append(n)
elif n.name == 'br':
chunks.append('\n')
else:
_as_text(n, chunks)
return ''.join(chunks) | [
"def",
"_as_text",
"(",
"node",
",",
"chunks",
"=",
"None",
")",
":",
"if",
"chunks",
"is",
"None",
":",
"chunks",
"=",
"[",
"]",
"for",
"n",
"in",
"node",
":",
"if",
"isinstance",
"(",
"n",
",",
"basestring",
")",
":",
"chunks",
".",
"append",
"... | Similar to node.text, but preserves whitespace around tags,
and converts <br/>s to \n. | [
"Similar",
"to",
"node",
".",
"text",
"but",
"preserves",
"whitespace",
"around",
"tags",
"and",
"converts",
"<br",
"/",
">",
"s",
"to",
"\\",
"n",
"."
] | [
"\"\"\"\n Similar to node.text, but preserves whitespace around tags,\n and converts <br/>s to \\n.\n \"\"\""
] | [
{
"param": "node",
"type": null
},
{
"param": "chunks",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chunks",
"type": null,
"docstring": null,
"docstring_tokens":... |
302544e4d77bcde7c4ec511deb322c1fbdc22bd4 | lym/allura-git | ForgeImporters/forgeimporters/google/__init__.py | [
"Apache-2.0"
] | Python | split_project_name | <not_specific> | def split_project_name(project_name):
'''
For hosted projects, the project_name includes the hosted domain. Split, like:
:param str project_name: "a/eclipselabs.org/p/restclient-tool"
:return: ``("/a/eclipselabs.org", "restclient-tool")``
'''
if project_name.startswith('a/'):
hosted_do... |
For hosted projects, the project_name includes the hosted domain. Split, like:
:param str project_name: "a/eclipselabs.org/p/restclient-tool"
:return: ``("/a/eclipselabs.org", "restclient-tool")``
| For hosted projects, the project_name includes the hosted domain. Split, like. | [
"For",
"hosted",
"projects",
"the",
"project_name",
"includes",
"the",
"hosted",
"domain",
".",
"Split",
"like",
"."
] | def split_project_name(project_name):
if project_name.startswith('a/'):
hosted_domain_prefix = '/a/' + project_name.split('/')[1]
project_name = project_name.split('/')[3]
else:
hosted_domain_prefix = ''
project_name = project_name
return hosted_domain_prefix, project_name | [
"def",
"split_project_name",
"(",
"project_name",
")",
":",
"if",
"project_name",
".",
"startswith",
"(",
"'a/'",
")",
":",
"hosted_domain_prefix",
"=",
"'/a/'",
"+",
"project_name",
".",
"split",
"(",
"'/'",
")",
"[",
"1",
"]",
"project_name",
"=",
"project... | For hosted projects, the project_name includes the hosted domain. | [
"For",
"hosted",
"projects",
"the",
"project_name",
"includes",
"the",
"hosted",
"domain",
"."
] | [
"'''\n For hosted projects, the project_name includes the hosted domain. Split, like:\n\n :param str project_name: \"a/eclipselabs.org/p/restclient-tool\"\n :return: ``(\"/a/eclipselabs.org\", \"restclient-tool\")``\n '''"
] | [
{
"param": "project_name",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "project_name",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null... |
302544e4d77bcde7c4ec511deb322c1fbdc22bd4 | lym/allura-git | ForgeImporters/forgeimporters/google/__init__.py | [
"Apache-2.0"
] | Python | iter_issues | null | def iter_issues(cls, project_name):
"""
Iterate over all issues for a project,
using paging to keep the responses reasonable.
"""
extractor = cls(project_name)
issue_ids = extractor.get_issue_ids(start=0)
while issue_ids:
for issue_id in sorted(issue_i... |
Iterate over all issues for a project,
using paging to keep the responses reasonable.
| Iterate over all issues for a project,
using paging to keep the responses reasonable. | [
"Iterate",
"over",
"all",
"issues",
"for",
"a",
"project",
"using",
"paging",
"to",
"keep",
"the",
"responses",
"reasonable",
"."
] | def iter_issues(cls, project_name):
extractor = cls(project_name)
issue_ids = extractor.get_issue_ids(start=0)
while issue_ids:
for issue_id in sorted(issue_ids):
try:
yield (int(issue_id), cls(project_name, 'issue', issue_id=issue_id))
... | [
"def",
"iter_issues",
"(",
"cls",
",",
"project_name",
")",
":",
"extractor",
"=",
"cls",
"(",
"project_name",
")",
"issue_ids",
"=",
"extractor",
".",
"get_issue_ids",
"(",
"start",
"=",
"0",
")",
"while",
"issue_ids",
":",
"for",
"issue_id",
"in",
"sorte... | Iterate over all issues for a project,
using paging to keep the responses reasonable. | [
"Iterate",
"over",
"all",
"issues",
"for",
"a",
"project",
"using",
"paging",
"to",
"keep",
"the",
"responses",
"reasonable",
"."
] | [
"\"\"\"\n Iterate over all issues for a project,\n using paging to keep the responses reasonable.\n \"\"\"",
"# get any new issues that were created while importing",
"# (jumping back a few in case some were deleted and new ones added)"
] | [
{
"param": "cls",
"type": null
},
{
"param": "project_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project_name",
"type": null,
"docstring": null,
"docstring_tok... |
622e0368cf6e103a6499dd00bb79e7bc1083cc27 | lym/allura-git | ForgeBlog/forgeblog/main.py | [
"Apache-2.0"
] | Python | install | null | def install(self, project):
'Set up any default permissions and roles here'
super(ForgeBlogApp, self).install(project)
# Setup permissions
role_admin = M.ProjectRole.by_name('Admin')._id
role_developer = M.ProjectRole.by_name('Developer')._id
role_auth = M.ProjectRole.by... | Set up any default permissions and roles here | Set up any default permissions and roles here | [
"Set",
"up",
"any",
"default",
"permissions",
"and",
"roles",
"here"
] | def install(self, project):
super(ForgeBlogApp, self).install(project)
role_admin = M.ProjectRole.by_name('Admin')._id
role_developer = M.ProjectRole.by_name('Developer')._id
role_auth = M.ProjectRole.by_name('*authenticated')._id
role_anon = M.ProjectRole.by_name('*anonymous')._... | [
"def",
"install",
"(",
"self",
",",
"project",
")",
":",
"super",
"(",
"ForgeBlogApp",
",",
"self",
")",
".",
"install",
"(",
"project",
")",
"role_admin",
"=",
"M",
".",
"ProjectRole",
".",
"by_name",
"(",
"'Admin'",
")",
".",
"_id",
"role_developer",
... | Set up any default permissions and roles here | [
"Set",
"up",
"any",
"default",
"permissions",
"and",
"roles",
"here"
] | [
"'Set up any default permissions and roles here'",
"# Setup permissions"
] | [
{
"param": "self",
"type": null
},
{
"param": "project",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project",
"type": null,
"docstring": null,
"docstring_tokens"... |
622e0368cf6e103a6499dd00bb79e7bc1083cc27 | lym/allura-git | ForgeBlog/forgeblog/main.py | [
"Apache-2.0"
] | Python | uninstall | null | def uninstall(self, project):
"Remove all the tool's artifacts from the database"
BM.Attachment.query.remove(dict(app_config_id=c.app.config._id))
BM.BlogPost.query.remove(dict(app_config_id=c.app.config._id))
BM.BlogPostSnapshot.query.remove(dict(app_config_id=c.app.config._id))
... | Remove all the tool's artifacts from the database | Remove all the tool's artifacts from the database | [
"Remove",
"all",
"the",
"tool",
"'",
"s",
"artifacts",
"from",
"the",
"database"
] | def uninstall(self, project):
BM.Attachment.query.remove(dict(app_config_id=c.app.config._id))
BM.BlogPost.query.remove(dict(app_config_id=c.app.config._id))
BM.BlogPostSnapshot.query.remove(dict(app_config_id=c.app.config._id))
super(ForgeBlogApp, self).uninstall(project) | [
"def",
"uninstall",
"(",
"self",
",",
"project",
")",
":",
"BM",
".",
"Attachment",
".",
"query",
".",
"remove",
"(",
"dict",
"(",
"app_config_id",
"=",
"c",
".",
"app",
".",
"config",
".",
"_id",
")",
")",
"BM",
".",
"BlogPost",
".",
"query",
".",... | Remove all the tool's artifacts from the database | [
"Remove",
"all",
"the",
"tool",
"'",
"s",
"artifacts",
"from",
"the",
"database"
] | [
"\"Remove all the tool's artifacts from the database\""
] | [
{
"param": "self",
"type": null
},
{
"param": "project",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project",
"type": null,
"docstring": null,
"docstring_tokens"... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | ldap_conn | <not_specific> | def ldap_conn(who=None, cred=None):
'''
Init & bind a connection with the given creds, or the admin creds if not
specified. Remember to unbind the connection when done.
'''
con = ldap.initialize(config['auth.ldap.server'])
con.bind_s(who or config['auth.ldap.admin_dn'],
cred or co... |
Init & bind a connection with the given creds, or the admin creds if not
specified. Remember to unbind the connection when done.
| Init & bind a connection with the given creds, or the admin creds if not
specified. Remember to unbind the connection when done. | [
"Init",
"&",
"bind",
"a",
"connection",
"with",
"the",
"given",
"creds",
"or",
"the",
"admin",
"creds",
"if",
"not",
"specified",
".",
"Remember",
"to",
"unbind",
"the",
"connection",
"when",
"done",
"."
] | def ldap_conn(who=None, cred=None):
con = ldap.initialize(config['auth.ldap.server'])
con.bind_s(who or config['auth.ldap.admin_dn'],
cred or config['auth.ldap.admin_password'])
return con | [
"def",
"ldap_conn",
"(",
"who",
"=",
"None",
",",
"cred",
"=",
"None",
")",
":",
"con",
"=",
"ldap",
".",
"initialize",
"(",
"config",
"[",
"'auth.ldap.server'",
"]",
")",
"con",
".",
"bind_s",
"(",
"who",
"or",
"config",
"[",
"'auth.ldap.admin_dn'",
"... | Init & bind a connection with the given creds, or the admin creds if not
specified. | [
"Init",
"&",
"bind",
"a",
"connection",
"with",
"the",
"given",
"creds",
"or",
"the",
"admin",
"creds",
"if",
"not",
"specified",
"."
] | [
"'''\n Init & bind a connection with the given creds, or the admin creds if not\n specified. Remember to unbind the connection when done.\n '''"
] | [
{
"param": "who",
"type": null
},
{
"param": "cred",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "who",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cred",
"type": null,
"docstring": null,
"docstring_tokens": []... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | register_project | <not_specific> | def register_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps=None):
'''Register a new project in the neighborhood. The given user will
become the project's superuser.
'''
self.validate_project(neighborhood, shortname,
... | Register a new project in the neighborhood. The given user will
become the project's superuser.
| Register a new project in the neighborhood. The given user will
become the project's superuser. | [
"Register",
"a",
"new",
"project",
"in",
"the",
"neighborhood",
".",
"The",
"given",
"user",
"will",
"become",
"the",
"project",
"'",
"s",
"superuser",
"."
] | def register_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps=None):
self.validate_project(neighborhood, shortname,
project_name, user, user_project, private_project)
return self._create_project(neighborhood, shortname, project_... | [
"def",
"register_project",
"(",
"self",
",",
"neighborhood",
",",
"shortname",
",",
"project_name",
",",
"user",
",",
"user_project",
",",
"private_project",
",",
"apps",
"=",
"None",
")",
":",
"self",
".",
"validate_project",
"(",
"neighborhood",
",",
"shortn... | Register a new project in the neighborhood. | [
"Register",
"a",
"new",
"project",
"in",
"the",
"neighborhood",
"."
] | [
"'''Register a new project in the neighborhood. The given user will\n become the project's superuser.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "neighborhood",
"type": null
},
{
"param": "shortname",
"type": null
},
{
"param": "project_name",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "user_project",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "neighborhood",
"type": null,
"docstring": null,
"docstring_to... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | validate_project | null | def validate_project(self, neighborhood, shortname, project_name, user, user_project, private_project):
'''
Validate that a project can be registered, before it is
'''
from allura import model as M
# Check for private project rights
if neighborhood.features['private_proj... |
Validate that a project can be registered, before it is
| Validate that a project can be registered, before it is | [
"Validate",
"that",
"a",
"project",
"can",
"be",
"registered",
"before",
"it",
"is"
] | def validate_project(self, neighborhood, shortname, project_name, user, user_project, private_project):
from allura import model as M
if neighborhood.features['private_projects'] is False and private_project:
raise ValueError(
"You can't create private projects for %s neighbo... | [
"def",
"validate_project",
"(",
"self",
",",
"neighborhood",
",",
"shortname",
",",
"project_name",
",",
"user",
",",
"user_project",
",",
"private_project",
")",
":",
"from",
"allura",
"import",
"model",
"as",
"M",
"if",
"neighborhood",
".",
"features",
"[",
... | Validate that a project can be registered, before it is | [
"Validate",
"that",
"a",
"project",
"can",
"be",
"registered",
"before",
"it",
"is"
] | [
"'''\n Validate that a project can be registered, before it is\n '''",
"# Check for private project rights",
"# Check for project limit creation"
] | [
{
"param": "self",
"type": null
},
{
"param": "neighborhood",
"type": null
},
{
"param": "shortname",
"type": null
},
{
"param": "project_name",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "user_project",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "neighborhood",
"type": null,
"docstring": null,
"docstring_to... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | _create_project | <not_specific> | def _create_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps):
'''
Actually create the project, no validation. This should not be called directly
under normal circumstances.
'''
from allura import model as M
project_template... |
Actually create the project, no validation. This should not be called directly
under normal circumstances.
| Actually create the project, no validation. This should not be called directly
under normal circumstances. | [
"Actually",
"create",
"the",
"project",
"no",
"validation",
".",
"This",
"should",
"not",
"be",
"called",
"directly",
"under",
"normal",
"circumstances",
"."
] | def _create_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps):
from allura import model as M
project_template = neighborhood.get_project_template()
p = M.Project(neighborhood_id=neighborhood._id,
shortname=shortname,
... | [
"def",
"_create_project",
"(",
"self",
",",
"neighborhood",
",",
"shortname",
",",
"project_name",
",",
"user",
",",
"user_project",
",",
"private_project",
",",
"apps",
")",
":",
"from",
"allura",
"import",
"model",
"as",
"M",
"project_template",
"=",
"neighb... | Actually create the project, no validation. | [
"Actually",
"create",
"the",
"project",
"no",
"validation",
"."
] | [
"'''\n Actually create the project, no validation. This should not be called directly\n under normal circumstances.\n '''",
"# Setup defaults from neighborhood project template if applicable",
"# Must provide a group name",
"# If the group already exists, we'll add users to it,",
"# bu... | [
{
"param": "self",
"type": null
},
{
"param": "neighborhood",
"type": null
},
{
"param": "shortname",
"type": null
},
{
"param": "project_name",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "user_project",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "neighborhood",
"type": null,
"docstring": null,
"docstring_to... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | registration_date | <not_specific> | def registration_date(self, project):
'''
Return the datetime the project was created.
'''
return project._id.generation_time |
Return the datetime the project was created.
| Return the datetime the project was created. | [
"Return",
"the",
"datetime",
"the",
"project",
"was",
"created",
"."
] | def registration_date(self, project):
return project._id.generation_time | [
"def",
"registration_date",
"(",
"self",
",",
"project",
")",
":",
"return",
"project",
".",
"_id",
".",
"generation_time"
] | Return the datetime the project was created. | [
"Return",
"the",
"datetime",
"the",
"project",
"was",
"created",
"."
] | [
"'''\n Return the datetime the project was created.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "project",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project",
"type": null,
"docstring": null,
"docstring_tokens"... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | project_from_url | <not_specific> | def project_from_url(self, url):
'''Returns a tuple (project, error).
Where project is the Project instane parsed from url or None if project
can't be parsed. In that case error will be a string describing the error.
'''
from allura.model import Project, Neighborhood
if ... | Returns a tuple (project, error).
Where project is the Project instane parsed from url or None if project
can't be parsed. In that case error will be a string describing the error.
| Returns a tuple (project, error).
Where project is the Project instane parsed from url or None if project
can't be parsed. In that case error will be a string describing the error. | [
"Returns",
"a",
"tuple",
"(",
"project",
"error",
")",
".",
"Where",
"project",
"is",
"the",
"Project",
"instane",
"parsed",
"from",
"url",
"or",
"None",
"if",
"project",
"can",
"'",
"t",
"be",
"parsed",
".",
"In",
"that",
"case",
"error",
"will",
"be"... | def project_from_url(self, url):
from allura.model import Project, Neighborhood
if url is None:
return None, u'Empty url'
url = urlparse(url)
url = [u for u in url.path.split('/') if u]
if len(url) == 0:
return None, u'Empty url'
if len(url) == 1:
... | [
"def",
"project_from_url",
"(",
"self",
",",
"url",
")",
":",
"from",
"allura",
".",
"model",
"import",
"Project",
",",
"Neighborhood",
"if",
"url",
"is",
"None",
":",
"return",
"None",
",",
"u'Empty url'",
"url",
"=",
"urlparse",
"(",
"url",
")",
"url",... | Returns a tuple (project, error). | [
"Returns",
"a",
"tuple",
"(",
"project",
"error",
")",
"."
] | [
"'''Returns a tuple (project, error).\n\n Where project is the Project instane parsed from url or None if project\n can't be parsed. In that case error will be a string describing the error.\n '''",
"# Maybe subproject"
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
e06132379291359dd147e2492f2c00759bd9f090 | lym/allura-git | Allura/allura/lib/plugin.py | [
"Apache-2.0"
] | Python | app_icon_url | <not_specific> | def app_icon_url(self, app, size):
"""returns the default icon for the given app (or non-app thing like 'subproject').
Takes an instance of class Application, or else a string.
Expected to be overriden by derived Themes.
"""
if isinstance(app, unicode):
app = ... | returns the default icon for the given app (or non-app thing like 'subproject').
Takes an instance of class Application, or else a string.
Expected to be overriden by derived Themes.
| returns the default icon for the given app (or non-app thing like 'subproject').
Takes an instance of class Application, or else a string.
Expected to be overriden by derived Themes. | [
"returns",
"the",
"default",
"icon",
"for",
"the",
"given",
"app",
"(",
"or",
"non",
"-",
"app",
"thing",
"like",
"'",
"subproject",
"'",
")",
".",
"Takes",
"an",
"instance",
"of",
"class",
"Application",
"or",
"else",
"a",
"string",
".",
"Expected",
"... | def app_icon_url(self, app, size):
if isinstance(app, unicode):
app = str(app)
if isinstance(app, str):
if app in self.icons and size in self.icons[app]:
return g.theme_href(self.icons[app][size])
elif app in g.entry_points['tool']:
ret... | [
"def",
"app_icon_url",
"(",
"self",
",",
"app",
",",
"size",
")",
":",
"if",
"isinstance",
"(",
"app",
",",
"unicode",
")",
":",
"app",
"=",
"str",
"(",
"app",
")",
"if",
"isinstance",
"(",
"app",
",",
"str",
")",
":",
"if",
"app",
"in",
"self",
... | returns the default icon for the given app (or non-app thing like 'subproject'). | [
"returns",
"the",
"default",
"icon",
"for",
"the",
"given",
"app",
"(",
"or",
"non",
"-",
"app",
"thing",
"like",
"'",
"subproject",
"'",
")",
"."
] | [
"\"\"\"returns the default icon for the given app (or non-app thing like 'subproject').\n Takes an instance of class Application, or else a string.\n Expected to be overriden by derived Themes.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "app",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "app",
"type": null,
"docstring": null,
"docstring_tokens": []... |
9be92763e36d80e76cf9ee120e64d586ec60d75d | lym/allura-git | Allura/allura/ext/user_profile/user_main.py | [
"Apache-2.0"
] | Python | profile_sections | <not_specific> | def profile_sections(self):
"""
Loads and caches user profile sections from the entry-point
group ``[allura.user_profile.sections]``.
Profile sections are loaded unless disabled (see
`allura.lib.helpers.iter_entry_points`) and are sorted according
to the `user_profile_se... |
Loads and caches user profile sections from the entry-point
group ``[allura.user_profile.sections]``.
Profile sections are loaded unless disabled (see
`allura.lib.helpers.iter_entry_points`) and are sorted according
to the `user_profile_sections.order` config value.
Th... | Loads and caches user profile sections from the entry-point
group ``[allura.user_profile.sections]``.
Profile sections are loaded unless disabled (see
`allura.lib.helpers.iter_entry_points`) and are sorted according
to the `user_profile_sections.order` config value.
The config should contain a comma-separated list of... | [
"Loads",
"and",
"caches",
"user",
"profile",
"sections",
"from",
"the",
"entry",
"-",
"point",
"group",
"`",
"`",
"[",
"allura",
".",
"user_profile",
".",
"sections",
"]",
"`",
"`",
".",
"Profile",
"sections",
"are",
"loaded",
"unless",
"disabled",
"(",
... | def profile_sections(self):
if hasattr(UserProfileApp, '_sections'):
return UserProfileApp._sections
sections = {}
for ep in h.iter_entry_points('allura.user_profile.sections'):
sections[ep.name] = ep.load()
section_ordering = tg.config.get('user_profile_sections.... | [
"def",
"profile_sections",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"UserProfileApp",
",",
"'_sections'",
")",
":",
"return",
"UserProfileApp",
".",
"_sections",
"sections",
"=",
"{",
"}",
"for",
"ep",
"in",
"h",
".",
"iter_entry_points",
"(",
"'allura.u... | Loads and caches user profile sections from the entry-point
group ``[allura.user_profile.sections]``. | [
"Loads",
"and",
"caches",
"user",
"profile",
"sections",
"from",
"the",
"entry",
"-",
"point",
"group",
"`",
"`",
"[",
"allura",
".",
"user_profile",
".",
"sections",
"]",
"`",
"`",
"."
] | [
"\"\"\"\n Loads and caches user profile sections from the entry-point\n group ``[allura.user_profile.sections]``.\n\n Profile sections are loaded unless disabled (see\n `allura.lib.helpers.iter_entry_points`) and are sorted according\n to the `user_profile_sections.order` config v... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9be92763e36d80e76cf9ee120e64d586ec60d75d | lym/allura-git | Allura/allura/ext/user_profile/user_main.py | [
"Apache-2.0"
] | Python | send_message | <not_specific> | def send_message(self):
"""Render form for sending a message to another user.
"""
self._check_can_message(c.user, c.project.user_project_of)
delay = c.user.time_to_next_user_message()
expire_time = str(delay) if delay else None
c.form = F.send_message
return dic... | Render form for sending a message to another user.
| Render form for sending a message to another user. | [
"Render",
"form",
"for",
"sending",
"a",
"message",
"to",
"another",
"user",
"."
] | def send_message(self):
self._check_can_message(c.user, c.project.user_project_of)
delay = c.user.time_to_next_user_message()
expire_time = str(delay) if delay else None
c.form = F.send_message
return dict(user=c.project.user_project_of, expire_time=expire_time) | [
"def",
"send_message",
"(",
"self",
")",
":",
"self",
".",
"_check_can_message",
"(",
"c",
".",
"user",
",",
"c",
".",
"project",
".",
"user_project_of",
")",
"delay",
"=",
"c",
".",
"user",
".",
"time_to_next_user_message",
"(",
")",
"expire_time",
"=",
... | Render form for sending a message to another user. | [
"Render",
"form",
"for",
"sending",
"a",
"message",
"to",
"another",
"user",
"."
] | [
"\"\"\"Render form for sending a message to another user.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9be92763e36d80e76cf9ee120e64d586ec60d75d | lym/allura-git | Allura/allura/ext/user_profile/user_main.py | [
"Apache-2.0"
] | Python | send_user_message | <not_specific> | def send_user_message(self, subject='', message='', cc=None):
"""Handle POST for sending a message to another user.
"""
self._check_can_message(c.user, c.project.user_project_of)
if cc:
cc = c.user.get_pref('email_address')
if c.user.can_send_user_message():
... | Handle POST for sending a message to another user.
| Handle POST for sending a message to another user. | [
"Handle",
"POST",
"for",
"sending",
"a",
"message",
"to",
"another",
"user",
"."
] | def send_user_message(self, subject='', message='', cc=None):
self._check_can_message(c.user, c.project.user_project_of)
if cc:
cc = c.user.get_pref('email_address')
if c.user.can_send_user_message():
c.user.send_user_message(
c.project.user_project_of, su... | [
"def",
"send_user_message",
"(",
"self",
",",
"subject",
"=",
"''",
",",
"message",
"=",
"''",
",",
"cc",
"=",
"None",
")",
":",
"self",
".",
"_check_can_message",
"(",
"c",
".",
"user",
",",
"c",
".",
"project",
".",
"user_project_of",
")",
"if",
"c... | Handle POST for sending a message to another user. | [
"Handle",
"POST",
"for",
"sending",
"a",
"message",
"to",
"another",
"user",
"."
] | [
"\"\"\"Handle POST for sending a message to another user.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "subject",
"type": null
},
{
"param": "message",
"type": null
},
{
"param": "cc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "subject",
"type": null,
"docstring": null,
"docstring_tokens"... |
9be92763e36d80e76cf9ee120e64d586ec60d75d | lym/allura-git | Allura/allura/ext/user_profile/user_main.py | [
"Apache-2.0"
] | Python | display | <not_specific> | def display(self, *a, **kw):
"""
Renders the section using the context from :meth:`prepare_context`
and the :attr:`template`, if :meth:`check_display` returns True.
If overridden or this base class is not used, this method should
return either plain text (which will be escaped) ... |
Renders the section using the context from :meth:`prepare_context`
and the :attr:`template`, if :meth:`check_display` returns True.
If overridden or this base class is not used, this method should
return either plain text (which will be escaped) or a `jinja2.Markup`
instance.
... |
If overridden or this base class is not used, this method should
return either plain text (which will be escaped) or a `jinja2.Markup`
instance. | [
"If",
"overridden",
"or",
"this",
"base",
"class",
"is",
"not",
"used",
"this",
"method",
"should",
"return",
"either",
"plain",
"text",
"(",
"which",
"will",
"be",
"escaped",
")",
"or",
"a",
"`",
"jinja2",
".",
"Markup",
"`",
"instance",
"."
] | def display(self, *a, **kw):
if not self.check_display():
return ''
try:
tmpl = g.jinja2_env.get_template(self.template)
context = self.prepare_context({
'h': h,
'c': c,
'g': g,
'user': self.user,
... | [
"def",
"display",
"(",
"self",
",",
"*",
"a",
",",
"**",
"kw",
")",
":",
"if",
"not",
"self",
".",
"check_display",
"(",
")",
":",
"return",
"''",
"try",
":",
"tmpl",
"=",
"g",
".",
"jinja2_env",
".",
"get_template",
"(",
"self",
".",
"template",
... | Renders the section using the context from :meth:`prepare_context`
and the :attr:`template`, if :meth:`check_display` returns True. | [
"Renders",
"the",
"section",
"using",
"the",
"context",
"from",
":",
"meth",
":",
"`",
"prepare_context",
"`",
"and",
"the",
":",
"attr",
":",
"`",
"template",
"`",
"if",
":",
"meth",
":",
"`",
"check_display",
"`",
"returns",
"True",
"."
] | [
"\"\"\"\n Renders the section using the context from :meth:`prepare_context`\n and the :attr:`template`, if :meth:`check_display` returns True.\n\n If overridden or this base class is not used, this method should\n return either plain text (which will be escaped) or a `jinja2.Markup`\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
25472919203ebe5836b70f137991e15fb8f51c77 | lym/allura-git | Allura/allura/tasks/mail_tasks.py | [
"Apache-2.0"
] | Python | sendmail | null | def sendmail(fromaddr, destinations, text, reply_to, subject,
message_id, in_reply_to=None, sender=None, references=None):
'''
Send an email to the specified list of destinations with respect to the preferred email format specified by user.
It is best for broadcast messages.
:param fromadd... |
Send an email to the specified list of destinations with respect to the preferred email format specified by user.
It is best for broadcast messages.
:param fromaddr: ObjectId or str(ObjectId) of user, or email address str
| Send an email to the specified list of destinations with respect to the preferred email format specified by user.
It is best for broadcast messages. | [
"Send",
"an",
"email",
"to",
"the",
"specified",
"list",
"of",
"destinations",
"with",
"respect",
"to",
"the",
"preferred",
"email",
"format",
"specified",
"by",
"user",
".",
"It",
"is",
"best",
"for",
"broadcast",
"messages",
"."
] | def sendmail(fromaddr, destinations, text, reply_to, subject,
message_id, in_reply_to=None, sender=None, references=None):
from allura import model as M
addrs_plain = []
addrs_html = []
addrs_multi = []
if fromaddr is None:
fromaddr = g.noreply
elif not isinstance(fromaddr, ... | [
"def",
"sendmail",
"(",
"fromaddr",
",",
"destinations",
",",
"text",
",",
"reply_to",
",",
"subject",
",",
"message_id",
",",
"in_reply_to",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"references",
"=",
"None",
")",
":",
"from",
"allura",
"import",
"... | Send an email to the specified list of destinations with respect to the preferred email format specified by user. | [
"Send",
"an",
"email",
"to",
"the",
"specified",
"list",
"of",
"destinations",
"with",
"respect",
"to",
"the",
"preferred",
"email",
"format",
"specified",
"by",
"user",
"."
] | [
"'''\n Send an email to the specified list of destinations with respect to the preferred email format specified by user.\n It is best for broadcast messages.\n\n :param fromaddr: ObjectId or str(ObjectId) of user, or email address str\n\n '''",
"# Divide addresses based on preferred email formats"
] | [
{
"param": "fromaddr",
"type": null
},
{
"param": "destinations",
"type": null
},
{
"param": "text",
"type": null
},
{
"param": "reply_to",
"type": null
},
{
"param": "subject",
"type": null
},
{
"param": "message_id",
"type": null
},
{
"pa... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fromaddr",
"type": null,
"docstring": "ObjectId or str(ObjectId) of user, or email address str",
"docstring_tokens": [
"ObjectId",
"or",
"str",
"(",
"ObjectId",
")",
"of"... |
25472919203ebe5836b70f137991e15fb8f51c77 | lym/allura-git | Allura/allura/tasks/mail_tasks.py | [
"Apache-2.0"
] | Python | sendsimplemail | null | def sendsimplemail(
fromaddr,
toaddr,
text,
reply_to,
subject,
message_id,
in_reply_to=None,
sender=None,
references=None,
cc=None):
'''
Send a single mail to the specified address.
It is best for single user notifications.
... |
Send a single mail to the specified address.
It is best for single user notifications.
:param fromaddr: ObjectId or str(ObjectId) of user, or email address str
:param toaddr: ObjectId or str(ObjectId) of user, or email address str
| Send a single mail to the specified address.
It is best for single user notifications. | [
"Send",
"a",
"single",
"mail",
"to",
"the",
"specified",
"address",
".",
"It",
"is",
"best",
"for",
"single",
"user",
"notifications",
"."
] | def sendsimplemail(
fromaddr,
toaddr,
text,
reply_to,
subject,
message_id,
in_reply_to=None,
sender=None,
references=None,
cc=None):
from allura import model as M
if fromaddr is None:
fromaddr = g.noreply
elif not isinst... | [
"def",
"sendsimplemail",
"(",
"fromaddr",
",",
"toaddr",
",",
"text",
",",
"reply_to",
",",
"subject",
",",
"message_id",
",",
"in_reply_to",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"references",
"=",
"None",
",",
"cc",
"=",
"None",
")",
":",
"fr... | Send a single mail to the specified address. | [
"Send",
"a",
"single",
"mail",
"to",
"the",
"specified",
"address",
"."
] | [
"'''\n Send a single mail to the specified address.\n It is best for single user notifications.\n\n :param fromaddr: ObjectId or str(ObjectId) of user, or email address str\n :param toaddr: ObjectId or str(ObjectId) of user, or email address str\n\n '''"
] | [
{
"param": "fromaddr",
"type": null
},
{
"param": "toaddr",
"type": null
},
{
"param": "text",
"type": null
},
{
"param": "reply_to",
"type": null
},
{
"param": "subject",
"type": null
},
{
"param": "message_id",
"type": null
},
{
"param": ... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fromaddr",
"type": null,
"docstring": "ObjectId or str(ObjectId) of user, or email address str",
"docstring_tokens": [
"ObjectId",
"or",
"str",
"(",
"ObjectId",
")",
"of"... |
1ca82e89899773d5f4ce783704864d1e40539350 | lym/allura-git | Allura/allura/model/repo_refresh.py | [
"Apache-2.0"
] | Python | refresh_commit_trees | <not_specific> | def refresh_commit_trees(ci, cache):
'''Refresh the list of trees included withn a commit'''
if ci.tree_id is None:
return cache
trees_doc = TreesDoc(dict(
_id=ci._id,
tree_ids=list(trees(ci.tree_id, cache))))
trees_doc.m.save(safe=False)
new_cache = dict(
(oid, cache... | Refresh the list of trees included withn a commit | Refresh the list of trees included withn a commit | [
"Refresh",
"the",
"list",
"of",
"trees",
"included",
"withn",
"a",
"commit"
] | def refresh_commit_trees(ci, cache):
if ci.tree_id is None:
return cache
trees_doc = TreesDoc(dict(
_id=ci._id,
tree_ids=list(trees(ci.tree_id, cache))))
trees_doc.m.save(safe=False)
new_cache = dict(
(oid, cache[oid])
for oid in trees_doc.tree_ids)
return new... | [
"def",
"refresh_commit_trees",
"(",
"ci",
",",
"cache",
")",
":",
"if",
"ci",
".",
"tree_id",
"is",
"None",
":",
"return",
"cache",
"trees_doc",
"=",
"TreesDoc",
"(",
"dict",
"(",
"_id",
"=",
"ci",
".",
"_id",
",",
"tree_ids",
"=",
"list",
"(",
"tree... | Refresh the list of trees included withn a commit | [
"Refresh",
"the",
"list",
"of",
"trees",
"included",
"withn",
"a",
"commit"
] | [
"'''Refresh the list of trees included withn a commit'''"
] | [
{
"param": "ci",
"type": null
},
{
"param": "cache",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ci",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cache",
"type": null,
"docstring": null,
"docstring_tokens": []... |
1ca82e89899773d5f4ce783704864d1e40539350 | lym/allura-git | Allura/allura/model/repo_refresh.py | [
"Apache-2.0"
] | Python | trees | null | def trees(id, cache):
'''Recursively generate the list of trees contained within a given tree ID'''
yield id
entries = cache.get(id, None)
if entries is None:
t = TreeDoc.m.get(_id=id)
entries = [o.id for o in t.tree_ids]
cache[id] = entries
for i in entries:
for x in... | Recursively generate the list of trees contained within a given tree ID | Recursively generate the list of trees contained within a given tree ID | [
"Recursively",
"generate",
"the",
"list",
"of",
"trees",
"contained",
"within",
"a",
"given",
"tree",
"ID"
] | def trees(id, cache):
yield id
entries = cache.get(id, None)
if entries is None:
t = TreeDoc.m.get(_id=id)
entries = [o.id for o in t.tree_ids]
cache[id] = entries
for i in entries:
for x in trees(i, cache):
yield x | [
"def",
"trees",
"(",
"id",
",",
"cache",
")",
":",
"yield",
"id",
"entries",
"=",
"cache",
".",
"get",
"(",
"id",
",",
"None",
")",
"if",
"entries",
"is",
"None",
":",
"t",
"=",
"TreeDoc",
".",
"m",
".",
"get",
"(",
"_id",
"=",
"id",
")",
"en... | Recursively generate the list of trees contained within a given tree ID | [
"Recursively",
"generate",
"the",
"list",
"of",
"trees",
"contained",
"within",
"a",
"given",
"tree",
"ID"
] | [
"'''Recursively generate the list of trees contained within a given tree ID'''"
] | [
{
"param": "id",
"type": null
},
{
"param": "cache",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cache",
"type": null,
"docstring": null,
"docstring_tokens": []... |
1ca82e89899773d5f4ce783704864d1e40539350 | lym/allura-git | Allura/allura/model/repo_refresh.py | [
"Apache-2.0"
] | Python | send_notifications | null | def send_notifications(repo, commit_ids):
"""Create appropriate notification and feed objects for a refresh
:param repo: A repository artifact instance.
:type repo: Repository
:param commit_ids: A list of commit hash strings.
:type commit_ids: list
"""
from allura.model import Feed, Notifi... | Create appropriate notification and feed objects for a refresh
:param repo: A repository artifact instance.
:type repo: Repository
:param commit_ids: A list of commit hash strings.
:type commit_ids: list
| Create appropriate notification and feed objects for a refresh | [
"Create",
"appropriate",
"notification",
"and",
"feed",
"objects",
"for",
"a",
"refresh"
] | def send_notifications(repo, commit_ids):
from allura.model import Feed, Notification
commit_msgs = []
base_url = tg.config['base_url']
last_branch = []
for oids in utils.chunked_iter(commit_ids, QSIZE):
chunk = list(oids)
index = dict(
(doc._id, doc)
for doc ... | [
"def",
"send_notifications",
"(",
"repo",
",",
"commit_ids",
")",
":",
"from",
"allura",
".",
"model",
"import",
"Feed",
",",
"Notification",
"commit_msgs",
"=",
"[",
"]",
"base_url",
"=",
"tg",
".",
"config",
"[",
"'base_url'",
"]",
"last_branch",
"=",
"[... | Create appropriate notification and feed objects for a refresh | [
"Create",
"appropriate",
"notification",
"and",
"feed",
"objects",
"for",
"a",
"refresh"
] | [
"\"\"\"Create appropriate notification and feed objects for a refresh\n\n :param repo: A repository artifact instance.\n :type repo: Repository\n\n :param commit_ids: A list of commit hash strings.\n :type commit_ids: list\n \"\"\""
] | [
{
"param": "repo",
"type": null
},
{
"param": "commit_ids",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "repo",
"type": null,
"docstring": "A repository artifact instance.",
"docstring_tokens": [
"A",
"repository",
"artifact",
"instance",
"."
],
"default": null,
"is_option... |
1ca82e89899773d5f4ce783704864d1e40539350 | lym/allura-git | Allura/allura/model/repo_refresh.py | [
"Apache-2.0"
] | Python | compute_lcds | <not_specific> | def compute_lcds(commit, model_cache, lcid_cache):
'''
Compute LastCommit data for every Tree node under this tree.
'''
trees = model_cache.get(TreesDoc, dict(_id=commit._id))
if not trees:
log.error('Missing TreesDoc for %s; skipping compute_lcd' % commit)
return
with h.push_con... |
Compute LastCommit data for every Tree node under this tree.
| Compute LastCommit data for every Tree node under this tree. | [
"Compute",
"LastCommit",
"data",
"for",
"every",
"Tree",
"node",
"under",
"this",
"tree",
"."
] | def compute_lcds(commit, model_cache, lcid_cache):
trees = model_cache.get(TreesDoc, dict(_id=commit._id))
if not trees:
log.error('Missing TreesDoc for %s; skipping compute_lcd' % commit)
return
with h.push_config(c, model_cache=model_cache, lcid_cache=lcid_cache):
_update_tree_cach... | [
"def",
"compute_lcds",
"(",
"commit",
",",
"model_cache",
",",
"lcid_cache",
")",
":",
"trees",
"=",
"model_cache",
".",
"get",
"(",
"TreesDoc",
",",
"dict",
"(",
"_id",
"=",
"commit",
".",
"_id",
")",
")",
"if",
"not",
"trees",
":",
"log",
".",
"err... | Compute LastCommit data for every Tree node under this tree. | [
"Compute",
"LastCommit",
"data",
"for",
"every",
"Tree",
"node",
"under",
"this",
"tree",
"."
] | [
"'''\n Compute LastCommit data for every Tree node under this tree.\n '''"
] | [
{
"param": "commit",
"type": null
},
{
"param": "model_cache",
"type": null
},
{
"param": "lcid_cache",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "commit",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_cache",
"type": null,
"docstring": null,
"docstring_t... |
1ca82e89899773d5f4ce783704864d1e40539350 | lym/allura-git | Allura/allura/model/repo_refresh.py | [
"Apache-2.0"
] | Python | _pull_tree | <not_specific> | def _pull_tree(cache, tree_id, *context):
'''
Since the Tree instances stick around in our cache,
subsequent calls to set_context are overwriting our
in-use copies and confusing the walk. So, make an
memory-only copy for our use.
'''
cache_tree = cache.get(Tree, dict(_id=tree_id))
new_t... |
Since the Tree instances stick around in our cache,
subsequent calls to set_context are overwriting our
in-use copies and confusing the walk. So, make an
memory-only copy for our use.
| Since the Tree instances stick around in our cache,
subsequent calls to set_context are overwriting our
in-use copies and confusing the walk. So, make an
memory-only copy for our use. | [
"Since",
"the",
"Tree",
"instances",
"stick",
"around",
"in",
"our",
"cache",
"subsequent",
"calls",
"to",
"set_context",
"are",
"overwriting",
"our",
"in",
"-",
"use",
"copies",
"and",
"confusing",
"the",
"walk",
".",
"So",
"make",
"an",
"memory",
"-",
"o... | def _pull_tree(cache, tree_id, *context):
cache_tree = cache.get(Tree, dict(_id=tree_id))
new_tree = Tree(
_id=cache_tree._id,
tree_ids=cache_tree.tree_ids,
blob_ids=cache_tree.blob_ids,
other_ids=cache_tree.other_ids,
)
session(new_tree).expunge(new_tree)
new_tree.se... | [
"def",
"_pull_tree",
"(",
"cache",
",",
"tree_id",
",",
"*",
"context",
")",
":",
"cache_tree",
"=",
"cache",
".",
"get",
"(",
"Tree",
",",
"dict",
"(",
"_id",
"=",
"tree_id",
")",
")",
"new_tree",
"=",
"Tree",
"(",
"_id",
"=",
"cache_tree",
".",
"... | Since the Tree instances stick around in our cache,
subsequent calls to set_context are overwriting our
in-use copies and confusing the walk. | [
"Since",
"the",
"Tree",
"instances",
"stick",
"around",
"in",
"our",
"cache",
"subsequent",
"calls",
"to",
"set_context",
"are",
"overwriting",
"our",
"in",
"-",
"use",
"copies",
"and",
"confusing",
"the",
"walk",
"."
] | [
"'''\n Since the Tree instances stick around in our cache,\n subsequent calls to set_context are overwriting our\n in-use copies and confusing the walk. So, make an\n memory-only copy for our use.\n '''"
] | [
{
"param": "cache",
"type": null
},
{
"param": "tree_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tree_id",
"type": null,
"docstring": null,
"docstring_tokens... |
6d0ce0fe467fcfba3d833e86847ae9cd5a93a8bf | ERS-HCL/chest-x-ray-model-deep-learning | lambda-multilabel/pytorch/app.py | [
"MIT"
] | Python | load_model | <not_specific> | def load_model():
"""Loads the PyTorch model into memory from a file on S3.
Returns
------
Vision model: Module
Returns the vision PyTorch model to use for inference.
"""
global classes
#global
#thresholds = THRESHOLD_VALUES # Above needs
logger.info("**load... | Loads the PyTorch model into memory from a file on S3.
Returns
------
Vision model: Module
Returns the vision PyTorch model to use for inference.
| Loads the PyTorch model into memory from a file on S3.
Returns
Vision model: Module
Returns the vision PyTorch model to use for inference. | [
"Loads",
"the",
"PyTorch",
"model",
"into",
"memory",
"from",
"a",
"file",
"on",
"S3",
".",
"Returns",
"Vision",
"model",
":",
"Module",
"Returns",
"the",
"vision",
"PyTorch",
"model",
"to",
"use",
"for",
"inference",
"."
] | def load_model():
global classes
logger.info("**load_model**")
obj = s3.get_object(Bucket=MODEL_BUCKET, Key=MODEL_KEY)
bytestream = io.BytesIO(obj['Body'].read())
tar = tarfile.open(fileobj=bytestream, mode="r:gz")
for member in tar.getmembers():
if member.name.endswith(".txt"):
... | [
"def",
"load_model",
"(",
")",
":",
"global",
"classes",
"logger",
".",
"info",
"(",
"\"**load_model**\"",
")",
"obj",
"=",
"s3",
".",
"get_object",
"(",
"Bucket",
"=",
"MODEL_BUCKET",
",",
"Key",
"=",
"MODEL_KEY",
")",
"bytestream",
"=",
"io",
".",
"Byt... | Loads the PyTorch model into memory from a file on S3. | [
"Loads",
"the",
"PyTorch",
"model",
"into",
"memory",
"from",
"a",
"file",
"on",
"S3",
"."
] | [
"\"\"\"Loads the PyTorch model into memory from a file on S3.\n\n Returns\n ------\n Vision model: Module\n Returns the vision PyTorch model to use for inference.\n \n \"\"\"",
"#global ",
"#thresholds = THRESHOLD_VALUES # Above needs"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6d0ce0fe467fcfba3d833e86847ae9cd5a93a8bf | ERS-HCL/chest-x-ray-model-deep-learning | lambda-multilabel/pytorch/app.py | [
"MIT"
] | Python | predict | <not_specific> | def predict(input_object, model):
"""Predicts the class from an input image.
Parameters
----------
input_object: Tensor, required
The tensor object containing the image pixels reshaped and normalized.
Returns
------
Response object: dict
Returns the predicted class and conf... | Predicts the class from an input image.
Parameters
----------
input_object: Tensor, required
The tensor object containing the image pixels reshaped and normalized.
Returns
------
Response object: dict
Returns the predicted class and confidence score.
| Predicts the class from an input image.
Parameters
Tensor, required
The tensor object containing the image pixels reshaped and normalized.
Returns
Response object: dict
Returns the predicted class and confidence score. | [
"Predicts",
"the",
"class",
"from",
"an",
"input",
"image",
".",
"Parameters",
"Tensor",
"required",
"The",
"tensor",
"object",
"containing",
"the",
"image",
"pixels",
"reshaped",
"and",
"normalized",
".",
"Returns",
"Response",
"object",
":",
"dict",
"Returns",... | def predict(input_object, model):
logger.info("Calling **predict** on model")
start_time = time.time()
predict_values = model(input_object)
inference_time = time.time() - start_time
logger.info("--- Inference time: %s seconds ---" % (time.time() - start_time))
response = prediction_one_label(pre... | [
"def",
"predict",
"(",
"input_object",
",",
"model",
")",
":",
"logger",
".",
"info",
"(",
"\"Calling **predict** on model\"",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"predict_values",
"=",
"model",
"(",
"input_object",
")",
"inference_time",
"=... | Predicts the class from an input image. | [
"Predicts",
"the",
"class",
"from",
"an",
"input",
"image",
"."
] | [
"\"\"\"Predicts the class from an input image.\n\n Parameters\n ----------\n input_object: Tensor, required\n The tensor object containing the image pixels reshaped and normalized.\n\n Returns\n ------\n Response object: dict\n Returns the predicted class and confidence score.\n \... | [
{
"param": "input_object",
"type": null
},
{
"param": "model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_object",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_t... |
6d0ce0fe467fcfba3d833e86847ae9cd5a93a8bf | ERS-HCL/chest-x-ray-model-deep-learning | lambda-multilabel/pytorch/app.py | [
"MIT"
] | Python | input_fn | <not_specific> | def input_fn(request_body):
"""Pre-processes the input data from JSON to PyTorch Tensor.
Parameters
----------
request_body: dict, required
The request body submitted by the client. Expect an entry 'url' containing a URL of an image to classify.
Returns
------
PyTorch Tensor object... | Pre-processes the input data from JSON to PyTorch Tensor.
Parameters
----------
request_body: dict, required
The request body submitted by the client. Expect an entry 'url' containing a URL of an image to classify.
Returns
------
PyTorch Tensor object: Tensor
| Pre-processes the input data from JSON to PyTorch Tensor.
Parameters
dict, required
The request body submitted by the client. Expect an entry 'url' containing a URL of an image to classify.
Returns
PyTorch Tensor object: Tensor | [
"Pre",
"-",
"processes",
"the",
"input",
"data",
"from",
"JSON",
"to",
"PyTorch",
"Tensor",
".",
"Parameters",
"dict",
"required",
"The",
"request",
"body",
"submitted",
"by",
"the",
"client",
".",
"Expect",
"an",
"entry",
"'",
"url",
"'",
"containing",
"a... | def input_fn(request_body):
logger.info("Getting input URL to a image Tensor object")
if isinstance(request_body, str):
request_body = json.loads(request_body)
img_url = request_body['url']
img_tensor = load_and_process_image(img_url, image_sz)
return img_tensor | [
"def",
"input_fn",
"(",
"request_body",
")",
":",
"logger",
".",
"info",
"(",
"\"Getting input URL to a image Tensor object\"",
")",
"if",
"isinstance",
"(",
"request_body",
",",
"str",
")",
":",
"request_body",
"=",
"json",
".",
"loads",
"(",
"request_body",
")... | Pre-processes the input data from JSON to PyTorch Tensor. | [
"Pre",
"-",
"processes",
"the",
"input",
"data",
"from",
"JSON",
"to",
"PyTorch",
"Tensor",
"."
] | [
"\"\"\"Pre-processes the input data from JSON to PyTorch Tensor.\n\n Parameters\n ----------\n request_body: dict, required\n The request body submitted by the client. Expect an entry 'url' containing a URL of an image to classify.\n\n Returns\n ------\n PyTorch Tensor object: Tensor\n \... | [
{
"param": "request_body",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request_body",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5366058608b38197a604862b281f6aa7b77cfb8a | smackware/rdisq | rdisq/request/dispatcher.py | [
"MIT"
] | Python | filter_services | Iterable[
"ReceiverServiceStatus"] | def filter_services(self, service_filter: Callable[["ReceiverServiceStatus"], bool]) -> Iterable[
"ReceiverServiceStatus"]:
"""Filters the services-statuses in redis with the service_filter function, and returns those that pass
:return: Statuses of services that match the filter.
"""
... | Filters the services-statuses in redis with the service_filter function, and returns those that pass
:return: Statuses of services that match the filter.
| Filters the services-statuses in redis with the service_filter function, and returns those that pass | [
"Filters",
"the",
"services",
"-",
"statuses",
"in",
"redis",
"with",
"the",
"service_filter",
"function",
"and",
"returns",
"those",
"that",
"pass"
] | def filter_services(self, service_filter: Callable[["ReceiverServiceStatus"], bool]) -> Iterable[
"ReceiverServiceStatus"]:
services = self.get_receiver_services()
return filter(service_filter, services.values()) | [
"def",
"filter_services",
"(",
"self",
",",
"service_filter",
":",
"Callable",
"[",
"[",
"\"ReceiverServiceStatus\"",
"]",
",",
"bool",
"]",
")",
"->",
"Iterable",
"[",
"\"ReceiverServiceStatus\"",
"]",
":",
"services",
"=",
"self",
".",
"get_receiver_services",
... | Filters the services-statuses in redis with the service_filter function, and returns those that pass | [
"Filters",
"the",
"services",
"-",
"statuses",
"in",
"redis",
"with",
"the",
"service_filter",
"function",
"and",
"returns",
"those",
"that",
"pass"
] | [
"\"\"\"Filters the services-statuses in redis with the service_filter function, and returns those that pass\n\n :return: Statuses of services that match the filter.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "service_filter",
"type": "Callable[[\"ReceiverServiceStatus\"], bool]"
}
] | {
"returns": [
{
"docstring": "Statuses of services that match the filter.",
"docstring_tokens": [
"Statuses",
"of",
"services",
"that",
"match",
"the",
"filter",
"."
],
"type": null
}
],
"raises": [],
"params": [
... |
5366058608b38197a604862b281f6aa7b77cfb8a | smackware/rdisq | rdisq/request/dispatcher.py | [
"MIT"
] | Python | find_queues_for_services | FrozenSet[QueueName] | def find_queues_for_services(self, service_uids: Set[str]) -> FrozenSet[QueueName]:
"""
Find all queues that are listened to by all these services.
:param service_uids: Set IDs of queues to match.
:return: Set of queue names.
"""
services = self.get_receiver_services().v... |
Find all queues that are listened to by all these services.
:param service_uids: Set IDs of queues to match.
:return: Set of queue names.
| Find all queues that are listened to by all these services. | [
"Find",
"all",
"queues",
"that",
"are",
"listened",
"to",
"by",
"all",
"these",
"services",
"."
] | def find_queues_for_services(self, service_uids: Set[str]) -> FrozenSet[QueueName]:
services = self.get_receiver_services().values()
queue_to_services: Dict[QueueName, set] = defaultdict(set)
for service in services:
for q in service.broadcast_queues:
queue_to_service... | [
"def",
"find_queues_for_services",
"(",
"self",
",",
"service_uids",
":",
"Set",
"[",
"str",
"]",
")",
"->",
"FrozenSet",
"[",
"QueueName",
"]",
":",
"services",
"=",
"self",
".",
"get_receiver_services",
"(",
")",
".",
"values",
"(",
")",
"queue_to_services... | Find all queues that are listened to by all these services. | [
"Find",
"all",
"queues",
"that",
"are",
"listened",
"to",
"by",
"all",
"these",
"services",
"."
] | [
"\"\"\"\n Find all queues that are listened to by all these services.\n\n :param service_uids: Set IDs of queues to match.\n :return: Set of queue names.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "service_uids",
"type": "Set[str]"
}
] | {
"returns": [
{
"docstring": "Set of queue names.",
"docstring_tokens": [
"Set",
"of",
"queue",
"names",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | _pawn_distance_to_promote | <not_specific> | def _pawn_distance_to_promote(position:int, color:bool):
"""Returns the number of moves this pawn must make before it
gets promoted. Position is an int 0-63, and color is chess.WHITE or chess.BLACK
"""
assert position in range(64)
rank = (position // 8) + 1 # 1-8
if color == chess.WHITE:
... | Returns the number of moves this pawn must make before it
gets promoted. Position is an int 0-63, and color is chess.WHITE or chess.BLACK
| Returns the number of moves this pawn must make before it
gets promoted. Position is an int 0-63, and color is chess.WHITE or chess.BLACK | [
"Returns",
"the",
"number",
"of",
"moves",
"this",
"pawn",
"must",
"make",
"before",
"it",
"gets",
"promoted",
".",
"Position",
"is",
"an",
"int",
"0",
"-",
"63",
"and",
"color",
"is",
"chess",
".",
"WHITE",
"or",
"chess",
".",
"BLACK"
] | def _pawn_distance_to_promote(position:int, color:bool):
assert position in range(64)
rank = (position // 8) + 1
if color == chess.WHITE:
return 8-rank
else:
return rank | [
"def",
"_pawn_distance_to_promote",
"(",
"position",
":",
"int",
",",
"color",
":",
"bool",
")",
":",
"assert",
"position",
"in",
"range",
"(",
"64",
")",
"rank",
"=",
"(",
"position",
"//",
"8",
")",
"+",
"1",
"if",
"color",
"==",
"chess",
".",
"WHI... | Returns the number of moves this pawn must make before it
gets promoted. | [
"Returns",
"the",
"number",
"of",
"moves",
"this",
"pawn",
"must",
"make",
"before",
"it",
"gets",
"promoted",
"."
] | [
"\"\"\"Returns the number of moves this pawn must make before it \n gets promoted. Position is an int 0-63, and color is chess.WHITE or chess.BLACK\n \"\"\"",
"# 1-8"
] | [
{
"param": "position",
"type": "int"
},
{
"param": "color",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "position",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "color",
"type": "bool",
"docstring": null,
"docstring_to... |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | pawn_position_bonus | float | def pawn_position_bonus(b:Board) -> float:
"""Returns white - black advantage just for pawn position.
"""
total = 0
for color, sign in [(chess.WHITE, 1), (chess.BLACK, -1)]:
for pawn in b.pieces(chess.PAWN, color):
dist = _pawn_distance_to_promote(pawn, sign)
total += sig... | Returns white - black advantage just for pawn position.
| Returns white - black advantage just for pawn position. | [
"Returns",
"white",
"-",
"black",
"advantage",
"just",
"for",
"pawn",
"position",
"."
] | def pawn_position_bonus(b:Board) -> float:
total = 0
for color, sign in [(chess.WHITE, 1), (chess.BLACK, -1)]:
for pawn in b.pieces(chess.PAWN, color):
dist = _pawn_distance_to_promote(pawn, sign)
total += sign * HEURISTIC.PAWN_PROMOTION / dist
return total | [
"def",
"pawn_position_bonus",
"(",
"b",
":",
"Board",
")",
"->",
"float",
":",
"total",
"=",
"0",
"for",
"color",
",",
"sign",
"in",
"[",
"(",
"chess",
".",
"WHITE",
",",
"1",
")",
",",
"(",
"chess",
".",
"BLACK",
",",
"-",
"1",
")",
"]",
":",
... | Returns white - black advantage just for pawn position. | [
"Returns",
"white",
"-",
"black",
"advantage",
"just",
"for",
"pawn",
"position",
"."
] | [
"\"\"\"Returns white - black advantage just for pawn position.\n \"\"\""
] | [
{
"param": "b",
"type": "Board"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": "Board",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | score_board | float | def score_board(b:Board) -> float:
"""Returns a score for the board.
Uses the board's own score function (my_score) if monkey-patched in,
else uses score_material_and_win by default
"""
if hasattr(b,'my_score'):
return b.my_score()
else:
return score_material_and_win(b) | Returns a score for the board.
Uses the board's own score function (my_score) if monkey-patched in,
else uses score_material_and_win by default
| Returns a score for the board.
Uses the board's own score function (my_score) if monkey-patched in,
else uses score_material_and_win by default | [
"Returns",
"a",
"score",
"for",
"the",
"board",
".",
"Uses",
"the",
"board",
"'",
"s",
"own",
"score",
"function",
"(",
"my_score",
")",
"if",
"monkey",
"-",
"patched",
"in",
"else",
"uses",
"score_material_and_win",
"by",
"default"
] | def score_board(b:Board) -> float:
if hasattr(b,'my_score'):
return b.my_score()
else:
return score_material_and_win(b) | [
"def",
"score_board",
"(",
"b",
":",
"Board",
")",
"->",
"float",
":",
"if",
"hasattr",
"(",
"b",
",",
"'my_score'",
")",
":",
"return",
"b",
".",
"my_score",
"(",
")",
"else",
":",
"return",
"score_material_and_win",
"(",
"b",
")"
] | Returns a score for the board. | [
"Returns",
"a",
"score",
"for",
"the",
"board",
"."
] | [
"\"\"\"Returns a score for the board.\n Uses the board's own score function (my_score) if monkey-patched in,\n else uses score_material_and_win by default\n \"\"\""
] | [
{
"param": "b",
"type": "Board"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": "Board",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | pick_move | Move | def pick_move(b:Board, verbose:bool=False) -> Move:
"""Enumerate all valid moves, and pick the one most advantageous to the current player
"""
best_score = None
best_moves = None
def is_better(reference_score, new_score) -> bool:
if reference_score is None:
return True
if... | Enumerate all valid moves, and pick the one most advantageous to the current player
| Enumerate all valid moves, and pick the one most advantageous to the current player | [
"Enumerate",
"all",
"valid",
"moves",
"and",
"pick",
"the",
"one",
"most",
"advantageous",
"to",
"the",
"current",
"player"
] | def pick_move(b:Board, verbose:bool=False) -> Move:
best_score = None
best_moves = None
def is_better(reference_score, new_score) -> bool:
if reference_score is None:
return True
if b.turn == chess.WHITE:
return new_score > reference_score
else:
re... | [
"def",
"pick_move",
"(",
"b",
":",
"Board",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"Move",
":",
"best_score",
"=",
"None",
"best_moves",
"=",
"None",
"def",
"is_better",
"(",
"reference_score",
",",
"new_score",
")",
"->",
"bool",
":",
"... | Enumerate all valid moves, and pick the one most advantageous to the current player | [
"Enumerate",
"all",
"valid",
"moves",
"and",
"pick",
"the",
"one",
"most",
"advantageous",
"to",
"the",
"current",
"player"
] | [
"\"\"\"Enumerate all valid moves, and pick the one most advantageous to the current player\n \"\"\""
] | [
{
"param": "b",
"type": "Board"
},
{
"param": "verbose",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": "Board",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "verbose",
"type": "bool",
"docstring": null,
"docstring_token... |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | move | [bool, str] | def move(self, move:str) -> [bool, str]:
"""Returns true if the move succeeded
"""
try:
self.b.push_uci(move)
return True, f"you moved: {move}"
except ValueError as e:
msg = str(e)
if msg.startswith("illegal uci"):
return Fa... | Returns true if the move succeeded
| Returns true if the move succeeded | [
"Returns",
"true",
"if",
"the",
"move",
"succeeded"
] | def move(self, move:str) -> [bool, str]:
try:
self.b.push_uci(move)
return True, f"you moved: {move}"
except ValueError as e:
msg = str(e)
if msg.startswith("illegal uci"):
return False, f"illegal move: {move}. Try something like d2d4 or h... | [
"def",
"move",
"(",
"self",
",",
"move",
":",
"str",
")",
"->",
"[",
"bool",
",",
"str",
"]",
":",
"try",
":",
"self",
".",
"b",
".",
"push_uci",
"(",
"move",
")",
"return",
"True",
",",
"f\"you moved: {move}\"",
"except",
"ValueError",
"as",
"e",
... | Returns true if the move succeeded | [
"Returns",
"true",
"if",
"the",
"move",
"succeeded"
] | [
"\"\"\"Returns true if the move succeeded\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "move",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "move",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | bot_move | <not_specific> | def bot_move(self):
"""Computer makes a move herself, and updates the board
"""
m = lookahead1_move(self.b)
if m:
return self.move(m.uci())
else:
return False, "No valid moves" | Computer makes a move herself, and updates the board
| Computer makes a move herself, and updates the board | [
"Computer",
"makes",
"a",
"move",
"herself",
"and",
"updates",
"the",
"board"
] | def bot_move(self):
m = lookahead1_move(self.b)
if m:
return self.move(m.uci())
else:
return False, "No valid moves" | [
"def",
"bot_move",
"(",
"self",
")",
":",
"m",
"=",
"lookahead1_move",
"(",
"self",
".",
"b",
")",
"if",
"m",
":",
"return",
"self",
".",
"move",
"(",
"m",
".",
"uci",
"(",
")",
")",
"else",
":",
"return",
"False",
",",
"\"No valid moves\""
] | Computer makes a move herself, and updates the board | [
"Computer",
"makes",
"a",
"move",
"herself",
"and",
"updates",
"the",
"board"
] | [
"\"\"\"Computer makes a move herself, and updates the board\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
450977a75506b1ba6c52bfd2e89d4d9e078d75b1 | leopd/kidpawn | kidpawn.py | [
"BSD-3-Clause"
] | Python | game_over_msg | str | def game_over_msg(self) -> str:
"""If the game is over, returns a string why.
If game is not over, return blank
"""
if self.b.is_game_over():
return f"Game over: {self.b.result()}"
else:
return None | If the game is over, returns a string why.
If game is not over, return blank
| If the game is over, returns a string why.
If game is not over, return blank | [
"If",
"the",
"game",
"is",
"over",
"returns",
"a",
"string",
"why",
".",
"If",
"game",
"is",
"not",
"over",
"return",
"blank"
] | def game_over_msg(self) -> str:
if self.b.is_game_over():
return f"Game over: {self.b.result()}"
else:
return None | [
"def",
"game_over_msg",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"b",
".",
"is_game_over",
"(",
")",
":",
"return",
"f\"Game over: {self.b.result()}\"",
"else",
":",
"return",
"None"
] | If the game is over, returns a string why. | [
"If",
"the",
"game",
"is",
"over",
"returns",
"a",
"string",
"why",
"."
] | [
"\"\"\"If the game is over, returns a string why.\n If game is not over, return blank\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
78b35c539f73de2fc49cf626475775de2f4b4934 | FoamyGuy/NeoTrellis-M4-CircuitPython-Music-Fun | wave_generator/tone_maker.py | [
"MIT"
] | Python | append_silence | <not_specific> | def append_silence(duration_milliseconds=500):
"""
Adding silence is easy - we add zeros to the end of our array
"""
num_samples = duration_milliseconds * (sample_rate / 1000.0)
for x in range(int(num_samples)):
audio.append(0.0)
return |
Adding silence is easy - we add zeros to the end of our array
| Adding silence is easy - we add zeros to the end of our array | [
"Adding",
"silence",
"is",
"easy",
"-",
"we",
"add",
"zeros",
"to",
"the",
"end",
"of",
"our",
"array"
] | def append_silence(duration_milliseconds=500):
num_samples = duration_milliseconds * (sample_rate / 1000.0)
for x in range(int(num_samples)):
audio.append(0.0)
return | [
"def",
"append_silence",
"(",
"duration_milliseconds",
"=",
"500",
")",
":",
"num_samples",
"=",
"duration_milliseconds",
"*",
"(",
"sample_rate",
"/",
"1000.0",
")",
"for",
"x",
"in",
"range",
"(",
"int",
"(",
"num_samples",
")",
")",
":",
"audio",
".",
"... | Adding silence is easy - we add zeros to the end of our array | [
"Adding",
"silence",
"is",
"easy",
"-",
"we",
"add",
"zeros",
"to",
"the",
"end",
"of",
"our",
"array"
] | [
"\"\"\"\n Adding silence is easy - we add zeros to the end of our array\n \"\"\""
] | [
{
"param": "duration_milliseconds",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "duration_milliseconds",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
78b35c539f73de2fc49cf626475775de2f4b4934 | FoamyGuy/NeoTrellis-M4-CircuitPython-Music-Fun | wave_generator/tone_maker.py | [
"MIT"
] | Python | append_sinewave | <not_specific> | def append_sinewave(
freq=440.0,
duration_milliseconds=500,
volume=1.0):
"""
The sine wave generated here is the standard beep. If you want something
more aggresive you could try a square or saw tooth waveform. Though there
are some rather complicated issues with making high q... |
The sine wave generated here is the standard beep. If you want something
more aggresive you could try a square or saw tooth waveform. Though there
are some rather complicated issues with making high quality square and
sawtooth waves...
| The sine wave generated here is the standard beep. If you want something
more aggresive you could try a square or saw tooth waveform. Though there
are some rather complicated issues with making high quality square and
sawtooth waves | [
"The",
"sine",
"wave",
"generated",
"here",
"is",
"the",
"standard",
"beep",
".",
"If",
"you",
"want",
"something",
"more",
"aggresive",
"you",
"could",
"try",
"a",
"square",
"or",
"saw",
"tooth",
"waveform",
".",
"Though",
"there",
"are",
"some",
"rather"... | def append_sinewave(
freq=440.0,
duration_milliseconds=500,
volume=1.0):
global audio
num_samples = duration_milliseconds * (sample_rate / 1000.0)
for x in range(int(num_samples)):
audio.append(volume * math.sin(2 * math.pi * freq * (x / sample_rate)))
return | [
"def",
"append_sinewave",
"(",
"freq",
"=",
"440.0",
",",
"duration_milliseconds",
"=",
"500",
",",
"volume",
"=",
"1.0",
")",
":",
"global",
"audio",
"num_samples",
"=",
"duration_milliseconds",
"*",
"(",
"sample_rate",
"/",
"1000.0",
")",
"for",
"x",
"in",... | The sine wave generated here is the standard beep. | [
"The",
"sine",
"wave",
"generated",
"here",
"is",
"the",
"standard",
"beep",
"."
] | [
"\"\"\"\n The sine wave generated here is the standard beep. If you want something\n more aggresive you could try a square or saw tooth waveform. Though there\n are some rather complicated issues with making high quality square and\n sawtooth waves...\n \"\"\"",
"# using global variables isn't c... | [
{
"param": "freq",
"type": null
},
{
"param": "duration_milliseconds",
"type": null
},
{
"param": "volume",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "freq",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "duration_milliseconds",
"type": null,
"docstring": null,
"doc... |
8b71a65cfff8f6c445f47dded794e002a745a3e0 | speedyturkey/pystax | pystax/cli.py | [
"MIT"
] | Python | cfn_safe | <not_specific> | def cfn_safe(string):
"""
Cloudformation names consist of alphanumeric characters and dashes only.
"""
return re.sub(r"[\W_]", "-", string) |
Cloudformation names consist of alphanumeric characters and dashes only.
| Cloudformation names consist of alphanumeric characters and dashes only. | [
"Cloudformation",
"names",
"consist",
"of",
"alphanumeric",
"characters",
"and",
"dashes",
"only",
"."
] | def cfn_safe(string):
return re.sub(r"[\W_]", "-", string) | [
"def",
"cfn_safe",
"(",
"string",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r\"[\\W_]\"",
",",
"\"-\"",
",",
"string",
")"
] | Cloudformation names consist of alphanumeric characters and dashes only. | [
"Cloudformation",
"names",
"consist",
"of",
"alphanumeric",
"characters",
"and",
"dashes",
"only",
"."
] | [
"\"\"\"\n Cloudformation names consist of alphanumeric characters and dashes only.\n \"\"\""
] | [
{
"param": "string",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
22c5df299108b33ccf1cdc4251b514de335f9a80 | speedyturkey/pystax | pystax/stax.py | [
"MIT"
] | Python | stack_name_to_class_name | <not_specific> | def stack_name_to_class_name(stack_name):
"""
remove delimiters, camel case the stack name
"""
delimiters = ["_", "-"]
names = re.split("|".join(delimiters), stack_name)
return "".join([name.title() for name in names]) |
remove delimiters, camel case the stack name
| remove delimiters, camel case the stack name | [
"remove",
"delimiters",
"camel",
"case",
"the",
"stack",
"name"
] | def stack_name_to_class_name(stack_name):
delimiters = ["_", "-"]
names = re.split("|".join(delimiters), stack_name)
return "".join([name.title() for name in names]) | [
"def",
"stack_name_to_class_name",
"(",
"stack_name",
")",
":",
"delimiters",
"=",
"[",
"\"_\"",
",",
"\"-\"",
"]",
"names",
"=",
"re",
".",
"split",
"(",
"\"|\"",
".",
"join",
"(",
"delimiters",
")",
",",
"stack_name",
")",
"return",
"\"\"",
".",
"join"... | remove delimiters, camel case the stack name | [
"remove",
"delimiters",
"camel",
"case",
"the",
"stack",
"name"
] | [
"\"\"\"\n remove delimiters, camel case the stack name\n \"\"\""
] | [
{
"param": "stack_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stack_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
22c5df299108b33ccf1cdc4251b514de335f9a80 | speedyturkey/pystax | pystax/stax.py | [
"MIT"
] | Python | add_stack | null | def add_stack(stack_name, opts=None):
"""
add a stack by name, creates class as needed
"""
if opts is None:
opts = {}
stack_list.append(stack_name)
class_name = stack_name_to_class_name(stack_name)
stack_class = locals().get(class_name)
if not stack_class:
stack_class = S... |
add a stack by name, creates class as needed
| add a stack by name, creates class as needed | [
"add",
"a",
"stack",
"by",
"name",
"creates",
"class",
"as",
"needed"
] | def add_stack(stack_name, opts=None):
if opts is None:
opts = {}
stack_list.append(stack_name)
class_name = stack_name_to_class_name(stack_name)
stack_class = locals().get(class_name)
if not stack_class:
stack_class = Stack(stack_name)
stack_command = stack_command_factory(stack_... | [
"def",
"add_stack",
"(",
"stack_name",
",",
"opts",
"=",
"None",
")",
":",
"if",
"opts",
"is",
"None",
":",
"opts",
"=",
"{",
"}",
"stack_list",
".",
"append",
"(",
"stack_name",
")",
"class_name",
"=",
"stack_name_to_class_name",
"(",
"stack_name",
")",
... | add a stack by name, creates class as needed | [
"add",
"a",
"stack",
"by",
"name",
"creates",
"class",
"as",
"needed"
] | [
"\"\"\"\n add a stack by name, creates class as needed\n \"\"\"",
"# TODO include mixin stuff here",
"# TODO imports, type, groups (whatever those are)"
] | [
{
"param": "stack_name",
"type": null
},
{
"param": "opts",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stack_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": null,
"docstring": null,
"docstring_toke... |
22c5df299108b33ccf1cdc4251b514de335f9a80 | speedyturkey/pystax | pystax/stax.py | [
"MIT"
] | Python | find_or_create_stack | <not_specific> | def find_or_create_stack(stack_name):
"""
stax calls this variable `id` but it seems to be the stack name
"""
class_name = stack_name_to_class_name(stack_name)
stack_class = locals().get(class_name)
if not stack_class:
stack_class = Stack(stack_name)
return stack_class |
stax calls this variable `id` but it seems to be the stack name
| stax calls this variable `id` but it seems to be the stack name | [
"stax",
"calls",
"this",
"variable",
"`",
"id",
"`",
"but",
"it",
"seems",
"to",
"be",
"the",
"stack",
"name"
] | def find_or_create_stack(stack_name):
class_name = stack_name_to_class_name(stack_name)
stack_class = locals().get(class_name)
if not stack_class:
stack_class = Stack(stack_name)
return stack_class | [
"def",
"find_or_create_stack",
"(",
"stack_name",
")",
":",
"class_name",
"=",
"stack_name_to_class_name",
"(",
"stack_name",
")",
"stack_class",
"=",
"locals",
"(",
")",
".",
"get",
"(",
"class_name",
")",
"if",
"not",
"stack_class",
":",
"stack_class",
"=",
... | stax calls this variable `id` but it seems to be the stack name | [
"stax",
"calls",
"this",
"variable",
"`",
"id",
"`",
"but",
"it",
"seems",
"to",
"be",
"the",
"stack",
"name"
] | [
"\"\"\"\n stax calls this variable `id` but it seems to be the stack name\n \"\"\""
] | [
{
"param": "stack_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stack_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea4c6d409875583f0aceb3420b1ea04e7a100c9a | alatiera/Ellinofreneia-crawler | src/crawler.py | [
"MIT"
] | Python | dl | null | def dl(contenturl, opt):
"""Takes url as content location and opt as youtube_dl options"""
with youtube_dl.YoutubeDL(opt) as ydl:
try:
print('downloading from: {}'.format(contenturl))
ydl.download([contenturl])
except youtube_dl.DownloadError:
# youtube_dl 404... | Takes url as content location and opt as youtube_dl options | Takes url as content location and opt as youtube_dl options | [
"Takes",
"url",
"as",
"content",
"location",
"and",
"opt",
"as",
"youtube_dl",
"options"
] | def dl(contenturl, opt):
with youtube_dl.YoutubeDL(opt) as ydl:
try:
print('downloading from: {}'.format(contenturl))
ydl.download([contenturl])
except youtube_dl.DownloadError:
print('\nDownload Error\n')
except KeyboardInterrupt:
print('\nCan... | [
"def",
"dl",
"(",
"contenturl",
",",
"opt",
")",
":",
"with",
"youtube_dl",
".",
"YoutubeDL",
"(",
"opt",
")",
"as",
"ydl",
":",
"try",
":",
"print",
"(",
"'downloading from: {}'",
".",
"format",
"(",
"contenturl",
")",
")",
"ydl",
".",
"download",
"("... | Takes url as content location and opt as youtube_dl options | [
"Takes",
"url",
"as",
"content",
"location",
"and",
"opt",
"as",
"youtube_dl",
"options"
] | [
"\"\"\"Takes url as content location and opt as youtube_dl options\"\"\"",
"# youtube_dl 404 error"
] | [
{
"param": "contenturl",
"type": null
},
{
"param": "opt",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "contenturl",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opt",
"type": null,
"docstring": null,
"docstring_token... |
ea4c6d409875583f0aceb3420b1ea04e7a100c9a | alatiera/Ellinofreneia-crawler | src/crawler.py | [
"MIT"
] | Python | multidl | null | def multidl(list):
"""iterates a list of urls and passes them to dl()"""
for i in list:
# figure what dl options to use
if re.search('video', i):
# yt_dl defaults to what it wants with empty {}
ydl_opts = {}
dl(getTVEpisode(i), ydl_opts)
else:
... | iterates a list of urls and passes them to dl() | iterates a list of urls and passes them to dl() | [
"iterates",
"a",
"list",
"of",
"urls",
"and",
"passes",
"them",
"to",
"dl",
"()"
] | def multidl(list):
for i in list:
if re.search('video', i):
ydl_opts = {}
dl(getTVEpisode(i), ydl_opts)
else:
dl(i, ytdl.config_existance()) | [
"def",
"multidl",
"(",
"list",
")",
":",
"for",
"i",
"in",
"list",
":",
"if",
"re",
".",
"search",
"(",
"'video'",
",",
"i",
")",
":",
"ydl_opts",
"=",
"{",
"}",
"dl",
"(",
"getTVEpisode",
"(",
"i",
")",
",",
"ydl_opts",
")",
"else",
":",
"dl",... | iterates a list of urls and passes them to dl() | [
"iterates",
"a",
"list",
"of",
"urls",
"and",
"passes",
"them",
"to",
"dl",
"()"
] | [
"\"\"\"iterates a list of urls and passes them to dl()\"\"\"",
"# figure what dl options to use",
"# yt_dl defaults to what it wants with empty {}"
] | [
{
"param": "list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea4c6d409875583f0aceb3420b1ea04e7a100c9a | alatiera/Ellinofreneia-crawler | src/crawler.py | [
"MIT"
] | Python | backlog | <not_specific> | def backlog(stype, count):
"""Points to diff backlogs to fetch"""
print('Fetching backlog...')
if stype == 'radio':
getRadioShow(radiourl + radioargs + str(count))
count += 11
return count
elif stype == 'tv':
getTVShow(tvurl + tvargs + str(count))
count += 21
... | Points to diff backlogs to fetch | Points to diff backlogs to fetch | [
"Points",
"to",
"diff",
"backlogs",
"to",
"fetch"
] | def backlog(stype, count):
print('Fetching backlog...')
if stype == 'radio':
getRadioShow(radiourl + radioargs + str(count))
count += 11
return count
elif stype == 'tv':
getTVShow(tvurl + tvargs + str(count))
count += 21
return count
else:
print('u... | [
"def",
"backlog",
"(",
"stype",
",",
"count",
")",
":",
"print",
"(",
"'Fetching backlog...'",
")",
"if",
"stype",
"==",
"'radio'",
":",
"getRadioShow",
"(",
"radiourl",
"+",
"radioargs",
"+",
"str",
"(",
"count",
")",
")",
"count",
"+=",
"11",
"return",... | Points to diff backlogs to fetch | [
"Points",
"to",
"diff",
"backlogs",
"to",
"fetch"
] | [
"\"\"\"Points to diff backlogs to fetch\"\"\""
] | [
{
"param": "stype",
"type": null
},
{
"param": "count",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stype",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": null,
"docstring": null,
"docstring_tokens":... |
ea4c6d409875583f0aceb3420b1ea04e7a100c9a | alatiera/Ellinofreneia-crawler | src/crawler.py | [
"MIT"
] | Python | showlimit | <not_specific> | def showlimit(stype):
"""Passes the page and the type to limit() """
if stype == 'radio':
page = requests.get(radiourl)
return limit(page.text)
elif stype == 'tv':
page = requests.get(tvurl)
return limit(page.text) | Passes the page and the type to limit() | Passes the page and the type to limit() | [
"Passes",
"the",
"page",
"and",
"the",
"type",
"to",
"limit",
"()"
] | def showlimit(stype):
if stype == 'radio':
page = requests.get(radiourl)
return limit(page.text)
elif stype == 'tv':
page = requests.get(tvurl)
return limit(page.text) | [
"def",
"showlimit",
"(",
"stype",
")",
":",
"if",
"stype",
"==",
"'radio'",
":",
"page",
"=",
"requests",
".",
"get",
"(",
"radiourl",
")",
"return",
"limit",
"(",
"page",
".",
"text",
")",
"elif",
"stype",
"==",
"'tv'",
":",
"page",
"=",
"requests",... | Passes the page and the type to limit() | [
"Passes",
"the",
"page",
"and",
"the",
"type",
"to",
"limit",
"()"
] | [
"\"\"\"Passes the page and the type to limit() \"\"\""
] | [
{
"param": "stype",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stype",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56d9e1a8f381f84ab8bbc18d446fb8686eae1d54 | lvarin/ega-download-client | pyega3/libs/utils.py | [
"Apache-2.0"
] | Python | verify_output_dir | <not_specific> | def verify_output_dir(output_dir):
"""
Checks whether the directory, specified by the "output_dir" parameter,
exists or not. If "output_dir" points to a non-existent directory,
then a NotADirectoryError exception is thrown, otherwise the absolute path
of that directory is returned.
"""
absol... |
Checks whether the directory, specified by the "output_dir" parameter,
exists or not. If "output_dir" points to a non-existent directory,
then a NotADirectoryError exception is thrown, otherwise the absolute path
of that directory is returned.
| Checks whether the directory, specified by the "output_dir" parameter,
exists or not. If "output_dir" points to a non-existent directory,
then a NotADirectoryError exception is thrown, otherwise the absolute path
of that directory is returned. | [
"Checks",
"whether",
"the",
"directory",
"specified",
"by",
"the",
"\"",
"output_dir",
"\"",
"parameter",
"exists",
"or",
"not",
".",
"If",
"\"",
"output_dir",
"\"",
"points",
"to",
"a",
"non",
"-",
"existent",
"directory",
"then",
"a",
"NotADirectoryError",
... | def verify_output_dir(output_dir):
absolut_path_of_output_dir = os.path.abspath(output_dir)
if os.path.isdir(absolut_path_of_output_dir):
return absolut_path_of_output_dir
else:
raise NotADirectoryError(f'The "{output_dir}" directory, which was specified by the --output-dir '
... | [
"def",
"verify_output_dir",
"(",
"output_dir",
")",
":",
"absolut_path_of_output_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"output_dir",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"absolut_path_of_output_dir",
")",
":",
"return",
"absolut_path_of_... | Checks whether the directory, specified by the "output_dir" parameter,
exists or not. | [
"Checks",
"whether",
"the",
"directory",
"specified",
"by",
"the",
"\"",
"output_dir",
"\"",
"parameter",
"exists",
"or",
"not",
"."
] | [
"\"\"\"\n Checks whether the directory, specified by the \"output_dir\" parameter,\n exists or not. If \"output_dir\" points to a non-existent directory,\n then a NotADirectoryError exception is thrown, otherwise the absolute path\n of that directory is returned.\n \"\"\""
] | [
{
"param": "output_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "output_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d0be81878d9325ee6d85604916110d7cfd600a | lvarin/ega-download-client | pyega3/libs/server_config.py | [
"Apache-2.0"
] | Python | from_file | <not_specific> | def from_file(filepath):
"""Load server config for EMBL/EBI EGA from specified file"""
filepath = os.path.expanduser(filepath)
if not os.path.exists(filepath):
logging.error(f"{filepath} does not exist")
sys.exit()
try:
with open(filepath) as f:
... | Load server config for EMBL/EBI EGA from specified file | Load server config for EMBL/EBI EGA from specified file | [
"Load",
"server",
"config",
"for",
"EMBL",
"/",
"EBI",
"EGA",
"from",
"specified",
"file"
] | def from_file(filepath):
filepath = os.path.expanduser(filepath)
if not os.path.exists(filepath):
logging.error(f"{filepath} does not exist")
sys.exit()
try:
with open(filepath) as f:
custom_server_config = json.load(f)
def check_ke... | [
"def",
"from_file",
"(",
"filepath",
")",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filepath",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"logging",
".",
"error",
"(",
"f\"{filepath} does not ex... | Load server config for EMBL/EBI EGA from specified file | [
"Load",
"server",
"config",
"for",
"EMBL",
"/",
"EBI",
"EGA",
"from",
"specified",
"file"
] | [
"\"\"\"Load server config for EMBL/EBI EGA from specified file\"\"\""
] | [
{
"param": "filepath",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b1280637c8e143c805a9c7aae9e9e3ee63e3a58a | lvarin/ega-download-client | test/conftest.py | [
"Apache-2.0"
] | Python | temporary_output_file | <not_specific> | def temporary_output_file():
"""Returns a file-path to a random, temporary file-name."""
_, output_file_path = tempfile.mkstemp()
os.remove(output_file_path)
return output_file_path | Returns a file-path to a random, temporary file-name. | Returns a file-path to a random, temporary file-name. | [
"Returns",
"a",
"file",
"-",
"path",
"to",
"a",
"random",
"temporary",
"file",
"-",
"name",
"."
] | def temporary_output_file():
_, output_file_path = tempfile.mkstemp()
os.remove(output_file_path)
return output_file_path | [
"def",
"temporary_output_file",
"(",
")",
":",
"_",
",",
"output_file_path",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"os",
".",
"remove",
"(",
"output_file_path",
")",
"return",
"output_file_path"
] | Returns a file-path to a random, temporary file-name. | [
"Returns",
"a",
"file",
"-",
"path",
"to",
"a",
"random",
"temporary",
"file",
"-",
"name",
"."
] | [
"\"\"\"Returns a file-path to a random, temporary file-name.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f2bf17325c42535dedb3ff1bb3fa10a631d4c3e2 | lvarin/ega-download-client | pyega3/libs/credentials.py | [
"Apache-2.0"
] | Python | from_file | <not_specific> | def from_file(filepath):
"""Load credentials for EMBL/EBI EGA from specified file"""
result = Credentials()
filepath = os.path.expanduser(filepath)
if not os.path.exists(filepath):
logging.error(f"{filepath} does not exist")
else:
try:
with... | Load credentials for EMBL/EBI EGA from specified file | Load credentials for EMBL/EBI EGA from specified file | [
"Load",
"credentials",
"for",
"EMBL",
"/",
"EBI",
"EGA",
"from",
"specified",
"file"
] | def from_file(filepath):
result = Credentials()
filepath = os.path.expanduser(filepath)
if not os.path.exists(filepath):
logging.error(f"{filepath} does not exist")
else:
try:
with open(filepath) as f:
cfg = json.load(f)
... | [
"def",
"from_file",
"(",
"filepath",
")",
":",
"result",
"=",
"Credentials",
"(",
")",
"filepath",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filepath",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"logging",
"... | Load credentials for EMBL/EBI EGA from specified file | [
"Load",
"credentials",
"for",
"EMBL",
"/",
"EBI",
"EGA",
"from",
"specified",
"file"
] | [
"\"\"\"Load credentials for EMBL/EBI EGA from specified file\"\"\""
] | [
{
"param": "filepath",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
30d59fff463be0e80789724355ef0d4f3e6f0a78 | lvarin/ega-download-client | pyega3/libs/data_set.py | [
"Apache-2.0"
] | Python | list_authorized_datasets | <not_specific> | def list_authorized_datasets(data_client):
"""List datasets to which the credentialed user has authorized access"""
reply = data_client.get_json("/metadata/datasets")
if reply is None:
logging.error(
"You do not currently have access to any datasets at EGA according... | List datasets to which the credentialed user has authorized access | List datasets to which the credentialed user has authorized access | [
"List",
"datasets",
"to",
"which",
"the",
"credentialed",
"user",
"has",
"authorized",
"access"
] | def list_authorized_datasets(data_client):
reply = data_client.get_json("/metadata/datasets")
if reply is None:
logging.error(
"You do not currently have access to any datasets at EGA according to our databases."
" If you believe you should have access please ... | [
"def",
"list_authorized_datasets",
"(",
"data_client",
")",
":",
"reply",
"=",
"data_client",
".",
"get_json",
"(",
"\"/metadata/datasets\"",
")",
"if",
"reply",
"is",
"None",
":",
"logging",
".",
"error",
"(",
"\"You do not currently have access to any datasets at EGA ... | List datasets to which the credentialed user has authorized access | [
"List",
"datasets",
"to",
"which",
"the",
"credentialed",
"user",
"has",
"authorized",
"access"
] | [
"\"\"\"List datasets to which the credentialed user has authorized access\"\"\""
] | [
{
"param": "data_client",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_client",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a1699e80908556d961657b25e172df36d0e454dd | lvarin/ega-download-client | test/test_delete_temporary_files.py | [
"Apache-2.0"
] | Python | download_with_exception | null | def download_with_exception(mock_requests, output_file_path, mock_server_config, file):
"""
Simulates downloading a file of the given size: "true_file_size".
During the transfer, an exception happens and the temporary file is either deleted
or kept, depending on the TEMPORARY_FILES_SHOULD_BE_DELETED fla... |
Simulates downloading a file of the given size: "true_file_size".
During the transfer, an exception happens and the temporary file is either deleted
or kept, depending on the TEMPORARY_FILES_SHOULD_BE_DELETED flag.
| Simulates downloading a file of the given size: "true_file_size".
During the transfer, an exception happens and the temporary file is either deleted
or kept, depending on the TEMPORARY_FILES_SHOULD_BE_DELETED flag. | [
"Simulates",
"downloading",
"a",
"file",
"of",
"the",
"given",
"size",
":",
"\"",
"true_file_size",
"\"",
".",
"During",
"the",
"transfer",
"an",
"exception",
"happens",
"and",
"the",
"temporary",
"file",
"is",
"either",
"deleted",
"or",
"kept",
"depending",
... | def download_with_exception(mock_requests, output_file_path, mock_server_config, file):
number_of_retries = 2
not_enough_bytes = int(expected_file_size / 3 - 1000)
content = bytearray(os.urandom(not_enough_bytes))
output_dir = os.path.dirname(output_file_path)
mock_requests.add(responses.GET, f'{moc... | [
"def",
"download_with_exception",
"(",
"mock_requests",
",",
"output_file_path",
",",
"mock_server_config",
",",
"file",
")",
":",
"number_of_retries",
"=",
"2",
"not_enough_bytes",
"=",
"int",
"(",
"expected_file_size",
"/",
"3",
"-",
"1000",
")",
"content",
"=",... | Simulates downloading a file of the given size: "true_file_size". | [
"Simulates",
"downloading",
"a",
"file",
"of",
"the",
"given",
"size",
":",
"\"",
"true_file_size",
"\"",
"."
] | [
"\"\"\"\n Simulates downloading a file of the given size: \"true_file_size\".\n During the transfer, an exception happens and the temporary file is either deleted\n or kept, depending on the TEMPORARY_FILES_SHOULD_BE_DELETED flag.\n \"\"\"",
"# First, normal GET request:",
"# Then all the retry atte... | [
{
"param": "mock_requests",
"type": null
},
{
"param": "output_file_path",
"type": null
},
{
"param": "mock_server_config",
"type": null
},
{
"param": "file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mock_requests",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_file_path",
"type": null,
"docstring": null,
... |
dfc905f14e72fa6a8406da33e0fdf64552dbfd65 | ooknosi/finite_dino_bot | src/finite_dino_bot.py | [
"Apache-2.0"
] | Python | retrieve_definition | <not_specific> | def retrieve_definition(query):
"""Retrieve and extract first set of word definitions.
Returns
-------
dict
defintion, query_url, word_class, word
"""
print('Looking up "{}"...'.format(query))
query_url = FiniteDinoBot.DEFINE_URL + query.replace(' ',... | Retrieve and extract first set of word definitions.
Returns
-------
dict
defintion, query_url, word_class, word
| Retrieve and extract first set of word definitions.
Returns
| [
"Retrieve",
"and",
"extract",
"first",
"set",
"of",
"word",
"definitions",
".",
"Returns"
] | def retrieve_definition(query):
print('Looking up "{}"...'.format(query))
query_url = FiniteDinoBot.DEFINE_URL + query.replace(' ', '_')
url_request = urllib.request.Request(
query_url,
headers={'User-Agent': (
'Mozilla/5.0 (Linux x86_64)'
... | [
"def",
"retrieve_definition",
"(",
"query",
")",
":",
"print",
"(",
"'Looking up \"{}\"...'",
".",
"format",
"(",
"query",
")",
")",
"query_url",
"=",
"FiniteDinoBot",
".",
"DEFINE_URL",
"+",
"query",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"url_request... | Retrieve and extract first set of word definitions. | [
"Retrieve",
"and",
"extract",
"first",
"set",
"of",
"word",
"definitions",
"."
] | [
"\"\"\"Retrieve and extract first set of word definitions.\n\n Returns\n -------\n dict\n defintion, query_url, word_class, word\n \"\"\""
] | [
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | authenticate | <not_specific> | def authenticate(self, max_attempts=-1, seconds_between_attempts=60):
"""Authenticates SITE_NAME with Reddit.
Sets self.reddit and self.username on success.
Parameters
----------
max_attempts : int, optional
Maximum number of authentication attempts before failure.
... | Authenticates SITE_NAME with Reddit.
Sets self.reddit and self.username on success.
Parameters
----------
max_attempts : int, optional
Maximum number of authentication attempts before failure.
Defaults to -1 (infinite attempts).
seconds_between_attempts :... | Authenticates SITE_NAME with Reddit.
Parameters
max_attempts : int, optional
Maximum number of authentication attempts before failure.
Defaults to -1 (infinite attempts).
seconds_between_attempts : int, optional
Seconds to wait between authentication attempts.
Defaults to 60. | [
"Authenticates",
"SITE_NAME",
"with",
"Reddit",
".",
"Parameters",
"max_attempts",
":",
"int",
"optional",
"Maximum",
"number",
"of",
"authentication",
"attempts",
"before",
"failure",
".",
"Defaults",
"to",
"-",
"1",
"(",
"infinite",
"attempts",
")",
".",
"seco... | def authenticate(self, max_attempts=-1, seconds_between_attempts=60):
attempt = 0
while attempt != max_attempts:
try:
print("Authenticating as {}...".format(self.site_name))
self.reddit = praw.Reddit(self.site_name)
self.username = self.reddit.... | [
"def",
"authenticate",
"(",
"self",
",",
"max_attempts",
"=",
"-",
"1",
",",
"seconds_between_attempts",
"=",
"60",
")",
":",
"attempt",
"=",
"0",
"while",
"attempt",
"!=",
"max_attempts",
":",
"try",
":",
"print",
"(",
"\"Authenticating as {}...\"",
".",
"f... | Authenticates SITE_NAME with Reddit. | [
"Authenticates",
"SITE_NAME",
"with",
"Reddit",
"."
] | [
"\"\"\"Authenticates SITE_NAME with Reddit.\n Sets self.reddit and self.username on success.\n\n Parameters\n ----------\n max_attempts : int, optional\n Maximum number of authentication attempts before failure.\n Defaults to -1 (infinite attempts).\n seconds... | [
{
"param": "self",
"type": null
},
{
"param": "max_attempts",
"type": null
},
{
"param": "seconds_between_attempts",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_attempts",
"type": null,
"docstring": null,
"docstring_to... |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | retrieve_comments | null | def retrieve_comments(self):
"""Retrieves comments from subreddits, filters for keyword trigger, and
excludes processed comments.
Returns
-------
generator
Dict of reddit.Comment and query.
"""
try:
print("Retrieving {} comments...".forma... | Retrieves comments from subreddits, filters for keyword trigger, and
excludes processed comments.
Returns
-------
generator
Dict of reddit.Comment and query.
| Retrieves comments from subreddits, filters for keyword trigger, and
excludes processed comments.
Returns
generator
Dict of reddit.Comment and query. | [
"Retrieves",
"comments",
"from",
"subreddits",
"filters",
"for",
"keyword",
"trigger",
"and",
"excludes",
"processed",
"comments",
".",
"Returns",
"generator",
"Dict",
"of",
"reddit",
".",
"Comment",
"and",
"query",
"."
] | def retrieve_comments(self):
try:
print("Retrieving {} comments...".format(self.retrieval_limit))
comments = self.reddit.subreddit(self.subreddits).comments(
limit=self.retrieval_limit
)
for comment in comments:
if (comment.auth... | [
"def",
"retrieve_comments",
"(",
"self",
")",
":",
"try",
":",
"print",
"(",
"\"Retrieving {} comments...\"",
".",
"format",
"(",
"self",
".",
"retrieval_limit",
")",
")",
"comments",
"=",
"self",
".",
"reddit",
".",
"subreddit",
"(",
"self",
".",
"subreddit... | Retrieves comments from subreddits, filters for keyword trigger, and
excludes processed comments. | [
"Retrieves",
"comments",
"from",
"subreddits",
"filters",
"for",
"keyword",
"trigger",
"and",
"excludes",
"processed",
"comments",
"."
] | [
"\"\"\"Retrieves comments from subreddits, filters for keyword trigger, and\n excludes processed comments.\n\n Returns\n -------\n generator\n Dict of reddit.Comment and query.\n\n \"\"\"",
"#and not self.has_already_replied(comment)",
"#and not self.is_summon_chain... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | submit_comment | <not_specific> | def submit_comment(self, target, comment):
"""Submit comment to target submission or comment.
Parameters
----------
target : reddit.submission object or reddit.comment object
Target Reddit submission or comment.
comment : str
Comment to post.
Ret... | Submit comment to target submission or comment.
Parameters
----------
target : reddit.submission object or reddit.comment object
Target Reddit submission or comment.
comment : str
Comment to post.
Returns
-------
object
reddit... | Submit comment to target submission or comment.
Parameters
target : reddit.submission object or reddit.comment object
Target Reddit submission or comment.
comment : str
Comment to post.
Returns
object
reddit.comment of newly created comment. | [
"Submit",
"comment",
"to",
"target",
"submission",
"or",
"comment",
".",
"Parameters",
"target",
":",
"reddit",
".",
"submission",
"object",
"or",
"reddit",
".",
"comment",
"object",
"Target",
"Reddit",
"submission",
"or",
"comment",
".",
"comment",
":",
"str"... | def submit_comment(self, target, comment):
try:
if target.author != self.username:
print("Posting reply...")
return target.reply(comment)
except praw.exceptions.APIException as error:
print("API Error:", error)
raise | [
"def",
"submit_comment",
"(",
"self",
",",
"target",
",",
"comment",
")",
":",
"try",
":",
"if",
"target",
".",
"author",
"!=",
"self",
".",
"username",
":",
"print",
"(",
"\"Posting reply...\"",
")",
"return",
"target",
".",
"reply",
"(",
"comment",
")"... | Submit comment to target submission or comment. | [
"Submit",
"comment",
"to",
"target",
"submission",
"or",
"comment",
"."
] | [
"\"\"\"Submit comment to target submission or comment.\n\n Parameters\n ----------\n target : reddit.submission object or reddit.comment object\n Target Reddit submission or comment.\n comment : str\n Comment to post.\n\n Returns\n -------\n obj... | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "comment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | write_cache | null | def write_cache(file, mem_cache):
"""Writes list into file, converting list to \n separated contents.
Overwrites original cache file.
Creates cache file if does not exist.
Parameters
----------
file : str
Location of cache file.
mem_cache : list or de... | Writes list into file, converting list to \n separated contents.
Overwrites original cache file.
Creates cache file if does not exist.
Parameters
----------
file : str
Location of cache file.
mem_cache : list or deque
Items in memory cache
... | Writes list into file, converting list to \n separated contents.
Overwrites original cache file.
Creates cache file if does not exist.
Parameters
file : str
Location of cache file.
mem_cache : list or deque
Items in memory cache | [
"Writes",
"list",
"into",
"file",
"converting",
"list",
"to",
"\\",
"n",
"separated",
"contents",
".",
"Overwrites",
"original",
"cache",
"file",
".",
"Creates",
"cache",
"file",
"if",
"does",
"not",
"exist",
".",
"Parameters",
"file",
":",
"str",
"Location"... | def write_cache(file, mem_cache):
try:
print("Saving memory into cache file...")
with open(file, 'w') as cache_file:
try:
cache_file.write(mem_cache.popleft())
for entry in mem_cache:
cache_file.write('\n'+en... | [
"def",
"write_cache",
"(",
"file",
",",
"mem_cache",
")",
":",
"try",
":",
"print",
"(",
"\"Saving memory into cache file...\"",
")",
"with",
"open",
"(",
"file",
",",
"'w'",
")",
"as",
"cache_file",
":",
"try",
":",
"cache_file",
".",
"write",
"(",
"mem_c... | Writes list into file, converting list to \n separated contents. | [
"Writes",
"list",
"into",
"file",
"converting",
"list",
"to",
"\\",
"n",
"separated",
"contents",
"."
] | [
"\"\"\"Writes list into file, converting list to \\n separated contents.\n Overwrites original cache file.\n Creates cache file if does not exist.\n\n Parameters\n ----------\n file : str\n Location of cache file.\n mem_cache : list or deque\n Items in... | [
{
"param": "file",
"type": null
},
{
"param": "mem_cache",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mem_cache",
"type": null,
"docstring": null,
"docstring_token... |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | bot_exit | null | def bot_exit(self, *args, **kwargs):
"""Saves self.processed_comments into cache file before exiting."""
# pylint: disable=unused-argument
print("\nStopping bot...")
self.write_cache(CACHE_FILE, self.processed_comments)
print("Bot stopped")
sys.exit() | Saves self.processed_comments into cache file before exiting. | Saves self.processed_comments into cache file before exiting. | [
"Saves",
"self",
".",
"processed_comments",
"into",
"cache",
"file",
"before",
"exiting",
"."
] | def bot_exit(self, *args, **kwargs):
print("\nStopping bot...")
self.write_cache(CACHE_FILE, self.processed_comments)
print("Bot stopped")
sys.exit() | [
"def",
"bot_exit",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"print",
"(",
"\"\\nStopping bot...\"",
")",
"self",
".",
"write_cache",
"(",
"CACHE_FILE",
",",
"self",
".",
"processed_comments",
")",
"print",
"(",
"\"Bot stopped\"",
")",
... | Saves self.processed_comments into cache file before exiting. | [
"Saves",
"self",
".",
"processed_comments",
"into",
"cache",
"file",
"before",
"exiting",
"."
] | [
"\"\"\"Saves self.processed_comments into cache file before exiting.\"\"\"",
"# pylint: disable=unused-argument"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | is_summon_chain | <not_specific> | def is_summon_chain(self, target):
"""Checks if parent comment of target is from self.
Used to prevent infinite reply loop caused by another bot.
Parameters
----------
target : reddit.comment object
Target Reddit comment.
Returns
-------
bool... | Checks if parent comment of target is from self.
Used to prevent infinite reply loop caused by another bot.
Parameters
----------
target : reddit.comment object
Target Reddit comment.
Returns
-------
bool
True if parent comment of target ... | Checks if parent comment of target is from self.
Used to prevent infinite reply loop caused by another bot.
Parameters
target : reddit.comment object
Target Reddit comment.
Returns
bool
True if parent comment of target is from bot. False otherwise. | [
"Checks",
"if",
"parent",
"comment",
"of",
"target",
"is",
"from",
"self",
".",
"Used",
"to",
"prevent",
"infinite",
"reply",
"loop",
"caused",
"by",
"another",
"bot",
".",
"Parameters",
"target",
":",
"reddit",
".",
"comment",
"object",
"Target",
"Reddit",
... | def is_summon_chain(self, target):
return True if (
not target.is_root and target.parent().author == self.username
) else False | [
"def",
"is_summon_chain",
"(",
"self",
",",
"target",
")",
":",
"return",
"True",
"if",
"(",
"not",
"target",
".",
"is_root",
"and",
"target",
".",
"parent",
"(",
")",
".",
"author",
"==",
"self",
".",
"username",
")",
"else",
"False"
] | Checks if parent comment of target is from self. | [
"Checks",
"if",
"parent",
"comment",
"of",
"target",
"is",
"from",
"self",
"."
] | [
"\"\"\"Checks if parent comment of target is from self.\n Used to prevent infinite reply loop caused by another bot.\n\n Parameters\n ----------\n target : reddit.comment object\n Target Reddit comment.\n\n Returns\n -------\n bool\n True if par... | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
32e936c1612851ed8d2da1d06d4bb7a9414f5d96 | ooknosi/finite_dino_bot | src/reddit_bot.py | [
"Apache-2.0"
] | Python | has_already_replied | <not_specific> | def has_already_replied(self, target):
"""Checks if target comment has already been replied by bot.
Used to prevent multiple replies to the same request.
Parameters
----------
target : reddit.comment object
Target Reddit comment.
Returns
-------
... | Checks if target comment has already been replied by bot.
Used to prevent multiple replies to the same request.
Parameters
----------
target : reddit.comment object
Target Reddit comment.
Returns
-------
bool
True if parent comment of tar... | Checks if target comment has already been replied by bot.
Used to prevent multiple replies to the same request.
Parameters
target : reddit.comment object
Target Reddit comment.
Returns
bool
True if parent comment of target is from bot. False otherwise. | [
"Checks",
"if",
"target",
"comment",
"has",
"already",
"been",
"replied",
"by",
"bot",
".",
"Used",
"to",
"prevent",
"multiple",
"replies",
"to",
"the",
"same",
"request",
".",
"Parameters",
"target",
":",
"reddit",
".",
"comment",
"object",
"Target",
"Reddi... | def has_already_replied(self, target):
try:
target.refresh()
for reply in target.replies.list():
if reply.author == self.username:
print("Comment already processed.")
return True
print("Processing comment...")
... | [
"def",
"has_already_replied",
"(",
"self",
",",
"target",
")",
":",
"try",
":",
"target",
".",
"refresh",
"(",
")",
"for",
"reply",
"in",
"target",
".",
"replies",
".",
"list",
"(",
")",
":",
"if",
"reply",
".",
"author",
"==",
"self",
".",
"username... | Checks if target comment has already been replied by bot. | [
"Checks",
"if",
"target",
"comment",
"has",
"already",
"been",
"replied",
"by",
"bot",
"."
] | [
"\"\"\"Checks if target comment has already been replied by bot.\n Used to prevent multiple replies to the same request.\n\n Parameters\n ----------\n target : reddit.comment object\n Target Reddit comment.\n\n Returns\n -------\n bool\n True if... | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
28893d1463ec2be812ee9b7ce874ed0813fb3941 | vishalbelsare/dora | dora/regressors/gp/train.py | [
"Apache-2.0"
] | Python | batch_start | <not_specific> | def batch_start(opt_config, initial_values):
"""
Sets initial values of the optimiser parameters
Returned as an OptConfig instance or a list of OptConfig instances
Arguments:
opt_config : An instance of OptConfig
initial_values : List or np.array of initial parameters values
R... |
Sets initial values of the optimiser parameters
Returned as an OptConfig instance or a list of OptConfig instances
Arguments:
opt_config : An instance of OptConfig
initial_values : List or np.array of initial parameters values
Returns:
batch_config : A OptConfig instan... | Sets initial values of the optimiser parameters
Returned as an OptConfig instance or a list of OptConfig instances | [
"Sets",
"initial",
"values",
"of",
"the",
"optimiser",
"parameters",
"Returned",
"as",
"an",
"OptConfig",
"instance",
"or",
"a",
"list",
"of",
"OptConfig",
"instances"
] | def batch_start(opt_config, initial_values):
if hasattr(initial_values[0], '__iter__'):
batch_config = []
for value in initial_values:
opt_config_copy = copy.deepcopy(opt_config)
opt_config_copy.sigma.initialVal = value
batch_config.append(opt_config_copy)
els... | [
"def",
"batch_start",
"(",
"opt_config",
",",
"initial_values",
")",
":",
"if",
"hasattr",
"(",
"initial_values",
"[",
"0",
"]",
",",
"'__iter__'",
")",
":",
"batch_config",
"=",
"[",
"]",
"for",
"value",
"in",
"initial_values",
":",
"opt_config_copy",
"=",
... | Sets initial values of the optimiser parameters
Returned as an OptConfig instance or a list of OptConfig instances | [
"Sets",
"initial",
"values",
"of",
"the",
"optimiser",
"parameters",
"Returned",
"as",
"an",
"OptConfig",
"instance",
"or",
"a",
"list",
"of",
"OptConfig",
"instances"
] | [
"\"\"\"\n Sets initial values of the optimiser parameters\n Returned as an OptConfig instance or a list of OptConfig instances\n\n Arguments:\n opt_config : An instance of OptConfig\n initial_values : List or np.array of initial parameters values\n Returns:\n batch_config :... | [
{
"param": "opt_config",
"type": null
},
{
"param": "initial_values",
"type": null
}
] | {
"returns": [
{
"docstring": "batch_config : A OptConfig instance or a list of OptConfig instances",
"docstring_tokens": [
"batch_config",
":",
"A",
"OptConfig",
"instance",
"or",
"a",
"list",
"of",
"OptConfig",
... |
d63c5bed1d70e8a85abab0ad1c1d056dd564e95d | vishalbelsare/dora | demos/example_processes.py | [
"Apache-2.0"
] | Python | simulate_measurement_vector | <not_specific> | def simulate_measurement_vector(X, uid=None):
"""
An example of a vector valued observation process.
The true model is two Gaussian blobs located at centre1 and centre2.
The model is queried with a 2-D location and returns an vector of length
output_len with values corresponding to the unde... |
An example of a vector valued observation process.
The true model is two Gaussian blobs located at centre1 and centre2.
The model is queried with a 2-D location and returns an vector of length
output_len with values corresponding to the underlying function's values
along a z-axis.
| An example of a vector valued observation process.
The true model is two Gaussian blobs located at centre1 and centre2.
The model is queried with a 2-D location and returns an vector of length
output_len with values corresponding to the underlying function's values
along a z-axis. | [
"An",
"example",
"of",
"a",
"vector",
"valued",
"observation",
"process",
".",
"The",
"true",
"model",
"is",
"two",
"Gaussian",
"blobs",
"located",
"at",
"centre1",
"and",
"centre2",
".",
"The",
"model",
"is",
"queried",
"with",
"a",
"2",
"-",
"D",
"loca... | def simulate_measurement_vector(X, uid=None):
assert X.shape == (2,)
measurement_range = [0, 1]
centre1 = np.array([1.5, 1.4, 0.3])
centre2 = np.array([2.50, 2.0, 0.7])
l1 = 0.2
l2 = 0.3
output_len = 20
Z = np.arange(measurement_range[0], measurement_range[1],
(measurem... | [
"def",
"simulate_measurement_vector",
"(",
"X",
",",
"uid",
"=",
"None",
")",
":",
"assert",
"X",
".",
"shape",
"==",
"(",
"2",
",",
")",
"measurement_range",
"=",
"[",
"0",
",",
"1",
"]",
"centre1",
"=",
"np",
".",
"array",
"(",
"[",
"1.5",
",",
... | An example of a vector valued observation process. | [
"An",
"example",
"of",
"a",
"vector",
"valued",
"observation",
"process",
"."
] | [
"\"\"\"\r\n An example of a vector valued observation process.\r\n\r\n The true model is two Gaussian blobs located at centre1 and centre2.\r\n\r\n The model is queried with a 2-D location and returns an vector of length\r\n output_len with values corresponding to the underlying function's values\r\n ... | [
{
"param": "X",
"type": null
},
{
"param": "uid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uid",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
14aded56809d32d8618dfdf6ecca7589d1d0d3be | vishalbelsare/dora | dora/active_sampling/utils.py | [
"Apache-2.0"
] | Python | shape | <not_specific> | def shape(self):
"""
The shape of the ArrayBuffer.
See Also
--------
numpy.ndarray.shape : Analogous Class Property
"""
return self.__value.shape |
The shape of the ArrayBuffer.
See Also
--------
numpy.ndarray.shape : Analogous Class Property
| The shape of the ArrayBuffer.
See Also
numpy.ndarray.shape : Analogous Class Property | [
"The",
"shape",
"of",
"the",
"ArrayBuffer",
".",
"See",
"Also",
"numpy",
".",
"ndarray",
".",
"shape",
":",
"Analogous",
"Class",
"Property"
] | def shape(self):
return self.__value.shape | [
"def",
"shape",
"(",
"self",
")",
":",
"return",
"self",
".",
"__value",
".",
"shape"
] | The shape of the ArrayBuffer. | [
"The",
"shape",
"of",
"the",
"ArrayBuffer",
"."
] | [
"\"\"\"\n The shape of the ArrayBuffer.\n\n See Also\n --------\n numpy.ndarray.shape : Analogous Class Property\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
14aded56809d32d8618dfdf6ecca7589d1d0d3be | vishalbelsare/dora | dora/active_sampling/utils.py | [
"Apache-2.0"
] | Python | ndim | <not_specific> | def ndim(self):
"""
The number of dimensions of the ArrayBuffer.
See Also
--------
numpy.ndarray.ndim : Analogous Class Property
"""
return self.__value.ndim |
The number of dimensions of the ArrayBuffer.
See Also
--------
numpy.ndarray.ndim : Analogous Class Property
| The number of dimensions of the ArrayBuffer.
See Also
numpy.ndarray.ndim : Analogous Class Property | [
"The",
"number",
"of",
"dimensions",
"of",
"the",
"ArrayBuffer",
".",
"See",
"Also",
"numpy",
".",
"ndarray",
".",
"ndim",
":",
"Analogous",
"Class",
"Property"
] | def ndim(self):
return self.__value.ndim | [
"def",
"ndim",
"(",
"self",
")",
":",
"return",
"self",
".",
"__value",
".",
"ndim"
] | The number of dimensions of the ArrayBuffer. | [
"The",
"number",
"of",
"dimensions",
"of",
"the",
"ArrayBuffer",
"."
] | [
"\"\"\"\n The number of dimensions of the ArrayBuffer.\n\n See Also\n --------\n numpy.ndarray.ndim : Analogous Class Property\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
14aded56809d32d8618dfdf6ecca7589d1d0d3be | vishalbelsare/dora | dora/active_sampling/utils.py | [
"Apache-2.0"
] | Python | append | null | def append(self, value):
"""
Add an array_like to the buffer.
This extending its first axis by adding a (1 x value.shape) row
onto the end.
Parameters
----------
value : array_like
A one dimensional array of length dims consistent with the buffer.
... |
Add an array_like to the buffer.
This extending its first axis by adding a (1 x value.shape) row
onto the end.
Parameters
----------
value : array_like
A one dimensional array of length dims consistent with the buffer.
| Add an array_like to the buffer.
This extending its first axis by adding a (1 x value.shape) row
onto the end.
Parameters
value : array_like
A one dimensional array of length dims consistent with the buffer. | [
"Add",
"an",
"array_like",
"to",
"the",
"buffer",
".",
"This",
"extending",
"its",
"first",
"axis",
"by",
"adding",
"a",
"(",
"1",
"x",
"value",
".",
"shape",
")",
"row",
"onto",
"the",
"end",
".",
"Parameters",
"value",
":",
"array_like",
"A",
"one",
... | def append(self, value):
value = np.asarray(value)
if self.__buffer is None:
newsize = (ArrayBuffer.initial_size,) + value.shape
self.__buffer = np.zeros(newsize, value.dtype)
assert(value.ndim == self.__buffer.ndim - 1)
assert(value.shape == self.__buffer.shape... | [
"def",
"append",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"np",
".",
"asarray",
"(",
"value",
")",
"if",
"self",
".",
"__buffer",
"is",
"None",
":",
"newsize",
"=",
"(",
"ArrayBuffer",
".",
"initial_size",
",",
")",
"+",
"value",
".",
"sh... | Add an array_like to the buffer. | [
"Add",
"an",
"array_like",
"to",
"the",
"buffer",
"."
] | [
"\"\"\"\n Add an array_like to the buffer.\n\n This extending its first axis by adding a (1 x value.shape) row\n onto the end.\n\n Parameters\n ----------\n value : array_like\n A one dimensional array of length dims consistent with the buffer.\n \"\"\"",
... | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c8dae308404aeefffef6bd12cf61dfe9244ca302 | vishalbelsare/dora | dora/active_sampling/delaunay_sampler.py | [
"Apache-2.0"
] | Python | update | <not_specific> | def update(self, uid, y_true):
"""
Update a job with its observed value.
Parameters
----------
uid : str
A hexadecimal ID that identifies the job to be updated
y_true : float
The observed value corresponding to the job identified by 'uid'
... |
Update a job with its observed value.
Parameters
----------
uid : str
A hexadecimal ID that identifies the job to be updated
y_true : float
The observed value corresponding to the job identified by 'uid'
Returns
-------
int
... | Update a job with its observed value.
Parameters
uid : str
A hexadecimal ID that identifies the job to be updated
y_true : float
The observed value corresponding to the job identified by 'uid'
Returns
int
Index location in the data lists 'Delaunay.X' and
'Delaunay.y' corresponding to the job being updated | [
"Update",
"a",
"job",
"with",
"its",
"observed",
"value",
".",
"Parameters",
"uid",
":",
"str",
"A",
"hexadecimal",
"ID",
"that",
"identifies",
"the",
"job",
"to",
"be",
"updated",
"y_true",
":",
"float",
"The",
"observed",
"value",
"corresponding",
"to",
... | def update(self, uid, y_true):
return self._update(uid, y_true) | [
"def",
"update",
"(",
"self",
",",
"uid",
",",
"y_true",
")",
":",
"return",
"self",
".",
"_update",
"(",
"uid",
",",
"y_true",
")"
] | Update a job with its observed value. | [
"Update",
"a",
"job",
"with",
"its",
"observed",
"value",
"."
] | [
"\"\"\"\n Update a job with its observed value.\n\n Parameters\n ----------\n uid : str\n A hexadecimal ID that identifies the job to be updated\n y_true : float\n The observed value corresponding to the job identified by 'uid'\n\n Returns\n ---... | [
{
"param": "self",
"type": null
},
{
"param": "uid",
"type": null
},
{
"param": "y_true",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uid",
"type": null,
"docstring": null,
"docstring_tokens": []... |
c8dae308404aeefffef6bd12cf61dfe9244ca302 | vishalbelsare/dora | dora/active_sampling/delaunay_sampler.py | [
"Apache-2.0"
] | Python | pick | <not_specific> | def pick(self):
"""
Pick the next feature location for the next observation to be taken.
This uses the recursive Delaunay subdivision algorithm.
Returns
-------
numpy.ndarray
Location in the parameter space for the next observation to be
taken
... |
Pick the next feature location for the next observation to be taken.
This uses the recursive Delaunay subdivision algorithm.
Returns
-------
numpy.ndarray
Location in the parameter space for the next observation to be
taken
str
A ran... | Pick the next feature location for the next observation to be taken.
This uses the recursive Delaunay subdivision algorithm.
Returns
numpy.ndarray
Location in the parameter space for the next observation to be
taken
str
A random hexadecimal ID to identify the corresponding job | [
"Pick",
"the",
"next",
"feature",
"location",
"for",
"the",
"next",
"observation",
"to",
"be",
"taken",
".",
"This",
"uses",
"the",
"recursive",
"Delaunay",
"subdivision",
"algorithm",
".",
"Returns",
"numpy",
".",
"ndarray",
"Location",
"in",
"the",
"paramete... | def pick(self):
n = len(self.X)
n_corners = 2 ** self.dims
if n < n_corners + 1:
xq = grid_sample(self.lower, self.upper, n)
yq_exp = [0.]
else:
X = self.X()
y = self.y()
virtual = self.virtual_flag()
if not self.t... | [
"def",
"pick",
"(",
"self",
")",
":",
"n",
"=",
"len",
"(",
"self",
".",
"X",
")",
"n_corners",
"=",
"2",
"**",
"self",
".",
"dims",
"if",
"n",
"<",
"n_corners",
"+",
"1",
":",
"xq",
"=",
"grid_sample",
"(",
"self",
".",
"lower",
",",
"self",
... | Pick the next feature location for the next observation to be taken. | [
"Pick",
"the",
"next",
"feature",
"location",
"for",
"the",
"next",
"observation",
"to",
"be",
"taken",
"."
] | [
"\"\"\"\n Pick the next feature location for the next observation to be taken.\n\n This uses the recursive Delaunay subdivision algorithm.\n\n Returns\n -------\n numpy.ndarray\n Location in the parameter space for the next observation to be\n taken\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8502b06fa79c07e0fec046c16ccbcc6dace3b04 | vishalbelsare/dora | dora/server/response.py | [
"Apache-2.0"
] | Python | returns_json | <not_specific> | def returns_json(f):
""" A decorator for Flask route handlers that return JSON.
Any route handler decorated by this function needs to return a pair
(dictionary, status code). The dictionary is automatically converted into
a JSON string. The status code is an integer. The content type of the
respons... | A decorator for Flask route handlers that return JSON.
Any route handler decorated by this function needs to return a pair
(dictionary, status code). The dictionary is automatically converted into
a JSON string. The status code is an integer. The content type of the
response is automatically set to JS... | A decorator for Flask route handlers that return JSON.
Any route handler decorated by this function needs to return a pair
(dictionary, status code). The dictionary is automatically converted into
a JSON string. The status code is an integer. The content type of the
response is automatically set to JSON. | [
"A",
"decorator",
"for",
"Flask",
"route",
"handlers",
"that",
"return",
"JSON",
".",
"Any",
"route",
"handler",
"decorated",
"by",
"this",
"function",
"needs",
"to",
"return",
"a",
"pair",
"(",
"dictionary",
"status",
"code",
")",
".",
"The",
"dictionary",
... | def returns_json(f):
@wraps(f)
def decorated_handler(*args, **kwargs):
r, status = f(*args, **kwargs)
return fl.Response(json.dumps(r, sort_keys=True), status,
content_type='application/json; charset=utf-8')
return decorated_handler | [
"def",
"returns_json",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated_handler",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"r",
",",
"status",
"=",
"f",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"return",
"fl",
".",
... | A decorator for Flask route handlers that return JSON. | [
"A",
"decorator",
"for",
"Flask",
"route",
"handlers",
"that",
"return",
"JSON",
"."
] | [
"\"\"\" A decorator for Flask route handlers that return JSON.\n\n Any route handler decorated by this function needs to return a pair\n (dictionary, status code). The dictionary is automatically converted into\n a JSON string. The status code is an integer. The content type of the\n response is automat... | [
{
"param": "f",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1819b31bc572d34cc69a5b9ce6132c3150364525 | vishalbelsare/dora | dora/regressors/gp/linalg.py | [
"Apache-2.0"
] | Python | jitchol | <not_specific> | def jitchol(X, overwrite_a = False, check_finite = True):
"""Add jitter until a positive definite matrix occurs"""
n = X.shape[0]
I = np.eye(n)
jitter = 1e-8
max_jitter = 1e10
L = None
X_dash = X
while jitter < max_jitter:
try:
L = la.cholesky(X_dash, lower = True, ... | Add jitter until a positive definite matrix occurs | Add jitter until a positive definite matrix occurs | [
"Add",
"jitter",
"until",
"a",
"positive",
"definite",
"matrix",
"occurs"
] | def jitchol(X, overwrite_a = False, check_finite = True):
n = X.shape[0]
I = np.eye(n)
jitter = 1e-8
max_jitter = 1e10
L = None
X_dash = X
while jitter < max_jitter:
try:
L = la.cholesky(X_dash, lower = True,
overwrite_a = overwrite_a, check_finite = chec... | [
"def",
"jitchol",
"(",
"X",
",",
"overwrite_a",
"=",
"False",
",",
"check_finite",
"=",
"True",
")",
":",
"n",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"I",
"=",
"np",
".",
"eye",
"(",
"n",
")",
"jitter",
"=",
"1e-8",
"max_jitter",
"=",
"1e10",
"... | Add jitter until a positive definite matrix occurs | [
"Add",
"jitter",
"until",
"a",
"positive",
"definite",
"matrix",
"occurs"
] | [
"\"\"\"Add jitter until a positive definite matrix occurs\"\"\""
] | [
{
"param": "X",
"type": null
},
{
"param": "overwrite_a",
"type": null
},
{
"param": "check_finite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "overwrite_a",
"type": null,
"docstring": null,
"docstring_tokens... |
1819b31bc572d34cc69a5b9ce6132c3150364525 | vishalbelsare/dora | dora/regressors/gp/linalg.py | [
"Apache-2.0"
] | Python | choleskyjitter | <not_specific> | def choleskyjitter(A, overwrite_a = False, check_finite = True):
"""Add jitter stochastically until a positive definite matrix occurs"""
# Avoid preparing for jittering if we can already find the cholesky
# with no problem
try:
return la.cholesky(A, lower = True, overwrite_a = overwrite_a,
... | Add jitter stochastically until a positive definite matrix occurs | Add jitter stochastically until a positive definite matrix occurs | [
"Add",
"jitter",
"stochastically",
"until",
"a",
"positive",
"definite",
"matrix",
"occurs"
] | def choleskyjitter(A, overwrite_a = False, check_finite = True):
try:
return la.cholesky(A, lower = True, overwrite_a = overwrite_a,
check_finite = check_finite)
except Exception:
pass
n = A.shape[0]
maxscale = 1e10
minscale = 1e-4
scale = minscale
while scal... | [
"def",
"choleskyjitter",
"(",
"A",
",",
"overwrite_a",
"=",
"False",
",",
"check_finite",
"=",
"True",
")",
":",
"try",
":",
"return",
"la",
".",
"cholesky",
"(",
"A",
",",
"lower",
"=",
"True",
",",
"overwrite_a",
"=",
"overwrite_a",
",",
"check_finite"... | Add jitter stochastically until a positive definite matrix occurs | [
"Add",
"jitter",
"stochastically",
"until",
"a",
"positive",
"definite",
"matrix",
"occurs"
] | [
"\"\"\"Add jitter stochastically until a positive definite matrix occurs\"\"\"",
"# Avoid preparing for jittering if we can already find the cholesky ",
"# with no problem",
"# Prepare for jittering (all the magic numbers here are arbitary...)",
"# Keep jittering stochastically, increasing the jitter magnit... | [
{
"param": "A",
"type": null
},
{
"param": "overwrite_a",
"type": null
},
{
"param": "check_finite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "A",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "overwrite_a",
"type": null,
"docstring": null,
"docstring_tokens... |
c45f8595f81647ad98ea873a1ffa669e5119c90c | vishalbelsare/dora | tests/test_sampler.py | [
"Apache-2.0"
] | Python | verify_common_samplers | null | def verify_common_samplers(update_ref_data=False,
sampler_model='GaussianProcess'):
"""
Test a general sampler's output.
For any implemented sampling method, this function tests if the final
collection of active sampled outputs are the same as before. If the
r... |
Test a general sampler's output.
For any implemented sampling method, this function tests if the final
collection of active sampled outputs are the same as before. If the
reference data is to be updated, it can also do so by setting the
corresponding fixture through 'py.test --upda... | Test a general sampler's output.
For any implemented sampling method, this function tests if the final
collection of active sampled outputs are the same as before. If the
reference data is to be updated, it can also do so by setting the
corresponding fixture through 'py.test --update-ref-data=True'.
note :.
This will... | [
"Test",
"a",
"general",
"sampler",
"'",
"s",
"output",
".",
"For",
"any",
"implemented",
"sampling",
"method",
"this",
"function",
"tests",
"if",
"the",
"final",
"collection",
"of",
"active",
"sampled",
"outputs",
"are",
"the",
"same",
"as",
"before",
".",
... | def verify_common_samplers(update_ref_data=False,
sampler_model='GaussianProcess'):
from demos.demo_python_api import main
sampler = main(sampler_model=sampler_model)
cwd = os.path.dirname(__file__)
filename = '%s/data/ref_data_%s.npz' % (cwd, sampler_model)
if update_ref_... | [
"def",
"verify_common_samplers",
"(",
"update_ref_data",
"=",
"False",
",",
"sampler_model",
"=",
"'GaussianProcess'",
")",
":",
"from",
"demos",
".",
"demo_python_api",
"import",
"main",
"sampler",
"=",
"main",
"(",
"sampler_model",
"=",
"sampler_model",
")",
"cw... | Test a general sampler's output. | [
"Test",
"a",
"general",
"sampler",
"'",
"s",
"output",
"."
] | [
"\"\"\"\n Test a general sampler's output.\n\n For any implemented sampling method, this function tests if the final\n collection of active sampled outputs are the same as before. If the\n reference data is to be updated, it can also do so by setting the\n corresponding fixture throug... | [
{
"param": "update_ref_data",
"type": null
},
{
"param": "sampler_model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "update_ref_data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sampler_model",
"type": null,
"docstring": null,
"... |
6d62da3035960e5ec8d3f379d2ce38c08a695e0b | vishalbelsare/dora | dora/server/server.py | [
"Apache-2.0"
] | Python | initialise_sampler | <not_specific> | def initialise_sampler():
""" Initialise the Sampler Model
This expects a dict containing:
lower : a list of the lower bounds of the region of interest
upper : a list of the upper bounds of the region of interest
Optional dict entries for the model initialisation:
kerneldef ... | Initialise the Sampler Model
This expects a dict containing:
lower : a list of the lower bounds of the region of interest
upper : a list of the upper bounds of the region of interest
Optional dict entries for the model initialisation:
kerneldef : Kernel function definition. See... | Initialise the Sampler Model
This expects a dict containing:
lower : a list of the lower bounds of the region of interest
upper : a list of the upper bounds of the region of interest
Optional dict entries for the model initialisation:
kerneldef : Kernel function definition. See the 'gp' module.
n_train : int
Number of... | [
"Initialise",
"the",
"Sampler",
"Model",
"This",
"expects",
"a",
"dict",
"containing",
":",
"lower",
":",
"a",
"list",
"of",
"the",
"lower",
"bounds",
"of",
"the",
"region",
"of",
"interest",
"upper",
":",
"a",
"list",
"of",
"the",
"upper",
"bounds",
"of... | def initialise_sampler():
initDict = fl.request.json
if not hasattr(fl.current_app, 'samplers'):
fl.current_app.samplers = {}
samplerid = len(fl.current_app.samplers)
fl.current_app.samplers[samplerid] \
= GPsampler(initDict['lower'], initDict['upper'], acq_name=initDict['acq_name'],
... | [
"def",
"initialise_sampler",
"(",
")",
":",
"initDict",
"=",
"fl",
".",
"request",
".",
"json",
"if",
"not",
"hasattr",
"(",
"fl",
".",
"current_app",
",",
"'samplers'",
")",
":",
"fl",
".",
"current_app",
".",
"samplers",
"=",
"{",
"}",
"samplerid",
"... | Initialise the Sampler Model
This expects a dict containing:
lower : a list of the lower bounds of the region of interest
upper : a list of the upper bounds of the region of interest | [
"Initialise",
"the",
"Sampler",
"Model",
"This",
"expects",
"a",
"dict",
"containing",
":",
"lower",
":",
"a",
"list",
"of",
"the",
"lower",
"bounds",
"of",
"the",
"region",
"of",
"interest",
"upper",
":",
"a",
"list",
"of",
"the",
"upper",
"bounds",
"of... | [
"\"\"\" Initialise the Sampler Model\n This expects a dict containing:\n lower : a list of the lower bounds of the region of interest\n upper : a list of the upper bounds of the region of interest\n\n Optional dict entries for the model initialisation:\n kerneldef : Kernel functio... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.