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 |
|---|---|---|---|---|---|---|---|---|---|---|
FujiMakoto/AgentML | agentml/parser/trigger/__init__.py | Trigger._parse_topic | def _parse_topic(self, element):
"""
Parse and assign the topic for this trigger
:param element: The XML Element object
:type element: etree._Element
"""
self._log.debug('Setting Trigger topic: {topic}'.format(topic=element.text))
super(Trigger, self)._parse_topi... | python | def _parse_topic(self, element):
"""
Parse and assign the topic for this trigger
:param element: The XML Element object
:type element: etree._Element
"""
self._log.debug('Setting Trigger topic: {topic}'.format(topic=element.text))
super(Trigger, self)._parse_topi... | [
"def",
"_parse_topic",
"(",
"self",
",",
"element",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"'Setting Trigger topic: {topic}'",
".",
"format",
"(",
"topic",
"=",
"element",
".",
"text",
")",
")",
"super",
"(",
"Trigger",
",",
"self",
")",
".",
... | Parse and assign the topic for this trigger
:param element: The XML Element object
:type element: etree._Element | [
"Parse",
"and",
"assign",
"the",
"topic",
"for",
"this",
"trigger",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/__init__.py#L271-L278 |
FujiMakoto/AgentML | agentml/parser/trigger/__init__.py | Trigger._parse_pattern | def _parse_pattern(self, element):
"""
Parse the trigger pattern
:param element: The XML Element object
:type element: etree._Element
"""
# If this is a raw regular expression, compile it and immediately return
self._log.info('Parsing Trigger Pattern: ' + element... | python | def _parse_pattern(self, element):
"""
Parse the trigger pattern
:param element: The XML Element object
:type element: etree._Element
"""
# If this is a raw regular expression, compile it and immediately return
self._log.info('Parsing Trigger Pattern: ' + element... | [
"def",
"_parse_pattern",
"(",
"self",
",",
"element",
")",
":",
"# If this is a raw regular expression, compile it and immediately return",
"self",
".",
"_log",
".",
"info",
"(",
"'Parsing Trigger Pattern: '",
"+",
"element",
".",
"text",
")",
"self",
".",
"pattern_word... | Parse the trigger pattern
:param element: The XML Element object
:type element: etree._Element | [
"Parse",
"the",
"trigger",
"pattern",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/__init__.py#L288-L376 |
FujiMakoto/AgentML | agentml/parser/trigger/__init__.py | Trigger._parse_redirect | def _parse_redirect(self, element):
"""
Parse a trigger redirect
:param element: The XML Element object
:type element: etree._Element
"""
self._log.info('Parsing new redirected Response')
self._responses.add(Response(self, element, self.file_path)) | python | def _parse_redirect(self, element):
"""
Parse a trigger redirect
:param element: The XML Element object
:type element: etree._Element
"""
self._log.info('Parsing new redirected Response')
self._responses.add(Response(self, element, self.file_path)) | [
"def",
"_parse_redirect",
"(",
"self",
",",
"element",
")",
":",
"self",
".",
"_log",
".",
"info",
"(",
"'Parsing new redirected Response'",
")",
"self",
".",
"_responses",
".",
"add",
"(",
"Response",
"(",
"self",
",",
"element",
",",
"self",
".",
"file_p... | Parse a trigger redirect
:param element: The XML Element object
:type element: etree._Element | [
"Parse",
"a",
"trigger",
"redirect",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/__init__.py#L396-L403 |
FujiMakoto/AgentML | agentml/parser/trigger/__init__.py | Trigger._parse_condition | def _parse_condition(self, element):
"""
Parse a trigger condition
:param element: The XML Element object
:type element: etree._Element
"""
self._log.info('Parsing new Condition')
condition = Condition(self, element, self.file_path)
for statement in condi... | python | def _parse_condition(self, element):
"""
Parse a trigger condition
:param element: The XML Element object
:type element: etree._Element
"""
self._log.info('Parsing new Condition')
condition = Condition(self, element, self.file_path)
for statement in condi... | [
"def",
"_parse_condition",
"(",
"self",
",",
"element",
")",
":",
"self",
".",
"_log",
".",
"info",
"(",
"'Parsing new Condition'",
")",
"condition",
"=",
"Condition",
"(",
"self",
",",
"element",
",",
"self",
".",
"file_path",
")",
"for",
"statement",
"in... | Parse a trigger condition
:param element: The XML Element object
:type element: etree._Element | [
"Parse",
"a",
"trigger",
"condition",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/__init__.py#L405-L418 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/run/Cleaner.py | Cleaner.clear | def clear(correlation_id, components):
"""
Clears state of multiple components.
To be cleaned state components must implement [[ICleanable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution throu... | python | def clear(correlation_id, components):
"""
Clears state of multiple components.
To be cleaned state components must implement [[ICleanable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution throu... | [
"def",
"clear",
"(",
"correlation_id",
",",
"components",
")",
":",
"if",
"components",
"==",
"None",
":",
"return",
"for",
"component",
"in",
"components",
":",
"Cleaner",
".",
"clear_one",
"(",
"correlation_id",
",",
"component",
")"
] | Clears state of multiple components.
To be cleaned state components must implement [[ICleanable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param components: the list of comp... | [
"Clears",
"state",
"of",
"multiple",
"components",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/run/Cleaner.py#L36-L51 |
lcgong/redbean | redbean/iso8601.py | parse_datetime | def parse_datetime(value):
"""Parses a string and return a datetime.datetime.
This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.
Raises ValueError if the input is well formatted but not a valid datetime.
Returns None if t... | python | def parse_datetime(value):
"""Parses a string and return a datetime.datetime.
This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.
Raises ValueError if the input is well formatted but not a valid datetime.
Returns None if t... | [
"def",
"parse_datetime",
"(",
"value",
")",
":",
"match",
"=",
"datetime_re",
".",
"match",
"(",
"value",
")",
"if",
"match",
":",
"kw",
"=",
"match",
".",
"groupdict",
"(",
")",
"if",
"kw",
"[",
"'microsecond'",
"]",
":",
"kw",
"[",
"'microsecond'",
... | Parses a string and return a datetime.datetime.
This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.
Raises ValueError if the input is well formatted but not a valid datetime.
Returns None if the input isn't well formatted. | [
"Parses",
"a",
"string",
"and",
"return",
"a",
"datetime",
".",
"datetime",
"."
] | train | https://github.com/lcgong/redbean/blob/45df9ff1e807e742771c752808d7fdac4007c919/redbean/iso8601.py#L73-L98 |
sysr-q/mattdaemon | mattdaemon/daemon.py | daemon.status | def status(self):
"""
Check if the daemon is currently running.
Requires procfs, so it will only work on POSIX compliant OS'.
"""
# Get the pid from the pidfile
try:
pf = file(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()
except IOError:
pid = None
if not pid:
return False
... | python | def status(self):
"""
Check if the daemon is currently running.
Requires procfs, so it will only work on POSIX compliant OS'.
"""
# Get the pid from the pidfile
try:
pf = file(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()
except IOError:
pid = None
if not pid:
return False
... | [
"def",
"status",
"(",
"self",
")",
":",
"# Get the pid from the pidfile",
"try",
":",
"pf",
"=",
"file",
"(",
"self",
".",
"pidfile",
",",
"'r'",
")",
"pid",
"=",
"int",
"(",
"pf",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
")",
"pf",
".",
"c... | Check if the daemon is currently running.
Requires procfs, so it will only work on POSIX compliant OS'. | [
"Check",
"if",
"the",
"daemon",
"is",
"currently",
"running",
".",
"Requires",
"procfs",
"so",
"it",
"will",
"only",
"work",
"on",
"POSIX",
"compliant",
"OS",
"."
] | train | https://github.com/sysr-q/mattdaemon/blob/bc32a372f46650e0ca69b84da320fa7fee3d192d/mattdaemon/daemon.py#L174-L193 |
demurgos/py-pathmatch | pathmatch/pathspec.py | PathspecList.match | def match(self, path):
u"""
:type path: text_type
:param path: The path to match against this list of path specs.
:return:
"""
for spec in reversed(self.pathspecs): # type: Pathspec
if spec.pattern.match(path):
return not spec.negated
... | python | def match(self, path):
u"""
:type path: text_type
:param path: The path to match against this list of path specs.
:return:
"""
for spec in reversed(self.pathspecs): # type: Pathspec
if spec.pattern.match(path):
return not spec.negated
... | [
"def",
"match",
"(",
"self",
",",
"path",
")",
":",
"for",
"spec",
"in",
"reversed",
"(",
"self",
".",
"pathspecs",
")",
":",
"# type: Pathspec",
"if",
"spec",
".",
"pattern",
".",
"match",
"(",
"path",
")",
":",
"return",
"not",
"spec",
".",
"negate... | u"""
:type path: text_type
:param path: The path to match against this list of path specs.
:return: | [
"u"
] | train | https://github.com/demurgos/py-pathmatch/blob/70b3aa99ee34da8b80b6ec6340862b760159d2a1/pathmatch/pathspec.py#L66-L77 |
uw-it-aca/uw-restclients-catalyst | uw_catalyst/__init__.py | get_resource | def get_resource(url, headers):
"""
Issue a GET request with the given url and headers,
and return a response in json format.
:returns: http response with content in json
"""
headers["Accept"] = "application/json"
response = Catalyst_DAO().getURL(url, headers)
if response.status != 200:... | python | def get_resource(url, headers):
"""
Issue a GET request with the given url and headers,
and return a response in json format.
:returns: http response with content in json
"""
headers["Accept"] = "application/json"
response = Catalyst_DAO().getURL(url, headers)
if response.status != 200:... | [
"def",
"get_resource",
"(",
"url",
",",
"headers",
")",
":",
"headers",
"[",
"\"Accept\"",
"]",
"=",
"\"application/json\"",
"response",
"=",
"Catalyst_DAO",
"(",
")",
".",
"getURL",
"(",
"url",
",",
"headers",
")",
"if",
"response",
".",
"status",
"!=",
... | Issue a GET request with the given url and headers,
and return a response in json format.
:returns: http response with content in json | [
"Issue",
"a",
"GET",
"request",
"with",
"the",
"given",
"url",
"and",
"headers",
"and",
"return",
"a",
"response",
"in",
"json",
"format",
".",
":",
"returns",
":",
"http",
"response",
"with",
"content",
"in",
"json"
] | train | https://github.com/uw-it-aca/uw-restclients-catalyst/blob/17216e1e38d6da05eaed235e9329f62774626d80/uw_catalyst/__init__.py#L7-L22 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book._process_lines | def _process_lines(self, lines):
"""
循环处理所有的行
:param lines:
:type lines:
:return:
:rtype:
"""
if self._chapterization:
idx = 1
chapter = Chapter('前言', 0)
for line in lines:
if self._is_chapter_title(line)... | python | def _process_lines(self, lines):
"""
循环处理所有的行
:param lines:
:type lines:
:return:
:rtype:
"""
if self._chapterization:
idx = 1
chapter = Chapter('前言', 0)
for line in lines:
if self._is_chapter_title(line)... | [
"def",
"_process_lines",
"(",
"self",
",",
"lines",
")",
":",
"if",
"self",
".",
"_chapterization",
":",
"idx",
"=",
"1",
"chapter",
"=",
"Chapter",
"(",
"'前言', 0)",
"",
"",
"",
"for",
"line",
"in",
"lines",
":",
"if",
"self",
".",
"_is_chapter_title",... | 循环处理所有的行
:param lines:
:type lines:
:return:
:rtype: | [
"循环处理所有的行",
":",
"param",
"lines",
":",
":",
"type",
"lines",
":",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L125-L149 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book._is_chapter_title | def _is_chapter_title(self, line):
"""
检测是否章节标题
:param line:
:type line:
:return:
:rtype:
"""
striped_line = line.strip()
# 第X章
if striped_line.startswith('第'):
if 3 <= len(striped_line) < 30 and '章' in striped_line:
... | python | def _is_chapter_title(self, line):
"""
检测是否章节标题
:param line:
:type line:
:return:
:rtype:
"""
striped_line = line.strip()
# 第X章
if striped_line.startswith('第'):
if 3 <= len(striped_line) < 30 and '章' in striped_line:
... | [
"def",
"_is_chapter_title",
"(",
"self",
",",
"line",
")",
":",
"striped_line",
"=",
"line",
".",
"strip",
"(",
")",
"# 第X章",
"if",
"striped_line",
".",
"startswith",
"(",
"'第'):",
"",
"",
"if",
"3",
"<=",
"len",
"(",
"striped_line",
")",
"<",
"30",
... | 检测是否章节标题
:param line:
:type line:
:return:
:rtype: | [
"检测是否章节标题",
":",
"param",
"line",
":",
":",
"type",
"line",
":",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L152-L170 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book.gen_opf | def gen_opf(self, book_idx):
"""
生成项目文件
:return:
:rtype:
"""
if self._chapterization:
title = '{title}-{book_idx}'.format(title=self._title, book_idx=book_idx)
book = 'book-{book_idx}'.format(book_idx=book_idx)
toc = 'toc-{book_idx}'.fo... | python | def gen_opf(self, book_idx):
"""
生成项目文件
:return:
:rtype:
"""
if self._chapterization:
title = '{title}-{book_idx}'.format(title=self._title, book_idx=book_idx)
book = 'book-{book_idx}'.format(book_idx=book_idx)
toc = 'toc-{book_idx}'.fo... | [
"def",
"gen_opf",
"(",
"self",
",",
"book_idx",
")",
":",
"if",
"self",
".",
"_chapterization",
":",
"title",
"=",
"'{title}-{book_idx}'",
".",
"format",
"(",
"title",
"=",
"self",
".",
"_title",
",",
"book_idx",
"=",
"book_idx",
")",
"book",
"=",
"'book... | 生成项目文件
:return:
:rtype: | [
"生成项目文件",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L184-L237 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book._start_end_of_index | def _start_end_of_index(self, book_idx):
"""
根据book_idx计算开始和结束的chapter id
:param book_idx:
:type int:
:return:
:rtype:
"""
start = (book_idx - 1) * self._max_chapters
end = min(book_idx * self._max_chapters, len(self._chapters))
return (sta... | python | def _start_end_of_index(self, book_idx):
"""
根据book_idx计算开始和结束的chapter id
:param book_idx:
:type int:
:return:
:rtype:
"""
start = (book_idx - 1) * self._max_chapters
end = min(book_idx * self._max_chapters, len(self._chapters))
return (sta... | [
"def",
"_start_end_of_index",
"(",
"self",
",",
"book_idx",
")",
":",
"start",
"=",
"(",
"book_idx",
"-",
"1",
")",
"*",
"self",
".",
"_max_chapters",
"end",
"=",
"min",
"(",
"book_idx",
"*",
"self",
".",
"_max_chapters",
",",
"len",
"(",
"self",
".",
... | 根据book_idx计算开始和结束的chapter id
:param book_idx:
:type int:
:return:
:rtype: | [
"根据book_idx计算开始和结束的chapter",
"id",
":",
"param",
"book_idx",
":",
":",
"type",
"int",
":",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L240-L250 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book.gen_ncx | def gen_ncx(self, book_idx):
"""
生成NCX文件内容
:return:
:rtype:
"""
start, end = self._start_end_of_index(book_idx)
ncx_base = """<?xml version="1.0"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="ht... | python | def gen_ncx(self, book_idx):
"""
生成NCX文件内容
:return:
:rtype:
"""
start, end = self._start_end_of_index(book_idx)
ncx_base = """<?xml version="1.0"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="ht... | [
"def",
"gen_ncx",
"(",
"self",
",",
"book_idx",
")",
":",
"start",
",",
"end",
"=",
"self",
".",
"_start_end_of_index",
"(",
"book_idx",
")",
"ncx_base",
"=",
"\"\"\"<?xml version=\"1.0\"?>\n<!DOCTYPE ncx PUBLIC \"-//NISO//DTD ncx 2005-1//EN\"\n \"http://www.daisy.org/z3986/2... | 生成NCX文件内容
:return:
:rtype: | [
"生成NCX文件内容",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L253-L277 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book._gen_toc | def _gen_toc(self, idx):
"""
生成目录html
:return:
:rtype:
"""
if not self._chapterization:
return ''
start, end = self._start_end_of_index(idx)
chap_infos = '\n'.join([" <li><a href=\"#ch{}\">{}</a></li>".format(
chap._idx,... | python | def _gen_toc(self, idx):
"""
生成目录html
:return:
:rtype:
"""
if not self._chapterization:
return ''
start, end = self._start_end_of_index(idx)
chap_infos = '\n'.join([" <li><a href=\"#ch{}\">{}</a></li>".format(
chap._idx,... | [
"def",
"_gen_toc",
"(",
"self",
",",
"idx",
")",
":",
"if",
"not",
"self",
".",
"_chapterization",
":",
"return",
"''",
"start",
",",
"end",
"=",
"self",
".",
"_start_end_of_index",
"(",
"idx",
")",
"chap_infos",
"=",
"'\\n'",
".",
"join",
"(",
"[",
... | 生成目录html
:return:
:rtype: | [
"生成目录html",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L280-L304 |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | Book.gen_html | def gen_html(self, book_idx):
"""
生成HTML文件
:return:
:rtype:
"""
toc = self._gen_toc(book_idx)
start, end = self._start_end_of_index(book_idx)
content = '\n'.join([chap.txt2html() for chap in self._chapters[start: end]])
html = """<!DOCTYPE html
PUB... | python | def gen_html(self, book_idx):
"""
生成HTML文件
:return:
:rtype:
"""
toc = self._gen_toc(book_idx)
start, end = self._start_end_of_index(book_idx)
content = '\n'.join([chap.txt2html() for chap in self._chapters[start: end]])
html = """<!DOCTYPE html
PUB... | [
"def",
"gen_html",
"(",
"self",
",",
"book_idx",
")",
":",
"toc",
"=",
"self",
".",
"_gen_toc",
"(",
"book_idx",
")",
"start",
",",
"end",
"=",
"self",
".",
"_start_end_of_index",
"(",
"book_idx",
")",
"content",
"=",
"'\\n'",
".",
"join",
"(",
"[",
... | 生成HTML文件
:return:
:rtype: | [
"生成HTML文件",
":",
"return",
":",
":",
"rtype",
":"
] | train | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L307-L344 |
LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.func | def func(self, name: str):
"""return the first func defined named name"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and f._name == name):
return f | python | def func(self, name: str):
"""return the first func defined named name"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and f._name == name):
return f | [
"def",
"func",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"isinstance",
"(",
"f",
".",
"_ctype",
",",
"FuncType",
")",
"and",
"f",
"."... | return the first func defined named name | [
"return",
"the",
"first",
"func",
"defined",
"named",
"name"
] | train | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L369-L375 |
LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.type | def type(self, name: str):
"""return the first complete definition of type 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
return f | python | def type(self, name: str):
"""return the first complete definition of type 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
return f | [
"def",
"type",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"f",
".",
"_ctype",
".",
"_storage",
"==",
"Storages",
".",
"TYPEDEF",
"and",
... | return the first complete definition of type 'name | [
"return",
"the",
"first",
"complete",
"definition",
"of",
"type",
"name"
] | train | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L385-L391 |
LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.declallfuncs | def declallfuncs(self):
"""generator on all declaration of function"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)):
yield f | python | def declallfuncs(self):
"""generator on all declaration of function"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)):
yield f | [
"def",
"declallfuncs",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"isinstance",
"(",
"f",
".",
"_ctype",
",",
"FuncType",
")",
")",
":",
"yield",
"f"
] | generator on all declaration of function | [
"generator",
"on",
"all",
"declaration",
"of",
"function"
] | train | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L417-L422 |
LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.declallvars | def declallvars(self):
"""generator on all declaration of variable"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)):
yield f | python | def declallvars(self):
"""generator on all declaration of variable"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)):
yield f | [
"def",
"declallvars",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"not",
"isinstance",
"(",
"f",
".",
"_ctype",
",",
"FuncType",
")",
")",
":",
"yield",
"f"
] | generator on all declaration of variable | [
"generator",
"on",
"all",
"declaration",
"of",
"variable"
] | train | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L424-L429 |
LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.declalltypes | def declalltypes(self):
"""generator on all declaration of type"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF):
yield f | python | def declalltypes(self):
"""generator on all declaration of type"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF):
yield f | [
"def",
"declalltypes",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"f",
".",
"_ctype",
".",
"_storage",
"==",
"Storages",
".",
"TYPEDEF",
")",
":",
"yield",
"f"
] | generator on all declaration of type | [
"generator",
"on",
"all",
"declaration",
"of",
"type"
] | train | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L431-L436 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgets/actionreportdialog.py | TextPopupButton.show_popup | def show_popup(self, *args, **kwargs):
"""Show a popup with a textedit
:returns: None
:rtype: None
:raises: None
"""
self.mw = JB_MainWindow(parent=self, flags=QtCore.Qt.Dialog)
self.mw.setWindowTitle(self.popuptitle)
self.mw.setWindowModality(QtCore.Qt.A... | python | def show_popup(self, *args, **kwargs):
"""Show a popup with a textedit
:returns: None
:rtype: None
:raises: None
"""
self.mw = JB_MainWindow(parent=self, flags=QtCore.Qt.Dialog)
self.mw.setWindowTitle(self.popuptitle)
self.mw.setWindowModality(QtCore.Qt.A... | [
"def",
"show_popup",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"mw",
"=",
"JB_MainWindow",
"(",
"parent",
"=",
"self",
",",
"flags",
"=",
"QtCore",
".",
"Qt",
".",
"Dialog",
")",
"self",
".",
"mw",
".",
"setWi... | Show a popup with a textedit
:returns: None
:rtype: None
:raises: None | [
"Show",
"a",
"popup",
"with",
"a",
"textedit"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/actionreportdialog.py#L36-L55 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgets/actionreportdialog.py | TracebackButton.set_index | def set_index(self, index):
"""Display the data of the given index
:param index: the index to paint
:type index: QtCore.QModelIndex
:returns: None
:rtype: None
:raises: None
"""
item = index.internalPointer()
self.actionunit = item.internal_data()... | python | def set_index(self, index):
"""Display the data of the given index
:param index: the index to paint
:type index: QtCore.QModelIndex
:returns: None
:rtype: None
:raises: None
"""
item = index.internalPointer()
self.actionunit = item.internal_data()... | [
"def",
"set_index",
"(",
"self",
",",
"index",
")",
":",
"item",
"=",
"index",
".",
"internalPointer",
"(",
")",
"self",
".",
"actionunit",
"=",
"item",
".",
"internal_data",
"(",
")",
"self",
".",
"setEnabled",
"(",
"bool",
"(",
"self",
".",
"actionun... | Display the data of the given index
:param index: the index to paint
:type index: QtCore.QModelIndex
:returns: None
:rtype: None
:raises: None | [
"Display",
"the",
"data",
"of",
"the",
"given",
"index"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/actionreportdialog.py#L84-L95 |
ravenac95/overlay4u | overlay4u/__init__.py | mount | def mount(directory, lower_dir, upper_dir, mount_table=None):
"""Creates a mount"""
return OverlayFS.mount(directory, lower_dir, upper_dir,
mount_table=mount_table) | python | def mount(directory, lower_dir, upper_dir, mount_table=None):
"""Creates a mount"""
return OverlayFS.mount(directory, lower_dir, upper_dir,
mount_table=mount_table) | [
"def",
"mount",
"(",
"directory",
",",
"lower_dir",
",",
"upper_dir",
",",
"mount_table",
"=",
"None",
")",
":",
"return",
"OverlayFS",
".",
"mount",
"(",
"directory",
",",
"lower_dir",
",",
"upper_dir",
",",
"mount_table",
"=",
"mount_table",
")"
] | Creates a mount | [
"Creates",
"a",
"mount"
] | train | https://github.com/ravenac95/overlay4u/blob/621eecc0d4d40951aa8afcb533b5eec5d91c73cc/overlay4u/__init__.py#L4-L7 |
TrainerDex/TrainerDex.py | trainerdex/leaderboard.py | DiscordLeaderboard.filter_teams | def filter_teams(self, teams):
"""Expects an iterable of team IDs"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['faction']['id'] in teams] | python | def filter_teams(self, teams):
"""Expects an iterable of team IDs"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['faction']['id'] in teams] | [
"def",
"filter_teams",
"(",
"self",
",",
"teams",
")",
":",
"return",
"[",
"LeaderboardInstance",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_leaderboard",
"if",
"x",
"[",
"'faction'",
"]",
"[",
"'id'",
"]",
"in",
"teams",
"]"
] | Expects an iterable of team IDs | [
"Expects",
"an",
"iterable",
"of",
"team",
"IDs"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/leaderboard.py#L123-L125 |
TrainerDex/TrainerDex.py | trainerdex/leaderboard.py | DiscordLeaderboard.filter_users | def filter_users(self, users):
"""Expects an interable of User IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['user_id'] in users] | python | def filter_users(self, users):
"""Expects an interable of User IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['user_id'] in users] | [
"def",
"filter_users",
"(",
"self",
",",
"users",
")",
":",
"return",
"[",
"LeaderboardInstance",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_leaderboard",
"if",
"x",
"[",
"'user_id'",
"]",
"in",
"users",
"]"
] | Expects an interable of User IDs ints | [
"Expects",
"an",
"interable",
"of",
"User",
"IDs",
"ints"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/leaderboard.py#L127-L129 |
TrainerDex/TrainerDex.py | trainerdex/leaderboard.py | DiscordLeaderboard.filter_trainers | def filter_trainers(self, trainers):
"""Expects an interable of Trainer IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['id'] in trainers] | python | def filter_trainers(self, trainers):
"""Expects an interable of Trainer IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['id'] in trainers] | [
"def",
"filter_trainers",
"(",
"self",
",",
"trainers",
")",
":",
"return",
"[",
"LeaderboardInstance",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_leaderboard",
"if",
"x",
"[",
"'id'",
"]",
"in",
"trainers",
"]"
] | Expects an interable of Trainer IDs ints | [
"Expects",
"an",
"interable",
"of",
"Trainer",
"IDs",
"ints"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/leaderboard.py#L131-L133 |
willkg/phil | phil/util.py | normalize_path | def normalize_path(path, filetype=FILE):
"""Takes a path and a filetype, verifies existence and type, and
returns absolute path.
"""
if not path:
raise ValueError('"{0}" is not a valid path.'.format(path))
if not os.path.exists(path):
raise ValueError('"{0}" does not exist.'.format(... | python | def normalize_path(path, filetype=FILE):
"""Takes a path and a filetype, verifies existence and type, and
returns absolute path.
"""
if not path:
raise ValueError('"{0}" is not a valid path.'.format(path))
if not os.path.exists(path):
raise ValueError('"{0}" does not exist.'.format(... | [
"def",
"normalize_path",
"(",
"path",
",",
"filetype",
"=",
"FILE",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"'\"{0}\" is not a valid path.'",
".",
"format",
"(",
"path",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"("... | Takes a path and a filetype, verifies existence and type, and
returns absolute path. | [
"Takes",
"a",
"path",
"and",
"a",
"filetype",
"verifies",
"existence",
"and",
"type",
"and",
"returns",
"absolute",
"path",
"."
] | train | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L49-L63 |
willkg/phil | phil/util.py | err | def err(*output, **kwargs):
"""Writes output to stderr.
:arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap
the output.
"""
output = 'Error: ' + ' '.join([str(o) for o in output])
if kwargs.get('wrap') is not False:
output = '\n'.join(wrap(output, kwargs.get('indent',... | python | def err(*output, **kwargs):
"""Writes output to stderr.
:arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap
the output.
"""
output = 'Error: ' + ' '.join([str(o) for o in output])
if kwargs.get('wrap') is not False:
output = '\n'.join(wrap(output, kwargs.get('indent',... | [
"def",
"err",
"(",
"*",
"output",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"'Error: '",
"+",
"' '",
".",
"join",
"(",
"[",
"str",
"(",
"o",
")",
"for",
"o",
"in",
"output",
"]",
")",
"if",
"kwargs",
".",
"get",
"(",
"'wrap'",
")",
"i... | Writes output to stderr.
:arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap
the output. | [
"Writes",
"output",
"to",
"stderr",
"."
] | train | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L77-L90 |
willkg/phil | phil/util.py | out | def out(*output, **kwargs):
"""Writes output to stdout.
:arg wrap: If you set ``wrap=False``, then ``out`` won't textwrap
the output.
"""
output = ' '.join([str(o) for o in output])
if kwargs.get('wrap') is not False:
output = '\n'.join(wrap(output, kwargs.get('indent', '')))
e... | python | def out(*output, **kwargs):
"""Writes output to stdout.
:arg wrap: If you set ``wrap=False``, then ``out`` won't textwrap
the output.
"""
output = ' '.join([str(o) for o in output])
if kwargs.get('wrap') is not False:
output = '\n'.join(wrap(output, kwargs.get('indent', '')))
e... | [
"def",
"out",
"(",
"*",
"output",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"' '",
".",
"join",
"(",
"[",
"str",
"(",
"o",
")",
"for",
"o",
"in",
"output",
"]",
")",
"if",
"kwargs",
".",
"get",
"(",
"'wrap'",
")",
"is",
"not",
"False"... | Writes output to stdout.
:arg wrap: If you set ``wrap=False``, then ``out`` won't textwrap
the output. | [
"Writes",
"output",
"to",
"stdout",
"."
] | train | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L93-L106 |
willkg/phil | phil/util.py | convert_rrule | def convert_rrule(rrule):
"""Converts icalendar rrule to dateutil rrule."""
args = {}
# TODO: rrule['freq'] is a list, but I'm unclear as to why.
freq = FREQ_MAP[rrule['freq'][0]]
keys = ['wkst', 'until', 'bysetpos', 'interval',
'bymonth', 'bymonthday', 'byyearday', 'byweekno',
... | python | def convert_rrule(rrule):
"""Converts icalendar rrule to dateutil rrule."""
args = {}
# TODO: rrule['freq'] is a list, but I'm unclear as to why.
freq = FREQ_MAP[rrule['freq'][0]]
keys = ['wkst', 'until', 'bysetpos', 'interval',
'bymonth', 'bymonthday', 'byyearday', 'byweekno',
... | [
"def",
"convert_rrule",
"(",
"rrule",
")",
":",
"args",
"=",
"{",
"}",
"# TODO: rrule['freq'] is a list, but I'm unclear as to why.",
"freq",
"=",
"FREQ_MAP",
"[",
"rrule",
"[",
"'freq'",
"]",
"[",
"0",
"]",
"]",
"keys",
"=",
"[",
"'wkst'",
",",
"'until'",
"... | Converts icalendar rrule to dateutil rrule. | [
"Converts",
"icalendar",
"rrule",
"to",
"dateutil",
"rrule",
"."
] | train | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L198-L223 |
willkg/phil | phil/util.py | parse_ics | def parse_ics(icsfile):
"""Takes an icsfilename, parses it, and returns Events."""
events = []
cal = Calendar.from_ical(open(icsfile, 'rb').read())
for component in cal.walk('vevent'):
dtstart = component['dtstart'].dt
rrule = component['rrule']
freq, args = convert_rrule(rrule... | python | def parse_ics(icsfile):
"""Takes an icsfilename, parses it, and returns Events."""
events = []
cal = Calendar.from_ical(open(icsfile, 'rb').read())
for component in cal.walk('vevent'):
dtstart = component['dtstart'].dt
rrule = component['rrule']
freq, args = convert_rrule(rrule... | [
"def",
"parse_ics",
"(",
"icsfile",
")",
":",
"events",
"=",
"[",
"]",
"cal",
"=",
"Calendar",
".",
"from_ical",
"(",
"open",
"(",
"icsfile",
",",
"'rb'",
")",
".",
"read",
"(",
")",
")",
"for",
"component",
"in",
"cal",
".",
"walk",
"(",
"'vevent'... | Takes an icsfilename, parses it, and returns Events. | [
"Takes",
"an",
"icsfilename",
"parses",
"it",
"and",
"returns",
"Events",
"."
] | train | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L226-L249 |
maxzheng/remoteconfig | remoteconfig/manager.py | RemoteConfig.read | def read(self, sources, cache_duration=None):
"""
Queues the config sources to be read later (when config is accessed), or reads immediately if config has already been
accessed.
:param file/str/list sources: Config source URL (http/https), source string, file name, or file pointer... | python | def read(self, sources, cache_duration=None):
"""
Queues the config sources to be read later (when config is accessed), or reads immediately if config has already been
accessed.
:param file/str/list sources: Config source URL (http/https), source string, file name, or file pointer... | [
"def",
"read",
"(",
"self",
",",
"sources",
",",
"cache_duration",
"=",
"None",
")",
":",
"if",
"cache_duration",
"is",
"not",
"None",
":",
"self",
".",
"_cache_duration",
"=",
"cache_duration",
"return",
"super",
"(",
"RemoteConfig",
",",
"self",
")",
"."... | Queues the config sources to be read later (when config is accessed), or reads immediately if config has already been
accessed.
:param file/str/list sources: Config source URL (http/https), source string, file name, or file pointer, or list
of the other sourc... | [
"Queues",
"the",
"config",
"sources",
"to",
"be",
"read",
"later",
"(",
"when",
"config",
"is",
"accessed",
")",
"or",
"reads",
"immediately",
"if",
"config",
"has",
"already",
"been",
"accessed",
"."
] | train | https://github.com/maxzheng/remoteconfig/blob/6edd0bfb9a507abcb2eb0339c5284deb066548b6/remoteconfig/manager.py#L23-L38 |
maxzheng/remoteconfig | remoteconfig/manager.py | RemoteConfig._read | def _read(self, source):
"""
Reads and parses the config source
:param file/str source: Config source URL (http/https), or string, file name, or file pointer.
"""
if source.startswith('http://') or source.startswith('https://'):
source = url_content(source, cache... | python | def _read(self, source):
"""
Reads and parses the config source
:param file/str source: Config source URL (http/https), or string, file name, or file pointer.
"""
if source.startswith('http://') or source.startswith('https://'):
source = url_content(source, cache... | [
"def",
"_read",
"(",
"self",
",",
"source",
")",
":",
"if",
"source",
".",
"startswith",
"(",
"'http://'",
")",
"or",
"source",
".",
"startswith",
"(",
"'https://'",
")",
":",
"source",
"=",
"url_content",
"(",
"source",
",",
"cache_duration",
"=",
"self... | Reads and parses the config source
:param file/str source: Config source URL (http/https), or string, file name, or file pointer. | [
"Reads",
"and",
"parses",
"the",
"config",
"source"
] | train | https://github.com/maxzheng/remoteconfig/blob/6edd0bfb9a507abcb2eb0339c5284deb066548b6/remoteconfig/manager.py#L40-L49 |
wickman/compactor | compactor/process.py | Process.route | def route(cls, path):
"""A decorator to indicate that a method should be a routable HTTP endpoint.
.. code-block:: python
from compactor.process import Process
class WebProcess(Process):
@Process.route('/hello/world')
def hello_world(self, handler):
return hand... | python | def route(cls, path):
"""A decorator to indicate that a method should be a routable HTTP endpoint.
.. code-block:: python
from compactor.process import Process
class WebProcess(Process):
@Process.route('/hello/world')
def hello_world(self, handler):
return hand... | [
"def",
"route",
"(",
"cls",
",",
"path",
")",
":",
"if",
"not",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"raise",
"ValueError",
"(",
"'Routes must start with \"/\"'",
")",
"def",
"wrap",
"(",
"fn",
")",
":",
"setattr",
"(",
"fn",
",",
"cls",
... | A decorator to indicate that a method should be a routable HTTP endpoint.
.. code-block:: python
from compactor.process import Process
class WebProcess(Process):
@Process.route('/hello/world')
def hello_world(self, handler):
return handler.write('<html><title>hello... | [
"A",
"decorator",
"to",
"indicate",
"that",
"a",
"method",
"should",
"be",
"a",
"routable",
"HTTP",
"endpoint",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L15-L43 |
wickman/compactor | compactor/process.py | Process.install | def install(cls, mbox):
"""A decorator to indicate a remotely callable method on a process.
.. code-block:: python
from compactor.process import Process
class PingProcess(Process):
@Process.install('ping')
def ping(self, from_pid, body):
# do something
The... | python | def install(cls, mbox):
"""A decorator to indicate a remotely callable method on a process.
.. code-block:: python
from compactor.process import Process
class PingProcess(Process):
@Process.install('ping')
def ping(self, from_pid, body):
# do something
The... | [
"def",
"install",
"(",
"cls",
",",
"mbox",
")",
":",
"def",
"wrap",
"(",
"fn",
")",
":",
"setattr",
"(",
"fn",
",",
"cls",
".",
"INSTALL_ATTRIBUTE",
",",
"mbox",
")",
"return",
"fn",
"return",
"wrap"
] | A decorator to indicate a remotely callable method on a process.
.. code-block:: python
from compactor.process import Process
class PingProcess(Process):
@Process.install('ping')
def ping(self, from_pid, body):
# do something
The installed method should take `... | [
"A",
"decorator",
"to",
"indicate",
"a",
"remotely",
"callable",
"method",
"on",
"a",
"process",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L49-L71 |
wickman/compactor | compactor/process.py | Process.pid | def pid(self):
"""The pid of this process.
:raises: Will raise a ``Process.UnboundProcess`` exception if the
process is not bound to a context.
"""
self._assert_bound()
return PID(self._context.ip, self._context.port, self.name) | python | def pid(self):
"""The pid of this process.
:raises: Will raise a ``Process.UnboundProcess`` exception if the
process is not bound to a context.
"""
self._assert_bound()
return PID(self._context.ip, self._context.port, self.name) | [
"def",
"pid",
"(",
"self",
")",
":",
"self",
".",
"_assert_bound",
"(",
")",
"return",
"PID",
"(",
"self",
".",
"_context",
".",
"ip",
",",
"self",
".",
"_context",
".",
"port",
",",
"self",
".",
"name",
")"
] | The pid of this process.
:raises: Will raise a ``Process.UnboundProcess`` exception if the
process is not bound to a context. | [
"The",
"pid",
"of",
"this",
"process",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L120-L127 |
wickman/compactor | compactor/process.py | Process.send | def send(self, to, method, body=None):
"""Send a message to another process.
Sending messages is done asynchronously and is not guaranteed to succeed.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:param method: The method/mailbox name of the... | python | def send(self, to, method, body=None):
"""Send a message to another process.
Sending messages is done asynchronously and is not guaranteed to succeed.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:param method: The method/mailbox name of the... | [
"def",
"send",
"(",
"self",
",",
"to",
",",
"method",
",",
"body",
"=",
"None",
")",
":",
"self",
".",
"_assert_bound",
"(",
")",
"self",
".",
"_context",
".",
"send",
"(",
"self",
".",
"pid",
",",
"to",
",",
"method",
",",
"body",
")"
] | Send a message to another process.
Sending messages is done asynchronously and is not guaranteed to succeed.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:param method: The method/mailbox name of the remote method.
:type method: ``str``
... | [
"Send",
"a",
"message",
"to",
"another",
"process",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L175-L193 |
wickman/compactor | compactor/process.py | Process.link | def link(self, to):
"""Link to another process.
The ``link`` operation is not guaranteed to succeed. If it does, when
the other process terminates, the ``exited`` method will be called with
its pid.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :clas... | python | def link(self, to):
"""Link to another process.
The ``link`` operation is not guaranteed to succeed. If it does, when
the other process terminates, the ``exited`` method will be called with
its pid.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :clas... | [
"def",
"link",
"(",
"self",
",",
"to",
")",
":",
"self",
".",
"_assert_bound",
"(",
")",
"self",
".",
"_context",
".",
"link",
"(",
"self",
".",
"pid",
",",
"to",
")"
] | Link to another process.
The ``link`` operation is not guaranteed to succeed. If it does, when
the other process terminates, the ``exited`` method will be called with
its pid.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:raises: Will r... | [
"Link",
"to",
"another",
"process",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L195-L211 |
wickman/compactor | compactor/process.py | ProtobufProcess.install | def install(cls, message_type):
"""A decorator to indicate a remotely callable method on a process using protocol buffers.
.. code-block:: python
from compactor.process import ProtobufProcess
from messages_pb2 import RequestMessage, ResponseMessage
class PingProcess(ProtobufProcess):
... | python | def install(cls, message_type):
"""A decorator to indicate a remotely callable method on a process using protocol buffers.
.. code-block:: python
from compactor.process import ProtobufProcess
from messages_pb2 import RequestMessage, ResponseMessage
class PingProcess(ProtobufProcess):
... | [
"def",
"install",
"(",
"cls",
",",
"message_type",
")",
":",
"def",
"wrap",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped_fn",
"(",
"self",
",",
"from_pid",
",",
"message_str",
")",
":",
"message",
"=",
"message... | A decorator to indicate a remotely callable method on a process using protocol buffers.
.. code-block:: python
from compactor.process import ProtobufProcess
from messages_pb2 import RequestMessage, ResponseMessage
class PingProcess(ProtobufProcess):
@ProtobufProcess.install(Requ... | [
"A",
"decorator",
"to",
"indicate",
"a",
"remotely",
"callable",
"method",
"on",
"a",
"process",
"using",
"protocol",
"buffers",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L227-L257 |
wickman/compactor | compactor/process.py | ProtobufProcess.send | def send(self, to, message):
"""Send a message to another process.
Same as ``Process.send`` except that ``message`` is a protocol buffer.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:param message: The message to send
:type method: A pr... | python | def send(self, to, message):
"""Send a message to another process.
Same as ``Process.send`` except that ``message`` is a protocol buffer.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:param message: The message to send
:type method: A pr... | [
"def",
"send",
"(",
"self",
",",
"to",
",",
"message",
")",
":",
"super",
"(",
"ProtobufProcess",
",",
"self",
")",
".",
"send",
"(",
"to",
",",
"message",
".",
"DESCRIPTOR",
".",
"full_name",
",",
"message",
".",
"SerializeToString",
"(",
")",
")"
] | Send a message to another process.
Same as ``Process.send`` except that ``message`` is a protocol buffer.
Returns immediately.
:param to: The pid of the process to send a message.
:type to: :class:`PID`
:param message: The message to send
:type method: A protocol buffer instance.
:raises:... | [
"Send",
"a",
"message",
"to",
"another",
"process",
"."
] | train | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/process.py#L259-L274 |
s-m-i-t-a/railroad | railroad/actions.py | actions | def actions(acts, done):
'''
Prepare actions pipeline.
:param tuple acts: called functions
:param function done: get result from actions
:returns function: function that starts executio
'''
def _intermediate(acc, action):
result = action(acc['state'])
values = concatv(acc['... | python | def actions(acts, done):
'''
Prepare actions pipeline.
:param tuple acts: called functions
:param function done: get result from actions
:returns function: function that starts executio
'''
def _intermediate(acc, action):
result = action(acc['state'])
values = concatv(acc['... | [
"def",
"actions",
"(",
"acts",
",",
"done",
")",
":",
"def",
"_intermediate",
"(",
"acc",
",",
"action",
")",
":",
"result",
"=",
"action",
"(",
"acc",
"[",
"'state'",
"]",
")",
"values",
"=",
"concatv",
"(",
"acc",
"[",
"'values'",
"]",
",",
"[",
... | Prepare actions pipeline.
:param tuple acts: called functions
:param function done: get result from actions
:returns function: function that starts executio | [
"Prepare",
"actions",
"pipeline",
"."
] | train | https://github.com/s-m-i-t-a/railroad/blob/ddb4afa018b8523b5d8c3a86e55388d1ea0ab37c/railroad/actions.py#L8-L32 |
s-m-i-t-a/railroad | railroad/actions.py | lift | def lift(fn=None, state_fn=None):
"""
The lift decorator function will be used to abstract away the management
of the state object used as the intermediate representation of actions.
:param function answer: a function to provide
the result of some action given a value
:p... | python | def lift(fn=None, state_fn=None):
"""
The lift decorator function will be used to abstract away the management
of the state object used as the intermediate representation of actions.
:param function answer: a function to provide
the result of some action given a value
:p... | [
"def",
"lift",
"(",
"fn",
"=",
"None",
",",
"state_fn",
"=",
"None",
")",
":",
"if",
"fn",
"is",
"None",
":",
"return",
"partial",
"(",
"lift",
",",
"state_fn",
"=",
"state_fn",
")",
"@",
"wraps",
"(",
"fn",
")",
"def",
"_lift",
"(",
"*",
"args",... | The lift decorator function will be used to abstract away the management
of the state object used as the intermediate representation of actions.
:param function answer: a function to provide
the result of some action given a value
:param function state: a function to provide wha... | [
"The",
"lift",
"decorator",
"function",
"will",
"be",
"used",
"to",
"abstract",
"away",
"the",
"management",
"of",
"the",
"state",
"object",
"used",
"as",
"the",
"intermediate",
"representation",
"of",
"actions",
"."
] | train | https://github.com/s-m-i-t-a/railroad/blob/ddb4afa018b8523b5d8c3a86e55388d1ea0ab37c/railroad/actions.py#L35-L56 |
SeabornGames/RequestClient | example_bindings/account_access.py | Account_Access.put | def put(self, account_id, user_id):
""" Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict
"""
return s... | python | def put(self, account_id, user_id):
""" Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict
"""
return s... | [
"def",
"put",
"(",
"self",
",",
"account_id",
",",
"user_id",
")",
":",
"return",
"self",
".",
"connection",
".",
"put",
"(",
"'account/access'",
",",
"data",
"=",
"dict",
"(",
"account_id",
"=",
"account_id",
",",
"user_id",
"=",
"user_id",
")",
")"
] | Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict | [
"Only",
"the",
"primary",
"on",
"the",
"account",
"can",
"add",
"or",
"remove",
"user",
"s",
"access",
"to",
"an",
"account",
":",
"param",
"account_id",
":",
"int",
"of",
"the",
"account_id",
"for",
"the",
"account",
":",
"param",
"user_id",
":",
"int",... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/example_bindings/account_access.py#L17-L23 |
SeabornGames/RequestClient | example_bindings/account_access.py | Account_Access.delete | def delete(self, account_id, user_id):
""" Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict
"""
retur... | python | def delete(self, account_id, user_id):
""" Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict
"""
retur... | [
"def",
"delete",
"(",
"self",
",",
"account_id",
",",
"user_id",
")",
":",
"return",
"self",
".",
"connection",
".",
"delete",
"(",
"'account/access'",
",",
"account_id",
"=",
"account_id",
",",
"user_id",
"=",
"user_id",
")"
] | Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict | [
"Only",
"the",
"primary",
"on",
"the",
"account",
"can",
"add",
"or",
"remove",
"user",
"s",
"access",
"to",
"an",
"account",
":",
"param",
"account_id",
":",
"int",
"of",
"the",
"account_id",
"for",
"the",
"account",
":",
"param",
"user_id",
":",
"int",... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/example_bindings/account_access.py#L25-L31 |
kervi/kervi-devices | kervi/devices/motors/LN298.py | _DCMotorController._set_speed | def _set_speed(self, motor, speed):
"""
Change the speed of a motor on the controller.
:param motor: The motor to change.
:type motor: ``int``
:param speed: Speed from -100 to +100, 0 is stop
:type speed: ``int``
"""
self._validate_motor(motor)
... | python | def _set_speed(self, motor, speed):
"""
Change the speed of a motor on the controller.
:param motor: The motor to change.
:type motor: ``int``
:param speed: Speed from -100 to +100, 0 is stop
:type speed: ``int``
"""
self._validate_motor(motor)
... | [
"def",
"_set_speed",
"(",
"self",
",",
"motor",
",",
"speed",
")",
":",
"self",
".",
"_validate_motor",
"(",
"motor",
")",
"en",
",",
"in1",
",",
"in2",
"=",
"self",
".",
"_motors",
"[",
"motor",
"-",
"1",
"]",
"if",
"speed",
"==",
"0",
":",
"en"... | Change the speed of a motor on the controller.
:param motor: The motor to change.
:type motor: ``int``
:param speed: Speed from -100 to +100, 0 is stop
:type speed: ``int`` | [
"Change",
"the",
"speed",
"of",
"a",
"motor",
"on",
"the",
"controller",
"."
] | train | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/motors/LN298.py#L14-L39 |
arximboldi/cooper | cooper/cooper.py | check_all_params_are_keyword | def check_all_params_are_keyword(method):
"""
Raises CooperativeError if method any parameter that is not a
named keyword parameter
"""
args, varargs, keywords, defaults = inspect.getargspec(method)
# Always have self, thus the -1
if len(args or []) - 1 != len(defaults or []):
rais... | python | def check_all_params_are_keyword(method):
"""
Raises CooperativeError if method any parameter that is not a
named keyword parameter
"""
args, varargs, keywords, defaults = inspect.getargspec(method)
# Always have self, thus the -1
if len(args or []) - 1 != len(defaults or []):
rais... | [
"def",
"check_all_params_are_keyword",
"(",
"method",
")",
":",
"args",
",",
"varargs",
",",
"keywords",
",",
"defaults",
"=",
"inspect",
".",
"getargspec",
"(",
"method",
")",
"# Always have self, thus the -1",
"if",
"len",
"(",
"args",
"or",
"[",
"]",
")",
... | Raises CooperativeError if method any parameter that is not a
named keyword parameter | [
"Raises",
"CooperativeError",
"if",
"method",
"any",
"parameter",
"that",
"is",
"not",
"a",
"named",
"keyword",
"parameter"
] | train | https://github.com/arximboldi/cooper/blob/639d00932a21290fb9d7fe1cb0aed283b6785820/cooper/cooper.py#L45-L60 |
arximboldi/cooper | cooper/cooper.py | make_keyword_extractor | def make_keyword_extractor(method):
"""
Removes all keyword parameters required by 'method' from
dictionary 'keys' and returns them in a separate dictionary.
"""
args, _1, _2, defs = inspect.getargspec(method)
key_args = args[-len(defs or []):]
def extractor(keys):
new = {}
... | python | def make_keyword_extractor(method):
"""
Removes all keyword parameters required by 'method' from
dictionary 'keys' and returns them in a separate dictionary.
"""
args, _1, _2, defs = inspect.getargspec(method)
key_args = args[-len(defs or []):]
def extractor(keys):
new = {}
... | [
"def",
"make_keyword_extractor",
"(",
"method",
")",
":",
"args",
",",
"_1",
",",
"_2",
",",
"defs",
"=",
"inspect",
".",
"getargspec",
"(",
"method",
")",
"key_args",
"=",
"args",
"[",
"-",
"len",
"(",
"defs",
"or",
"[",
"]",
")",
":",
"]",
"def",... | Removes all keyword parameters required by 'method' from
dictionary 'keys' and returns them in a separate dictionary. | [
"Removes",
"all",
"keyword",
"parameters",
"required",
"by",
"method",
"from",
"dictionary",
"keys",
"and",
"returns",
"them",
"in",
"a",
"separate",
"dictionary",
"."
] | train | https://github.com/arximboldi/cooper/blob/639d00932a21290fb9d7fe1cb0aed283b6785820/cooper/cooper.py#L65-L80 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | JB_Plugin._load | def _load(self, ):
"""Loads the plugin
:raises: errors.PluginInitError
"""
try:
self.init()
except Exception as e:
log.exception("Load failed!")
raise errors.PluginInitError('%s' % e)
self.__status = self.__LOADED | python | def _load(self, ):
"""Loads the plugin
:raises: errors.PluginInitError
"""
try:
self.init()
except Exception as e:
log.exception("Load failed!")
raise errors.PluginInitError('%s' % e)
self.__status = self.__LOADED | [
"def",
"_load",
"(",
"self",
",",
")",
":",
"try",
":",
"self",
".",
"init",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"log",
".",
"exception",
"(",
"\"Load failed!\"",
")",
"raise",
"errors",
".",
"PluginInitError",
"(",
"'%s'",
"%",
"e",
")"... | Loads the plugin
:raises: errors.PluginInitError | [
"Loads",
"the",
"plugin"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L82-L92 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | JB_Plugin._unload | def _unload(self, ):
"""Unloads the plugin
:raises: errors.PluginUninitError
"""
try:
self.uninit()
except Exception as e:
log.exception("Unload failed!")
raise errors.PluginUninitError('%s' % e)
self.__status = self.__UNLOADED | python | def _unload(self, ):
"""Unloads the plugin
:raises: errors.PluginUninitError
"""
try:
self.uninit()
except Exception as e:
log.exception("Unload failed!")
raise errors.PluginUninitError('%s' % e)
self.__status = self.__UNLOADED | [
"def",
"_unload",
"(",
"self",
",",
")",
":",
"try",
":",
"self",
".",
"uninit",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"log",
".",
"exception",
"(",
"\"Unload failed!\"",
")",
"raise",
"errors",
".",
"PluginUninitError",
"(",
"'%s'",
"%",
"e... | Unloads the plugin
:raises: errors.PluginUninitError | [
"Unloads",
"the",
"plugin"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L94-L104 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | JB_Plugin.get_config | def get_config(self, ):
"""Return the user config for this plugin
You have to provide a configspec,
put the configspec file in the same folder as your plugin.
Name it like your class and put 'ini' as extension.
"""
# get the module of the plugin class
mod = sys.m... | python | def get_config(self, ):
"""Return the user config for this plugin
You have to provide a configspec,
put the configspec file in the same folder as your plugin.
Name it like your class and put 'ini' as extension.
"""
# get the module of the plugin class
mod = sys.m... | [
"def",
"get_config",
"(",
"self",
",",
")",
":",
"# get the module of the plugin class",
"mod",
"=",
"sys",
".",
"modules",
"[",
"self",
".",
"__module__",
"]",
"# get the file from where it was imported",
"modfile",
"=",
"mod",
".",
"__file__",
"# get the module dire... | Return the user config for this plugin
You have to provide a configspec,
put the configspec file in the same folder as your plugin.
Name it like your class and put 'ini' as extension. | [
"Return",
"the",
"user",
"config",
"for",
"this",
"plugin"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L141-L163 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | PluginManager.find_plugins | def find_plugins(self, path):
"""Return a list with all plugins found in path
:param path: the directory with plugins
:type path: str
:returns: list of JB_Plugin subclasses
:rtype: list
:raises: None
"""
ext = os.extsep+'py'
files = []
for... | python | def find_plugins(self, path):
"""Return a list with all plugins found in path
:param path: the directory with plugins
:type path: str
:returns: list of JB_Plugin subclasses
:rtype: list
:raises: None
"""
ext = os.extsep+'py'
files = []
for... | [
"def",
"find_plugins",
"(",
"self",
",",
"path",
")",
":",
"ext",
"=",
"os",
".",
"extsep",
"+",
"'py'",
"files",
"=",
"[",
"]",
"for",
"(",
"dirpath",
",",
"dirnames",
",",
"filenames",
")",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"files... | Return a list with all plugins found in path
:param path: the directory with plugins
:type path: str
:returns: list of JB_Plugin subclasses
:rtype: list
:raises: None | [
"Return",
"a",
"list",
"with",
"all",
"plugins",
"found",
"in",
"path"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L301-L333 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | PluginManager.gather_plugins | def gather_plugins(self):
"""Return all plugins that are found in the plugin paths
Looks in the envvar ``JUKEBOX_PLUGIN_PATH``.
:returns:
:rtype:
:raises:
"""
plugins = []
cfg = get_core_config()
pathenv = cfg['jukebox']['pluginpaths']
pa... | python | def gather_plugins(self):
"""Return all plugins that are found in the plugin paths
Looks in the envvar ``JUKEBOX_PLUGIN_PATH``.
:returns:
:rtype:
:raises:
"""
plugins = []
cfg = get_core_config()
pathenv = cfg['jukebox']['pluginpaths']
pa... | [
"def",
"gather_plugins",
"(",
"self",
")",
":",
"plugins",
"=",
"[",
"]",
"cfg",
"=",
"get_core_config",
"(",
")",
"pathenv",
"=",
"cfg",
"[",
"'jukebox'",
"]",
"[",
"'pluginpaths'",
"]",
"pathenv",
"=",
"os",
".",
"pathsep",
".",
"join",
"(",
"(",
"... | Return all plugins that are found in the plugin paths
Looks in the envvar ``JUKEBOX_PLUGIN_PATH``.
:returns:
:rtype:
:raises: | [
"Return",
"all",
"plugins",
"that",
"are",
"found",
"in",
"the",
"plugin",
"paths"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L335-L354 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | PluginManager.load_plugins | def load_plugins(self, ):
"""Loads all found plugins
:returns: None
:rtype: None
:raises: None
"""
for p in self.__plugins.values():
try:
self.load_plugin(p)
except errors.PluginInitError:
log.exception('Initializin... | python | def load_plugins(self, ):
"""Loads all found plugins
:returns: None
:rtype: None
:raises: None
"""
for p in self.__plugins.values():
try:
self.load_plugin(p)
except errors.PluginInitError:
log.exception('Initializin... | [
"def",
"load_plugins",
"(",
"self",
",",
")",
":",
"for",
"p",
"in",
"self",
".",
"__plugins",
".",
"values",
"(",
")",
":",
"try",
":",
"self",
".",
"load_plugin",
"(",
"p",
")",
"except",
"errors",
".",
"PluginInitError",
":",
"log",
".",
"exceptio... | Loads all found plugins
:returns: None
:rtype: None
:raises: None | [
"Loads",
"all",
"found",
"plugins"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L356-L367 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | PluginManager.load_plugin | def load_plugin(self, p):
"""Load the specified plugin
:param p: The plugin to load
:type p: Subclass of JB_Plugin
:returns: None
:rtype: None
:raises: errors.PluginInitError
"""
if p.is_loaded():
return
# load required plugins first
... | python | def load_plugin(self, p):
"""Load the specified plugin
:param p: The plugin to load
:type p: Subclass of JB_Plugin
:returns: None
:rtype: None
:raises: errors.PluginInitError
"""
if p.is_loaded():
return
# load required plugins first
... | [
"def",
"load_plugin",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
".",
"is_loaded",
"(",
")",
":",
"return",
"# load required plugins first",
"reqnames",
"=",
"p",
".",
"required",
"reqplugins",
"=",
"[",
"]",
"for",
"name",
"in",
"reqnames",
":",
"try",... | Load the specified plugin
:param p: The plugin to load
:type p: Subclass of JB_Plugin
:returns: None
:rtype: None
:raises: errors.PluginInitError | [
"Load",
"the",
"specified",
"plugin"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L369-L397 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | PluginManager.unload_plugins | def unload_plugins(self, ):
""" Unloads all loaded plugins
:returns: None
:rtype: None
:raises: None
"""
for p in self.__plugins.values():
if p.is_loaded():
try:
p._unload()
log.info('Uninitialized the p... | python | def unload_plugins(self, ):
""" Unloads all loaded plugins
:returns: None
:rtype: None
:raises: None
"""
for p in self.__plugins.values():
if p.is_loaded():
try:
p._unload()
log.info('Uninitialized the p... | [
"def",
"unload_plugins",
"(",
"self",
",",
")",
":",
"for",
"p",
"in",
"self",
".",
"__plugins",
".",
"values",
"(",
")",
":",
"if",
"p",
".",
"is_loaded",
"(",
")",
":",
"try",
":",
"p",
".",
"_unload",
"(",
")",
"log",
".",
"info",
"(",
"'Uni... | Unloads all loaded plugins
:returns: None
:rtype: None
:raises: None | [
"Unloads",
"all",
"loaded",
"plugins"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L399-L412 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/plugins.py | PluginManager.__import_file | def __import_file(self, f):
"""Import the specified file and return the imported module
:param f: the file to import
:type f: str
:returns: The imported module
:rtype: module
:raises: None
"""
directory, module_name = os.path.split(f)
module_name ... | python | def __import_file(self, f):
"""Import the specified file and return the imported module
:param f: the file to import
:type f: str
:returns: The imported module
:rtype: module
:raises: None
"""
directory, module_name = os.path.split(f)
module_name ... | [
"def",
"__import_file",
"(",
"self",
",",
"f",
")",
":",
"directory",
",",
"module_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"f",
")",
"module_name",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"module_name",
")",
"[",
"0",
"]",
"path",
"... | Import the specified file and return the imported module
:param f: the file to import
:type f: str
:returns: The imported module
:rtype: module
:raises: None | [
"Import",
"the",
"specified",
"file",
"and",
"return",
"the",
"imported",
"module"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L414-L429 |
gevious/flask_slither | flask_slither/resources.py | BaseResource._exception_handler | def _exception_handler(self, e):
"""This exception handler catches should only be invoked when we need
to quit the workflow prematurely. It takes in an `ApiException`
which will contain the error, details of the error and status code.
When the application is in testing mode, it... | python | def _exception_handler(self, e):
"""This exception handler catches should only be invoked when we need
to quit the workflow prematurely. It takes in an `ApiException`
which will contain the error, details of the error and status code.
When the application is in testing mode, it... | [
"def",
"_exception_handler",
"(",
"self",
",",
"e",
")",
":",
"if",
"isinstance",
"(",
"e",
".",
"message",
",",
"dict",
")",
":",
"return",
"self",
".",
"_prep_response",
"(",
"e",
".",
"message",
"[",
"'msg'",
"]",
",",
"status",
"=",
"e",
".",
"... | This exception handler catches should only be invoked when we need
to quit the workflow prematurely. It takes in an `ApiException`
which will contain the error, details of the error and status code.
When the application is in testing mode, it will also return the
stack trace | [
"This",
"exception",
"handler",
"catches",
"should",
"only",
"be",
"invoked",
"when",
"we",
"need",
"to",
"quit",
"the",
"workflow",
"prematurely",
".",
"It",
"takes",
"in",
"an",
"ApiException",
"which",
"will",
"contain",
"the",
"error",
"details",
"of",
"... | train | https://github.com/gevious/flask_slither/blob/bf1fd1e58224c19883f4b19c5f727f47ee9857da/flask_slither/resources.py#L68-L83 |
gevious/flask_slither | flask_slither/resources.py | BaseResource._get_instance | def _get_instance(self, **kwargs):
"""Loads the record specified by the `obj_id` path in the url and
stores it in g._resource_instance"""
current_app.logger.info("Getting instance")
current_app.logger.debug("kwargs: {}".format(kwargs))
current_app.logger.info(
"Lo... | python | def _get_instance(self, **kwargs):
"""Loads the record specified by the `obj_id` path in the url and
stores it in g._resource_instance"""
current_app.logger.info("Getting instance")
current_app.logger.debug("kwargs: {}".format(kwargs))
current_app.logger.info(
"Lo... | [
"def",
"_get_instance",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"current_app",
".",
"logger",
".",
"info",
"(",
"\"Getting instance\"",
")",
"current_app",
".",
"logger",
".",
"debug",
"(",
"\"kwargs: {}\"",
".",
"format",
"(",
"kwargs",
")",
")",
... | Loads the record specified by the `obj_id` path in the url and
stores it in g._resource_instance | [
"Loads",
"the",
"record",
"specified",
"by",
"the",
"obj_id",
"path",
"in",
"the",
"url",
"and",
"stores",
"it",
"in",
"g",
".",
"_resource_instance"
] | train | https://github.com/gevious/flask_slither/blob/bf1fd1e58224c19883f4b19c5f727f47ee9857da/flask_slither/resources.py#L85-L97 |
gevious/flask_slither | flask_slither/resources.py | BaseResource.merge_record_data | def merge_record_data(self, changes, orig_record=None):
"""This method merges PATCH requests with the db record to ensure no
data is lost. In addition, it is also a hook for other fields to
be overwritten, to ensure immutable fields aren't changed by a
request."""
curren... | python | def merge_record_data(self, changes, orig_record=None):
"""This method merges PATCH requests with the db record to ensure no
data is lost. In addition, it is also a hook for other fields to
be overwritten, to ensure immutable fields aren't changed by a
request."""
curren... | [
"def",
"merge_record_data",
"(",
"self",
",",
"changes",
",",
"orig_record",
"=",
"None",
")",
":",
"current_app",
".",
"logger",
".",
"info",
"(",
"\"Merging request data with db record\"",
")",
"current_app",
".",
"logger",
".",
"debug",
"(",
"\"orig_record: {}\... | This method merges PATCH requests with the db record to ensure no
data is lost. In addition, it is also a hook for other fields to
be overwritten, to ensure immutable fields aren't changed by a
request. | [
"This",
"method",
"merges",
"PATCH",
"requests",
"with",
"the",
"db",
"record",
"to",
"ensure",
"no",
"data",
"is",
"lost",
".",
"In",
"addition",
"it",
"is",
"also",
"a",
"hook",
"for",
"other",
"fields",
"to",
"be",
"overwritten",
"to",
"ensure",
"immu... | train | https://github.com/gevious/flask_slither/blob/bf1fd1e58224c19883f4b19c5f727f47ee9857da/flask_slither/resources.py#L173-L188 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | str_name_value | def str_name_value(name, value, tab=4, ljust=25):
"""
This will return a str of name and value with uniform spacing
:param name: str of the name
:param value: str of the value
:param tab: int of the number of spaces before the name
:param ljust: int of the name ljust to apply to name
... | python | def str_name_value(name, value, tab=4, ljust=25):
"""
This will return a str of name and value with uniform spacing
:param name: str of the name
:param value: str of the value
:param tab: int of the number of spaces before the name
:param ljust: int of the name ljust to apply to name
... | [
"def",
"str_name_value",
"(",
"name",
",",
"value",
",",
"tab",
"=",
"4",
",",
"ljust",
"=",
"25",
")",
":",
"rep_name",
"=",
"(",
"name",
".",
"startswith",
"(",
"'_'",
")",
"and",
"name",
"[",
"1",
":",
"]",
")",
"or",
"name",
"try",
":",
"re... | This will return a str of name and value with uniform spacing
:param name: str of the name
:param value: str of the value
:param tab: int of the number of spaces before the name
:param ljust: int of the name ljust to apply to name
:return: str of the formatted string | [
"This",
"will",
"return",
"a",
"str",
"of",
"name",
"and",
"value",
"with",
"uniform",
"spacing",
":",
"param",
"name",
":",
"str",
"of",
"the",
"name",
":",
"param",
"value",
":",
"str",
"of",
"the",
"value",
":",
"param",
"tab",
":",
"int",
"of",
... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L21-L37 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | set_pprint_format | def set_pprint_format(indent=None, width=None, depth=None):
"""
This will set the constants for the pprint
:param indent: number of spaces to indent
:param width: max width of the line
:param depth: mas depth of the objects
:return: current settings
"""
if indent is not None:
PPR... | python | def set_pprint_format(indent=None, width=None, depth=None):
"""
This will set the constants for the pprint
:param indent: number of spaces to indent
:param width: max width of the line
:param depth: mas depth of the objects
:return: current settings
"""
if indent is not None:
PPR... | [
"def",
"set_pprint_format",
"(",
"indent",
"=",
"None",
",",
"width",
"=",
"None",
",",
"depth",
"=",
"None",
")",
":",
"if",
"indent",
"is",
"not",
"None",
":",
"PPRINT_FORMAT",
"[",
"'indent'",
"]",
"=",
"indent",
"if",
"width",
"is",
"not",
"None",
... | This will set the constants for the pprint
:param indent: number of spaces to indent
:param width: max width of the line
:param depth: mas depth of the objects
:return: current settings | [
"This",
"will",
"set",
"the",
"constants",
"for",
"the",
"pprint",
":",
"param",
"indent",
":",
"number",
"of",
"spaces",
"to",
"indent",
":",
"param",
"width",
":",
"max",
"width",
"of",
"the",
"line",
":",
"param",
"depth",
":",
"mas",
"depth",
"of",... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L40-L54 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | repr_return | def repr_return(func):
"""
This is a decorator to give the return value a pretty print repr
"""
def repr_return_decorator(*args, **kwargs):
ret = func(*args, **kwargs)
if isinstance(ret, basestring):
return ret
if type(ret) in repr_map:
return repr_map[t... | python | def repr_return(func):
"""
This is a decorator to give the return value a pretty print repr
"""
def repr_return_decorator(*args, **kwargs):
ret = func(*args, **kwargs)
if isinstance(ret, basestring):
return ret
if type(ret) in repr_map:
return repr_map[t... | [
"def",
"repr_return",
"(",
"func",
")",
":",
"def",
"repr_return_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"ret",
",",
"basestring",
... | This is a decorator to give the return value a pretty print repr | [
"This",
"is",
"a",
"decorator",
"to",
"give",
"the",
"return",
"value",
"a",
"pretty",
"print",
"repr"
] | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L71-L90 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | ReprDict.repr_setup | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None:
"""
self._n... | python | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None:
"""
self._n... | [
"def",
"repr_setup",
"(",
"self",
",",
"name",
"=",
"None",
",",
"col_names",
"=",
"None",
",",
"col_types",
"=",
"None",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"self",
".",
"_name"
] | This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None: | [
"This",
"wasn",
"t",
"safe",
"to",
"pass",
"into",
"init",
"because",
"of",
"the",
"inheritance",
":",
"param",
"name",
":",
"name",
"of",
"the",
"api",
"return",
"type",
"(",
"ex",
".",
"CAMERA_DATA_LIST",
")",
":",
"param",
"col_names",
":",
":",
"pa... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L118-L126 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | ReprList.repr_setup | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None:
"""
self._n... | python | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None:
"""
self._n... | [
"def",
"repr_setup",
"(",
"self",
",",
"name",
"=",
"None",
",",
"col_names",
"=",
"None",
",",
"col_types",
"=",
"None",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"self",
".",
"_name",
"self",
".",
"_col_names",
"=",
"col_names",
"or",
"sel... | This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None: | [
"This",
"wasn",
"t",
"safe",
"to",
"pass",
"into",
"init",
"because",
"of",
"the",
"inheritance",
":",
"param",
"name",
":",
"name",
"of",
"the",
"api",
"return",
"type",
"(",
"ex",
".",
"CAMERA_DATA_LIST",
")",
":",
"param",
"col_names",
":",
":",
"pa... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L153-L165 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | ReprListList.list_of_dict | def list_of_dict(self):
"""
This will convert the data from a list of list to a list of dictionary
:return: list of dict
"""
ret = []
for row in self:
ret.append(dict([(self._col_names[i], row[i]) for i in
range(len(self._col_names... | python | def list_of_dict(self):
"""
This will convert the data from a list of list to a list of dictionary
:return: list of dict
"""
ret = []
for row in self:
ret.append(dict([(self._col_names[i], row[i]) for i in
range(len(self._col_names... | [
"def",
"list_of_dict",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
":",
"ret",
".",
"append",
"(",
"dict",
"(",
"[",
"(",
"self",
".",
"_col_names",
"[",
"i",
"]",
",",
"row",
"[",
"i",
"]",
")",
"for",
"i",
"in",... | This will convert the data from a list of list to a list of dictionary
:return: list of dict | [
"This",
"will",
"convert",
"the",
"data",
"from",
"a",
"list",
"of",
"list",
"to",
"a",
"list",
"of",
"dictionary",
":",
"return",
":",
"list",
"of",
"dict"
] | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L256-L269 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | ReprListList.append | def append(self, obj):
"""
If it is a list it will append the obj, if it is a dictionary
it will convert it to a list and append
:param obj: dict or list of the object to append
:return: None
"""
if isinstance(obj, dict) and self._col_names:
obj = [obj... | python | def append(self, obj):
"""
If it is a list it will append the obj, if it is a dictionary
it will convert it to a list and append
:param obj: dict or list of the object to append
:return: None
"""
if isinstance(obj, dict) and self._col_names:
obj = [obj... | [
"def",
"append",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
"and",
"self",
".",
"_col_names",
":",
"obj",
"=",
"[",
"obj",
".",
"get",
"(",
"col",
",",
"None",
")",
"for",
"col",
"in",
"self",
".",
"_co... | If it is a list it will append the obj, if it is a dictionary
it will convert it to a list and append
:param obj: dict or list of the object to append
:return: None | [
"If",
"it",
"is",
"a",
"list",
"it",
"will",
"append",
"the",
"obj",
"if",
"it",
"is",
"a",
"dictionary",
"it",
"will",
"convert",
"it",
"to",
"a",
"list",
"and",
"append",
":",
"param",
"obj",
":",
"dict",
"or",
"list",
"of",
"the",
"object",
"to"... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L271-L282 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | ReprListDict.list_of_list | def list_of_list(self):
"""
This will convert the data from a list of dict to a list of list
:return: list of dict
"""
ret = [[row.get(key, '') for key in self._col_names] for row in self]
return ReprListList(ret, col_names=self._col_names,
col... | python | def list_of_list(self):
"""
This will convert the data from a list of dict to a list of list
:return: list of dict
"""
ret = [[row.get(key, '') for key in self._col_names] for row in self]
return ReprListList(ret, col_names=self._col_names,
col... | [
"def",
"list_of_list",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"[",
"row",
".",
"get",
"(",
"key",
",",
"''",
")",
"for",
"key",
"in",
"self",
".",
"_col_names",
"]",
"for",
"row",
"in",
"self",
"]",
"return",
"ReprListList",
"(",
"ret",
",",
"co... | This will convert the data from a list of dict to a list of list
:return: list of dict | [
"This",
"will",
"convert",
"the",
"data",
"from",
"a",
"list",
"of",
"dict",
"to",
"a",
"list",
"of",
"list",
":",
"return",
":",
"list",
"of",
"dict"
] | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L313-L323 |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | ReprTuple.repr_setup | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
"""
self._name = name or self._name
self._col_types = col_types or self._col_types | python | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
"""
self._name = name or self._name
self._col_types = col_types or self._col_types | [
"def",
"repr_setup",
"(",
"self",
",",
"name",
"=",
"None",
",",
"col_names",
"=",
"None",
",",
"col_types",
"=",
"None",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"self",
".",
"_name",
"self",
".",
"_col_types",
"=",
"col_types",
"or",
"sel... | This wasn't safe to pass into init because of the inheritance | [
"This",
"wasn",
"t",
"safe",
"to",
"pass",
"into",
"init",
"because",
"of",
"the",
"inheritance"
] | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L356-L361 |
openvax/typechecks | typechecks/__init__.py | require_string | def require_string(obj, name=None, nonempty=False):
"""
Raise an exception if the obj is not of type str or unicode.
If name is provided it is used in the exception message.
If nonempty=True, then an exception is raised if the object is the empty
string.
"""
require_instance(obj, string_ty... | python | def require_string(obj, name=None, nonempty=False):
"""
Raise an exception if the obj is not of type str or unicode.
If name is provided it is used in the exception message.
If nonempty=True, then an exception is raised if the object is the empty
string.
"""
require_instance(obj, string_ty... | [
"def",
"require_string",
"(",
"obj",
",",
"name",
"=",
"None",
",",
"nonempty",
"=",
"False",
")",
":",
"require_instance",
"(",
"obj",
",",
"string_types",
",",
"name",
",",
"\"string\"",
")",
"if",
"nonempty",
"and",
"not",
"obj",
":",
"raise",
"ValueE... | Raise an exception if the obj is not of type str or unicode.
If name is provided it is used in the exception message.
If nonempty=True, then an exception is raised if the object is the empty
string. | [
"Raise",
"an",
"exception",
"if",
"the",
"obj",
"is",
"not",
"of",
"type",
"str",
"or",
"unicode",
"."
] | train | https://github.com/openvax/typechecks/blob/5340b4e8a2f419b3a7aa816a5b19e2e0a6ce0679/typechecks/__init__.py#L32-L45 |
openvax/typechecks | typechecks/__init__.py | require_instance | def require_instance(obj, types=None, name=None, type_name=None, truncate_at=80):
"""
Raise an exception if obj is not an instance of one of the specified types.
Similarly to isinstance, 'types' may be either a single type or a tuple of
types.
If name or type_name is provided, it is used in the ex... | python | def require_instance(obj, types=None, name=None, type_name=None, truncate_at=80):
"""
Raise an exception if obj is not an instance of one of the specified types.
Similarly to isinstance, 'types' may be either a single type or a tuple of
types.
If name or type_name is provided, it is used in the ex... | [
"def",
"require_instance",
"(",
"obj",
",",
"types",
"=",
"None",
",",
"name",
"=",
"None",
",",
"type_name",
"=",
"None",
",",
"truncate_at",
"=",
"80",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"types",
")",
":",
"obj_string",
"=",
"str... | Raise an exception if obj is not an instance of one of the specified types.
Similarly to isinstance, 'types' may be either a single type or a tuple of
types.
If name or type_name is provided, it is used in the exception message.
The object's string representation is also included in the message,
t... | [
"Raise",
"an",
"exception",
"if",
"obj",
"is",
"not",
"an",
"instance",
"of",
"one",
"of",
"the",
"specified",
"types",
"."
] | train | https://github.com/openvax/typechecks/blob/5340b4e8a2f419b3a7aa816a5b19e2e0a6ce0679/typechecks/__init__.py#L59-L82 |
openvax/typechecks | typechecks/__init__.py | require_iterable_of | def require_iterable_of(objs, types, name=None, type_name=None, truncate_at=80):
"""
Raise an exception if objs is not an iterable with each element an instance
of one of the specified types.
See `require_instance` for descriptions of the other parameters.
"""
# Fast pass for common case where ... | python | def require_iterable_of(objs, types, name=None, type_name=None, truncate_at=80):
"""
Raise an exception if objs is not an iterable with each element an instance
of one of the specified types.
See `require_instance` for descriptions of the other parameters.
"""
# Fast pass for common case where ... | [
"def",
"require_iterable_of",
"(",
"objs",
",",
"types",
",",
"name",
"=",
"None",
",",
"type_name",
"=",
"None",
",",
"truncate_at",
"=",
"80",
")",
":",
"# Fast pass for common case where all types are correct.",
"# This avoids the more expensive loop below. A typical spe... | Raise an exception if objs is not an iterable with each element an instance
of one of the specified types.
See `require_instance` for descriptions of the other parameters. | [
"Raise",
"an",
"exception",
"if",
"objs",
"is",
"not",
"an",
"iterable",
"with",
"each",
"element",
"an",
"instance",
"of",
"one",
"of",
"the",
"specified",
"types",
"."
] | train | https://github.com/openvax/typechecks/blob/5340b4e8a2f419b3a7aa816a5b19e2e0a6ce0679/typechecks/__init__.py#L84-L109 |
praekeltfoundation/molo.yourtips | molo/yourtips/templatetags/tip_tags.py | your_tips_on_homepage | def your_tips_on_homepage(context):
"""
A template tag for the Tip of the Day on the homepage.
Note that:
* If there is an active featured_in_homepage tip it will take precedence.
* If there is no featured tip a popular tip will be displayed.
* If there is no featured tip and no popular tip,
... | python | def your_tips_on_homepage(context):
"""
A template tag for the Tip of the Day on the homepage.
Note that:
* If there is an active featured_in_homepage tip it will take precedence.
* If there is no featured tip a popular tip will be displayed.
* If there is no featured tip and no popular tip,
... | [
"def",
"your_tips_on_homepage",
"(",
"context",
")",
":",
"context",
"=",
"copy",
"(",
"context",
")",
"site_main",
"=",
"context",
"[",
"'request'",
"]",
".",
"site",
".",
"root_page",
"if",
"get_your_tip",
"(",
"context",
")",
":",
"tip_on_homepage",
"=",
... | A template tag for the Tip of the Day on the homepage.
Note that:
* If there is an active featured_in_homepage tip it will take precedence.
* If there is no featured tip a popular tip will be displayed.
* If there is no featured tip and no popular tip,
the most recent tip will be displayed.
... | [
"A",
"template",
"tag",
"for",
"the",
"Tip",
"of",
"the",
"Day",
"on",
"the",
"homepage",
".",
"Note",
"that",
":",
"*",
"If",
"there",
"is",
"an",
"active",
"featured_in_homepage",
"tip",
"it",
"will",
"take",
"precedence",
".",
"*",
"If",
"there",
"i... | train | https://github.com/praekeltfoundation/molo.yourtips/blob/8b3e3b1ff52cd4a78ccca5d153b3909a1f21625f/molo/yourtips/templatetags/tip_tags.py#L13-L48 |
praekeltfoundation/molo.yourtips | molo/yourtips/templatetags/tip_tags.py | your_tips_on_tip_submission_form | def your_tips_on_tip_submission_form(context):
"""
A template tag to display the most recent and popular tip
on the tip submission form.
:param context: takes context
"""
context = copy(context)
site_main = context['request'].site.root_page
most_recent_tip = (YourTipsArticlePage.objects... | python | def your_tips_on_tip_submission_form(context):
"""
A template tag to display the most recent and popular tip
on the tip submission form.
:param context: takes context
"""
context = copy(context)
site_main = context['request'].site.root_page
most_recent_tip = (YourTipsArticlePage.objects... | [
"def",
"your_tips_on_tip_submission_form",
"(",
"context",
")",
":",
"context",
"=",
"copy",
"(",
"context",
")",
"site_main",
"=",
"context",
"[",
"'request'",
"]",
".",
"site",
".",
"root_page",
"most_recent_tip",
"=",
"(",
"YourTipsArticlePage",
".",
"objects... | A template tag to display the most recent and popular tip
on the tip submission form.
:param context: takes context | [
"A",
"template",
"tag",
"to",
"display",
"the",
"most",
"recent",
"and",
"popular",
"tip",
"on",
"the",
"tip",
"submission",
"form",
".",
":",
"param",
"context",
":",
"takes",
"context"
] | train | https://github.com/praekeltfoundation/molo.yourtips/blob/8b3e3b1ff52cd4a78ccca5d153b3909a1f21625f/molo/yourtips/templatetags/tip_tags.py#L55-L80 |
praekeltfoundation/molo.yourtips | molo/yourtips/templatetags/tip_tags.py | your_tips_create_tip_on_homepage | def your_tips_create_tip_on_homepage(context):
"""
A template tag to display a banner with a link on the homepage.
Note that:
* homepage_action_copy: Can be changed on the YourTip page.
:param context: takes context
"""
context = copy(context)
if get_your_tip(context):
homepage_a... | python | def your_tips_create_tip_on_homepage(context):
"""
A template tag to display a banner with a link on the homepage.
Note that:
* homepage_action_copy: Can be changed on the YourTip page.
:param context: takes context
"""
context = copy(context)
if get_your_tip(context):
homepage_a... | [
"def",
"your_tips_create_tip_on_homepage",
"(",
"context",
")",
":",
"context",
"=",
"copy",
"(",
"context",
")",
"if",
"get_your_tip",
"(",
"context",
")",
":",
"homepage_action_copy",
"=",
"get_your_tip",
"(",
"context",
")",
".",
"homepage_action_copy",
"contex... | A template tag to display a banner with a link on the homepage.
Note that:
* homepage_action_copy: Can be changed on the YourTip page.
:param context: takes context | [
"A",
"template",
"tag",
"to",
"display",
"a",
"banner",
"with",
"a",
"link",
"on",
"the",
"homepage",
".",
"Note",
"that",
":",
"*",
"homepage_action_copy",
":",
"Can",
"be",
"changed",
"on",
"the",
"YourTip",
"page",
".",
":",
"param",
"context",
":",
... | train | https://github.com/praekeltfoundation/molo.yourtips/blob/8b3e3b1ff52cd4a78ccca5d153b3909a1f21625f/molo/yourtips/templatetags/tip_tags.py#L87-L101 |
praekeltfoundation/molo.yourtips | molo/yourtips/templatetags/tip_tags.py | your_tips_breadcrumbs | def your_tips_breadcrumbs(context, active_breadcrumb_title=None):
"""
A template tag to display breadcrumbs on the recent and popular tip views.
:param context: takes context
"""
context = copy(context)
if get_your_tip(context):
context.update({
'your_tip_page_slug': get_you... | python | def your_tips_breadcrumbs(context, active_breadcrumb_title=None):
"""
A template tag to display breadcrumbs on the recent and popular tip views.
:param context: takes context
"""
context = copy(context)
if get_your_tip(context):
context.update({
'your_tip_page_slug': get_you... | [
"def",
"your_tips_breadcrumbs",
"(",
"context",
",",
"active_breadcrumb_title",
"=",
"None",
")",
":",
"context",
"=",
"copy",
"(",
"context",
")",
"if",
"get_your_tip",
"(",
"context",
")",
":",
"context",
".",
"update",
"(",
"{",
"'your_tip_page_slug'",
":",... | A template tag to display breadcrumbs on the recent and popular tip views.
:param context: takes context | [
"A",
"template",
"tag",
"to",
"display",
"breadcrumbs",
"on",
"the",
"recent",
"and",
"popular",
"tip",
"views",
".",
":",
"param",
"context",
":",
"takes",
"context"
] | train | https://github.com/praekeltfoundation/molo.yourtips/blob/8b3e3b1ff52cd4a78ccca5d153b3909a1f21625f/molo/yourtips/templatetags/tip_tags.py#L108-L120 |
praekeltfoundation/molo.yourtips | molo/yourtips/templatetags/tip_tags.py | get_your_tip | def get_your_tip(context):
"""
A simple tag to return the YourTips page.
:param context: takes context
:return: A YourTip object
"""
site_main = context['request'].site.root_page
return YourTip.objects.descendant_of(site_main).live().first() | python | def get_your_tip(context):
"""
A simple tag to return the YourTips page.
:param context: takes context
:return: A YourTip object
"""
site_main = context['request'].site.root_page
return YourTip.objects.descendant_of(site_main).live().first() | [
"def",
"get_your_tip",
"(",
"context",
")",
":",
"site_main",
"=",
"context",
"[",
"'request'",
"]",
".",
"site",
".",
"root_page",
"return",
"YourTip",
".",
"objects",
".",
"descendant_of",
"(",
"site_main",
")",
".",
"live",
"(",
")",
".",
"first",
"("... | A simple tag to return the YourTips page.
:param context: takes context
:return: A YourTip object | [
"A",
"simple",
"tag",
"to",
"return",
"the",
"YourTips",
"page",
".",
":",
"param",
"context",
":",
"takes",
"context",
":",
"return",
":",
"A",
"YourTip",
"object"
] | train | https://github.com/praekeltfoundation/molo.yourtips/blob/8b3e3b1ff52cd4a78ccca5d153b3909a1f21625f/molo/yourtips/templatetags/tip_tags.py#L124-L131 |
jkwill87/teletype | teletype/io/windows.py | get_key | def get_key(raw=False):
""" Gets a single key from stdin
"""
while True:
try:
if kbhit():
char = getch()
ordinal = ord(char)
if ordinal in (0, 224):
extention = ord(getch())
scan_code = ordinal + exte... | python | def get_key(raw=False):
""" Gets a single key from stdin
"""
while True:
try:
if kbhit():
char = getch()
ordinal = ord(char)
if ordinal in (0, 224):
extention = ord(getch())
scan_code = ordinal + exte... | [
"def",
"get_key",
"(",
"raw",
"=",
"False",
")",
":",
"while",
"True",
":",
"try",
":",
"if",
"kbhit",
"(",
")",
":",
"char",
"=",
"getch",
"(",
")",
"ordinal",
"=",
"ord",
"(",
"char",
")",
"if",
"ordinal",
"in",
"(",
"0",
",",
"224",
")",
"... | Gets a single key from stdin | [
"Gets",
"a",
"single",
"key",
"from",
"stdin"
] | train | https://github.com/jkwill87/teletype/blob/8ba95c56dcb5e4d7f6ae155eb6cdabfdfaf346cf/teletype/io/windows.py#L6-L24 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/RecursiveObjectWriter.py | RecursiveObjectWriter.set_property | def set_property(obj, name, value):
"""
Recursively sets value of object and its subobjects property specified by its name.
The object can be a user defined object, map or array.
The property name correspondently must be object property, map key or array index.
If the property ... | python | def set_property(obj, name, value):
"""
Recursively sets value of object and its subobjects property specified by its name.
The object can be a user defined object, map or array.
The property name correspondently must be object property, map key or array index.
If the property ... | [
"def",
"set_property",
"(",
"obj",
",",
"name",
",",
"value",
")",
":",
"if",
"obj",
"==",
"None",
"or",
"name",
"==",
"None",
":",
"return",
"names",
"=",
"name",
".",
"split",
"(",
"\".\"",
")",
"if",
"names",
"==",
"None",
"or",
"len",
"(",
"n... | Recursively sets value of object and its subobjects property specified by its name.
The object can be a user defined object, map or array.
The property name correspondently must be object property, map key or array index.
If the property does not exist or introspection fails
this metho... | [
"Recursively",
"sets",
"value",
"of",
"object",
"and",
"its",
"subobjects",
"property",
"specified",
"by",
"its",
"name",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/RecursiveObjectWriter.py#L45-L68 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/RecursiveObjectWriter.py | RecursiveObjectWriter.set_properties | def set_properties(obj, values):
"""
Recursively sets values of some (all) object and its subobjects properties.
The object can be a user defined object, map or array.
Property values correspondently are object properties, map key-pairs or array elements with their indexes.
If ... | python | def set_properties(obj, values):
"""
Recursively sets values of some (all) object and its subobjects properties.
The object can be a user defined object, map or array.
Property values correspondently are object properties, map key-pairs or array elements with their indexes.
If ... | [
"def",
"set_properties",
"(",
"obj",
",",
"values",
")",
":",
"if",
"values",
"==",
"None",
"or",
"len",
"(",
"values",
")",
"==",
"0",
":",
"return",
"for",
"(",
"key",
",",
"value",
")",
"in",
"values",
".",
"items",
"(",
")",
":",
"RecursiveObje... | Recursively sets values of some (all) object and its subobjects properties.
The object can be a user defined object, map or array.
Property values correspondently are object properties, map key-pairs or array elements with their indexes.
If some properties do not exist or introspection fails t... | [
"Recursively",
"sets",
"values",
"of",
"some",
"(",
"all",
")",
"object",
"and",
"its",
"subobjects",
"properties",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/RecursiveObjectWriter.py#L72-L89 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/RecursiveObjectWriter.py | RecursiveObjectWriter.copy_properties | def copy_properties(dest, src):
"""
Copies content of one object to another object
by recursively reading all properties from source object
and then recursively writing them to destination object.
:param dest: a destination object to write properties to.
:param src: a s... | python | def copy_properties(dest, src):
"""
Copies content of one object to another object
by recursively reading all properties from source object
and then recursively writing them to destination object.
:param dest: a destination object to write properties to.
:param src: a s... | [
"def",
"copy_properties",
"(",
"dest",
",",
"src",
")",
":",
"if",
"dest",
"==",
"None",
"or",
"src",
"==",
"None",
":",
"return",
"values",
"=",
"RecursiveObjectReader",
".",
"get_properties",
"(",
"src",
")",
"RecursiveObjectWriter",
".",
"set_properties",
... | Copies content of one object to another object
by recursively reading all properties from source object
and then recursively writing them to destination object.
:param dest: a destination object to write properties to.
:param src: a source object to read properties from | [
"Copies",
"content",
"of",
"one",
"object",
"to",
"another",
"object",
"by",
"recursively",
"reading",
"all",
"properties",
"from",
"source",
"object",
"and",
"then",
"recursively",
"writing",
"them",
"to",
"destination",
"object",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/RecursiveObjectWriter.py#L93-L107 |
FujiMakoto/AgentML | agentml/parser/trigger/condition/types/user_var.py | UserVarType.get | def get(self, agentml, user=None, key=None):
"""
Evaluate and return the current value of a user variable
:param user: The active user object
:type user: agentml.User or None
:param agentml: The active AgentML instance
:type agentml: AgentML
:param key: The va... | python | def get(self, agentml, user=None, key=None):
"""
Evaluate and return the current value of a user variable
:param user: The active user object
:type user: agentml.User or None
:param agentml: The active AgentML instance
:type agentml: AgentML
:param key: The va... | [
"def",
"get",
"(",
"self",
",",
"agentml",
",",
"user",
"=",
"None",
",",
"key",
"=",
"None",
")",
":",
"if",
"not",
"user",
"or",
"not",
"key",
":",
"return",
"try",
":",
"return",
"user",
".",
"get_var",
"(",
"key",
")",
"except",
"VarNotDefinedE... | Evaluate and return the current value of a user variable
:param user: The active user object
:type user: agentml.User or None
:param agentml: The active AgentML instance
:type agentml: AgentML
:param key: The variables key
:type key: str
:return: Current val... | [
"Evaluate",
"and",
"return",
"the",
"current",
"value",
"of",
"a",
"user",
"variable",
":",
"param",
"user",
":",
"The",
"active",
"user",
"object",
":",
"type",
"user",
":",
"agentml",
".",
"User",
"or",
"None"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/condition/types/user_var.py#L15-L36 |
zabertech/python-izaber | izaber/date.py | time_range_cutter_at_time | def time_range_cutter_at_time(local,time_range,time_cut=(0,0,0)):
""" Given a range, return a list of DateTimes that match the time_cut
between start and end.
:param local: if False [default] use UTC datetime. If True use localtz
:param time_range: the TimeRange object
:param time_c... | python | def time_range_cutter_at_time(local,time_range,time_cut=(0,0,0)):
""" Given a range, return a list of DateTimes that match the time_cut
between start and end.
:param local: if False [default] use UTC datetime. If True use localtz
:param time_range: the TimeRange object
:param time_c... | [
"def",
"time_range_cutter_at_time",
"(",
"local",
",",
"time_range",
",",
"time_cut",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"(",
"start",
",",
"end",
")",
"=",
"time_range",
".",
"get",
"(",
"local",
")",
"index",
"=",
"start",
".",
"re... | Given a range, return a list of DateTimes that match the time_cut
between start and end.
:param local: if False [default] use UTC datetime. If True use localtz
:param time_range: the TimeRange object
:param time_cut: HH:MM:SS of when to cut. eg: (0,0,0) for midnight | [
"Given",
"a",
"range",
"return",
"a",
"list",
"of",
"DateTimes",
"that",
"match",
"the",
"time_cut",
"between",
"start",
"and",
"end",
"."
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L11-L34 |
zabertech/python-izaber | izaber/date.py | TimeRange.delta | def delta(self,local=False):
""" Returns the number of days of difference
"""
(s,e) = self.get(local)
return e-s | python | def delta(self,local=False):
""" Returns the number of days of difference
"""
(s,e) = self.get(local)
return e-s | [
"def",
"delta",
"(",
"self",
",",
"local",
"=",
"False",
")",
":",
"(",
"s",
",",
"e",
")",
"=",
"self",
".",
"get",
"(",
"local",
")",
"return",
"e",
"-",
"s"
] | Returns the number of days of difference | [
"Returns",
"the",
"number",
"of",
"days",
"of",
"difference"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L54-L58 |
zabertech/python-izaber | izaber/date.py | TimeRange.hours | def hours(self,local=False):
""" Returns the number of hours of difference
"""
delta = self.delta(local)
return delta.total_seconds()/3600 | python | def hours(self,local=False):
""" Returns the number of hours of difference
"""
delta = self.delta(local)
return delta.total_seconds()/3600 | [
"def",
"hours",
"(",
"self",
",",
"local",
"=",
"False",
")",
":",
"delta",
"=",
"self",
".",
"delta",
"(",
"local",
")",
"return",
"delta",
".",
"total_seconds",
"(",
")",
"/",
"3600"
] | Returns the number of hours of difference | [
"Returns",
"the",
"number",
"of",
"hours",
"of",
"difference"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L60-L64 |
zabertech/python-izaber | izaber/date.py | TimeRange.days | def days(self,local=False):
""" Returns the number of days of difference
"""
delta = self.delta(local)
return delta.days | python | def days(self,local=False):
""" Returns the number of days of difference
"""
delta = self.delta(local)
return delta.days | [
"def",
"days",
"(",
"self",
",",
"local",
"=",
"False",
")",
":",
"delta",
"=",
"self",
".",
"delta",
"(",
"local",
")",
"return",
"delta",
".",
"days"
] | Returns the number of days of difference | [
"Returns",
"the",
"number",
"of",
"days",
"of",
"difference"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L67-L71 |
zabertech/python-izaber | izaber/date.py | TimeRange.chunks | def chunks(self,local,cutter_callback=None,*cutter_callback_args,**cutter_callback_kwargs):
""" Takes a time range and returns sub timeranges based upon
the cuts that cutter callback provides
:param local: if False [default] use UTC datetime. If True use localtz
:param cutte... | python | def chunks(self,local,cutter_callback=None,*cutter_callback_args,**cutter_callback_kwargs):
""" Takes a time range and returns sub timeranges based upon
the cuts that cutter callback provides
:param local: if False [default] use UTC datetime. If True use localtz
:param cutte... | [
"def",
"chunks",
"(",
"self",
",",
"local",
",",
"cutter_callback",
"=",
"None",
",",
"*",
"cutter_callback_args",
",",
"*",
"*",
"cutter_callback_kwargs",
")",
":",
"# First we get all the slices we want to take out of this time range.",
"if",
"not",
"cutter_callback",
... | Takes a time range and returns sub timeranges based upon
the cuts that cutter callback provides
:param local: if False [default] use UTC datetime. If True use localtz
:param cutter_callback: This should be a callback function that
takes the current TimeRange and ... | [
"Takes",
"a",
"time",
"range",
"and",
"returns",
"sub",
"timeranges",
"based",
"upon",
"the",
"cuts",
"that",
"cutter",
"callback",
"provides"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L87-L147 |
zabertech/python-izaber | izaber/date.py | TimeRange.str | def str(self,local):
""" Return the string representation of the time range
:param local: if False [default] use UTC datetime. If True use localtz
"""
s = self.start_time.str(local) \
+ u" to " \
+ self.end_time.str(local)
return s | python | def str(self,local):
""" Return the string representation of the time range
:param local: if False [default] use UTC datetime. If True use localtz
"""
s = self.start_time.str(local) \
+ u" to " \
+ self.end_time.str(local)
return s | [
"def",
"str",
"(",
"self",
",",
"local",
")",
":",
"s",
"=",
"self",
".",
"start_time",
".",
"str",
"(",
"local",
")",
"+",
"u\" to \"",
"+",
"self",
".",
"end_time",
".",
"str",
"(",
"local",
")",
"return",
"s"
] | Return the string representation of the time range
:param local: if False [default] use UTC datetime. If True use localtz | [
"Return",
"the",
"string",
"representation",
"of",
"the",
"time",
"range"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L149-L157 |
zabertech/python-izaber | izaber/date.py | DateTime.daily_hours | def daily_hours(self,local=False):
""" This returns a number from 0 to 24 that describes the number
of hours passed in a day. This is very useful for hr.attendances
"""
data = self.get(local)
daily_hours = (data.hour +
data.minute / 60.0 +
... | python | def daily_hours(self,local=False):
""" This returns a number from 0 to 24 that describes the number
of hours passed in a day. This is very useful for hr.attendances
"""
data = self.get(local)
daily_hours = (data.hour +
data.minute / 60.0 +
... | [
"def",
"daily_hours",
"(",
"self",
",",
"local",
"=",
"False",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"local",
")",
"daily_hours",
"=",
"(",
"data",
".",
"hour",
"+",
"data",
".",
"minute",
"/",
"60.0",
"+",
"data",
".",
"second",
"/",
"... | This returns a number from 0 to 24 that describes the number
of hours passed in a day. This is very useful for hr.attendances | [
"This",
"returns",
"a",
"number",
"from",
"0",
"to",
"24",
"that",
"describes",
"the",
"number",
"of",
"hours",
"passed",
"in",
"a",
"day",
".",
"This",
"is",
"very",
"useful",
"for",
"hr",
".",
"attendances"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L340-L348 |
zabertech/python-izaber | izaber/date.py | DateTime.date | def date(self,local=False):
""" Return the date object associated
:param local: if False [default] return UTC date. If True return localtz date
"""
return Date(self.get(local).date(),self.local_tz) | python | def date(self,local=False):
""" Return the date object associated
:param local: if False [default] return UTC date. If True return localtz date
"""
return Date(self.get(local).date(),self.local_tz) | [
"def",
"date",
"(",
"self",
",",
"local",
"=",
"False",
")",
":",
"return",
"Date",
"(",
"self",
".",
"get",
"(",
"local",
")",
".",
"date",
"(",
")",
",",
"self",
".",
"local_tz",
")"
] | Return the date object associated
:param local: if False [default] return UTC date. If True return localtz date | [
"Return",
"the",
"date",
"object",
"associated",
":",
"param",
"local",
":",
"if",
"False",
"[",
"default",
"]",
"return",
"UTC",
"date",
".",
"If",
"True",
"return",
"localtz",
"date"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L360-L364 |
zabertech/python-izaber | izaber/date.py | DateTime.str | def str(self,local=False,ifempty=None):
""" Returns the string representation of the datetime
"""
ts = self.get(local)
if not ts: return ifempty
return ts.strftime('%Y-%m-%d %H:%M:%S') | python | def str(self,local=False,ifempty=None):
""" Returns the string representation of the datetime
"""
ts = self.get(local)
if not ts: return ifempty
return ts.strftime('%Y-%m-%d %H:%M:%S') | [
"def",
"str",
"(",
"self",
",",
"local",
"=",
"False",
",",
"ifempty",
"=",
"None",
")",
":",
"ts",
"=",
"self",
".",
"get",
"(",
"local",
")",
"if",
"not",
"ts",
":",
"return",
"ifempty",
"return",
"ts",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
... | Returns the string representation of the datetime | [
"Returns",
"the",
"string",
"representation",
"of",
"the",
"datetime"
] | train | https://github.com/zabertech/python-izaber/blob/729bf9ef637e084c8ab3cc16c34cf659d3a79ee4/izaber/date.py#L366-L371 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | std_velocity | def std_velocity(particle, social, state):
"""
Standard particle velocity update according to the equation:
:math:`v_{ij}(t+1) &= \\omega v_{ij}(t) + \
c_1 r_{1j}(t)[y_{ij}(t) - x_{ij}(t)]\\:+ \
c_2 r_{2j}(t)[\\hat{y}_{ij}(t) - x_{ij}(t)],\\;\\;\
\\forall\\; j \\in\\; \\{1,...,n\\}`
If a v... | python | def std_velocity(particle, social, state):
"""
Standard particle velocity update according to the equation:
:math:`v_{ij}(t+1) &= \\omega v_{ij}(t) + \
c_1 r_{1j}(t)[y_{ij}(t) - x_{ij}(t)]\\:+ \
c_2 r_{2j}(t)[\\hat{y}_{ij}(t) - x_{ij}(t)],\\;\\;\
\\forall\\; j \\in\\; \\{1,...,n\\}`
If a v... | [
"def",
"std_velocity",
"(",
"particle",
",",
"social",
",",
"state",
")",
":",
"inertia",
"=",
"state",
".",
"params",
"[",
"'inertia'",
"]",
"c_1",
",",
"c_2",
"=",
"state",
".",
"params",
"[",
"'c_1'",
"]",
",",
"state",
".",
"params",
"[",
"'c_2'"... | Standard particle velocity update according to the equation:
:math:`v_{ij}(t+1) &= \\omega v_{ij}(t) + \
c_1 r_{1j}(t)[y_{ij}(t) - x_{ij}(t)]\\:+ \
c_2 r_{2j}(t)[\\hat{y}_{ij}(t) - x_{ij}(t)],\\;\\;\
\\forall\\; j \\in\\; \\{1,...,n\\}`
If a v_max parameter is supplied (state.params['v_max'] is no... | [
"Standard",
"particle",
"velocity",
"update",
"according",
"to",
"the",
"equation",
":"
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L40-L71 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | gc_velocity_update | def gc_velocity_update(particle, social, state):
""" Guaranteed convergence velocity update.
Args:
particle: cipy.algorithms.pso.Particle: Particle to update the velocity
for.
social: cipy.algorithms.pso.Particle: The social best for the particle.
state: cipy.algorithms.pso.... | python | def gc_velocity_update(particle, social, state):
""" Guaranteed convergence velocity update.
Args:
particle: cipy.algorithms.pso.Particle: Particle to update the velocity
for.
social: cipy.algorithms.pso.Particle: The social best for the particle.
state: cipy.algorithms.pso.... | [
"def",
"gc_velocity_update",
"(",
"particle",
",",
"social",
",",
"state",
")",
":",
"gbest",
"=",
"state",
".",
"swarm",
"[",
"gbest_idx",
"(",
"state",
".",
"swarm",
")",
"]",
".",
"position",
"if",
"not",
"np",
".",
"array_equal",
"(",
"gbest",
",",... | Guaranteed convergence velocity update.
Args:
particle: cipy.algorithms.pso.Particle: Particle to update the velocity
for.
social: cipy.algorithms.pso.Particle: The social best for the particle.
state: cipy.algorithms.pso.State: The state of the PSO algorithm.
Returns:
... | [
"Guaranteed",
"convergence",
"velocity",
"update",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L88-L111 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | initialize_particle | def initialize_particle(rng, domain, fitness_function):
""" Initializes a particle within a domain.
Args:
rng: numpy.random.RandomState: The random number generator.
domain: cipy.problems.core.Domain: The domain of the problem.
Returns:
cipy.algorithms.pso.Particle: A new, fully ini... | python | def initialize_particle(rng, domain, fitness_function):
""" Initializes a particle within a domain.
Args:
rng: numpy.random.RandomState: The random number generator.
domain: cipy.problems.core.Domain: The domain of the problem.
Returns:
cipy.algorithms.pso.Particle: A new, fully ini... | [
"def",
"initialize_particle",
"(",
"rng",
",",
"domain",
",",
"fitness_function",
")",
":",
"position",
"=",
"rng",
".",
"uniform",
"(",
"domain",
".",
"lower",
",",
"domain",
".",
"upper",
",",
"domain",
".",
"dimension",
")",
"fitness",
"=",
"fitness_fun... | Initializes a particle within a domain.
Args:
rng: numpy.random.RandomState: The random number generator.
domain: cipy.problems.core.Domain: The domain of the problem.
Returns:
cipy.algorithms.pso.Particle: A new, fully initialized particle. | [
"Initializes",
"a",
"particle",
"within",
"a",
"domain",
".",
"Args",
":",
"rng",
":",
"numpy",
".",
"random",
".",
"RandomState",
":",
"The",
"random",
"number",
"generator",
".",
"domain",
":",
"cipy",
".",
"problems",
".",
"core",
".",
"Domain",
":",
... | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L123-L138 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | update_fitness | def update_fitness(objective_function, particle):
""" Calculates and updates the fitness and best_fitness of a particle.
Fitness is calculated using the 'problem.fitness' function.
Args:
problem: The optimization problem encapsulating the fitness function
and optimization type.
... | python | def update_fitness(objective_function, particle):
""" Calculates and updates the fitness and best_fitness of a particle.
Fitness is calculated using the 'problem.fitness' function.
Args:
problem: The optimization problem encapsulating the fitness function
and optimization type.
... | [
"def",
"update_fitness",
"(",
"objective_function",
",",
"particle",
")",
":",
"fitness",
"=",
"objective_function",
"(",
"particle",
".",
"position",
")",
"best_fitness",
"=",
"particle",
".",
"best_fitness",
"cmp",
"=",
"comparator",
"(",
"fitness",
")",
"if",... | Calculates and updates the fitness and best_fitness of a particle.
Fitness is calculated using the 'problem.fitness' function.
Args:
problem: The optimization problem encapsulating the fitness function
and optimization type.
particle: cipy.algorithms.pso.Particle: Particle to updat... | [
"Calculates",
"and",
"updates",
"the",
"fitness",
"and",
"best_fitness",
"of",
"a",
"particle",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L141-L165 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | update_particle | def update_particle(position_update, velocity_update, state, nbest_topology,
idx_particle):
""" Update function for a particle.
Calculates and updates the velocity and position of a particle for a
single iteration of the PSO algorithm. Social best particle is determined
by the state... | python | def update_particle(position_update, velocity_update, state, nbest_topology,
idx_particle):
""" Update function for a particle.
Calculates and updates the velocity and position of a particle for a
single iteration of the PSO algorithm. Social best particle is determined
by the state... | [
"def",
"update_particle",
"(",
"position_update",
",",
"velocity_update",
",",
"state",
",",
"nbest_topology",
",",
"idx_particle",
")",
":",
"(",
"idx",
",",
"particle",
")",
"=",
"idx_particle",
"nbest",
"=",
"state",
".",
"swarm",
"[",
"nbest_topology",
"["... | Update function for a particle.
Calculates and updates the velocity and position of a particle for a
single iteration of the PSO algorithm. Social best particle is determined
by the state.params['topology'] function.
Args:
state: cipy.algorithms.pso.State: The state of the PSO algorithm.
... | [
"Update",
"function",
"for",
"a",
"particle",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L168-L194 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | gbest_idx | def gbest_idx(swarm):
""" gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle.
"""
best = 0
cmp = comparator(swarm[best].best_fitness)
for (idx, particle) in enumerate(swarm):
if cmp(particle... | python | def gbest_idx(swarm):
""" gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle.
"""
best = 0
cmp = comparator(swarm[best].best_fitness)
for (idx, particle) in enumerate(swarm):
if cmp(particle... | [
"def",
"gbest_idx",
"(",
"swarm",
")",
":",
"best",
"=",
"0",
"cmp",
"=",
"comparator",
"(",
"swarm",
"[",
"best",
"]",
".",
"best_fitness",
")",
"for",
"(",
"idx",
",",
"particle",
")",
"in",
"enumerate",
"(",
"swarm",
")",
":",
"if",
"cmp",
"(",
... | gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle. | [
"gbest",
"Neighbourhood",
"topology",
"function",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L202-L216 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | lbest_idx | def lbest_idx(state, idx):
""" lbest Neighbourhood topology function.
Neighbourhood size is determined by state.params['n_s'].
Args:
state: cipy.algorithms.pso.State: The state of the PSO algorithm.
idx: int: index of the particle in the swarm.
Returns:
int: The index of the l... | python | def lbest_idx(state, idx):
""" lbest Neighbourhood topology function.
Neighbourhood size is determined by state.params['n_s'].
Args:
state: cipy.algorithms.pso.State: The state of the PSO algorithm.
idx: int: index of the particle in the swarm.
Returns:
int: The index of the l... | [
"def",
"lbest_idx",
"(",
"state",
",",
"idx",
")",
":",
"swarm",
"=",
"state",
".",
"swarm",
"n_s",
"=",
"state",
".",
"params",
"[",
"'n_s'",
"]",
"cmp",
"=",
"comparator",
"(",
"swarm",
"[",
"0",
"]",
".",
"best_fitness",
")",
"indices",
"=",
"__... | lbest Neighbourhood topology function.
Neighbourhood size is determined by state.params['n_s'].
Args:
state: cipy.algorithms.pso.State: The state of the PSO algorithm.
idx: int: index of the particle in the swarm.
Returns:
int: The index of the lbest particle. | [
"lbest",
"Neighbourhood",
"topology",
"function",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L223-L243 |
avanwyk/cipy | cipy/algorithms/pso/functions.py | solution | def solution(swarm):
""" Determines the global best particle in the swarm.
Args:
swarm: iterable: an iterable that yields all particles in the swarm.
Returns:
cipy.algorithms.pso.Particle: The best particle in the swarm when
comparing the best_fitness values of the particles.
"... | python | def solution(swarm):
""" Determines the global best particle in the swarm.
Args:
swarm: iterable: an iterable that yields all particles in the swarm.
Returns:
cipy.algorithms.pso.Particle: The best particle in the swarm when
comparing the best_fitness values of the particles.
"... | [
"def",
"solution",
"(",
"swarm",
")",
":",
"best",
"=",
"swarm",
"[",
"0",
"]",
"cmp",
"=",
"comparator",
"(",
"best",
".",
"best_fitness",
")",
"for",
"particle",
"in",
"swarm",
":",
"if",
"cmp",
"(",
"particle",
".",
"best_fitness",
",",
"best",
".... | Determines the global best particle in the swarm.
Args:
swarm: iterable: an iterable that yields all particles in the swarm.
Returns:
cipy.algorithms.pso.Particle: The best particle in the swarm when
comparing the best_fitness values of the particles. | [
"Determines",
"the",
"global",
"best",
"particle",
"in",
"the",
"swarm",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L288-L303 |
mikeboers/sitetools | sitetools/logging.py | _setup_maya | def _setup_maya():
"""Setup Maya logging, but be *really* defensive about it."""
# We are having trouble with this in Mark Media. For some reason this
# remains importable from a uifutures.host launched from Maya.
return
try:
import maya.utils
except ImportError:
return
# ... | python | def _setup_maya():
"""Setup Maya logging, but be *really* defensive about it."""
# We are having trouble with this in Mark Media. For some reason this
# remains importable from a uifutures.host launched from Maya.
return
try:
import maya.utils
except ImportError:
return
# ... | [
"def",
"_setup_maya",
"(",
")",
":",
"# We are having trouble with this in Mark Media. For some reason this",
"# remains importable from a uifutures.host launched from Maya.",
"return",
"try",
":",
"import",
"maya",
".",
"utils",
"except",
"ImportError",
":",
"return",
"# Remove ... | Setup Maya logging, but be *really* defensive about it. | [
"Setup",
"Maya",
"logging",
"but",
"be",
"*",
"really",
"*",
"defensive",
"about",
"it",
"."
] | train | https://github.com/mikeboers/sitetools/blob/1ec4eea6902b4a276f868a711b783dd965c123b7/sitetools/logging.py#L337-L359 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.