repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
vpelletier/python-ioctl-opt | ioctl_opt/__init__.py | IOR | def IOR(type, nr, size):
"""
An ioctl with read parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument.
"""
return IOC(IOC_READ, type, nr, IOC_TYPECHECK(size)) | python | def IOR(type, nr, size):
"""
An ioctl with read parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument.
"""
return IOC(IOC_READ, type, nr, IOC_TYPECHECK(size)) | [
"def",
"IOR",
"(",
"type",
",",
"nr",
",",
"size",
")",
":",
"return",
"IOC",
"(",
"IOC_READ",
",",
"type",
",",
"nr",
",",
"IOC_TYPECHECK",
"(",
"size",
")",
")"
] | An ioctl with read parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument. | [
"An",
"ioctl",
"with",
"read",
"parameters",
"."
] | train | https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L79-L86 |
vpelletier/python-ioctl-opt | ioctl_opt/__init__.py | IOW | def IOW(type, nr, size):
"""
An ioctl with write parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument.
"""
return IOC(IOC_WRITE, type, nr, IOC_TYPECHECK(size)) | python | def IOW(type, nr, size):
"""
An ioctl with write parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument.
"""
return IOC(IOC_WRITE, type, nr, IOC_TYPECHECK(size)) | [
"def",
"IOW",
"(",
"type",
",",
"nr",
",",
"size",
")",
":",
"return",
"IOC",
"(",
"IOC_WRITE",
",",
"type",
",",
"nr",
",",
"IOC_TYPECHECK",
"(",
"size",
")",
")"
] | An ioctl with write parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument. | [
"An",
"ioctl",
"with",
"write",
"parameters",
"."
] | train | https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L88-L95 |
vpelletier/python-ioctl-opt | ioctl_opt/__init__.py | IOWR | def IOWR(type, nr, size):
"""
An ioctl with both read an writes parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument.
"""
return IOC(IOC_READ | IOC_WRITE, type, nr, IOC_TYPECHECK(size)) | python | def IOWR(type, nr, size):
"""
An ioctl with both read an writes parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument.
"""
return IOC(IOC_READ | IOC_WRITE, type, nr, IOC_TYPECHECK(size)) | [
"def",
"IOWR",
"(",
"type",
",",
"nr",
",",
"size",
")",
":",
"return",
"IOC",
"(",
"IOC_READ",
"|",
"IOC_WRITE",
",",
"type",
",",
"nr",
",",
"IOC_TYPECHECK",
"(",
"size",
")",
")"
] | An ioctl with both read an writes parameters.
size (ctype type or instance)
Type/structure of the argument passed to ioctl's "arg" argument. | [
"An",
"ioctl",
"with",
"both",
"read",
"an",
"writes",
"parameters",
"."
] | train | https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L97-L104 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | _get_last_dirs | def _get_last_dirs(path, num=1):
"""Get a path including only the trailing `num` directories.
Returns
-------
last_path : str
"""
head, tail = os.path.split(path)
last_path = str(tail)
for ii in range(num):
head, tail = os.path.split(head)
last_path = os.path.join(tail,... | python | def _get_last_dirs(path, num=1):
"""Get a path including only the trailing `num` directories.
Returns
-------
last_path : str
"""
head, tail = os.path.split(path)
last_path = str(tail)
for ii in range(num):
head, tail = os.path.split(head)
last_path = os.path.join(tail,... | [
"def",
"_get_last_dirs",
"(",
"path",
",",
"num",
"=",
"1",
")",
":",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"last_path",
"=",
"str",
"(",
"tail",
")",
"for",
"ii",
"in",
"range",
"(",
"num",
")",
":",
"hea... | Get a path including only the trailing `num` directories.
Returns
-------
last_path : str | [
"Get",
"a",
"path",
"including",
"only",
"the",
"trailing",
"num",
"directories",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L169-L184 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | Analysis.analyze | def analyze(self, args):
"""Run the analysis routines determined from the given `args`.
"""
self.log.info("Running catalog analysis")
if args.count:
self.count()
return | python | def analyze(self, args):
"""Run the analysis routines determined from the given `args`.
"""
self.log.info("Running catalog analysis")
if args.count:
self.count()
return | [
"def",
"analyze",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Running catalog analysis\"",
")",
"if",
"args",
".",
"count",
":",
"self",
".",
"count",
"(",
")",
"return"
] | Run the analysis routines determined from the given `args`. | [
"Run",
"the",
"analysis",
"routines",
"determined",
"from",
"the",
"given",
"args",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L34-L42 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | Analysis.count | def count(self):
"""Analyze the counts of ...things.
Returns
-------
retvals : dict
Dictionary of 'property-name: counts' pairs for further processing
"""
self.log.info("Running 'count'")
retvals = {}
# Numbers of 'tasks'
num_tasks =... | python | def count(self):
"""Analyze the counts of ...things.
Returns
-------
retvals : dict
Dictionary of 'property-name: counts' pairs for further processing
"""
self.log.info("Running 'count'")
retvals = {}
# Numbers of 'tasks'
num_tasks =... | [
"def",
"count",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Running 'count'\"",
")",
"retvals",
"=",
"{",
"}",
"# Numbers of 'tasks'",
"num_tasks",
"=",
"self",
".",
"_count_tasks",
"(",
")",
"retvals",
"[",
"'num_tasks'",
"]",
"=",
"... | Analyze the counts of ...things.
Returns
-------
retvals : dict
Dictionary of 'property-name: counts' pairs for further processing | [
"Analyze",
"the",
"counts",
"of",
"...",
"things",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L44-L64 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | Analysis._count_tasks | def _count_tasks(self):
"""Count the number of tasks, both in the json and directory.
Returns
-------
num_tasks : int
The total number of all tasks included in the `tasks.json` file.
"""
self.log.warning("Tasks:")
tasks, task_names = self.catalog._lo... | python | def _count_tasks(self):
"""Count the number of tasks, both in the json and directory.
Returns
-------
num_tasks : int
The total number of all tasks included in the `tasks.json` file.
"""
self.log.warning("Tasks:")
tasks, task_names = self.catalog._lo... | [
"def",
"_count_tasks",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"Tasks:\"",
")",
"tasks",
",",
"task_names",
"=",
"self",
".",
"catalog",
".",
"_load_task_list_from_file",
"(",
")",
"# Total number of all tasks",
"num_tasks",
"=",
"len... | Count the number of tasks, both in the json and directory.
Returns
-------
num_tasks : int
The total number of all tasks included in the `tasks.json` file. | [
"Count",
"the",
"number",
"of",
"tasks",
"both",
"in",
"the",
"json",
"and",
"directory",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L66-L87 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | Analysis._count_repo_files | def _count_repo_files(self):
"""Count the number of files in the data repositories.
`_COUNT_FILE_TYPES` are used to determine which file types are checked
explicitly.
`_IGNORE_FILES` determine which files are ignored in (most) counts.
Returns
-------
repo_files ... | python | def _count_repo_files(self):
"""Count the number of files in the data repositories.
`_COUNT_FILE_TYPES` are used to determine which file types are checked
explicitly.
`_IGNORE_FILES` determine which files are ignored in (most) counts.
Returns
-------
repo_files ... | [
"def",
"_count_repo_files",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"Files:\"",
")",
"num_files",
"=",
"0",
"repos",
"=",
"self",
".",
"catalog",
".",
"PATHS",
".",
"get_all_repo_folders",
"(",
")",
"num_type",
"=",
"np",
".",
... | Count the number of files in the data repositories.
`_COUNT_FILE_TYPES` are used to determine which file types are checked
explicitly.
`_IGNORE_FILES` determine which files are ignored in (most) counts.
Returns
-------
repo_files : int
Total number of (non-i... | [
"Count",
"the",
"number",
"of",
"files",
"in",
"the",
"data",
"repositories",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L89-L129 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | Analysis._file_nums_str | def _file_nums_str(self, n_all, n_type, n_ign):
"""Construct a string showing the number of different file types.
Returns
-------
f_str : str
"""
# 'other' is the difference between all and named
n_oth = n_all - np.sum(n_type)
f_str = "{} Files".format(n... | python | def _file_nums_str(self, n_all, n_type, n_ign):
"""Construct a string showing the number of different file types.
Returns
-------
f_str : str
"""
# 'other' is the difference between all and named
n_oth = n_all - np.sum(n_type)
f_str = "{} Files".format(n... | [
"def",
"_file_nums_str",
"(",
"self",
",",
"n_all",
",",
"n_type",
",",
"n_ign",
")",
":",
"# 'other' is the difference between all and named",
"n_oth",
"=",
"n_all",
"-",
"np",
".",
"sum",
"(",
"n_type",
")",
"f_str",
"=",
"\"{} Files\"",
".",
"format",
"(",
... | Construct a string showing the number of different file types.
Returns
-------
f_str : str | [
"Construct",
"a",
"string",
"showing",
"the",
"number",
"of",
"different",
"file",
"types",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L131-L147 |
astrocatalogs/astrocats | astrocats/catalog/analysis.py | Analysis._count_files_by_type | def _count_files_by_type(self, path, pattern, ignore=True):
"""Count files in the given path, with the given pattern.
If `ignore = True`, skip files in the `_IGNORE_FILES` list.
Returns
-------
num_files : int
"""
# Get all files matching the given path and pat... | python | def _count_files_by_type(self, path, pattern, ignore=True):
"""Count files in the given path, with the given pattern.
If `ignore = True`, skip files in the `_IGNORE_FILES` list.
Returns
-------
num_files : int
"""
# Get all files matching the given path and pat... | [
"def",
"_count_files_by_type",
"(",
"self",
",",
"path",
",",
"pattern",
",",
"ignore",
"=",
"True",
")",
":",
"# Get all files matching the given path and pattern",
"files",
"=",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"pattern",
")",
... | Count files in the given path, with the given pattern.
If `ignore = True`, skip files in the `_IGNORE_FILES` list.
Returns
-------
num_files : int | [
"Count",
"files",
"in",
"the",
"given",
"path",
"with",
"the",
"given",
"pattern",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L149-L166 |
astrocatalogs/astrocats | astrocats/catalog/source.py | Source.bibcode_from_url | def bibcode_from_url(cls, url):
"""Given a URL, try to find the ADS bibcode.
Currently: only `ads` URLs will work, e.g.
Returns
-------
code : str or 'None'
The Bibcode if found, otherwise 'None'
"""
try:
code = url.split('/abs/')
... | python | def bibcode_from_url(cls, url):
"""Given a URL, try to find the ADS bibcode.
Currently: only `ads` URLs will work, e.g.
Returns
-------
code : str or 'None'
The Bibcode if found, otherwise 'None'
"""
try:
code = url.split('/abs/')
... | [
"def",
"bibcode_from_url",
"(",
"cls",
",",
"url",
")",
":",
"try",
":",
"code",
"=",
"url",
".",
"split",
"(",
"'/abs/'",
")",
"code",
"=",
"code",
"[",
"1",
"]",
".",
"strip",
"(",
")",
"return",
"code",
"except",
":",
"return",
"None"
] | Given a URL, try to find the ADS bibcode.
Currently: only `ads` URLs will work, e.g.
Returns
-------
code : str or 'None'
The Bibcode if found, otherwise 'None' | [
"Given",
"a",
"URL",
"try",
"to",
"find",
"the",
"ADS",
"bibcode",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/source.py#L101-L117 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry._get_save_path | def _get_save_path(self, bury=False):
"""Return the path that this Entry should be saved to."""
filename = self.get_filename(self[self._KEYS.NAME])
# Put objects that shouldn't belong in this catalog in the boneyard
if bury:
outdir = self.catalog.get_repo_boneyard()
... | python | def _get_save_path(self, bury=False):
"""Return the path that this Entry should be saved to."""
filename = self.get_filename(self[self._KEYS.NAME])
# Put objects that shouldn't belong in this catalog in the boneyard
if bury:
outdir = self.catalog.get_repo_boneyard()
... | [
"def",
"_get_save_path",
"(",
"self",
",",
"bury",
"=",
"False",
")",
":",
"filename",
"=",
"self",
".",
"get_filename",
"(",
"self",
"[",
"self",
".",
"_KEYS",
".",
"NAME",
"]",
")",
"# Put objects that shouldn't belong in this catalog in the boneyard",
"if",
"... | Return the path that this Entry should be saved to. | [
"Return",
"the",
"path",
"that",
"this",
"Entry",
"should",
"be",
"saved",
"to",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L173-L197 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry._ordered | def _ordered(self, odict):
"""Convert the object into a plain OrderedDict."""
ndict = OrderedDict()
if isinstance(odict, CatDict) or isinstance(odict, Entry):
key = odict.sort_func
else:
key = None
nkeys = list(sorted(odict.keys(), key=key))
for ... | python | def _ordered(self, odict):
"""Convert the object into a plain OrderedDict."""
ndict = OrderedDict()
if isinstance(odict, CatDict) or isinstance(odict, Entry):
key = odict.sort_func
else:
key = None
nkeys = list(sorted(odict.keys(), key=key))
for ... | [
"def",
"_ordered",
"(",
"self",
",",
"odict",
")",
":",
"ndict",
"=",
"OrderedDict",
"(",
")",
"if",
"isinstance",
"(",
"odict",
",",
"CatDict",
")",
"or",
"isinstance",
"(",
"odict",
",",
"Entry",
")",
":",
"key",
"=",
"odict",
".",
"sort_func",
"el... | Convert the object into a plain OrderedDict. | [
"Convert",
"the",
"object",
"into",
"a",
"plain",
"OrderedDict",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L199-L224 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.get_hash | def get_hash(self, keys=[]):
"""Return a unique hash associated with the listed keys."""
if not len(keys):
keys = list(self.keys())
string_rep = ''
oself = self._ordered(deepcopy(self))
for key in keys:
string_rep += json.dumps(oself.get(key, ''), sort_ke... | python | def get_hash(self, keys=[]):
"""Return a unique hash associated with the listed keys."""
if not len(keys):
keys = list(self.keys())
string_rep = ''
oself = self._ordered(deepcopy(self))
for key in keys:
string_rep += json.dumps(oself.get(key, ''), sort_ke... | [
"def",
"get_hash",
"(",
"self",
",",
"keys",
"=",
"[",
"]",
")",
":",
"if",
"not",
"len",
"(",
"keys",
")",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
"string_rep",
"=",
"''",
"oself",
"=",
"self",
".",
"_ordered",
"(",
... | Return a unique hash associated with the listed keys. | [
"Return",
"a",
"unique",
"hash",
"associated",
"with",
"the",
"listed",
"keys",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L226-L236 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry._clean_quantity | def _clean_quantity(self, quantity):
"""Clean quantity value before it is added to entry."""
value = quantity.get(QUANTITY.VALUE, '').strip()
error = quantity.get(QUANTITY.E_VALUE, '').strip()
unit = quantity.get(QUANTITY.U_VALUE, '').strip()
kind = quantity.get(QUANTITY.KIND, ''... | python | def _clean_quantity(self, quantity):
"""Clean quantity value before it is added to entry."""
value = quantity.get(QUANTITY.VALUE, '').strip()
error = quantity.get(QUANTITY.E_VALUE, '').strip()
unit = quantity.get(QUANTITY.U_VALUE, '').strip()
kind = quantity.get(QUANTITY.KIND, ''... | [
"def",
"_clean_quantity",
"(",
"self",
",",
"quantity",
")",
":",
"value",
"=",
"quantity",
".",
"get",
"(",
"QUANTITY",
".",
"VALUE",
",",
"''",
")",
".",
"strip",
"(",
")",
"error",
"=",
"quantity",
".",
"get",
"(",
"QUANTITY",
".",
"E_VALUE",
",",... | Clean quantity value before it is added to entry. | [
"Clean",
"quantity",
"value",
"before",
"it",
"is",
"added",
"to",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L238-L267 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry._convert_odict_to_classes | def _convert_odict_to_classes(self,
data,
clean=False,
merge=True,
pop_schema=True,
compare_to_existing=True,
filter... | python | def _convert_odict_to_classes(self,
data,
clean=False,
merge=True,
pop_schema=True,
compare_to_existing=True,
filter... | [
"def",
"_convert_odict_to_classes",
"(",
"self",
",",
"data",
",",
"clean",
"=",
"False",
",",
"merge",
"=",
"True",
",",
"pop_schema",
"=",
"True",
",",
"compare_to_existing",
"=",
"True",
",",
"filter_on",
"=",
"{",
"}",
")",
":",
"self",
".",
"_log",
... | Convert `OrderedDict` into `Entry` or its derivative classes. | [
"Convert",
"OrderedDict",
"into",
"Entry",
"or",
"its",
"derivative",
"classes",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L346-L485 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry._check_cat_dict_source | def _check_cat_dict_source(self, cat_dict_class, key_in_self, **kwargs):
"""Check that a source exists and that a quantity isn't erroneous."""
# Make sure that a source is given
source = kwargs.get(cat_dict_class._KEYS.SOURCE, None)
if source is None:
raise CatDictError(
... | python | def _check_cat_dict_source(self, cat_dict_class, key_in_self, **kwargs):
"""Check that a source exists and that a quantity isn't erroneous."""
# Make sure that a source is given
source = kwargs.get(cat_dict_class._KEYS.SOURCE, None)
if source is None:
raise CatDictError(
... | [
"def",
"_check_cat_dict_source",
"(",
"self",
",",
"cat_dict_class",
",",
"key_in_self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Make sure that a source is given",
"source",
"=",
"kwargs",
".",
"get",
"(",
"cat_dict_class",
".",
"_KEYS",
".",
"SOURCE",
",",
"None"... | Check that a source exists and that a quantity isn't erroneous. | [
"Check",
"that",
"a",
"source",
"exists",
"and",
"that",
"a",
"quantity",
"isn",
"t",
"erroneous",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L487-L511 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry._add_cat_dict | def _add_cat_dict(self,
cat_dict_class,
key_in_self,
check_for_dupes=True,
compare_to_existing=True,
**kwargs):
"""Add a `CatDict` to this `Entry`.
CatDict only added if initialization succeeds... | python | def _add_cat_dict(self,
cat_dict_class,
key_in_self,
check_for_dupes=True,
compare_to_existing=True,
**kwargs):
"""Add a `CatDict` to this `Entry`.
CatDict only added if initialization succeeds... | [
"def",
"_add_cat_dict",
"(",
"self",
",",
"cat_dict_class",
",",
"key_in_self",
",",
"check_for_dupes",
"=",
"True",
",",
"compare_to_existing",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Make sure that a source is given, and is valid (nor erroneous)",
"if",
"... | Add a `CatDict` to this `Entry`.
CatDict only added if initialization succeeds and it
doesn't already exist within the Entry. | [
"Add",
"a",
"CatDict",
"to",
"this",
"Entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L525-L586 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.init_from_file | def init_from_file(cls,
catalog,
name=None,
path=None,
clean=False,
merge=True,
pop_schema=True,
ignore_keys=[],
compare_to_existing=Tru... | python | def init_from_file(cls,
catalog,
name=None,
path=None,
clean=False,
merge=True,
pop_schema=True,
ignore_keys=[],
compare_to_existing=Tru... | [
"def",
"init_from_file",
"(",
"cls",
",",
"catalog",
",",
"name",
"=",
"None",
",",
"path",
"=",
"None",
",",
"clean",
"=",
"False",
",",
"merge",
"=",
"True",
",",
"pop_schema",
"=",
"True",
",",
"ignore_keys",
"=",
"[",
"]",
",",
"compare_to_existing... | Construct a new `Entry` instance from an input file.
The input file can be given explicitly by `path`, or a path will
be constructed appropriately if possible.
Arguments
---------
catalog : `astrocats.catalog.catalog.Catalog` instance
The parent catalog object of wh... | [
"Construct",
"a",
"new",
"Entry",
"instance",
"from",
"an",
"input",
"file",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L595-L678 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_alias | def add_alias(self, alias, source, clean=True):
"""Add an alias, optionally 'cleaning' the alias string.
Calls the parent `catalog` method `clean_entry_name` - to apply the
same name-cleaning as is applied to entry names themselves.
Returns
-------
alias : str
... | python | def add_alias(self, alias, source, clean=True):
"""Add an alias, optionally 'cleaning' the alias string.
Calls the parent `catalog` method `clean_entry_name` - to apply the
same name-cleaning as is applied to entry names themselves.
Returns
-------
alias : str
... | [
"def",
"add_alias",
"(",
"self",
",",
"alias",
",",
"source",
",",
"clean",
"=",
"True",
")",
":",
"if",
"clean",
":",
"alias",
"=",
"self",
".",
"catalog",
".",
"clean_entry_name",
"(",
"alias",
")",
"self",
".",
"add_quantity",
"(",
"self",
".",
"_... | Add an alias, optionally 'cleaning' the alias string.
Calls the parent `catalog` method `clean_entry_name` - to apply the
same name-cleaning as is applied to entry names themselves.
Returns
-------
alias : str
The stored version of the alias (cleaned or not). | [
"Add",
"an",
"alias",
"optionally",
"cleaning",
"the",
"alias",
"string",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L680-L695 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_error | def add_error(self, value, **kwargs):
"""Add an `Error` instance to this entry."""
kwargs.update({ERROR.VALUE: value})
self._add_cat_dict(Error, self._KEYS.ERRORS, **kwargs)
return | python | def add_error(self, value, **kwargs):
"""Add an `Error` instance to this entry."""
kwargs.update({ERROR.VALUE: value})
self._add_cat_dict(Error, self._KEYS.ERRORS, **kwargs)
return | [
"def",
"add_error",
"(",
"self",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"ERROR",
".",
"VALUE",
":",
"value",
"}",
")",
"self",
".",
"_add_cat_dict",
"(",
"Error",
",",
"self",
".",
"_KEYS",
".",
"ERRORS"... | Add an `Error` instance to this entry. | [
"Add",
"an",
"Error",
"instance",
"to",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L697-L701 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_photometry | def add_photometry(self, compare_to_existing=True, **kwargs):
"""Add a `Photometry` instance to this entry."""
self._add_cat_dict(
Photometry,
self._KEYS.PHOTOMETRY,
compare_to_existing=compare_to_existing,
**kwargs)
return | python | def add_photometry(self, compare_to_existing=True, **kwargs):
"""Add a `Photometry` instance to this entry."""
self._add_cat_dict(
Photometry,
self._KEYS.PHOTOMETRY,
compare_to_existing=compare_to_existing,
**kwargs)
return | [
"def",
"add_photometry",
"(",
"self",
",",
"compare_to_existing",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_add_cat_dict",
"(",
"Photometry",
",",
"self",
".",
"_KEYS",
".",
"PHOTOMETRY",
",",
"compare_to_existing",
"=",
"compare_to_existi... | Add a `Photometry` instance to this entry. | [
"Add",
"a",
"Photometry",
"instance",
"to",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L703-L710 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.merge_dupes | def merge_dupes(self):
"""Merge two entries that correspond to the same entry."""
for dupe in self.dupe_of:
if dupe in self.catalog.entries:
if self.catalog.entries[dupe]._stub:
# merge = False to avoid infinite recursion
self.catalog.l... | python | def merge_dupes(self):
"""Merge two entries that correspond to the same entry."""
for dupe in self.dupe_of:
if dupe in self.catalog.entries:
if self.catalog.entries[dupe]._stub:
# merge = False to avoid infinite recursion
self.catalog.l... | [
"def",
"merge_dupes",
"(",
"self",
")",
":",
"for",
"dupe",
"in",
"self",
".",
"dupe_of",
":",
"if",
"dupe",
"in",
"self",
".",
"catalog",
".",
"entries",
":",
"if",
"self",
".",
"catalog",
".",
"entries",
"[",
"dupe",
"]",
".",
"_stub",
":",
"# me... | Merge two entries that correspond to the same entry. | [
"Merge",
"two",
"entries",
"that",
"correspond",
"to",
"the",
"same",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L712-L723 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_quantity | def add_quantity(self,
quantities,
value,
source,
check_for_dupes=True,
compare_to_existing=True,
**kwargs):
"""Add an `Quantity` instance to this entry."""
success = True
... | python | def add_quantity(self,
quantities,
value,
source,
check_for_dupes=True,
compare_to_existing=True,
**kwargs):
"""Add an `Quantity` instance to this entry."""
success = True
... | [
"def",
"add_quantity",
"(",
"self",
",",
"quantities",
",",
"value",
",",
"source",
",",
"check_for_dupes",
"=",
"True",
",",
"compare_to_existing",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"success",
"=",
"True",
"for",
"quantity",
"in",
"listify",... | Add an `Quantity` instance to this entry. | [
"Add",
"an",
"Quantity",
"instance",
"to",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L725-L746 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_self_source | def add_self_source(self):
"""Add a source that refers to the catalog itself.
For now this points to the Open Supernova Catalog by default.
"""
return self.add_source(
bibcode=self.catalog.OSC_BIBCODE,
name=self.catalog.OSC_NAME,
url=self.catalog.OSC_... | python | def add_self_source(self):
"""Add a source that refers to the catalog itself.
For now this points to the Open Supernova Catalog by default.
"""
return self.add_source(
bibcode=self.catalog.OSC_BIBCODE,
name=self.catalog.OSC_NAME,
url=self.catalog.OSC_... | [
"def",
"add_self_source",
"(",
"self",
")",
":",
"return",
"self",
".",
"add_source",
"(",
"bibcode",
"=",
"self",
".",
"catalog",
".",
"OSC_BIBCODE",
",",
"name",
"=",
"self",
".",
"catalog",
".",
"OSC_NAME",
",",
"url",
"=",
"self",
".",
"catalog",
"... | Add a source that refers to the catalog itself.
For now this points to the Open Supernova Catalog by default. | [
"Add",
"a",
"source",
"that",
"refers",
"to",
"the",
"catalog",
"itself",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L748-L757 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_source | def add_source(self, allow_alias=False, **kwargs):
"""Add a `Source` instance to this entry."""
if not allow_alias and SOURCE.ALIAS in kwargs:
err_str = "`{}` passed in kwargs, this shouldn't happen!".format(
SOURCE.ALIAS)
self._log.error(err_str)
rais... | python | def add_source(self, allow_alias=False, **kwargs):
"""Add a `Source` instance to this entry."""
if not allow_alias and SOURCE.ALIAS in kwargs:
err_str = "`{}` passed in kwargs, this shouldn't happen!".format(
SOURCE.ALIAS)
self._log.error(err_str)
rais... | [
"def",
"add_source",
"(",
"self",
",",
"allow_alias",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"allow_alias",
"and",
"SOURCE",
".",
"ALIAS",
"in",
"kwargs",
":",
"err_str",
"=",
"\"`{}` passed in kwargs, this shouldn't happen!\"",
".",
"fo... | Add a `Source` instance to this entry. | [
"Add",
"a",
"Source",
"instance",
"to",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L759-L779 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_model | def add_model(self, allow_alias=False, **kwargs):
"""Add a `Model` instance to this entry."""
if not allow_alias and MODEL.ALIAS in kwargs:
err_str = "`{}` passed in kwargs, this shouldn't happen!".format(
SOURCE.ALIAS)
self._log.error(err_str)
raise R... | python | def add_model(self, allow_alias=False, **kwargs):
"""Add a `Model` instance to this entry."""
if not allow_alias and MODEL.ALIAS in kwargs:
err_str = "`{}` passed in kwargs, this shouldn't happen!".format(
SOURCE.ALIAS)
self._log.error(err_str)
raise R... | [
"def",
"add_model",
"(",
"self",
",",
"allow_alias",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"allow_alias",
"and",
"MODEL",
".",
"ALIAS",
"in",
"kwargs",
":",
"err_str",
"=",
"\"`{}` passed in kwargs, this shouldn't happen!\"",
".",
"form... | Add a `Model` instance to this entry. | [
"Add",
"a",
"Model",
"instance",
"to",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L781-L801 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.add_spectrum | def add_spectrum(self, compare_to_existing=True, **kwargs):
"""Add a `Spectrum` instance to this entry."""
spec_key = self._KEYS.SPECTRA
# Make sure that a source is given, and is valid (nor erroneous)
source = self._check_cat_dict_source(Spectrum, spec_key, **kwargs)
if source i... | python | def add_spectrum(self, compare_to_existing=True, **kwargs):
"""Add a `Spectrum` instance to this entry."""
spec_key = self._KEYS.SPECTRA
# Make sure that a source is given, and is valid (nor erroneous)
source = self._check_cat_dict_source(Spectrum, spec_key, **kwargs)
if source i... | [
"def",
"add_spectrum",
"(",
"self",
",",
"compare_to_existing",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"spec_key",
"=",
"self",
".",
"_KEYS",
".",
"SPECTRA",
"# Make sure that a source is given, and is valid (nor erroneous)",
"source",
"=",
"self",
".",
"... | Add a `Spectrum` instance to this entry. | [
"Add",
"a",
"Spectrum",
"instance",
"to",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L803-L831 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.check | def check(self):
"""Check that the entry has the required fields."""
# Make sure there is a schema key in dict
if self._KEYS.SCHEMA not in self:
self[self._KEYS.SCHEMA] = self.catalog.SCHEMA.URL
# Make sure there is a name key in dict
if (self._KEYS.NAME not in self o... | python | def check(self):
"""Check that the entry has the required fields."""
# Make sure there is a schema key in dict
if self._KEYS.SCHEMA not in self:
self[self._KEYS.SCHEMA] = self.catalog.SCHEMA.URL
# Make sure there is a name key in dict
if (self._KEYS.NAME not in self o... | [
"def",
"check",
"(",
"self",
")",
":",
"# Make sure there is a schema key in dict",
"if",
"self",
".",
"_KEYS",
".",
"SCHEMA",
"not",
"in",
"self",
":",
"self",
"[",
"self",
".",
"_KEYS",
".",
"SCHEMA",
"]",
"=",
"self",
".",
"catalog",
".",
"SCHEMA",
".... | Check that the entry has the required fields. | [
"Check",
"that",
"the",
"entry",
"has",
"the",
"required",
"fields",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L833-L843 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.get_aliases | def get_aliases(self, includename=True):
"""Retrieve the aliases of this object as a list of strings.
Arguments
---------
includename : bool
Include the 'name' parameter in the list of aliases.
"""
# empty list if doesnt exist
alias_quanta = self.get(... | python | def get_aliases(self, includename=True):
"""Retrieve the aliases of this object as a list of strings.
Arguments
---------
includename : bool
Include the 'name' parameter in the list of aliases.
"""
# empty list if doesnt exist
alias_quanta = self.get(... | [
"def",
"get_aliases",
"(",
"self",
",",
"includename",
"=",
"True",
")",
":",
"# empty list if doesnt exist",
"alias_quanta",
"=",
"self",
".",
"get",
"(",
"self",
".",
"_KEYS",
".",
"ALIAS",
",",
"[",
"]",
")",
"aliases",
"=",
"[",
"aq",
"[",
"QUANTITY"... | Retrieve the aliases of this object as a list of strings.
Arguments
---------
includename : bool
Include the 'name' parameter in the list of aliases. | [
"Retrieve",
"the",
"aliases",
"of",
"this",
"object",
"as",
"a",
"list",
"of",
"strings",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L856-L869 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.get_entry_text | def get_entry_text(self, fname):
"""Retrieve the raw text from a file."""
if fname.split('.')[-1] == 'gz':
with gz.open(fname, 'rt') as f:
filetext = f.read()
else:
with codecs.open(fname, 'r') as f:
filetext = f.read()
return filet... | python | def get_entry_text(self, fname):
"""Retrieve the raw text from a file."""
if fname.split('.')[-1] == 'gz':
with gz.open(fname, 'rt') as f:
filetext = f.read()
else:
with codecs.open(fname, 'r') as f:
filetext = f.read()
return filet... | [
"def",
"get_entry_text",
"(",
"self",
",",
"fname",
")",
":",
"if",
"fname",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"==",
"'gz'",
":",
"with",
"gz",
".",
"open",
"(",
"fname",
",",
"'rt'",
")",
"as",
"f",
":",
"filetext",
"=",
"f",
... | Retrieve the raw text from a file. | [
"Retrieve",
"the",
"raw",
"text",
"from",
"a",
"file",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L871-L879 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.get_source_by_alias | def get_source_by_alias(self, alias):
"""Given an alias, find the corresponding source in this entry.
If the given alias doesn't exist (e.g. there are no sources), then a
`ValueError` is raised.
Arguments
---------
alias : str
The str-integer (e.g. '8') of t... | python | def get_source_by_alias(self, alias):
"""Given an alias, find the corresponding source in this entry.
If the given alias doesn't exist (e.g. there are no sources), then a
`ValueError` is raised.
Arguments
---------
alias : str
The str-integer (e.g. '8') of t... | [
"def",
"get_source_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"for",
"source",
"in",
"self",
".",
"get",
"(",
"self",
".",
"_KEYS",
".",
"SOURCES",
",",
"[",
"]",
")",
":",
"if",
"source",
"[",
"self",
".",
"_KEYS",
".",
"ALIAS",
"]",
"==",
... | Given an alias, find the corresponding source in this entry.
If the given alias doesn't exist (e.g. there are no sources), then a
`ValueError` is raised.
Arguments
---------
alias : str
The str-integer (e.g. '8') of the target source.
Returns
------... | [
"Given",
"an",
"alias",
"find",
"the",
"corresponding",
"source",
"in",
"this",
"entry",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L881-L902 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.get_stub | def get_stub(self):
"""Get a new `Entry` which contains the 'stub' of this one.
The 'stub' is only the name and aliases.
Usage:
-----
To convert a normal entry into a stub (for example), overwrite the
entry in place, i.e.
>>> entries[name] = entries[name].get_st... | python | def get_stub(self):
"""Get a new `Entry` which contains the 'stub' of this one.
The 'stub' is only the name and aliases.
Usage:
-----
To convert a normal entry into a stub (for example), overwrite the
entry in place, i.e.
>>> entries[name] = entries[name].get_st... | [
"def",
"get_stub",
"(",
"self",
")",
":",
"stub",
"=",
"type",
"(",
"self",
")",
"(",
"self",
".",
"catalog",
",",
"self",
"[",
"self",
".",
"_KEYS",
".",
"NAME",
"]",
",",
"stub",
"=",
"True",
")",
"if",
"self",
".",
"_KEYS",
".",
"ALIAS",
"in... | Get a new `Entry` which contains the 'stub' of this one.
The 'stub' is only the name and aliases.
Usage:
-----
To convert a normal entry into a stub (for example), overwrite the
entry in place, i.e.
>>> entries[name] = entries[name].get_stub()
Returns
-... | [
"Get",
"a",
"new",
"Entry",
"which",
"contains",
"the",
"stub",
"of",
"this",
"one",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L904-L934 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.is_erroneous | def is_erroneous(self, field, sources):
"""Check if attribute has been marked as being erroneous."""
if self._KEYS.ERRORS in self:
my_errors = self[self._KEYS.ERRORS]
for alias in sources.split(','):
source = self.get_source_by_alias(alias)
bib_err... | python | def is_erroneous(self, field, sources):
"""Check if attribute has been marked as being erroneous."""
if self._KEYS.ERRORS in self:
my_errors = self[self._KEYS.ERRORS]
for alias in sources.split(','):
source = self.get_source_by_alias(alias)
bib_err... | [
"def",
"is_erroneous",
"(",
"self",
",",
"field",
",",
"sources",
")",
":",
"if",
"self",
".",
"_KEYS",
".",
"ERRORS",
"in",
"self",
":",
"my_errors",
"=",
"self",
"[",
"self",
".",
"_KEYS",
".",
"ERRORS",
"]",
"for",
"alias",
"in",
"sources",
".",
... | Check if attribute has been marked as being erroneous. | [
"Check",
"if",
"attribute",
"has",
"been",
"marked",
"as",
"being",
"erroneous",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L936-L960 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.is_private | def is_private(self, key, sources):
"""Check if attribute is private."""
# aliases are always public.
if key == ENTRY.ALIAS:
return False
return all([
SOURCE.PRIVATE in self.get_source_by_alias(x)
for x in sources.split(',')
]) | python | def is_private(self, key, sources):
"""Check if attribute is private."""
# aliases are always public.
if key == ENTRY.ALIAS:
return False
return all([
SOURCE.PRIVATE in self.get_source_by_alias(x)
for x in sources.split(',')
]) | [
"def",
"is_private",
"(",
"self",
",",
"key",
",",
"sources",
")",
":",
"# aliases are always public.",
"if",
"key",
"==",
"ENTRY",
".",
"ALIAS",
":",
"return",
"False",
"return",
"all",
"(",
"[",
"SOURCE",
".",
"PRIVATE",
"in",
"self",
".",
"get_source_by... | Check if attribute is private. | [
"Check",
"if",
"attribute",
"is",
"private",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L962-L970 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.sanitize | def sanitize(self):
"""Sanitize the data (sort it, etc.) before writing it to disk.
Template method that can be overridden in each catalog's subclassed
`Entry` object.
"""
name = self[self._KEYS.NAME]
aliases = self.get_aliases(includename=False)
if name not in ... | python | def sanitize(self):
"""Sanitize the data (sort it, etc.) before writing it to disk.
Template method that can be overridden in each catalog's subclassed
`Entry` object.
"""
name = self[self._KEYS.NAME]
aliases = self.get_aliases(includename=False)
if name not in ... | [
"def",
"sanitize",
"(",
"self",
")",
":",
"name",
"=",
"self",
"[",
"self",
".",
"_KEYS",
".",
"NAME",
"]",
"aliases",
"=",
"self",
".",
"get_aliases",
"(",
"includename",
"=",
"False",
")",
"if",
"name",
"not",
"in",
"aliases",
":",
"# Assign the firs... | Sanitize the data (sort it, etc.) before writing it to disk.
Template method that can be overridden in each catalog's subclassed
`Entry` object. | [
"Sanitize",
"the",
"data",
"(",
"sort",
"it",
"etc",
".",
")",
"before",
"writing",
"it",
"to",
"disk",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L1003-L1086 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.save | def save(self, bury=False, final=False):
"""Write entry to JSON file in the proper location.
Arguments
---------
bury : bool
final : bool
If this is the 'final' save, perform additional sanitization and
cleaning operations.
"""
outdir, f... | python | def save(self, bury=False, final=False):
"""Write entry to JSON file in the proper location.
Arguments
---------
bury : bool
final : bool
If this is the 'final' save, perform additional sanitization and
cleaning operations.
"""
outdir, f... | [
"def",
"save",
"(",
"self",
",",
"bury",
"=",
"False",
",",
"final",
"=",
"False",
")",
":",
"outdir",
",",
"filename",
"=",
"self",
".",
"_get_save_path",
"(",
"bury",
"=",
"bury",
")",
"if",
"final",
":",
"self",
".",
"sanitize",
"(",
")",
"# FIX... | Write entry to JSON file in the proper location.
Arguments
---------
bury : bool
final : bool
If this is the 'final' save, perform additional sanitization and
cleaning operations. | [
"Write",
"entry",
"to",
"JSON",
"file",
"in",
"the",
"proper",
"location",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L1088-L1124 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | Entry.sort_func | def sort_func(self, key):
"""Used to sort keys when writing Entry to JSON format.
Should be supplemented/overridden by inheriting classes.
"""
if key == self._KEYS.SCHEMA:
return 'aaa'
if key == self._KEYS.NAME:
return 'aab'
if key == self._KEYS.S... | python | def sort_func(self, key):
"""Used to sort keys when writing Entry to JSON format.
Should be supplemented/overridden by inheriting classes.
"""
if key == self._KEYS.SCHEMA:
return 'aaa'
if key == self._KEYS.NAME:
return 'aab'
if key == self._KEYS.S... | [
"def",
"sort_func",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"==",
"self",
".",
"_KEYS",
".",
"SCHEMA",
":",
"return",
"'aaa'",
"if",
"key",
"==",
"self",
".",
"_KEYS",
".",
"NAME",
":",
"return",
"'aab'",
"if",
"key",
"==",
"self",
".",
"... | Used to sort keys when writing Entry to JSON format.
Should be supplemented/overridden by inheriting classes. | [
"Used",
"to",
"sort",
"keys",
"when",
"writing",
"Entry",
"to",
"JSON",
"format",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L1130-L1149 |
astrocatalogs/astrocats | astrocats/catalog/photometry.py | set_pd_mag_from_counts | def set_pd_mag_from_counts(photodict,
c='',
ec='',
lec='',
uec='',
zp=DEFAULT_ZP,
sig=DEFAULT_UL_SIGMA):
"""Set photometry dictionary from a counts measur... | python | def set_pd_mag_from_counts(photodict,
c='',
ec='',
lec='',
uec='',
zp=DEFAULT_ZP,
sig=DEFAULT_UL_SIGMA):
"""Set photometry dictionary from a counts measur... | [
"def",
"set_pd_mag_from_counts",
"(",
"photodict",
",",
"c",
"=",
"''",
",",
"ec",
"=",
"''",
",",
"lec",
"=",
"''",
",",
"uec",
"=",
"''",
",",
"zp",
"=",
"DEFAULT_ZP",
",",
"sig",
"=",
"DEFAULT_UL_SIGMA",
")",
":",
"with",
"localcontext",
"(",
")",... | Set photometry dictionary from a counts measurement. | [
"Set",
"photometry",
"dictionary",
"from",
"a",
"counts",
"measurement",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L421-L459 |
astrocatalogs/astrocats | astrocats/catalog/photometry.py | set_pd_mag_from_flux_density | def set_pd_mag_from_flux_density(photodict,
fd='',
efd='',
lefd='',
uefd='',
sig=DEFAULT_UL_SIGMA):
"""Set photometry dictionary from a flux density me... | python | def set_pd_mag_from_flux_density(photodict,
fd='',
efd='',
lefd='',
uefd='',
sig=DEFAULT_UL_SIGMA):
"""Set photometry dictionary from a flux density me... | [
"def",
"set_pd_mag_from_flux_density",
"(",
"photodict",
",",
"fd",
"=",
"''",
",",
"efd",
"=",
"''",
",",
"lefd",
"=",
"''",
",",
"uefd",
"=",
"''",
",",
"sig",
"=",
"DEFAULT_UL_SIGMA",
")",
":",
"with",
"localcontext",
"(",
")",
"as",
"ctx",
":",
"... | Set photometry dictionary from a flux density measurement.
`fd` is assumed to be in microjanskys. | [
"Set",
"photometry",
"dictionary",
"from",
"a",
"flux",
"density",
"measurement",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L462-L500 |
astrocatalogs/astrocats | astrocats/catalog/photometry.py | Photometry._check | def _check(self):
"""Check that entry attributes are legal."""
# Run the super method
super(Photometry, self)._check()
err_str = None
has_flux = self._KEYS.FLUX in self
has_flux_dens = self._KEYS.FLUX_DENSITY in self
has_u_flux = self._KEYS.U_FLUX in self
... | python | def _check(self):
"""Check that entry attributes are legal."""
# Run the super method
super(Photometry, self)._check()
err_str = None
has_flux = self._KEYS.FLUX in self
has_flux_dens = self._KEYS.FLUX_DENSITY in self
has_u_flux = self._KEYS.U_FLUX in self
... | [
"def",
"_check",
"(",
"self",
")",
":",
"# Run the super method",
"super",
"(",
"Photometry",
",",
"self",
")",
".",
"_check",
"(",
")",
"err_str",
"=",
"None",
"has_flux",
"=",
"self",
".",
"_KEYS",
".",
"FLUX",
"in",
"self",
"has_flux_dens",
"=",
"self... | Check that entry attributes are legal. | [
"Check",
"that",
"entry",
"attributes",
"are",
"legal",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L168-L208 |
astrocatalogs/astrocats | astrocats/catalog/photometry.py | Photometry.sort_func | def sort_func(self, key):
"""Specify order for attributes."""
if key == self._KEYS.TIME:
return 'aaa'
if key == self._KEYS.MODEL:
return 'zzy'
if key == self._KEYS.SOURCE:
return 'zzz'
return key | python | def sort_func(self, key):
"""Specify order for attributes."""
if key == self._KEYS.TIME:
return 'aaa'
if key == self._KEYS.MODEL:
return 'zzy'
if key == self._KEYS.SOURCE:
return 'zzz'
return key | [
"def",
"sort_func",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"==",
"self",
".",
"_KEYS",
".",
"TIME",
":",
"return",
"'aaa'",
"if",
"key",
"==",
"self",
".",
"_KEYS",
".",
"MODEL",
":",
"return",
"'zzy'",
"if",
"key",
"==",
"self",
".",
"_... | Specify order for attributes. | [
"Specify",
"order",
"for",
"attributes",
"."
] | train | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L221-L229 |
ergo/ziggurat_foundations | ziggurat_foundations/migrations/env.py | run_migrations_offline | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | python | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | [
"def",
"run_migrations_offline",
"(",
")",
":",
"url",
"=",
"get_url",
"(",
")",
"context",
".",
"configure",
"(",
"url",
"=",
"url",
",",
"version_table",
"=",
"\"alembic_ziggurat_foundations_version\"",
",",
"transaction_per_migration",
"=",
"True",
",",
")",
... | Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output. | [
"Run",
"migrations",
"in",
"offline",
"mode",
"."
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/migrations/env.py#L51-L71 |
ergo/ziggurat_foundations | ziggurat_foundations/migrations/env.py | run_migrations_online | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = create_engine(get_url())
connection = engine.connect()
context.configure(
connection=connection,
target_m... | python | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = create_engine(get_url())
connection = engine.connect()
context.configure(
connection=connection,
target_m... | [
"def",
"run_migrations_online",
"(",
")",
":",
"engine",
"=",
"create_engine",
"(",
"get_url",
"(",
")",
")",
"connection",
"=",
"engine",
".",
"connect",
"(",
")",
"context",
".",
"configure",
"(",
"connection",
"=",
"connection",
",",
"target_metadata",
"=... | Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context. | [
"Run",
"migrations",
"in",
"online",
"mode",
"."
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/migrations/env.py#L74-L95 |
ergo/ziggurat_foundations | ziggurat_foundations/models/services/user_resource_permission.py | UserResourcePermissionService.by_resource_user_and_perm | def by_resource_user_and_perm(
cls, user_id, perm_name, resource_id, db_session=None
):
"""
return all instances by user name, perm name and resource id
:param user_id:
:param perm_name:
:param resource_id:
:param db_session:
:return:
"""
... | python | def by_resource_user_and_perm(
cls, user_id, perm_name, resource_id, db_session=None
):
"""
return all instances by user name, perm name and resource id
:param user_id:
:param perm_name:
:param resource_id:
:param db_session:
:return:
"""
... | [
"def",
"by_resource_user_and_perm",
"(",
"cls",
",",
"user_id",
",",
"perm_name",
",",
"resource_id",
",",
"db_session",
"=",
"None",
")",
":",
"db_session",
"=",
"get_db_session",
"(",
"db_session",
")",
"query",
"=",
"db_session",
".",
"query",
"(",
"cls",
... | return all instances by user name, perm name and resource id
:param user_id:
:param perm_name:
:param resource_id:
:param db_session:
:return: | [
"return",
"all",
"instances",
"by",
"user",
"name",
"perm",
"name",
"and",
"resource",
"id"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user_resource_permission.py#L27-L44 |
erijo/tellcore-py | tellcore/library.py | Library.tdSensor | def tdSensor(self):
"""Get the next sensor while iterating.
:return: a dict with the keys: protocol, model, id, datatypes.
"""
protocol = create_string_buffer(20)
model = create_string_buffer(20)
sid = c_int()
datatypes = c_int()
self._lib.tdSensor(proto... | python | def tdSensor(self):
"""Get the next sensor while iterating.
:return: a dict with the keys: protocol, model, id, datatypes.
"""
protocol = create_string_buffer(20)
model = create_string_buffer(20)
sid = c_int()
datatypes = c_int()
self._lib.tdSensor(proto... | [
"def",
"tdSensor",
"(",
"self",
")",
":",
"protocol",
"=",
"create_string_buffer",
"(",
"20",
")",
"model",
"=",
"create_string_buffer",
"(",
"20",
")",
"sid",
"=",
"c_int",
"(",
")",
"datatypes",
"=",
"c_int",
"(",
")",
"self",
".",
"_lib",
".",
"tdSe... | Get the next sensor while iterating.
:return: a dict with the keys: protocol, model, id, datatypes. | [
"Get",
"the",
"next",
"sensor",
"while",
"iterating",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L409-L423 |
erijo/tellcore-py | tellcore/library.py | Library.tdSensorValue | def tdSensorValue(self, protocol, model, sid, datatype):
"""Get the sensor value for a given sensor.
:return: a dict with the keys: value, timestamp.
"""
value = create_string_buffer(20)
timestamp = c_int()
self._lib.tdSensorValue(protocol, model, sid, datatype,
... | python | def tdSensorValue(self, protocol, model, sid, datatype):
"""Get the sensor value for a given sensor.
:return: a dict with the keys: value, timestamp.
"""
value = create_string_buffer(20)
timestamp = c_int()
self._lib.tdSensorValue(protocol, model, sid, datatype,
... | [
"def",
"tdSensorValue",
"(",
"self",
",",
"protocol",
",",
"model",
",",
"sid",
",",
"datatype",
")",
":",
"value",
"=",
"create_string_buffer",
"(",
"20",
")",
"timestamp",
"=",
"c_int",
"(",
")",
"self",
".",
"_lib",
".",
"tdSensorValue",
"(",
"protoco... | Get the sensor value for a given sensor.
:return: a dict with the keys: value, timestamp. | [
"Get",
"the",
"sensor",
"value",
"for",
"a",
"given",
"sensor",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L425-L435 |
erijo/tellcore-py | tellcore/library.py | Library.tdController | def tdController(self):
"""Get the next controller while iterating.
:return: a dict with the keys: id, type, name, available.
"""
cid = c_int()
ctype = c_int()
name = create_string_buffer(255)
available = c_int()
self._lib.tdController(byref(cid), byref(... | python | def tdController(self):
"""Get the next controller while iterating.
:return: a dict with the keys: id, type, name, available.
"""
cid = c_int()
ctype = c_int()
name = create_string_buffer(255)
available = c_int()
self._lib.tdController(byref(cid), byref(... | [
"def",
"tdController",
"(",
"self",
")",
":",
"cid",
"=",
"c_int",
"(",
")",
"ctype",
"=",
"c_int",
"(",
")",
"name",
"=",
"create_string_buffer",
"(",
"255",
")",
"available",
"=",
"c_int",
"(",
")",
"self",
".",
"_lib",
".",
"tdController",
"(",
"b... | Get the next controller while iterating.
:return: a dict with the keys: id, type, name, available. | [
"Get",
"the",
"next",
"controller",
"while",
"iterating",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L437-L450 |
ergo/ziggurat_foundations | ziggurat_foundations/__init__.py | make_passwordmanager | def make_passwordmanager(schemes=None):
"""
schemes contains a list of replace this list with the hash(es) you wish
to support.
this example sets pbkdf2_sha256 as the default,
with support for legacy bcrypt hashes.
:param schemes:
:return: CryptContext()
"""
from passlib.context imp... | python | def make_passwordmanager(schemes=None):
"""
schemes contains a list of replace this list with the hash(es) you wish
to support.
this example sets pbkdf2_sha256 as the default,
with support for legacy bcrypt hashes.
:param schemes:
:return: CryptContext()
"""
from passlib.context imp... | [
"def",
"make_passwordmanager",
"(",
"schemes",
"=",
"None",
")",
":",
"from",
"passlib",
".",
"context",
"import",
"CryptContext",
"if",
"not",
"schemes",
":",
"schemes",
"=",
"[",
"\"pbkdf2_sha256\"",
",",
"\"bcrypt\"",
"]",
"pwd_context",
"=",
"CryptContext",
... | schemes contains a list of replace this list with the hash(es) you wish
to support.
this example sets pbkdf2_sha256 as the default,
with support for legacy bcrypt hashes.
:param schemes:
:return: CryptContext() | [
"schemes",
"contains",
"a",
"list",
"of",
"replace",
"this",
"list",
"with",
"the",
"hash",
"(",
"es",
")",
"you",
"wish",
"to",
"support",
".",
"this",
"example",
"sets",
"pbkdf2_sha256",
"as",
"the",
"default",
"with",
"support",
"for",
"legacy",
"bcrypt... | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/__init__.py#L43-L58 |
ergo/ziggurat_foundations | ziggurat_foundations/__init__.py | ziggurat_model_init | def ziggurat_model_init(
user=None,
group=None,
user_group=None,
group_permission=None,
user_permission=None,
user_resource_permission=None,
group_resource_permission=None,
resource=None,
external_identity=None,
*args,
**kwargs
):
"""
This function handles attaching m... | python | def ziggurat_model_init(
user=None,
group=None,
user_group=None,
group_permission=None,
user_permission=None,
user_resource_permission=None,
group_resource_permission=None,
resource=None,
external_identity=None,
*args,
**kwargs
):
"""
This function handles attaching m... | [
"def",
"ziggurat_model_init",
"(",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"user_group",
"=",
"None",
",",
"group_permission",
"=",
"None",
",",
"user_permission",
"=",
"None",
",",
"user_resource_permission",
"=",
"None",
",",
"group_resource_permi... | This function handles attaching model to service if model has one specified
as `_ziggurat_service`, Also attached a proxy object holding all model
definitions that services might use
:param args:
:param kwargs:
:param passwordmanager, the password manager to override default one
:param password... | [
"This",
"function",
"handles",
"attaching",
"model",
"to",
"service",
"if",
"model",
"has",
"one",
"specified",
"as",
"_ziggurat_service",
"Also",
"attached",
"a",
"proxy",
"object",
"holding",
"all",
"model",
"definitions",
"that",
"services",
"might",
"use"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/__init__.py#L61-L111 |
stephenmcd/gnotty | gnotty/views.py | messages | def messages(request, year=None, month=None, day=None,
template="gnotty/messages.html"):
"""
Show messages for the given query or day.
"""
query = request.REQUEST.get("q")
prev_url, next_url = None, None
messages = IRCMessage.objects.all()
if hide_joins_and_leaves(request):
... | python | def messages(request, year=None, month=None, day=None,
template="gnotty/messages.html"):
"""
Show messages for the given query or day.
"""
query = request.REQUEST.get("q")
prev_url, next_url = None, None
messages = IRCMessage.objects.all()
if hide_joins_and_leaves(request):
... | [
"def",
"messages",
"(",
"request",
",",
"year",
"=",
"None",
",",
"month",
"=",
"None",
",",
"day",
"=",
"None",
",",
"template",
"=",
"\"gnotty/messages.html\"",
")",
":",
"query",
"=",
"request",
".",
"REQUEST",
".",
"get",
"(",
"\"q\"",
")",
"prev_u... | Show messages for the given query or day. | [
"Show",
"messages",
"for",
"the",
"given",
"query",
"or",
"day",
"."
] | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/views.py#L25-L56 |
stephenmcd/gnotty | gnotty/views.py | calendar | def calendar(request, year=None, month=None, template="gnotty/calendar.html"):
"""
Show calendar months for the given year/month.
"""
try:
year = int(year)
except TypeError:
year = datetime.now().year
lookup = {"message_time__year": year}
if month:
lookup["message_ti... | python | def calendar(request, year=None, month=None, template="gnotty/calendar.html"):
"""
Show calendar months for the given year/month.
"""
try:
year = int(year)
except TypeError:
year = datetime.now().year
lookup = {"message_time__year": year}
if month:
lookup["message_ti... | [
"def",
"calendar",
"(",
"request",
",",
"year",
"=",
"None",
",",
"month",
"=",
"None",
",",
"template",
"=",
"\"gnotty/calendar.html\"",
")",
":",
"try",
":",
"year",
"=",
"int",
"(",
"year",
")",
"except",
"TypeError",
":",
"year",
"=",
"datetime",
"... | Show calendar months for the given year/month. | [
"Show",
"calendar",
"months",
"for",
"the",
"given",
"year",
"/",
"month",
"."
] | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/views.py#L59-L102 |
Yelp/swagger_zipkin | swagger_zipkin/decorate_client.py | decorate_client | def decorate_client(api_client, func, name):
"""A helper for decorating :class:`bravado.client.SwaggerClient`.
:class:`bravado.client.SwaggerClient` can be extended by creating a class
which wraps all calls to it. This helper is used in a :func:`__getattr__`
to check if the attr exists on the api_client... | python | def decorate_client(api_client, func, name):
"""A helper for decorating :class:`bravado.client.SwaggerClient`.
:class:`bravado.client.SwaggerClient` can be extended by creating a class
which wraps all calls to it. This helper is used in a :func:`__getattr__`
to check if the attr exists on the api_client... | [
"def",
"decorate_client",
"(",
"api_client",
",",
"func",
",",
"name",
")",
":",
"client_attr",
"=",
"getattr",
"(",
"api_client",
",",
"name",
")",
"if",
"not",
"callable",
"(",
"client_attr",
")",
":",
"return",
"client_attr",
"return",
"OperationDecorator",... | A helper for decorating :class:`bravado.client.SwaggerClient`.
:class:`bravado.client.SwaggerClient` can be extended by creating a class
which wraps all calls to it. This helper is used in a :func:`__getattr__`
to check if the attr exists on the api_client. If the attr does not exist
raise :class:`Attri... | [
"A",
"helper",
"for",
"decorating",
":",
"class",
":",
"bravado",
".",
"client",
".",
"SwaggerClient",
".",
":",
"class",
":",
"bravado",
".",
"client",
".",
"SwaggerClient",
"can",
"be",
"extended",
"by",
"creating",
"a",
"class",
"which",
"wraps",
"all",... | train | https://github.com/Yelp/swagger_zipkin/blob/8159b5d04f2c1089ae0a60851a5f097d7e09a40e/swagger_zipkin/decorate_client.py#L33-L71 |
ambitioninc/django-db-mutex | db_mutex/db_mutex.py | db_mutex.delete_expired_locks | def delete_expired_locks(self):
"""
Deletes all expired mutex locks if a ttl is provided.
"""
ttl_seconds = self.get_mutex_ttl_seconds()
if ttl_seconds is not None:
DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete() | python | def delete_expired_locks(self):
"""
Deletes all expired mutex locks if a ttl is provided.
"""
ttl_seconds = self.get_mutex_ttl_seconds()
if ttl_seconds is not None:
DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete() | [
"def",
"delete_expired_locks",
"(",
"self",
")",
":",
"ttl_seconds",
"=",
"self",
".",
"get_mutex_ttl_seconds",
"(",
")",
"if",
"ttl_seconds",
"is",
"not",
"None",
":",
"DBMutex",
".",
"objects",
".",
"filter",
"(",
"creation_time__lte",
"=",
"timezone",
".",
... | Deletes all expired mutex locks if a ttl is provided. | [
"Deletes",
"all",
"expired",
"mutex",
"locks",
"if",
"a",
"ttl",
"is",
"provided",
"."
] | train | https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L81-L87 |
ambitioninc/django-db-mutex | db_mutex/db_mutex.py | db_mutex.start | def start(self):
"""
Acquires the db mutex lock. Takes the necessary steps to delete any stale locks.
Throws a DBMutexError if it can't acquire the lock.
"""
# Delete any expired locks first
self.delete_expired_locks()
try:
with transaction.atomic():
... | python | def start(self):
"""
Acquires the db mutex lock. Takes the necessary steps to delete any stale locks.
Throws a DBMutexError if it can't acquire the lock.
"""
# Delete any expired locks first
self.delete_expired_locks()
try:
with transaction.atomic():
... | [
"def",
"start",
"(",
"self",
")",
":",
"# Delete any expired locks first",
"self",
".",
"delete_expired_locks",
"(",
")",
"try",
":",
"with",
"transaction",
".",
"atomic",
"(",
")",
":",
"self",
".",
"lock",
"=",
"DBMutex",
".",
"objects",
".",
"create",
"... | Acquires the db mutex lock. Takes the necessary steps to delete any stale locks.
Throws a DBMutexError if it can't acquire the lock. | [
"Acquires",
"the",
"db",
"mutex",
"lock",
".",
"Takes",
"the",
"necessary",
"steps",
"to",
"delete",
"any",
"stale",
"locks",
".",
"Throws",
"a",
"DBMutexError",
"if",
"it",
"can",
"t",
"acquire",
"the",
"lock",
"."
] | train | https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L98-L109 |
ambitioninc/django-db-mutex | db_mutex/db_mutex.py | db_mutex.stop | def stop(self):
"""
Releases the db mutex lock. Throws an error if the lock was released before the function finished.
"""
if not DBMutex.objects.filter(id=self.lock.id).exists():
raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id))
... | python | def stop(self):
"""
Releases the db mutex lock. Throws an error if the lock was released before the function finished.
"""
if not DBMutex.objects.filter(id=self.lock.id).exists():
raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id))
... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"not",
"DBMutex",
".",
"objects",
".",
"filter",
"(",
"id",
"=",
"self",
".",
"lock",
".",
"id",
")",
".",
"exists",
"(",
")",
":",
"raise",
"DBMutexTimeoutError",
"(",
"'Lock {0} expired before function complete... | Releases the db mutex lock. Throws an error if the lock was released before the function finished. | [
"Releases",
"the",
"db",
"mutex",
"lock",
".",
"Throws",
"an",
"error",
"if",
"the",
"lock",
"was",
"released",
"before",
"the",
"function",
"finished",
"."
] | train | https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L111-L118 |
ambitioninc/django-db-mutex | db_mutex/db_mutex.py | db_mutex.decorate_callable | def decorate_callable(self, func):
"""
Decorates a function with the db_mutex decorator by using this class as a context manager around
it.
"""
def wrapper(*args, **kwargs):
try:
with self:
result = func(*args, **kwargs)
... | python | def decorate_callable(self, func):
"""
Decorates a function with the db_mutex decorator by using this class as a context manager around
it.
"""
def wrapper(*args, **kwargs):
try:
with self:
result = func(*args, **kwargs)
... | [
"def",
"decorate_callable",
"(",
"self",
",",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"with",
"self",
":",
"result",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return... | Decorates a function with the db_mutex decorator by using this class as a context manager around
it. | [
"Decorates",
"a",
"function",
"with",
"the",
"db_mutex",
"decorator",
"by",
"using",
"this",
"class",
"as",
"a",
"context",
"manager",
"around",
"it",
"."
] | train | https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L120-L136 |
ergo/ziggurat_foundations | ziggurat_foundations/models/__init__.py | groupfinder | def groupfinder(userid, request):
"""
Default groupfinder implementaion for pyramid applications
:param userid:
:param request:
:return:
"""
if userid and hasattr(request, "user") and request.user:
groups = ["group:%s" % g.id for g in request.user.groups]
return groups
r... | python | def groupfinder(userid, request):
"""
Default groupfinder implementaion for pyramid applications
:param userid:
:param request:
:return:
"""
if userid and hasattr(request, "user") and request.user:
groups = ["group:%s" % g.id for g in request.user.groups]
return groups
r... | [
"def",
"groupfinder",
"(",
"userid",
",",
"request",
")",
":",
"if",
"userid",
"and",
"hasattr",
"(",
"request",
",",
"\"user\"",
")",
"and",
"request",
".",
"user",
":",
"groups",
"=",
"[",
"\"group:%s\"",
"%",
"g",
".",
"id",
"for",
"g",
"in",
"req... | Default groupfinder implementaion for pyramid applications
:param userid:
:param request:
:return: | [
"Default",
"groupfinder",
"implementaion",
"for",
"pyramid",
"applications"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/__init__.py#L7-L18 |
bosiakov/fa2l | fa2l/fa2l.py | force_atlas2_layout | def force_atlas2_layout(graph,
pos_list=None,
node_masses=None,
iterations=100,
outbound_attraction_distribution=False,
lin_log_mode=False,
prevent_overlapping=False,
... | python | def force_atlas2_layout(graph,
pos_list=None,
node_masses=None,
iterations=100,
outbound_attraction_distribution=False,
lin_log_mode=False,
prevent_overlapping=False,
... | [
"def",
"force_atlas2_layout",
"(",
"graph",
",",
"pos_list",
"=",
"None",
",",
"node_masses",
"=",
"None",
",",
"iterations",
"=",
"100",
",",
"outbound_attraction_distribution",
"=",
"False",
",",
"lin_log_mode",
"=",
"False",
",",
"prevent_overlapping",
"=",
"... | Position nodes using ForceAtlas2 force-directed algorithm
Parameters
----------
graph: NetworkX graph
A position will be assigned to every node in G.
pos_list : dict or None optional (default=None)
Initial positions for nodes as a dictionary with node as keys
and values as a c... | [
"Position",
"nodes",
"using",
"ForceAtlas2",
"force",
"-",
"directed",
"algorithm"
] | train | https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/fa2l.py#L10-L243 |
bosiakov/fa2l | fa2l/force.py | apply_repulsion | def apply_repulsion(repulsion, nodes, barnes_hut_optimize=False, region=None, barnes_hut_theta=1.2):
"""
Iterate through the nodes or edges and apply the forces directly to the node objects.
"""
if not barnes_hut_optimize:
for i in range(0, len(nodes)):
for j in range(0, i):
... | python | def apply_repulsion(repulsion, nodes, barnes_hut_optimize=False, region=None, barnes_hut_theta=1.2):
"""
Iterate through the nodes or edges and apply the forces directly to the node objects.
"""
if not barnes_hut_optimize:
for i in range(0, len(nodes)):
for j in range(0, i):
... | [
"def",
"apply_repulsion",
"(",
"repulsion",
",",
"nodes",
",",
"barnes_hut_optimize",
"=",
"False",
",",
"region",
"=",
"None",
",",
"barnes_hut_theta",
"=",
"1.2",
")",
":",
"if",
"not",
"barnes_hut_optimize",
":",
"for",
"i",
"in",
"range",
"(",
"0",
","... | Iterate through the nodes or edges and apply the forces directly to the node objects. | [
"Iterate",
"through",
"the",
"nodes",
"or",
"edges",
"and",
"apply",
"the",
"forces",
"directly",
"to",
"the",
"node",
"objects",
"."
] | train | https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/force.py#L4-L14 |
bosiakov/fa2l | fa2l/force.py | apply_gravity | def apply_gravity(repulsion, nodes, gravity, scaling_ratio):
"""
Iterate through the nodes or edges and apply the gravity directly to the node objects.
"""
for i in range(0, len(nodes)):
repulsion.apply_gravitation(nodes[i], gravity / scaling_ratio) | python | def apply_gravity(repulsion, nodes, gravity, scaling_ratio):
"""
Iterate through the nodes or edges and apply the gravity directly to the node objects.
"""
for i in range(0, len(nodes)):
repulsion.apply_gravitation(nodes[i], gravity / scaling_ratio) | [
"def",
"apply_gravity",
"(",
"repulsion",
",",
"nodes",
",",
"gravity",
",",
"scaling_ratio",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"nodes",
")",
")",
":",
"repulsion",
".",
"apply_gravitation",
"(",
"nodes",
"[",
"i",
"]",
... | Iterate through the nodes or edges and apply the gravity directly to the node objects. | [
"Iterate",
"through",
"the",
"nodes",
"or",
"edges",
"and",
"apply",
"the",
"gravity",
"directly",
"to",
"the",
"node",
"objects",
"."
] | train | https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/force.py#L17-L22 |
ergo/ziggurat_foundations | ziggurat_foundations/models/services/external_identity.py | ExternalIdentityService.get | def get(cls, external_id, local_user_id, provider_name, db_session=None):
"""
Fetch row using primary key -
will use existing object in session if already present
:param external_id:
:param local_user_id:
:param provider_name:
:param db_session:
:return:
... | python | def get(cls, external_id, local_user_id, provider_name, db_session=None):
"""
Fetch row using primary key -
will use existing object in session if already present
:param external_id:
:param local_user_id:
:param provider_name:
:param db_session:
:return:
... | [
"def",
"get",
"(",
"cls",
",",
"external_id",
",",
"local_user_id",
",",
"provider_name",
",",
"db_session",
"=",
"None",
")",
":",
"db_session",
"=",
"get_db_session",
"(",
"db_session",
")",
"return",
"db_session",
".",
"query",
"(",
"cls",
".",
"model",
... | Fetch row using primary key -
will use existing object in session if already present
:param external_id:
:param local_user_id:
:param provider_name:
:param db_session:
:return: | [
"Fetch",
"row",
"using",
"primary",
"key",
"-",
"will",
"use",
"existing",
"object",
"in",
"session",
"if",
"already",
"present"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L12-L26 |
ergo/ziggurat_foundations | ziggurat_foundations/models/services/external_identity.py | ExternalIdentityService.by_external_id_and_provider | def by_external_id_and_provider(cls, external_id, provider_name, db_session=None):
"""
Returns ExternalIdentity instance based on search params
:param external_id:
:param provider_name:
:param db_session:
:return: ExternalIdentity
"""
db_session = get_db_... | python | def by_external_id_and_provider(cls, external_id, provider_name, db_session=None):
"""
Returns ExternalIdentity instance based on search params
:param external_id:
:param provider_name:
:param db_session:
:return: ExternalIdentity
"""
db_session = get_db_... | [
"def",
"by_external_id_and_provider",
"(",
"cls",
",",
"external_id",
",",
"provider_name",
",",
"db_session",
"=",
"None",
")",
":",
"db_session",
"=",
"get_db_session",
"(",
"db_session",
")",
"query",
"=",
"db_session",
".",
"query",
"(",
"cls",
".",
"model... | Returns ExternalIdentity instance based on search params
:param external_id:
:param provider_name:
:param db_session:
:return: ExternalIdentity | [
"Returns",
"ExternalIdentity",
"instance",
"based",
"on",
"search",
"params"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L29-L42 |
ergo/ziggurat_foundations | ziggurat_foundations/models/services/external_identity.py | ExternalIdentityService.user_by_external_id_and_provider | def user_by_external_id_and_provider(
cls, external_id, provider_name, db_session=None
):
"""
Returns User instance based on search params
:param external_id:
:param provider_name:
:param db_session:
:return: User
"""
db_session = get_db_sessi... | python | def user_by_external_id_and_provider(
cls, external_id, provider_name, db_session=None
):
"""
Returns User instance based on search params
:param external_id:
:param provider_name:
:param db_session:
:return: User
"""
db_session = get_db_sessi... | [
"def",
"user_by_external_id_and_provider",
"(",
"cls",
",",
"external_id",
",",
"provider_name",
",",
"db_session",
"=",
"None",
")",
":",
"db_session",
"=",
"get_db_session",
"(",
"db_session",
")",
"query",
"=",
"db_session",
".",
"query",
"(",
"cls",
".",
"... | Returns User instance based on search params
:param external_id:
:param provider_name:
:param db_session:
:return: User | [
"Returns",
"User",
"instance",
"based",
"on",
"search",
"params"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L45-L61 |
ergo/ziggurat_foundations | ziggurat_foundations/models/services/user_permission.py | UserPermissionService.by_user_and_perm | def by_user_and_perm(cls, user_id, perm_name, db_session=None):
"""
return by user and permission name
:param user_id:
:param perm_name:
:param db_session:
:return:
"""
db_session = get_db_session(db_session)
query = db_session.query(cls.model).fi... | python | def by_user_and_perm(cls, user_id, perm_name, db_session=None):
"""
return by user and permission name
:param user_id:
:param perm_name:
:param db_session:
:return:
"""
db_session = get_db_session(db_session)
query = db_session.query(cls.model).fi... | [
"def",
"by_user_and_perm",
"(",
"cls",
",",
"user_id",
",",
"perm_name",
",",
"db_session",
"=",
"None",
")",
":",
"db_session",
"=",
"get_db_session",
"(",
"db_session",
")",
"query",
"=",
"db_session",
".",
"query",
"(",
"cls",
".",
"model",
")",
".",
... | return by user and permission name
:param user_id:
:param perm_name:
:param db_session:
:return: | [
"return",
"by",
"user",
"and",
"permission",
"name"
] | train | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user_permission.py#L26-L38 |
jucacrispim/pylint-mongoengine | pylint_mongoengine/utils.py | node_is_subclass | def node_is_subclass(cls, *subclass_names):
"""Checks if cls node has parent with subclass_name."""
if not isinstance(cls, (ClassDef, Instance)):
return False
# if cls.bases == YES:
# return False
for base_cls in cls.bases:
try:
for inf in base_cls.inferred(): # pra... | python | def node_is_subclass(cls, *subclass_names):
"""Checks if cls node has parent with subclass_name."""
if not isinstance(cls, (ClassDef, Instance)):
return False
# if cls.bases == YES:
# return False
for base_cls in cls.bases:
try:
for inf in base_cls.inferred(): # pra... | [
"def",
"node_is_subclass",
"(",
"cls",
",",
"*",
"subclass_names",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
",",
"(",
"ClassDef",
",",
"Instance",
")",
")",
":",
"return",
"False",
"# if cls.bases == YES:",
"# return False",
"for",
"base_cls",
"in"... | Checks if cls node has parent with subclass_name. | [
"Checks",
"if",
"cls",
"node",
"has",
"parent",
"with",
"subclass_name",
"."
] | train | https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L39-L60 |
jucacrispim/pylint-mongoengine | pylint_mongoengine/utils.py | is_field_method | def is_field_method(node):
"""Checks if a call to a field instance method is valid. A call is
valid if the call is a method of the underlying type. So, in a StringField
the methods from str are valid, in a ListField the methods from list are
valid and so on..."""
name = node.attrname
parent = no... | python | def is_field_method(node):
"""Checks if a call to a field instance method is valid. A call is
valid if the call is a method of the underlying type. So, in a StringField
the methods from str are valid, in a ListField the methods from list are
valid and so on..."""
name = node.attrname
parent = no... | [
"def",
"is_field_method",
"(",
"node",
")",
":",
"name",
"=",
"node",
".",
"attrname",
"parent",
"=",
"node",
".",
"last_child",
"(",
")",
"inferred",
"=",
"safe_infer",
"(",
"parent",
")",
"if",
"not",
"inferred",
":",
"return",
"False",
"for",
"cls_nam... | Checks if a call to a field instance method is valid. A call is
valid if the call is a method of the underlying type. So, in a StringField
the methods from str are valid, in a ListField the methods from list are
valid and so on... | [
"Checks",
"if",
"a",
"call",
"to",
"a",
"field",
"instance",
"method",
"is",
"valid",
".",
"A",
"call",
"is",
"valid",
"if",
"the",
"call",
"is",
"a",
"method",
"of",
"the",
"underlying",
"type",
".",
"So",
"in",
"a",
"StringField",
"the",
"methods",
... | train | https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L83-L99 |
jucacrispim/pylint-mongoengine | pylint_mongoengine/utils.py | get_node_parent_class | def get_node_parent_class(node):
"""Supposes that node is a mongoengine field in a class and tries to
get its parent class"""
while node.parent: # pragma no branch
if isinstance(node, ClassDef):
return node
node = node.parent | python | def get_node_parent_class(node):
"""Supposes that node is a mongoengine field in a class and tries to
get its parent class"""
while node.parent: # pragma no branch
if isinstance(node, ClassDef):
return node
node = node.parent | [
"def",
"get_node_parent_class",
"(",
"node",
")",
":",
"while",
"node",
".",
"parent",
":",
"# pragma no branch",
"if",
"isinstance",
"(",
"node",
",",
"ClassDef",
")",
":",
"return",
"node",
"node",
"=",
"node",
".",
"parent"
] | Supposes that node is a mongoengine field in a class and tries to
get its parent class | [
"Supposes",
"that",
"node",
"is",
"a",
"mongoengine",
"field",
"in",
"a",
"class",
"and",
"tries",
"to",
"get",
"its",
"parent",
"class"
] | train | https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L102-L110 |
jucacrispim/pylint-mongoengine | pylint_mongoengine/utils.py | get_field_definition | def get_field_definition(node):
""""node is a class attribute that is a mongoengine. Returns
the definition statement for the attribute
"""
name = node.attrname
cls = get_node_parent_class(node)
definition = cls.lookup(name)[1][0].statement()
return definition | python | def get_field_definition(node):
""""node is a class attribute that is a mongoengine. Returns
the definition statement for the attribute
"""
name = node.attrname
cls = get_node_parent_class(node)
definition = cls.lookup(name)[1][0].statement()
return definition | [
"def",
"get_field_definition",
"(",
"node",
")",
":",
"name",
"=",
"node",
".",
"attrname",
"cls",
"=",
"get_node_parent_class",
"(",
"node",
")",
"definition",
"=",
"cls",
".",
"lookup",
"(",
"name",
")",
"[",
"1",
"]",
"[",
"0",
"]",
".",
"statement"... | node is a class attribute that is a mongoengine. Returns
the definition statement for the attribute | [
"node",
"is",
"a",
"class",
"attribute",
"that",
"is",
"a",
"mongoengine",
".",
"Returns",
"the",
"definition",
"statement",
"for",
"the",
"attribute"
] | train | https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L122-L130 |
jucacrispim/pylint-mongoengine | pylint_mongoengine/utils.py | get_field_embedded_doc | def get_field_embedded_doc(node):
"""Returns de ClassDef for the related embedded document in a
embedded document field."""
definition = get_field_definition(node)
cls_name = definition.last_child().last_child()
cls = next(cls_name.infer())
return cls | python | def get_field_embedded_doc(node):
"""Returns de ClassDef for the related embedded document in a
embedded document field."""
definition = get_field_definition(node)
cls_name = definition.last_child().last_child()
cls = next(cls_name.infer())
return cls | [
"def",
"get_field_embedded_doc",
"(",
"node",
")",
":",
"definition",
"=",
"get_field_definition",
"(",
"node",
")",
"cls_name",
"=",
"definition",
".",
"last_child",
"(",
")",
".",
"last_child",
"(",
")",
"cls",
"=",
"next",
"(",
"cls_name",
".",
"infer",
... | Returns de ClassDef for the related embedded document in a
embedded document field. | [
"Returns",
"de",
"ClassDef",
"for",
"the",
"related",
"embedded",
"document",
"in",
"a",
"embedded",
"document",
"field",
"."
] | train | https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L133-L140 |
jucacrispim/pylint-mongoengine | pylint_mongoengine/utils.py | node_is_embedded_doc_attr | def node_is_embedded_doc_attr(node):
"""Checks if a node is a valid field or method in a embedded document.
"""
embedded_doc = get_field_embedded_doc(node.last_child())
name = node.attrname
try:
r = bool(embedded_doc.lookup(name)[1][0])
except IndexError:
r = False
return r | python | def node_is_embedded_doc_attr(node):
"""Checks if a node is a valid field or method in a embedded document.
"""
embedded_doc = get_field_embedded_doc(node.last_child())
name = node.attrname
try:
r = bool(embedded_doc.lookup(name)[1][0])
except IndexError:
r = False
return r | [
"def",
"node_is_embedded_doc_attr",
"(",
"node",
")",
":",
"embedded_doc",
"=",
"get_field_embedded_doc",
"(",
"node",
".",
"last_child",
"(",
")",
")",
"name",
"=",
"node",
".",
"attrname",
"try",
":",
"r",
"=",
"bool",
"(",
"embedded_doc",
".",
"lookup",
... | Checks if a node is a valid field or method in a embedded document. | [
"Checks",
"if",
"a",
"node",
"is",
"a",
"valid",
"field",
"or",
"method",
"in",
"a",
"embedded",
"document",
"."
] | train | https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L143-L153 |
stephenmcd/gnotty | gnotty/bots/base.py | BaseBot._dispatcher | def _dispatcher(self, connection, event):
"""
This is the method in ``SimpleIRCClient`` that all IRC events
get passed through. Here we map events to our own custom
event handlers, and call them.
"""
super(BaseBot, self)._dispatcher(connection, event)
for handler ... | python | def _dispatcher(self, connection, event):
"""
This is the method in ``SimpleIRCClient`` that all IRC events
get passed through. Here we map events to our own custom
event handlers, and call them.
"""
super(BaseBot, self)._dispatcher(connection, event)
for handler ... | [
"def",
"_dispatcher",
"(",
"self",
",",
"connection",
",",
"event",
")",
":",
"super",
"(",
"BaseBot",
",",
"self",
")",
".",
"_dispatcher",
"(",
"connection",
",",
"event",
")",
"for",
"handler",
"in",
"self",
".",
"events",
"[",
"event",
".",
"eventt... | This is the method in ``SimpleIRCClient`` that all IRC events
get passed through. Here we map events to our own custom
event handlers, and call them. | [
"This",
"is",
"the",
"method",
"in",
"SimpleIRCClient",
"that",
"all",
"IRC",
"events",
"get",
"passed",
"through",
".",
"Here",
"we",
"map",
"events",
"to",
"our",
"own",
"custom",
"event",
"handlers",
"and",
"call",
"them",
"."
] | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L57-L65 |
stephenmcd/gnotty | gnotty/bots/base.py | BaseBot.message_channel | def message_channel(self, message):
"""
We won't receive our own messages, so log them manually.
"""
self.log(None, message)
super(BaseBot, self).message_channel(message) | python | def message_channel(self, message):
"""
We won't receive our own messages, so log them manually.
"""
self.log(None, message)
super(BaseBot, self).message_channel(message) | [
"def",
"message_channel",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"log",
"(",
"None",
",",
"message",
")",
"super",
"(",
"BaseBot",
",",
"self",
")",
".",
"message_channel",
"(",
"message",
")"
] | We won't receive our own messages, so log them manually. | [
"We",
"won",
"t",
"receive",
"our",
"own",
"messages",
"so",
"log",
"them",
"manually",
"."
] | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L76-L81 |
stephenmcd/gnotty | gnotty/bots/base.py | BaseBot.on_pubmsg | def on_pubmsg(self, connection, event):
"""
Log any public messages, and also handle the command event.
"""
for message in event.arguments():
self.log(event, message)
command_args = filter(None, message.split())
command_name = command_args.pop(0)
... | python | def on_pubmsg(self, connection, event):
"""
Log any public messages, and also handle the command event.
"""
for message in event.arguments():
self.log(event, message)
command_args = filter(None, message.split())
command_name = command_args.pop(0)
... | [
"def",
"on_pubmsg",
"(",
"self",
",",
"connection",
",",
"event",
")",
":",
"for",
"message",
"in",
"event",
".",
"arguments",
"(",
")",
":",
"self",
".",
"log",
"(",
"event",
",",
"message",
")",
"command_args",
"=",
"filter",
"(",
"None",
",",
"mes... | Log any public messages, and also handle the command event. | [
"Log",
"any",
"public",
"messages",
"and",
"also",
"handle",
"the",
"command",
"event",
"."
] | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L92-L102 |
stephenmcd/gnotty | gnotty/bots/base.py | BaseBot.handle_command_event | def handle_command_event(self, event, command, args):
"""
Command handler - treats each word in the message
that triggered the command as an argument to the command,
and does some validation to ensure that the number of
arguments match.
"""
argspec = getargspec(co... | python | def handle_command_event(self, event, command, args):
"""
Command handler - treats each word in the message
that triggered the command as an argument to the command,
and does some validation to ensure that the number of
arguments match.
"""
argspec = getargspec(co... | [
"def",
"handle_command_event",
"(",
"self",
",",
"event",
",",
"command",
",",
"args",
")",
":",
"argspec",
"=",
"getargspec",
"(",
"command",
")",
"num_all_args",
"=",
"len",
"(",
"argspec",
".",
"args",
")",
"-",
"2",
"# Ignore self/event args",
"num_pos_a... | Command handler - treats each word in the message
that triggered the command as an argument to the command,
and does some validation to ensure that the number of
arguments match. | [
"Command",
"handler",
"-",
"treats",
"each",
"word",
"in",
"the",
"message",
"that",
"triggered",
"the",
"command",
"as",
"an",
"argument",
"to",
"the",
"command",
"and",
"does",
"some",
"validation",
"to",
"ensure",
"that",
"the",
"number",
"of",
"arguments... | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L104-L123 |
stephenmcd/gnotty | gnotty/bots/base.py | BaseBot.handle_timer_event | def handle_timer_event(self, handler):
"""
Runs each timer handler in a separate greenlet thread.
"""
while True:
handler(self)
sleep(handler.event.args["seconds"]) | python | def handle_timer_event(self, handler):
"""
Runs each timer handler in a separate greenlet thread.
"""
while True:
handler(self)
sleep(handler.event.args["seconds"]) | [
"def",
"handle_timer_event",
"(",
"self",
",",
"handler",
")",
":",
"while",
"True",
":",
"handler",
"(",
"self",
")",
"sleep",
"(",
"handler",
".",
"event",
".",
"args",
"[",
"\"seconds\"",
"]",
")"
] | Runs each timer handler in a separate greenlet thread. | [
"Runs",
"each",
"timer",
"handler",
"in",
"a",
"separate",
"greenlet",
"thread",
"."
] | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L125-L131 |
stephenmcd/gnotty | gnotty/bots/base.py | BaseBot.handle_webhook_event | def handle_webhook_event(self, environ, url, params):
"""
Webhook handler - each handler for the webhook event
takes an initial pattern argument for matching the URL
requested. Here we match the URL to the pattern for each
webhook handler, and bail out if it returns a response.
... | python | def handle_webhook_event(self, environ, url, params):
"""
Webhook handler - each handler for the webhook event
takes an initial pattern argument for matching the URL
requested. Here we match the URL to the pattern for each
webhook handler, and bail out if it returns a response.
... | [
"def",
"handle_webhook_event",
"(",
"self",
",",
"environ",
",",
"url",
",",
"params",
")",
":",
"for",
"handler",
"in",
"self",
".",
"events",
"[",
"\"webhook\"",
"]",
":",
"urlpattern",
"=",
"handler",
".",
"event",
".",
"args",
"[",
"\"urlpattern\"",
... | Webhook handler - each handler for the webhook event
takes an initial pattern argument for matching the URL
requested. Here we match the URL to the pattern for each
webhook handler, and bail out if it returns a response. | [
"Webhook",
"handler",
"-",
"each",
"handler",
"for",
"the",
"webhook",
"event",
"takes",
"an",
"initial",
"pattern",
"argument",
"for",
"matching",
"the",
"URL",
"requested",
".",
"Here",
"we",
"match",
"the",
"URL",
"to",
"the",
"pattern",
"for",
"each",
... | train | https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L133-L145 |
erijo/tellcore-py | tellcore/telldus.py | DeviceFactory | def DeviceFactory(id, lib=None):
"""Create the correct device instance based on device type and return it.
:return: a :class:`Device` or :class:`DeviceGroup` instance.
"""
lib = lib or Library()
if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP:
return DeviceGroup(id, lib=lib)
re... | python | def DeviceFactory(id, lib=None):
"""Create the correct device instance based on device type and return it.
:return: a :class:`Device` or :class:`DeviceGroup` instance.
"""
lib = lib or Library()
if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP:
return DeviceGroup(id, lib=lib)
re... | [
"def",
"DeviceFactory",
"(",
"id",
",",
"lib",
"=",
"None",
")",
":",
"lib",
"=",
"lib",
"or",
"Library",
"(",
")",
"if",
"lib",
".",
"tdGetDeviceType",
"(",
"id",
")",
"==",
"const",
".",
"TELLSTICK_TYPE_GROUP",
":",
"return",
"DeviceGroup",
"(",
"id"... | Create the correct device instance based on device type and return it.
:return: a :class:`Device` or :class:`DeviceGroup` instance. | [
"Create",
"the",
"correct",
"device",
"instance",
"based",
"on",
"device",
"type",
"and",
"return",
"it",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L266-L274 |
erijo/tellcore-py | tellcore/telldus.py | QueuedCallbackDispatcher.process_callback | def process_callback(self, block=True):
"""Dispatch a single callback in the current thread.
:param boolean block: If True, blocks waiting for a callback to come.
:return: True if a callback was processed; otherwise False.
"""
try:
(callback, args) = self._queue.get(... | python | def process_callback(self, block=True):
"""Dispatch a single callback in the current thread.
:param boolean block: If True, blocks waiting for a callback to come.
:return: True if a callback was processed; otherwise False.
"""
try:
(callback, args) = self._queue.get(... | [
"def",
"process_callback",
"(",
"self",
",",
"block",
"=",
"True",
")",
":",
"try",
":",
"(",
"callback",
",",
"args",
")",
"=",
"self",
".",
"_queue",
".",
"get",
"(",
"block",
"=",
"block",
")",
"try",
":",
"callback",
"(",
"*",
"args",
")",
"f... | Dispatch a single callback in the current thread.
:param boolean block: If True, blocks waiting for a callback to come.
:return: True if a callback was processed; otherwise False. | [
"Dispatch",
"a",
"single",
"callback",
"in",
"the",
"current",
"thread",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L48-L62 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.devices | def devices(self):
"""Return all known devices.
:return: list of :class:`Device` or :class:`DeviceGroup` instances.
"""
devices = []
count = self.lib.tdGetNumberOfDevices()
for i in range(count):
device = DeviceFactory(self.lib.tdGetDeviceId(i), lib=self.lib)... | python | def devices(self):
"""Return all known devices.
:return: list of :class:`Device` or :class:`DeviceGroup` instances.
"""
devices = []
count = self.lib.tdGetNumberOfDevices()
for i in range(count):
device = DeviceFactory(self.lib.tdGetDeviceId(i), lib=self.lib)... | [
"def",
"devices",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"]",
"count",
"=",
"self",
".",
"lib",
".",
"tdGetNumberOfDevices",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"device",
"=",
"DeviceFactory",
"(",
"self",
".",
"lib",
... | Return all known devices.
:return: list of :class:`Device` or :class:`DeviceGroup` instances. | [
"Return",
"all",
"known",
"devices",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L169-L179 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.sensors | def sensors(self):
"""Return all known sensors.
:return: list of :class:`Sensor` instances.
"""
sensors = []
try:
while True:
sensor = self.lib.tdSensor()
sensors.append(Sensor(lib=self.lib, **sensor))
except TelldusError as e:... | python | def sensors(self):
"""Return all known sensors.
:return: list of :class:`Sensor` instances.
"""
sensors = []
try:
while True:
sensor = self.lib.tdSensor()
sensors.append(Sensor(lib=self.lib, **sensor))
except TelldusError as e:... | [
"def",
"sensors",
"(",
"self",
")",
":",
"sensors",
"=",
"[",
"]",
"try",
":",
"while",
"True",
":",
"sensor",
"=",
"self",
".",
"lib",
".",
"tdSensor",
"(",
")",
"sensors",
".",
"append",
"(",
"Sensor",
"(",
"lib",
"=",
"self",
".",
"lib",
",",
... | Return all known sensors.
:return: list of :class:`Sensor` instances. | [
"Return",
"all",
"known",
"sensors",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L181-L194 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.controllers | def controllers(self):
"""Return all known controllers.
Requires Telldus core library version >= 2.1.2.
:return: list of :class:`Controller` instances.
"""
controllers = []
try:
while True:
controller = self.lib.tdController()
... | python | def controllers(self):
"""Return all known controllers.
Requires Telldus core library version >= 2.1.2.
:return: list of :class:`Controller` instances.
"""
controllers = []
try:
while True:
controller = self.lib.tdController()
... | [
"def",
"controllers",
"(",
"self",
")",
":",
"controllers",
"=",
"[",
"]",
"try",
":",
"while",
"True",
":",
"controller",
"=",
"self",
".",
"lib",
".",
"tdController",
"(",
")",
"del",
"controller",
"[",
"\"name\"",
"]",
"del",
"controller",
"[",
"\"a... | Return all known controllers.
Requires Telldus core library version >= 2.1.2.
:return: list of :class:`Controller` instances. | [
"Return",
"all",
"known",
"controllers",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L196-L213 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.add_device | def add_device(self, name, protocol, model=None, **parameters):
"""Add a new device.
:return: a :class:`Device` or :class:`DeviceGroup` instance.
"""
device = Device(self.lib.tdAddDevice(), lib=self.lib)
try:
device.name = name
device.protocol = protocol
... | python | def add_device(self, name, protocol, model=None, **parameters):
"""Add a new device.
:return: a :class:`Device` or :class:`DeviceGroup` instance.
"""
device = Device(self.lib.tdAddDevice(), lib=self.lib)
try:
device.name = name
device.protocol = protocol
... | [
"def",
"add_device",
"(",
"self",
",",
"name",
",",
"protocol",
",",
"model",
"=",
"None",
",",
"*",
"*",
"parameters",
")",
":",
"device",
"=",
"Device",
"(",
"self",
".",
"lib",
".",
"tdAddDevice",
"(",
")",
",",
"lib",
"=",
"self",
".",
"lib",
... | Add a new device.
:return: a :class:`Device` or :class:`DeviceGroup` instance. | [
"Add",
"a",
"new",
"device",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L215-L242 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.add_group | def add_group(self, name, devices):
"""Add a new device group.
:return: a :class:`DeviceGroup` instance.
"""
device = self.add_device(name, "group")
device.add_to_group(devices)
return device | python | def add_group(self, name, devices):
"""Add a new device group.
:return: a :class:`DeviceGroup` instance.
"""
device = self.add_device(name, "group")
device.add_to_group(devices)
return device | [
"def",
"add_group",
"(",
"self",
",",
"name",
",",
"devices",
")",
":",
"device",
"=",
"self",
".",
"add_device",
"(",
"name",
",",
"\"group\"",
")",
"device",
".",
"add_to_group",
"(",
"devices",
")",
"return",
"device"
] | Add a new device group.
:return: a :class:`DeviceGroup` instance. | [
"Add",
"a",
"new",
"device",
"group",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L244-L251 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.connect_controller | def connect_controller(self, vid, pid, serial):
"""Connect a controller."""
self.lib.tdConnectTellStickController(vid, pid, serial) | python | def connect_controller(self, vid, pid, serial):
"""Connect a controller."""
self.lib.tdConnectTellStickController(vid, pid, serial) | [
"def",
"connect_controller",
"(",
"self",
",",
"vid",
",",
"pid",
",",
"serial",
")",
":",
"self",
".",
"lib",
".",
"tdConnectTellStickController",
"(",
"vid",
",",
"pid",
",",
"serial",
")"
] | Connect a controller. | [
"Connect",
"a",
"controller",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L257-L259 |
erijo/tellcore-py | tellcore/telldus.py | TelldusCore.disconnect_controller | def disconnect_controller(self, vid, pid, serial):
"""Disconnect a controller."""
self.lib.tdDisconnectTellStickController(vid, pid, serial) | python | def disconnect_controller(self, vid, pid, serial):
"""Disconnect a controller."""
self.lib.tdDisconnectTellStickController(vid, pid, serial) | [
"def",
"disconnect_controller",
"(",
"self",
",",
"vid",
",",
"pid",
",",
"serial",
")",
":",
"self",
".",
"lib",
".",
"tdDisconnectTellStickController",
"(",
"vid",
",",
"pid",
",",
"serial",
")"
] | Disconnect a controller. | [
"Disconnect",
"a",
"controller",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L261-L263 |
erijo/tellcore-py | tellcore/telldus.py | Device.parameters | def parameters(self):
"""Get dict with all set parameters."""
parameters = {}
for name in self.PARAMETERS:
try:
parameters[name] = self.get_parameter(name)
except AttributeError:
pass
return parameters | python | def parameters(self):
"""Get dict with all set parameters."""
parameters = {}
for name in self.PARAMETERS:
try:
parameters[name] = self.get_parameter(name)
except AttributeError:
pass
return parameters | [
"def",
"parameters",
"(",
"self",
")",
":",
"parameters",
"=",
"{",
"}",
"for",
"name",
"in",
"self",
".",
"PARAMETERS",
":",
"try",
":",
"parameters",
"[",
"name",
"]",
"=",
"self",
".",
"get_parameter",
"(",
"name",
")",
"except",
"AttributeError",
"... | Get dict with all set parameters. | [
"Get",
"dict",
"with",
"all",
"set",
"parameters",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L323-L331 |
erijo/tellcore-py | tellcore/telldus.py | Device.get_parameter | def get_parameter(self, name):
"""Get a parameter."""
default_value = "$%!)(INVALID)(!%$"
value = self.lib.tdGetDeviceParameter(self.id, name, default_value)
if value == default_value:
raise AttributeError(name)
return value | python | def get_parameter(self, name):
"""Get a parameter."""
default_value = "$%!)(INVALID)(!%$"
value = self.lib.tdGetDeviceParameter(self.id, name, default_value)
if value == default_value:
raise AttributeError(name)
return value | [
"def",
"get_parameter",
"(",
"self",
",",
"name",
")",
":",
"default_value",
"=",
"\"$%!)(INVALID)(!%$\"",
"value",
"=",
"self",
".",
"lib",
".",
"tdGetDeviceParameter",
"(",
"self",
".",
"id",
",",
"name",
",",
"default_value",
")",
"if",
"value",
"==",
"... | Get a parameter. | [
"Get",
"a",
"parameter",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L333-L339 |
erijo/tellcore-py | tellcore/telldus.py | Device.set_parameter | def set_parameter(self, name, value):
"""Set a parameter."""
self.lib.tdSetDeviceParameter(self.id, name, str(value)) | python | def set_parameter(self, name, value):
"""Set a parameter."""
self.lib.tdSetDeviceParameter(self.id, name, str(value)) | [
"def",
"set_parameter",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"lib",
".",
"tdSetDeviceParameter",
"(",
"self",
".",
"id",
",",
"name",
",",
"str",
"(",
"value",
")",
")"
] | Set a parameter. | [
"Set",
"a",
"parameter",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L341-L343 |
erijo/tellcore-py | tellcore/telldus.py | DeviceGroup.add_to_group | def add_to_group(self, devices):
"""Add device(s) to the group."""
ids = {d.id for d in self.devices_in_group()}
ids.update(self._device_ids(devices))
self._set_group(ids) | python | def add_to_group(self, devices):
"""Add device(s) to the group."""
ids = {d.id for d in self.devices_in_group()}
ids.update(self._device_ids(devices))
self._set_group(ids) | [
"def",
"add_to_group",
"(",
"self",
",",
"devices",
")",
":",
"ids",
"=",
"{",
"d",
".",
"id",
"for",
"d",
"in",
"self",
".",
"devices_in_group",
"(",
")",
"}",
"ids",
".",
"update",
"(",
"self",
".",
"_device_ids",
"(",
"devices",
")",
")",
"self"... | Add device(s) to the group. | [
"Add",
"device",
"(",
"s",
")",
"to",
"the",
"group",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L406-L410 |
erijo/tellcore-py | tellcore/telldus.py | DeviceGroup.remove_from_group | def remove_from_group(self, devices):
"""Remove device(s) from the group."""
ids = {d.id for d in self.devices_in_group()}
ids.difference_update(self._device_ids(devices))
self._set_group(ids) | python | def remove_from_group(self, devices):
"""Remove device(s) from the group."""
ids = {d.id for d in self.devices_in_group()}
ids.difference_update(self._device_ids(devices))
self._set_group(ids) | [
"def",
"remove_from_group",
"(",
"self",
",",
"devices",
")",
":",
"ids",
"=",
"{",
"d",
".",
"id",
"for",
"d",
"in",
"self",
".",
"devices_in_group",
"(",
")",
"}",
"ids",
".",
"difference_update",
"(",
"self",
".",
"_device_ids",
"(",
"devices",
")",... | Remove device(s) from the group. | [
"Remove",
"device",
"(",
"s",
")",
"from",
"the",
"group",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L412-L416 |
erijo/tellcore-py | tellcore/telldus.py | DeviceGroup.devices_in_group | def devices_in_group(self):
"""Fetch list of devices in group."""
try:
devices = self.get_parameter('devices')
except AttributeError:
return []
ctor = DeviceFactory
return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x] | python | def devices_in_group(self):
"""Fetch list of devices in group."""
try:
devices = self.get_parameter('devices')
except AttributeError:
return []
ctor = DeviceFactory
return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x] | [
"def",
"devices_in_group",
"(",
"self",
")",
":",
"try",
":",
"devices",
"=",
"self",
".",
"get_parameter",
"(",
"'devices'",
")",
"except",
"AttributeError",
":",
"return",
"[",
"]",
"ctor",
"=",
"DeviceFactory",
"return",
"[",
"ctor",
"(",
"int",
"(",
... | Fetch list of devices in group. | [
"Fetch",
"list",
"of",
"devices",
"in",
"group",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L418-L426 |
erijo/tellcore-py | tellcore/telldus.py | Sensor.value | def value(self, datatype):
"""Return the :class:`SensorValue` for the given data type.
sensor.value(TELLSTICK_TEMPERATURE) is identical to calling
sensor.temperature().
"""
value = self.lib.tdSensorValue(
self.protocol, self.model, self.id, datatype)
return S... | python | def value(self, datatype):
"""Return the :class:`SensorValue` for the given data type.
sensor.value(TELLSTICK_TEMPERATURE) is identical to calling
sensor.temperature().
"""
value = self.lib.tdSensorValue(
self.protocol, self.model, self.id, datatype)
return S... | [
"def",
"value",
"(",
"self",
",",
"datatype",
")",
":",
"value",
"=",
"self",
".",
"lib",
".",
"tdSensorValue",
"(",
"self",
".",
"protocol",
",",
"self",
".",
"model",
",",
"self",
".",
"id",
",",
"datatype",
")",
"return",
"SensorValue",
"(",
"data... | Return the :class:`SensorValue` for the given data type.
sensor.value(TELLSTICK_TEMPERATURE) is identical to calling
sensor.temperature(). | [
"Return",
"the",
":",
"class",
":",
"SensorValue",
"for",
"the",
"given",
"data",
"type",
"."
] | train | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L478-L486 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _prepPointsForSegments | def _prepPointsForSegments(points):
"""
Move any off curves at the end of the contour
to the beginning of the contour. This makes
segmentation easier.
"""
while 1:
point = points[-1]
if point.segmentType:
break
else:
point = points.pop()
... | python | def _prepPointsForSegments(points):
"""
Move any off curves at the end of the contour
to the beginning of the contour. This makes
segmentation easier.
"""
while 1:
point = points[-1]
if point.segmentType:
break
else:
point = points.pop()
... | [
"def",
"_prepPointsForSegments",
"(",
"points",
")",
":",
"while",
"1",
":",
"point",
"=",
"points",
"[",
"-",
"1",
"]",
"if",
"point",
".",
"segmentType",
":",
"break",
"else",
":",
"point",
"=",
"points",
".",
"pop",
"(",
")",
"points",
".",
"inser... | Move any off curves at the end of the contour
to the beginning of the contour. This makes
segmentation easier. | [
"Move",
"any",
"off",
"curves",
"at",
"the",
"end",
"of",
"the",
"contour",
"to",
"the",
"beginning",
"of",
"the",
"contour",
".",
"This",
"makes",
"segmentation",
"easier",
"."
] | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L360-L374 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _reversePoints | def _reversePoints(points):
"""
Reverse the points. This differs from the
reversal point pen in RoboFab in that it doesn't
worry about maintaing the start point position.
That has no benefit within the context of this module.
"""
# copy the points
points = _copyPoints(points)
# find ... | python | def _reversePoints(points):
"""
Reverse the points. This differs from the
reversal point pen in RoboFab in that it doesn't
worry about maintaing the start point position.
That has no benefit within the context of this module.
"""
# copy the points
points = _copyPoints(points)
# find ... | [
"def",
"_reversePoints",
"(",
"points",
")",
":",
"# copy the points",
"points",
"=",
"_copyPoints",
"(",
"points",
")",
"# find the first on curve type and recycle",
"# it for the last on curve type",
"firstOnCurve",
"=",
"None",
"for",
"index",
",",
"point",
"in",
"en... | Reverse the points. This differs from the
reversal point pen in RoboFab in that it doesn't
worry about maintaing the start point position.
That has no benefit within the context of this module. | [
"Reverse",
"the",
"points",
".",
"This",
"differs",
"from",
"the",
"reversal",
"point",
"pen",
"in",
"RoboFab",
"in",
"that",
"it",
"doesn",
"t",
"worry",
"about",
"maintaing",
"the",
"start",
"point",
"position",
".",
"That",
"has",
"no",
"benefit",
"with... | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L385-L416 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _convertPointsToSegments | def _convertPointsToSegments(points, willBeReversed=False):
"""
Compile points into InputSegment objects.
"""
# get the last on curve
previousOnCurve = None
for point in reversed(points):
if point.segmentType is not None:
previousOnCurve = point.coordinates
break
... | python | def _convertPointsToSegments(points, willBeReversed=False):
"""
Compile points into InputSegment objects.
"""
# get the last on curve
previousOnCurve = None
for point in reversed(points):
if point.segmentType is not None:
previousOnCurve = point.coordinates
break
... | [
"def",
"_convertPointsToSegments",
"(",
"points",
",",
"willBeReversed",
"=",
"False",
")",
":",
"# get the last on curve",
"previousOnCurve",
"=",
"None",
"for",
"point",
"in",
"reversed",
"(",
"points",
")",
":",
"if",
"point",
".",
"segmentType",
"is",
"not",... | Compile points into InputSegment objects. | [
"Compile",
"points",
"into",
"InputSegment",
"objects",
"."
] | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L419-L447 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _tValueForPointOnCubicCurve | def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0):
"""
Finds a t value on a curve from a point.
The points must be originaly be a point on the curve.
This will only back trace the t value, needed to split the curve in parts
"""
pt1, pt2, pt3, pt4 = cubicCurve
a, b, c, d = be... | python | def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0):
"""
Finds a t value on a curve from a point.
The points must be originaly be a point on the curve.
This will only back trace the t value, needed to split the curve in parts
"""
pt1, pt2, pt3, pt4 = cubicCurve
a, b, c, d = be... | [
"def",
"_tValueForPointOnCubicCurve",
"(",
"point",
",",
"cubicCurve",
",",
"isHorizontal",
"=",
"0",
")",
":",
"pt1",
",",
"pt2",
",",
"pt3",
",",
"pt4",
"=",
"cubicCurve",
"a",
",",
"b",
",",
"c",
",",
"d",
"=",
"bezierTools",
".",
"calcCubicParameters... | Finds a t value on a curve from a point.
The points must be originaly be a point on the curve.
This will only back trace the t value, needed to split the curve in parts | [
"Finds",
"a",
"t",
"value",
"on",
"a",
"curve",
"from",
"a",
"point",
".",
"The",
"points",
"must",
"be",
"originaly",
"be",
"a",
"point",
"on",
"the",
"curve",
".",
"This",
"will",
"only",
"back",
"trace",
"the",
"t",
"value",
"needed",
"to",
"split... | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L950-L972 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _scalePoints | def _scalePoints(points, scale=1, convertToInteger=True):
"""
Scale points and optionally convert them to integers.
"""
if convertToInteger:
points = [
(int(round(x * scale)), int(round(y * scale)))
for (x, y) in points
]
else:
points = [(x * scale, y ... | python | def _scalePoints(points, scale=1, convertToInteger=True):
"""
Scale points and optionally convert them to integers.
"""
if convertToInteger:
points = [
(int(round(x * scale)), int(round(y * scale)))
for (x, y) in points
]
else:
points = [(x * scale, y ... | [
"def",
"_scalePoints",
"(",
"points",
",",
"scale",
"=",
"1",
",",
"convertToInteger",
"=",
"True",
")",
":",
"if",
"convertToInteger",
":",
"points",
"=",
"[",
"(",
"int",
"(",
"round",
"(",
"x",
"*",
"scale",
")",
")",
",",
"int",
"(",
"round",
"... | Scale points and optionally convert them to integers. | [
"Scale",
"points",
"and",
"optionally",
"convert",
"them",
"to",
"integers",
"."
] | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1007-L1018 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _scaleSinglePoint | def _scaleSinglePoint(point, scale=1, convertToInteger=True):
"""
Scale a single point
"""
x, y = point
if convertToInteger:
return int(round(x * scale)), int(round(y * scale))
else:
return (x * scale, y * scale) | python | def _scaleSinglePoint(point, scale=1, convertToInteger=True):
"""
Scale a single point
"""
x, y = point
if convertToInteger:
return int(round(x * scale)), int(round(y * scale))
else:
return (x * scale, y * scale) | [
"def",
"_scaleSinglePoint",
"(",
"point",
",",
"scale",
"=",
"1",
",",
"convertToInteger",
"=",
"True",
")",
":",
"x",
",",
"y",
"=",
"point",
"if",
"convertToInteger",
":",
"return",
"int",
"(",
"round",
"(",
"x",
"*",
"scale",
")",
")",
",",
"int",... | Scale a single point | [
"Scale",
"a",
"single",
"point"
] | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1021-L1029 |
typemytype/booleanOperations | Lib/booleanOperations/flatten.py | _flattenSegment | def _flattenSegment(segment, approximateSegmentLength=_approximateSegmentLength):
"""
Flatten the curve segment int a list of points.
The first and last points in the segment must be
on curves. The returned list of points will not
include the first on curve point.
false curves (where the off cur... | python | def _flattenSegment(segment, approximateSegmentLength=_approximateSegmentLength):
"""
Flatten the curve segment int a list of points.
The first and last points in the segment must be
on curves. The returned list of points will not
include the first on curve point.
false curves (where the off cur... | [
"def",
"_flattenSegment",
"(",
"segment",
",",
"approximateSegmentLength",
"=",
"_approximateSegmentLength",
")",
":",
"onCurve1",
",",
"offCurve1",
",",
"offCurve2",
",",
"onCurve2",
"=",
"segment",
"if",
"_pointOnLine",
"(",
"onCurve1",
",",
"onCurve2",
",",
"of... | Flatten the curve segment int a list of points.
The first and last points in the segment must be
on curves. The returned list of points will not
include the first on curve point.
false curves (where the off curves are not any
different from the on curves) must not be sent here.
duplicate points ... | [
"Flatten",
"the",
"curve",
"segment",
"int",
"a",
"list",
"of",
"points",
".",
"The",
"first",
"and",
"last",
"points",
"in",
"the",
"segment",
"must",
"be",
"on",
"curves",
".",
"The",
"returned",
"list",
"of",
"points",
"will",
"not",
"include",
"the",... | train | https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1059-L1086 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.