id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
43,700 | miyakogi/wdom | wdom/server/_tornado.py | WSHandler.on_close | def on_close(self) -> None:
"""Execute when connection closed."""
logger.info('WebSocket CLOSED')
if self in connections:
# Remove this connection from connection-list
connections.remove(self)
# close if auto_shutdown is enabled and there is no more connection
... | python | def on_close(self) -> None:
"""Execute when connection closed."""
logger.info('WebSocket CLOSED')
if self in connections:
# Remove this connection from connection-list
connections.remove(self)
# close if auto_shutdown is enabled and there is no more connection
... | [
"def",
"on_close",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'WebSocket CLOSED'",
")",
"if",
"self",
"in",
"connections",
":",
"# Remove this connection from connection-list",
"connections",
".",
"remove",
"(",
"self",
")",
"# close if auto... | Execute when connection closed. | [
"Execute",
"when",
"connection",
"closed",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L62-L70 |
43,701 | miyakogi/wdom | wdom/server/_tornado.py | Application.log_request | def log_request(self, handler: web.RequestHandler) -> None:
"""Handle access log."""
if 'log_function' in self.settings:
self.settings['log_function'](handler)
return
status = handler.get_status()
if status < 400:
log_method = logger.info
elif ... | python | def log_request(self, handler: web.RequestHandler) -> None:
"""Handle access log."""
if 'log_function' in self.settings:
self.settings['log_function'](handler)
return
status = handler.get_status()
if status < 400:
log_method = logger.info
elif ... | [
"def",
"log_request",
"(",
"self",
",",
"handler",
":",
"web",
".",
"RequestHandler",
")",
"->",
"None",
":",
"if",
"'log_function'",
"in",
"self",
".",
"settings",
":",
"self",
".",
"settings",
"[",
"'log_function'",
"]",
"(",
"handler",
")",
"return",
... | Handle access log. | [
"Handle",
"access",
"log",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L107-L124 |
43,702 | miyakogi/wdom | wdom/server/_tornado.py | Application.add_static_path | def add_static_path(self, prefix: str, path: str) -> None:
"""Add path to serve static files.
``prefix`` is used for url prefix to serve static files and ``path`` is
a path to the static file directory. ``prefix = '/_static'`` is
reserved for the server, so do not use it for your app.
... | python | def add_static_path(self, prefix: str, path: str) -> None:
"""Add path to serve static files.
``prefix`` is used for url prefix to serve static files and ``path`` is
a path to the static file directory. ``prefix = '/_static'`` is
reserved for the server, so do not use it for your app.
... | [
"def",
"add_static_path",
"(",
"self",
",",
"prefix",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"None",
":",
"pattern",
"=",
"prefix",
"if",
"not",
"pattern",
".",
"startswith",
"(",
"'/'",
")",
":",
"pattern",
"=",
"'/'",
"+",
"pattern",
"if",... | Add path to serve static files.
``prefix`` is used for url prefix to serve static files and ``path`` is
a path to the static file directory. ``prefix = '/_static'`` is
reserved for the server, so do not use it for your app. | [
"Add",
"path",
"to",
"serve",
"static",
"files",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L126-L141 |
43,703 | miyakogi/wdom | wdom/server/_tornado.py | Application.add_favicon_path | def add_favicon_path(self, path: str) -> None:
"""Add path to serve favicon file.
``path`` should be a directory, which contains favicon file
(``favicon.ico``) for your app.
"""
spec = web.URLSpec(
'/(favicon.ico)',
StaticFileHandler,
dict(pat... | python | def add_favicon_path(self, path: str) -> None:
"""Add path to serve favicon file.
``path`` should be a directory, which contains favicon file
(``favicon.ico``) for your app.
"""
spec = web.URLSpec(
'/(favicon.ico)',
StaticFileHandler,
dict(pat... | [
"def",
"add_favicon_path",
"(",
"self",
",",
"path",
":",
"str",
")",
"->",
"None",
":",
"spec",
"=",
"web",
".",
"URLSpec",
"(",
"'/(favicon.ico)'",
",",
"StaticFileHandler",
",",
"dict",
"(",
"path",
"=",
"path",
")",
")",
"# Need some check",
"handlers"... | Add path to serve favicon file.
``path`` should be a directory, which contains favicon file
(``favicon.ico``) for your app. | [
"Add",
"path",
"to",
"serve",
"favicon",
"file",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L143-L156 |
43,704 | yeasy/hyperledger-py | hyperledger/api/chaincode.py | ChainCodeApiMixin._exec_action | def _exec_action(self,
method,
type,
chaincodeID,
function,
args,
id,
secure_context=None,
confidentiality_level=CHAINCODE_CONFIDENTIAL_PUB,
... | python | def _exec_action(self,
method,
type,
chaincodeID,
function,
args,
id,
secure_context=None,
confidentiality_level=CHAINCODE_CONFIDENTIAL_PUB,
... | [
"def",
"_exec_action",
"(",
"self",
",",
"method",
",",
"type",
",",
"chaincodeID",
",",
"function",
",",
"args",
",",
"id",
",",
"secure_context",
"=",
"None",
",",
"confidentiality_level",
"=",
"CHAINCODE_CONFIDENTIAL_PUB",
",",
"metadata",
"=",
"None",
")",... | Private method to implement the deploy, invoke and query actions
Following http://www.jsonrpc.org/specification.
:param method: Chaincode action to exec. MUST within
DEFAULT_CHAINCODE_METHODS.
:param type: chaincode language type: 1 for golang, 2 for node.
:param chaincodeID: M... | [
"Private",
"method",
"to",
"implement",
"the",
"deploy",
"invoke",
"and",
"query",
"actions"
] | f24e9cc409b50628b911950466786be6fe74f09f | https://github.com/yeasy/hyperledger-py/blob/f24e9cc409b50628b911950466786be6fe74f09f/hyperledger/api/chaincode.py#L26-L72 |
43,705 | miyakogi/wdom | wdom/server/base.py | watch_dir | def watch_dir(path: str) -> None:
"""Add ``path`` to watch for autoreload."""
_compile_exclude_patterns()
if config.autoreload or config.debug:
# Add files to watch for autoreload
p = pathlib.Path(path)
p.resolve()
_add_watch_path(p) | python | def watch_dir(path: str) -> None:
"""Add ``path`` to watch for autoreload."""
_compile_exclude_patterns()
if config.autoreload or config.debug:
# Add files to watch for autoreload
p = pathlib.Path(path)
p.resolve()
_add_watch_path(p) | [
"def",
"watch_dir",
"(",
"path",
":",
"str",
")",
"->",
"None",
":",
"_compile_exclude_patterns",
"(",
")",
"if",
"config",
".",
"autoreload",
"or",
"config",
".",
"debug",
":",
"# Add files to watch for autoreload",
"p",
"=",
"pathlib",
".",
"Path",
"(",
"p... | Add ``path`` to watch for autoreload. | [
"Add",
"path",
"to",
"watch",
"for",
"autoreload",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/base.py#L54-L61 |
43,706 | miyakogi/wdom | wdom/server/base.py | open_browser | def open_browser(url: str, browser: str = None) -> None:
"""Open web browser."""
if '--open-browser' in sys.argv:
# Remove open browser to prevent making new tab on autoreload
sys.argv.remove('--open-browser')
if browser is None:
browser = config.browser
if browser in _browsers:
... | python | def open_browser(url: str, browser: str = None) -> None:
"""Open web browser."""
if '--open-browser' in sys.argv:
# Remove open browser to prevent making new tab on autoreload
sys.argv.remove('--open-browser')
if browser is None:
browser = config.browser
if browser in _browsers:
... | [
"def",
"open_browser",
"(",
"url",
":",
"str",
",",
"browser",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"if",
"'--open-browser'",
"in",
"sys",
".",
"argv",
":",
"# Remove open browser to prevent making new tab on autoreload",
"sys",
".",
"argv",
".",
"... | Open web browser. | [
"Open",
"web",
"browser",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/base.py#L64-L74 |
43,707 | miyakogi/wdom | wdom/css.py | parse_style_decl | def parse_style_decl(style: str, owner: AbstractNode = None
) -> CSSStyleDeclaration:
"""Make CSSStyleDeclaration from style string.
:arg AbstractNode owner: Owner of the style.
"""
_style = CSSStyleDeclaration(style, owner=owner)
return _style | python | def parse_style_decl(style: str, owner: AbstractNode = None
) -> CSSStyleDeclaration:
"""Make CSSStyleDeclaration from style string.
:arg AbstractNode owner: Owner of the style.
"""
_style = CSSStyleDeclaration(style, owner=owner)
return _style | [
"def",
"parse_style_decl",
"(",
"style",
":",
"str",
",",
"owner",
":",
"AbstractNode",
"=",
"None",
")",
"->",
"CSSStyleDeclaration",
":",
"_style",
"=",
"CSSStyleDeclaration",
"(",
"style",
",",
"owner",
"=",
"owner",
")",
"return",
"_style"
] | Make CSSStyleDeclaration from style string.
:arg AbstractNode owner: Owner of the style. | [
"Make",
"CSSStyleDeclaration",
"from",
"style",
"string",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L155-L162 |
43,708 | miyakogi/wdom | wdom/css.py | parse_style_rules | def parse_style_rules(styles: str) -> CSSRuleList:
"""Make CSSRuleList object from style string."""
rules = CSSRuleList()
for m in _style_rule_re.finditer(styles):
rules.append(CSSStyleRule(m.group(1), parse_style_decl(m.group(2))))
return rules | python | def parse_style_rules(styles: str) -> CSSRuleList:
"""Make CSSRuleList object from style string."""
rules = CSSRuleList()
for m in _style_rule_re.finditer(styles):
rules.append(CSSStyleRule(m.group(1), parse_style_decl(m.group(2))))
return rules | [
"def",
"parse_style_rules",
"(",
"styles",
":",
"str",
")",
"->",
"CSSRuleList",
":",
"rules",
"=",
"CSSRuleList",
"(",
")",
"for",
"m",
"in",
"_style_rule_re",
".",
"finditer",
"(",
"styles",
")",
":",
"rules",
".",
"append",
"(",
"CSSStyleRule",
"(",
"... | Make CSSRuleList object from style string. | [
"Make",
"CSSRuleList",
"object",
"from",
"style",
"string",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L208-L213 |
43,709 | miyakogi/wdom | wdom/css.py | CSSStyleDeclaration.cssText | def cssText(self) -> str:
"""String-representation."""
text = '; '.join('{0}: {1}'.format(k, v) for k, v in self.items())
if text:
text += ';'
return text | python | def cssText(self) -> str:
"""String-representation."""
text = '; '.join('{0}: {1}'.format(k, v) for k, v in self.items())
if text:
text += ';'
return text | [
"def",
"cssText",
"(",
"self",
")",
"->",
"str",
":",
"text",
"=",
"'; '",
".",
"join",
"(",
"'{0}: {1}'",
".",
"format",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
")",
"if",
"text",
":",
"text",
"+=... | String-representation. | [
"String",
"-",
"representation",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L82-L87 |
43,710 | miyakogi/wdom | wdom/css.py | CSSStyleDeclaration.removeProperty | def removeProperty(self, prop: str) -> str:
"""Remove the css property."""
removed_prop = self.get(prop)
# removed_prop may be False or '', so need to check it is None
if removed_prop is not None:
del self[prop]
return removed_prop | python | def removeProperty(self, prop: str) -> str:
"""Remove the css property."""
removed_prop = self.get(prop)
# removed_prop may be False or '', so need to check it is None
if removed_prop is not None:
del self[prop]
return removed_prop | [
"def",
"removeProperty",
"(",
"self",
",",
"prop",
":",
"str",
")",
"->",
"str",
":",
"removed_prop",
"=",
"self",
".",
"get",
"(",
"prop",
")",
"# removed_prop may be False or '', so need to check it is None",
"if",
"removed_prop",
"is",
"not",
"None",
":",
"de... | Remove the css property. | [
"Remove",
"the",
"css",
"property",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L110-L116 |
43,711 | miyakogi/wdom | wdom/css.py | CSSStyleDeclaration.setProperty | def setProperty(self, prop: str, value: str, priority: str = None
) -> None:
"""Set property as the value.
The third argument ``priority`` is not implemented yet.
"""
self[prop] = value | python | def setProperty(self, prop: str, value: str, priority: str = None
) -> None:
"""Set property as the value.
The third argument ``priority`` is not implemented yet.
"""
self[prop] = value | [
"def",
"setProperty",
"(",
"self",
",",
"prop",
":",
"str",
",",
"value",
":",
"str",
",",
"priority",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"self",
"[",
"prop",
"]",
"=",
"value"
] | Set property as the value.
The third argument ``priority`` is not implemented yet. | [
"Set",
"property",
"as",
"the",
"value",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L118-L124 |
43,712 | miyakogi/wdom | wdom/css.py | CSSStyleRule.cssText | def cssText(self) -> str:
"""Return string representation of this rule."""
_style = self.style.cssText
if _style:
return '{0} {{{1}}}'.format(self.selectorText, _style)
return '' | python | def cssText(self) -> str:
"""Return string representation of this rule."""
_style = self.style.cssText
if _style:
return '{0} {{{1}}}'.format(self.selectorText, _style)
return '' | [
"def",
"cssText",
"(",
"self",
")",
"->",
"str",
":",
"_style",
"=",
"self",
".",
"style",
".",
"cssText",
"if",
"_style",
":",
"return",
"'{0} {{{1}}}'",
".",
"format",
"(",
"self",
".",
"selectorText",
",",
"_style",
")",
"return",
"''"
] | Return string representation of this rule. | [
"Return",
"string",
"representation",
"of",
"this",
"rule",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L178-L183 |
43,713 | miyakogi/wdom | wdom/options.py | set_loglevel | def set_loglevel(level: Union[int, str, None] = None) -> None:
"""Set proper log-level.
:arg Optional[int, str] level: Level to be set. If None, use proper log
level from command line option. Default value is ``logging.INFO``.
"""
if level is not None:
lv = level_to_int(level)
elif conf... | python | def set_loglevel(level: Union[int, str, None] = None) -> None:
"""Set proper log-level.
:arg Optional[int, str] level: Level to be set. If None, use proper log
level from command line option. Default value is ``logging.INFO``.
"""
if level is not None:
lv = level_to_int(level)
elif conf... | [
"def",
"set_loglevel",
"(",
"level",
":",
"Union",
"[",
"int",
",",
"str",
",",
"None",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"level",
"is",
"not",
"None",
":",
"lv",
"=",
"level_to_int",
"(",
"level",
")",
"elif",
"config",
".",
"logging... | Set proper log-level.
:arg Optional[int, str] level: Level to be set. If None, use proper log
level from command line option. Default value is ``logging.INFO``. | [
"Set",
"proper",
"log",
"-",
"level",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/options.py#L115-L130 |
43,714 | miyakogi/wdom | wdom/options.py | parse_command_line | def parse_command_line() -> Namespace:
"""Parse command line options and set them to ``config``.
This function skips unknown command line options. After parsing options,
set log level and set options in ``tornado.options``.
"""
import tornado.options
parser.parse_known_args(namespace=config)
... | python | def parse_command_line() -> Namespace:
"""Parse command line options and set them to ``config``.
This function skips unknown command line options. After parsing options,
set log level and set options in ``tornado.options``.
"""
import tornado.options
parser.parse_known_args(namespace=config)
... | [
"def",
"parse_command_line",
"(",
")",
"->",
"Namespace",
":",
"import",
"tornado",
".",
"options",
"parser",
".",
"parse_known_args",
"(",
"namespace",
"=",
"config",
")",
"set_loglevel",
"(",
")",
"# set new log level based on commanline option",
"for",
"k",
",",
... | Parse command line options and set them to ``config``.
This function skips unknown command line options. After parsing options,
set log level and set options in ``tornado.options``. | [
"Parse",
"command",
"line",
"options",
"and",
"set",
"them",
"to",
"config",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/options.py#L133-L145 |
43,715 | miyakogi/wdom | wdom/util.py | suppress_logging | def suppress_logging() -> None:
"""Suppress log output to stdout.
This function is intended to be used in test's setup. This function removes
log handler of ``wdom`` logger and set NullHandler to suppress log.
"""
from wdom import options
options.root_logger.removeHandler(options._log_handler)
... | python | def suppress_logging() -> None:
"""Suppress log output to stdout.
This function is intended to be used in test's setup. This function removes
log handler of ``wdom`` logger and set NullHandler to suppress log.
"""
from wdom import options
options.root_logger.removeHandler(options._log_handler)
... | [
"def",
"suppress_logging",
"(",
")",
"->",
"None",
":",
"from",
"wdom",
"import",
"options",
"options",
".",
"root_logger",
".",
"removeHandler",
"(",
"options",
".",
"_log_handler",
")",
"options",
".",
"root_logger",
".",
"addHandler",
"(",
"logging",
".",
... | Suppress log output to stdout.
This function is intended to be used in test's setup. This function removes
log handler of ``wdom`` logger and set NullHandler to suppress log. | [
"Suppress",
"log",
"output",
"to",
"stdout",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/util.py#L41-L49 |
43,716 | miyakogi/wdom | wdom/util.py | reset | def reset() -> None:
"""Reset all wdom objects.
This function clear all connections, elements, and resistered custom
elements. This function also makes new document/application and set them.
"""
from wdom.document import get_new_document, set_document
from wdom.element import Element
from w... | python | def reset() -> None:
"""Reset all wdom objects.
This function clear all connections, elements, and resistered custom
elements. This function also makes new document/application and set them.
"""
from wdom.document import get_new_document, set_document
from wdom.element import Element
from w... | [
"def",
"reset",
"(",
")",
"->",
"None",
":",
"from",
"wdom",
".",
"document",
"import",
"get_new_document",
",",
"set_document",
"from",
"wdom",
".",
"element",
"import",
"Element",
"from",
"wdom",
".",
"server",
"import",
"_tornado",
"from",
"wdom",
".",
... | Reset all wdom objects.
This function clear all connections, elements, and resistered custom
elements. This function also makes new document/application and set them. | [
"Reset",
"all",
"wdom",
"objects",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/util.py#L52-L68 |
43,717 | yeasy/hyperledger-py | hyperledger/ssladapter/ssl_match_hostname.py | _dnsname_match | def _dnsname_match(dn, hostname, max_wildcards=1):
"""Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3
"""
pats = []
if not dn:
return False
split_dn = dn.split(r'.')
leftmost, remainder = split_dn[0], split_dn[1:]
wildcards = left... | python | def _dnsname_match(dn, hostname, max_wildcards=1):
"""Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3
"""
pats = []
if not dn:
return False
split_dn = dn.split(r'.')
leftmost, remainder = split_dn[0], split_dn[1:]
wildcards = left... | [
"def",
"_dnsname_match",
"(",
"dn",
",",
"hostname",
",",
"max_wildcards",
"=",
"1",
")",
":",
"pats",
"=",
"[",
"]",
"if",
"not",
"dn",
":",
"return",
"False",
"split_dn",
"=",
"dn",
".",
"split",
"(",
"r'.'",
")",
"leftmost",
",",
"remainder",
"=",... | Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3 | [
"Matching",
"according",
"to",
"RFC",
"6125",
"section",
"6",
".",
"4",
".",
"3"
] | f24e9cc409b50628b911950466786be6fe74f09f | https://github.com/yeasy/hyperledger-py/blob/f24e9cc409b50628b911950466786be6fe74f09f/hyperledger/ssladapter/ssl_match_hostname.py#L28-L75 |
43,718 | miyakogi/wdom | wdom/node.py | _ensure_node | def _ensure_node(node: Union[str, AbstractNode]) -> AbstractNode:
"""Ensure to be node.
If ``node`` is string, convert it to ``Text`` node.
"""
if isinstance(node, str):
return Text(node)
elif isinstance(node, Node):
return node
else:
raise TypeError('Invalid type to app... | python | def _ensure_node(node: Union[str, AbstractNode]) -> AbstractNode:
"""Ensure to be node.
If ``node`` is string, convert it to ``Text`` node.
"""
if isinstance(node, str):
return Text(node)
elif isinstance(node, Node):
return node
else:
raise TypeError('Invalid type to app... | [
"def",
"_ensure_node",
"(",
"node",
":",
"Union",
"[",
"str",
",",
"AbstractNode",
"]",
")",
"->",
"AbstractNode",
":",
"if",
"isinstance",
"(",
"node",
",",
"str",
")",
":",
"return",
"Text",
"(",
"node",
")",
"elif",
"isinstance",
"(",
"node",
",",
... | Ensure to be node.
If ``node`` is string, convert it to ``Text`` node. | [
"Ensure",
"to",
"be",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L373-L383 |
43,719 | miyakogi/wdom | wdom/node.py | Node.previousSibling | def previousSibling(self) -> Optional[AbstractNode]:
"""Return the previous sibling of this node.
If there is no previous sibling, return ``None``.
"""
parent = self.parentNode
if parent is None:
return None
return parent.childNodes.item(parent.childNodes.ind... | python | def previousSibling(self) -> Optional[AbstractNode]:
"""Return the previous sibling of this node.
If there is no previous sibling, return ``None``.
"""
parent = self.parentNode
if parent is None:
return None
return parent.childNodes.item(parent.childNodes.ind... | [
"def",
"previousSibling",
"(",
"self",
")",
"->",
"Optional",
"[",
"AbstractNode",
"]",
":",
"parent",
"=",
"self",
".",
"parentNode",
"if",
"parent",
"is",
"None",
":",
"return",
"None",
"return",
"parent",
".",
"childNodes",
".",
"item",
"(",
"parent",
... | Return the previous sibling of this node.
If there is no previous sibling, return ``None``. | [
"Return",
"the",
"previous",
"sibling",
"of",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L117-L125 |
43,720 | miyakogi/wdom | wdom/node.py | Node.ownerDocument | def ownerDocument(self) -> Optional[AbstractNode]:
"""Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: ... | python | def ownerDocument(self) -> Optional[AbstractNode]:
"""Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: ... | [
"def",
"ownerDocument",
"(",
"self",
")",
"->",
"Optional",
"[",
"AbstractNode",
"]",
":",
"if",
"self",
".",
"nodeType",
"==",
"Node",
".",
"DOCUMENT_NODE",
":",
"return",
"self",
"elif",
"self",
".",
"parentNode",
":",
"return",
"self",
".",
"parentNode"... | Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: Document or None | [
"Return",
"the",
"owner",
"document",
"of",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L140-L153 |
43,721 | miyakogi/wdom | wdom/node.py | Node.index | def index(self, node: AbstractNode) -> int:
"""Return index of the node.
If the node is not a child of this node, raise ``ValueError``.
"""
if node in self.childNodes:
return self.childNodes.index(node)
elif isinstance(node, Text):
for i, n in enumerate(s... | python | def index(self, node: AbstractNode) -> int:
"""Return index of the node.
If the node is not a child of this node, raise ``ValueError``.
"""
if node in self.childNodes:
return self.childNodes.index(node)
elif isinstance(node, Text):
for i, n in enumerate(s... | [
"def",
"index",
"(",
"self",
",",
"node",
":",
"AbstractNode",
")",
"->",
"int",
":",
"if",
"node",
"in",
"self",
".",
"childNodes",
":",
"return",
"self",
".",
"childNodes",
".",
"index",
"(",
"node",
")",
"elif",
"isinstance",
"(",
"node",
",",
"Te... | Return index of the node.
If the node is not a child of this node, raise ``ValueError``. | [
"Return",
"index",
"of",
"the",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L182-L194 |
43,722 | miyakogi/wdom | wdom/node.py | Node.insertBefore | def insertBefore(self, node: AbstractNode,
ref_node: AbstractNode) -> AbstractNode:
"""Insert a node just before the reference node."""
return self._insert_before(node, ref_node) | python | def insertBefore(self, node: AbstractNode,
ref_node: AbstractNode) -> AbstractNode:
"""Insert a node just before the reference node."""
return self._insert_before(node, ref_node) | [
"def",
"insertBefore",
"(",
"self",
",",
"node",
":",
"AbstractNode",
",",
"ref_node",
":",
"AbstractNode",
")",
"->",
"AbstractNode",
":",
"return",
"self",
".",
"_insert_before",
"(",
"node",
",",
"ref_node",
")"
] | Insert a node just before the reference node. | [
"Insert",
"a",
"node",
"just",
"before",
"the",
"reference",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L222-L225 |
43,723 | miyakogi/wdom | wdom/node.py | Node.replaceChild | def replaceChild(self, new_child: AbstractNode,
old_child: AbstractNode) -> AbstractNode:
"""Replace an old child with new child."""
return self._replace_child(new_child, old_child) | python | def replaceChild(self, new_child: AbstractNode,
old_child: AbstractNode) -> AbstractNode:
"""Replace an old child with new child."""
return self._replace_child(new_child, old_child) | [
"def",
"replaceChild",
"(",
"self",
",",
"new_child",
":",
"AbstractNode",
",",
"old_child",
":",
"AbstractNode",
")",
"->",
"AbstractNode",
":",
"return",
"self",
".",
"_replace_child",
"(",
"new_child",
",",
"old_child",
")"
] | Replace an old child with new child. | [
"Replace",
"an",
"old",
"child",
"with",
"new",
"child",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L250-L253 |
43,724 | miyakogi/wdom | wdom/node.py | Node.cloneNode | def cloneNode(self, deep: bool=False) -> AbstractNode:
"""Return new copy of this node.
If optional argument ``deep`` is specified and is True, new node has
clones of child nodes of this node (if presents).
"""
if deep:
return self._clone_node_deep()
return s... | python | def cloneNode(self, deep: bool=False) -> AbstractNode:
"""Return new copy of this node.
If optional argument ``deep`` is specified and is True, new node has
clones of child nodes of this node (if presents).
"""
if deep:
return self._clone_node_deep()
return s... | [
"def",
"cloneNode",
"(",
"self",
",",
"deep",
":",
"bool",
"=",
"False",
")",
"->",
"AbstractNode",
":",
"if",
"deep",
":",
"return",
"self",
".",
"_clone_node_deep",
"(",
")",
"return",
"self",
".",
"_clone_node",
"(",
")"
] | Return new copy of this node.
If optional argument ``deep`` is specified and is True, new node has
clones of child nodes of this node (if presents). | [
"Return",
"new",
"copy",
"of",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L269-L277 |
43,725 | miyakogi/wdom | wdom/node.py | NodeList.item | def item(self, index: int) -> Optional[Node]:
"""Return item with the index.
If the index is negative number or out of the list, return None.
"""
if not isinstance(index, int):
raise TypeError(
'Indeces must be integer, not {}'.format(type(index)))
re... | python | def item(self, index: int) -> Optional[Node]:
"""Return item with the index.
If the index is negative number or out of the list, return None.
"""
if not isinstance(index, int):
raise TypeError(
'Indeces must be integer, not {}'.format(type(index)))
re... | [
"def",
"item",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"Optional",
"[",
"Node",
"]",
":",
"if",
"not",
"isinstance",
"(",
"index",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'Indeces must be integer, not {}'",
".",
"format",
"(",
"type",... | Return item with the index.
If the index is negative number or out of the list, return None. | [
"Return",
"item",
"with",
"the",
"index",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L344-L352 |
43,726 | miyakogi/wdom | wdom/node.py | ParentNode.children | def children(self) -> NodeList:
"""Return list of child nodes.
Currently this is not a live object.
"""
return NodeList([e for e in self.childNodes
if e.nodeType == Node.ELEMENT_NODE]) | python | def children(self) -> NodeList:
"""Return list of child nodes.
Currently this is not a live object.
"""
return NodeList([e for e in self.childNodes
if e.nodeType == Node.ELEMENT_NODE]) | [
"def",
"children",
"(",
"self",
")",
"->",
"NodeList",
":",
"return",
"NodeList",
"(",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"childNodes",
"if",
"e",
".",
"nodeType",
"==",
"Node",
".",
"ELEMENT_NODE",
"]",
")"
] | Return list of child nodes.
Currently this is not a live object. | [
"Return",
"list",
"of",
"child",
"nodes",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L402-L408 |
43,727 | miyakogi/wdom | wdom/node.py | ParentNode.firstElementChild | def firstElementChild(self) -> Optional[AbstractNode]:
"""First Element child node.
If this node has no element child, return None.
"""
for child in self.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
return child
return None | python | def firstElementChild(self) -> Optional[AbstractNode]:
"""First Element child node.
If this node has no element child, return None.
"""
for child in self.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
return child
return None | [
"def",
"firstElementChild",
"(",
"self",
")",
"->",
"Optional",
"[",
"AbstractNode",
"]",
":",
"for",
"child",
"in",
"self",
".",
"childNodes",
":",
"if",
"child",
".",
"nodeType",
"==",
"Node",
".",
"ELEMENT_NODE",
":",
"return",
"child",
"return",
"None"... | First Element child node.
If this node has no element child, return None. | [
"First",
"Element",
"child",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L411-L419 |
43,728 | miyakogi/wdom | wdom/node.py | ParentNode.lastElementChild | def lastElementChild(self) -> Optional[AbstractNode]:
"""Last Element child node.
If this node has no element child, return None.
"""
for child in reversed(self.childNodes): # type: ignore
if child.nodeType == Node.ELEMENT_NODE:
return child
return N... | python | def lastElementChild(self) -> Optional[AbstractNode]:
"""Last Element child node.
If this node has no element child, return None.
"""
for child in reversed(self.childNodes): # type: ignore
if child.nodeType == Node.ELEMENT_NODE:
return child
return N... | [
"def",
"lastElementChild",
"(",
"self",
")",
"->",
"Optional",
"[",
"AbstractNode",
"]",
":",
"for",
"child",
"in",
"reversed",
"(",
"self",
".",
"childNodes",
")",
":",
"# type: ignore",
"if",
"child",
".",
"nodeType",
"==",
"Node",
".",
"ELEMENT_NODE",
"... | Last Element child node.
If this node has no element child, return None. | [
"Last",
"Element",
"child",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L422-L430 |
43,729 | miyakogi/wdom | wdom/node.py | ParentNode.prepend | def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
"""Insert new nodes before first child node."""
node = _to_node_list(nodes)
if self.firstChild:
self.insertBefore(node, self.firstChild)
else:
self.appendChild(node) | python | def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
"""Insert new nodes before first child node."""
node = _to_node_list(nodes)
if self.firstChild:
self.insertBefore(node, self.firstChild)
else:
self.appendChild(node) | [
"def",
"prepend",
"(",
"self",
",",
"*",
"nodes",
":",
"Union",
"[",
"str",
",",
"AbstractNode",
"]",
")",
"->",
"None",
":",
"node",
"=",
"_to_node_list",
"(",
"nodes",
")",
"if",
"self",
".",
"firstChild",
":",
"self",
".",
"insertBefore",
"(",
"no... | Insert new nodes before first child node. | [
"Insert",
"new",
"nodes",
"before",
"first",
"child",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L432-L438 |
43,730 | miyakogi/wdom | wdom/node.py | ParentNode.append | def append(self, *nodes: Union[AbstractNode, str]) -> None:
"""Append new nodes after last child node."""
node = _to_node_list(nodes)
self.appendChild(node) | python | def append(self, *nodes: Union[AbstractNode, str]) -> None:
"""Append new nodes after last child node."""
node = _to_node_list(nodes)
self.appendChild(node) | [
"def",
"append",
"(",
"self",
",",
"*",
"nodes",
":",
"Union",
"[",
"AbstractNode",
",",
"str",
"]",
")",
"->",
"None",
":",
"node",
"=",
"_to_node_list",
"(",
"nodes",
")",
"self",
".",
"appendChild",
"(",
"node",
")"
] | Append new nodes after last child node. | [
"Append",
"new",
"nodes",
"after",
"last",
"child",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L440-L443 |
43,731 | miyakogi/wdom | wdom/node.py | NonDocumentTypeChildNode.nextElementSibling | def nextElementSibling(self) -> Optional[AbstractNode]:
"""Next Element Node.
If this node has no next element node, return None.
"""
if self.parentNode is None:
return None
siblings = self.parentNode.childNodes
for i in range(siblings.index(self) + 1, len(si... | python | def nextElementSibling(self) -> Optional[AbstractNode]:
"""Next Element Node.
If this node has no next element node, return None.
"""
if self.parentNode is None:
return None
siblings = self.parentNode.childNodes
for i in range(siblings.index(self) + 1, len(si... | [
"def",
"nextElementSibling",
"(",
"self",
")",
"->",
"Optional",
"[",
"AbstractNode",
"]",
":",
"if",
"self",
".",
"parentNode",
"is",
"None",
":",
"return",
"None",
"siblings",
"=",
"self",
".",
"parentNode",
".",
"childNodes",
"for",
"i",
"in",
"range",
... | Next Element Node.
If this node has no next element node, return None. | [
"Next",
"Element",
"Node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L465-L477 |
43,732 | miyakogi/wdom | wdom/node.py | ChildNode.before | def before(self, *nodes: Union[AbstractNode, str]) -> None:
"""Insert nodes before this node.
If nodes contains ``str``, it will be converted to Text node.
"""
if self.parentNode:
node = _to_node_list(nodes)
self.parentNode.insertBefore(node, self) | python | def before(self, *nodes: Union[AbstractNode, str]) -> None:
"""Insert nodes before this node.
If nodes contains ``str``, it will be converted to Text node.
"""
if self.parentNode:
node = _to_node_list(nodes)
self.parentNode.insertBefore(node, self) | [
"def",
"before",
"(",
"self",
",",
"*",
"nodes",
":",
"Union",
"[",
"AbstractNode",
",",
"str",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"parentNode",
":",
"node",
"=",
"_to_node_list",
"(",
"nodes",
")",
"self",
".",
"parentNode",
".",
"inser... | Insert nodes before this node.
If nodes contains ``str``, it will be converted to Text node. | [
"Insert",
"nodes",
"before",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L487-L494 |
43,733 | miyakogi/wdom | wdom/node.py | ChildNode.after | def after(self, *nodes: Union[AbstractNode, str]) -> None:
"""Append nodes after this node.
If nodes contains ``str``, it will be converted to Text node.
"""
if self.parentNode:
node = _to_node_list(nodes)
_next_node = self.nextSibling
if _next_node i... | python | def after(self, *nodes: Union[AbstractNode, str]) -> None:
"""Append nodes after this node.
If nodes contains ``str``, it will be converted to Text node.
"""
if self.parentNode:
node = _to_node_list(nodes)
_next_node = self.nextSibling
if _next_node i... | [
"def",
"after",
"(",
"self",
",",
"*",
"nodes",
":",
"Union",
"[",
"AbstractNode",
",",
"str",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"parentNode",
":",
"node",
"=",
"_to_node_list",
"(",
"nodes",
")",
"_next_node",
"=",
"self",
".",
"nextSi... | Append nodes after this node.
If nodes contains ``str``, it will be converted to Text node. | [
"Append",
"nodes",
"after",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L496-L507 |
43,734 | miyakogi/wdom | wdom/node.py | ChildNode.replaceWith | def replaceWith(self, *nodes: Union[AbstractNode, str]) -> None:
"""Replace this node with nodes.
If nodes contains ``str``, it will be converted to Text node.
"""
if self.parentNode:
node = _to_node_list(nodes)
self.parentNode.replaceChild(node, self) | python | def replaceWith(self, *nodes: Union[AbstractNode, str]) -> None:
"""Replace this node with nodes.
If nodes contains ``str``, it will be converted to Text node.
"""
if self.parentNode:
node = _to_node_list(nodes)
self.parentNode.replaceChild(node, self) | [
"def",
"replaceWith",
"(",
"self",
",",
"*",
"nodes",
":",
"Union",
"[",
"AbstractNode",
",",
"str",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"parentNode",
":",
"node",
"=",
"_to_node_list",
"(",
"nodes",
")",
"self",
".",
"parentNode",
".",
"... | Replace this node with nodes.
If nodes contains ``str``, it will be converted to Text node. | [
"Replace",
"this",
"node",
"with",
"nodes",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L509-L516 |
43,735 | miyakogi/wdom | wdom/node.py | CharacterData.insertData | def insertData(self, offset: int, string: str) -> None:
"""Insert ``string`` at offset on this node."""
self._insert_data(offset, string) | python | def insertData(self, offset: int, string: str) -> None:
"""Insert ``string`` at offset on this node."""
self._insert_data(offset, string) | [
"def",
"insertData",
"(",
"self",
",",
"offset",
":",
"int",
",",
"string",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_insert_data",
"(",
"offset",
",",
"string",
")"
] | Insert ``string`` at offset on this node. | [
"Insert",
"string",
"at",
"offset",
"on",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L575-L577 |
43,736 | miyakogi/wdom | wdom/node.py | CharacterData.deleteData | def deleteData(self, offset: int, count: int) -> None:
"""Delete data by offset to count letters."""
self._delete_data(offset, count) | python | def deleteData(self, offset: int, count: int) -> None:
"""Delete data by offset to count letters."""
self._delete_data(offset, count) | [
"def",
"deleteData",
"(",
"self",
",",
"offset",
":",
"int",
",",
"count",
":",
"int",
")",
"->",
"None",
":",
"self",
".",
"_delete_data",
"(",
"offset",
",",
"count",
")"
] | Delete data by offset to count letters. | [
"Delete",
"data",
"by",
"offset",
"to",
"count",
"letters",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L582-L584 |
43,737 | miyakogi/wdom | wdom/node.py | CharacterData.replaceData | def replaceData(self, offset: int, count: int, string: str) -> None:
"""Replace data from offset to count by string."""
self._replace_data(offset, count, string) | python | def replaceData(self, offset: int, count: int, string: str) -> None:
"""Replace data from offset to count by string."""
self._replace_data(offset, count, string) | [
"def",
"replaceData",
"(",
"self",
",",
"offset",
":",
"int",
",",
"count",
":",
"int",
",",
"string",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_replace_data",
"(",
"offset",
",",
"count",
",",
"string",
")"
] | Replace data from offset to count by string. | [
"Replace",
"data",
"from",
"offset",
"to",
"count",
"by",
"string",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L590-L592 |
43,738 | miyakogi/wdom | wdom/node.py | Text.html | def html(self) -> str:
"""Return html-escaped string representation of this node."""
if self.parentNode and self.parentNode._should_escape_text:
return html.escape(self.data)
return self.data | python | def html(self) -> str:
"""Return html-escaped string representation of this node."""
if self.parentNode and self.parentNode._should_escape_text:
return html.escape(self.data)
return self.data | [
"def",
"html",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"parentNode",
"and",
"self",
".",
"parentNode",
".",
"_should_escape_text",
":",
"return",
"html",
".",
"escape",
"(",
"self",
".",
"data",
")",
"return",
"self",
".",
"data"
] | Return html-escaped string representation of this node. | [
"Return",
"html",
"-",
"escaped",
"string",
"representation",
"of",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L635-L639 |
43,739 | miyakogi/wdom | wdom/event.py | create_event | def create_event(msg: EventMsgDict) -> Event:
"""Create Event from JSOM msg and set target nodes.
:arg EventTarget currentTarget: Current event target node.
:arg EventTarget target: Node which emitted this event first.
:arg dict init: Event options.
"""
proto = msg.get('proto', '')
cls = pr... | python | def create_event(msg: EventMsgDict) -> Event:
"""Create Event from JSOM msg and set target nodes.
:arg EventTarget currentTarget: Current event target node.
:arg EventTarget target: Node which emitted this event first.
:arg dict init: Event options.
"""
proto = msg.get('proto', '')
cls = pr... | [
"def",
"create_event",
"(",
"msg",
":",
"EventMsgDict",
")",
"->",
"Event",
":",
"proto",
"=",
"msg",
".",
"get",
"(",
"'proto'",
",",
"''",
")",
"cls",
"=",
"proto_dict",
".",
"get",
"(",
"proto",
",",
"Event",
")",
"e",
"=",
"cls",
"(",
"msg",
... | Create Event from JSOM msg and set target nodes.
:arg EventTarget currentTarget: Current event target node.
:arg EventTarget target: Node which emitted this event first.
:arg dict init: Event options. | [
"Create",
"Event",
"from",
"JSOM",
"msg",
"and",
"set",
"target",
"nodes",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L236-L246 |
43,740 | miyakogi/wdom | wdom/event.py | DataTransfer.getData | def getData(self, type: str) -> str:
"""Get data of type format.
If this DataTransfer object does not have `type` data, return empty
string.
:arg str type: Data format of the data, like 'text/plain'.
"""
return self.__data.get(normalize_type(type), '') | python | def getData(self, type: str) -> str:
"""Get data of type format.
If this DataTransfer object does not have `type` data, return empty
string.
:arg str type: Data format of the data, like 'text/plain'.
"""
return self.__data.get(normalize_type(type), '') | [
"def",
"getData",
"(",
"self",
",",
"type",
":",
"str",
")",
"->",
"str",
":",
"return",
"self",
".",
"__data",
".",
"get",
"(",
"normalize_type",
"(",
"type",
")",
",",
"''",
")"
] | Get data of type format.
If this DataTransfer object does not have `type` data, return empty
string.
:arg str type: Data format of the data, like 'text/plain'. | [
"Get",
"data",
"of",
"type",
"format",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L66-L73 |
43,741 | miyakogi/wdom | wdom/event.py | DataTransfer.setData | def setData(self, type: str, data: str) -> None:
"""Set data of type format.
:arg str type: Data format of the data, like 'text/plain'.
"""
type = normalize_type(type)
if type in self.__data:
del self.__data[type]
self.__data[type] = data | python | def setData(self, type: str, data: str) -> None:
"""Set data of type format.
:arg str type: Data format of the data, like 'text/plain'.
"""
type = normalize_type(type)
if type in self.__data:
del self.__data[type]
self.__data[type] = data | [
"def",
"setData",
"(",
"self",
",",
"type",
":",
"str",
",",
"data",
":",
"str",
")",
"->",
"None",
":",
"type",
"=",
"normalize_type",
"(",
"type",
")",
"if",
"type",
"in",
"self",
".",
"__data",
":",
"del",
"self",
".",
"__data",
"[",
"type",
"... | Set data of type format.
:arg str type: Data format of the data, like 'text/plain'. | [
"Set",
"data",
"of",
"type",
"format",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L75-L83 |
43,742 | miyakogi/wdom | wdom/event.py | DataTransfer.clearData | def clearData(self, type: str = '') -> None:
"""Remove data of type foramt.
If type argument is omitted, remove all data.
"""
type = normalize_type(type)
if not type:
self.__data.clear()
elif type in self.__data:
del self.__data[type] | python | def clearData(self, type: str = '') -> None:
"""Remove data of type foramt.
If type argument is omitted, remove all data.
"""
type = normalize_type(type)
if not type:
self.__data.clear()
elif type in self.__data:
del self.__data[type] | [
"def",
"clearData",
"(",
"self",
",",
"type",
":",
"str",
"=",
"''",
")",
"->",
"None",
":",
"type",
"=",
"normalize_type",
"(",
"type",
")",
"if",
"not",
"type",
":",
"self",
".",
"__data",
".",
"clear",
"(",
")",
"elif",
"type",
"in",
"self",
"... | Remove data of type foramt.
If type argument is omitted, remove all data. | [
"Remove",
"data",
"of",
"type",
"foramt",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L85-L94 |
43,743 | miyakogi/wdom | wdom/event.py | EventTarget.addEventListener | def addEventListener(self, event: str, listener: _EventListenerType
) -> None:
"""Add event listener to this node.
``event`` is a string which determines the event type when the new
listener called. Acceptable events are same as JavaScript, without
``on``. For e... | python | def addEventListener(self, event: str, listener: _EventListenerType
) -> None:
"""Add event listener to this node.
``event`` is a string which determines the event type when the new
listener called. Acceptable events are same as JavaScript, without
``on``. For e... | [
"def",
"addEventListener",
"(",
"self",
",",
"event",
":",
"str",
",",
"listener",
":",
"_EventListenerType",
")",
"->",
"None",
":",
"self",
".",
"_add_event_listener",
"(",
"event",
",",
"listener",
")"
] | Add event listener to this node.
``event`` is a string which determines the event type when the new
listener called. Acceptable events are same as JavaScript, without
``on``. For example, to add a listener which is called when this node
is clicked, event is ``'click``. | [
"Add",
"event",
"listener",
"to",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L312-L321 |
43,744 | miyakogi/wdom | wdom/event.py | EventTarget.removeEventListener | def removeEventListener(self, event: str, listener: _EventListenerType
) -> None:
"""Remove an event listener of this node.
The listener is removed only when both event type and listener is
matched.
"""
self._remove_event_listener(event, listener) | python | def removeEventListener(self, event: str, listener: _EventListenerType
) -> None:
"""Remove an event listener of this node.
The listener is removed only when both event type and listener is
matched.
"""
self._remove_event_listener(event, listener) | [
"def",
"removeEventListener",
"(",
"self",
",",
"event",
":",
"str",
",",
"listener",
":",
"_EventListenerType",
")",
"->",
"None",
":",
"self",
".",
"_remove_event_listener",
"(",
"event",
",",
"listener",
")"
] | Remove an event listener of this node.
The listener is removed only when both event type and listener is
matched. | [
"Remove",
"an",
"event",
"listener",
"of",
"this",
"node",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L335-L342 |
43,745 | miyakogi/wdom | wdom/event.py | WebEventTarget.on_response | def on_response(self, msg: Dict[str, str]) -> None:
"""Run when get response from browser."""
response = msg.get('data', False)
if response:
task = self.__tasks.pop(msg.get('reqid'), False)
if task and not task.cancelled() and not task.done():
task.set_res... | python | def on_response(self, msg: Dict[str, str]) -> None:
"""Run when get response from browser."""
response = msg.get('data', False)
if response:
task = self.__tasks.pop(msg.get('reqid'), False)
if task and not task.cancelled() and not task.done():
task.set_res... | [
"def",
"on_response",
"(",
"self",
",",
"msg",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"None",
":",
"response",
"=",
"msg",
".",
"get",
"(",
"'data'",
",",
"False",
")",
"if",
"response",
":",
"task",
"=",
"self",
".",
"__tasks",
"."... | Run when get response from browser. | [
"Run",
"when",
"get",
"response",
"from",
"browser",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L383-L389 |
43,746 | miyakogi/wdom | wdom/event.py | WebEventTarget.js_exec | def js_exec(self, method: str, *args: Union[int, str, bool]) -> None:
"""Execute ``method`` in the related node on browser.
Other keyword arguments are passed to ``params`` attribute.
If this node is not in any document tree (namely, this node does not
have parent node), the ``method`` ... | python | def js_exec(self, method: str, *args: Union[int, str, bool]) -> None:
"""Execute ``method`` in the related node on browser.
Other keyword arguments are passed to ``params`` attribute.
If this node is not in any document tree (namely, this node does not
have parent node), the ``method`` ... | [
"def",
"js_exec",
"(",
"self",
",",
"method",
":",
"str",
",",
"*",
"args",
":",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"connected",
":",
"self",
".",
"ws_send",
"(",
"dict",
"(",
"method",
... | Execute ``method`` in the related node on browser.
Other keyword arguments are passed to ``params`` attribute.
If this node is not in any document tree (namely, this node does not
have parent node), the ``method`` is not executed. | [
"Execute",
"method",
"in",
"the",
"related",
"node",
"on",
"browser",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L391-L399 |
43,747 | miyakogi/wdom | wdom/event.py | WebEventTarget.js_query | def js_query(self, query: str) -> Awaitable:
"""Send query to related DOM on browser.
:param str query: single string which indicates query type.
"""
if self.connected:
self.js_exec(query, self.__reqid)
fut = Future() # type: Future[str]
self.__tasks... | python | def js_query(self, query: str) -> Awaitable:
"""Send query to related DOM on browser.
:param str query: single string which indicates query type.
"""
if self.connected:
self.js_exec(query, self.__reqid)
fut = Future() # type: Future[str]
self.__tasks... | [
"def",
"js_query",
"(",
"self",
",",
"query",
":",
"str",
")",
"->",
"Awaitable",
":",
"if",
"self",
".",
"connected",
":",
"self",
".",
"js_exec",
"(",
"query",
",",
"self",
".",
"__reqid",
")",
"fut",
"=",
"Future",
"(",
")",
"# type: Future[str]",
... | Send query to related DOM on browser.
:param str query: single string which indicates query type. | [
"Send",
"query",
"to",
"related",
"DOM",
"on",
"browser",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L401-L414 |
43,748 | miyakogi/wdom | wdom/event.py | WebEventTarget.ws_send | def ws_send(self, obj: Dict[str, Union[Iterable[_T_MsgItem], _T_MsgItem]]
) -> None:
"""Send ``obj`` as message to the related nodes on browser.
:arg dict obj: Message is serialized by JSON object and send via
WebSocket connection.
"""
from wdom import server... | python | def ws_send(self, obj: Dict[str, Union[Iterable[_T_MsgItem], _T_MsgItem]]
) -> None:
"""Send ``obj`` as message to the related nodes on browser.
:arg dict obj: Message is serialized by JSON object and send via
WebSocket connection.
"""
from wdom import server... | [
"def",
"ws_send",
"(",
"self",
",",
"obj",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"Iterable",
"[",
"_T_MsgItem",
"]",
",",
"_T_MsgItem",
"]",
"]",
")",
"->",
"None",
":",
"from",
"wdom",
"import",
"server",
"if",
"self",
".",
"ownerDocument",
"i... | Send ``obj`` as message to the related nodes on browser.
:arg dict obj: Message is serialized by JSON object and send via
WebSocket connection. | [
"Send",
"obj",
"as",
"message",
"to",
"the",
"related",
"nodes",
"on",
"browser",
"."
] | a21bcd23e94baceee71161829f6897bee3fd39c1 | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L416-L427 |
43,749 | viveksck/changepoint | changepoint/mean_shift_model.py | MeanShiftModel.get_ts_stats_significance | def get_ts_stats_significance(self, x, ts, stat_ts_func, null_ts_func, B=1000, permute_fast=False, label_ts=''):
""" Returns the statistics, pvalues and the actual number of bootstrap
samples. """
stats_ts, pvals, nums = ts_stats_significance(
ts, stat_ts_func, null_ts_func, B=B,... | python | def get_ts_stats_significance(self, x, ts, stat_ts_func, null_ts_func, B=1000, permute_fast=False, label_ts=''):
""" Returns the statistics, pvalues and the actual number of bootstrap
samples. """
stats_ts, pvals, nums = ts_stats_significance(
ts, stat_ts_func, null_ts_func, B=B,... | [
"def",
"get_ts_stats_significance",
"(",
"self",
",",
"x",
",",
"ts",
",",
"stat_ts_func",
",",
"null_ts_func",
",",
"B",
"=",
"1000",
",",
"permute_fast",
"=",
"False",
",",
"label_ts",
"=",
"''",
")",
":",
"stats_ts",
",",
"pvals",
",",
"nums",
"=",
... | Returns the statistics, pvalues and the actual number of bootstrap
samples. | [
"Returns",
"the",
"statistics",
"pvalues",
"and",
"the",
"actual",
"number",
"of",
"bootstrap",
"samples",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L20-L25 |
43,750 | viveksck/changepoint | changepoint/mean_shift_model.py | MeanShiftModel.generate_null_timeseries | def generate_null_timeseries(self, ts, mu, sigma):
""" Generate a time series with a given mu and sigma. This serves as the
NULL distribution. """
l = len(ts)
return np.random.normal(mu, sigma, l) | python | def generate_null_timeseries(self, ts, mu, sigma):
""" Generate a time series with a given mu and sigma. This serves as the
NULL distribution. """
l = len(ts)
return np.random.normal(mu, sigma, l) | [
"def",
"generate_null_timeseries",
"(",
"self",
",",
"ts",
",",
"mu",
",",
"sigma",
")",
":",
"l",
"=",
"len",
"(",
"ts",
")",
"return",
"np",
".",
"random",
".",
"normal",
"(",
"mu",
",",
"sigma",
",",
"l",
")"
] | Generate a time series with a given mu and sigma. This serves as the
NULL distribution. | [
"Generate",
"a",
"time",
"series",
"with",
"a",
"given",
"mu",
"and",
"sigma",
".",
"This",
"serves",
"as",
"the",
"NULL",
"distribution",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L27-L31 |
43,751 | viveksck/changepoint | changepoint/mean_shift_model.py | MeanShiftModel.compute_balance_mean | def compute_balance_mean(self, ts, t):
""" Compute the balance. The right end - the left end."""
""" For changed words we expect an increase in the mean, and so only 1 """
return np.mean(ts[t + 1:]) - np.mean(ts[:t + 1]) | python | def compute_balance_mean(self, ts, t):
""" Compute the balance. The right end - the left end."""
""" For changed words we expect an increase in the mean, and so only 1 """
return np.mean(ts[t + 1:]) - np.mean(ts[:t + 1]) | [
"def",
"compute_balance_mean",
"(",
"self",
",",
"ts",
",",
"t",
")",
":",
"\"\"\" For changed words we expect an increase in the mean, and so only 1 \"\"\"",
"return",
"np",
".",
"mean",
"(",
"ts",
"[",
"t",
"+",
"1",
":",
"]",
")",
"-",
"np",
".",
"mean",
"(... | Compute the balance. The right end - the left end. | [
"Compute",
"the",
"balance",
".",
"The",
"right",
"end",
"-",
"the",
"left",
"end",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L37-L40 |
43,752 | viveksck/changepoint | changepoint/mean_shift_model.py | MeanShiftModel.compute_balance_median | def compute_balance_median(self, ts, t):
""" Compute the balance at either end."""
return np.median(ts[t + 1:]) - np.median(ts[:t + 1]) | python | def compute_balance_median(self, ts, t):
""" Compute the balance at either end."""
return np.median(ts[t + 1:]) - np.median(ts[:t + 1]) | [
"def",
"compute_balance_median",
"(",
"self",
",",
"ts",
",",
"t",
")",
":",
"return",
"np",
".",
"median",
"(",
"ts",
"[",
"t",
"+",
"1",
":",
"]",
")",
"-",
"np",
".",
"median",
"(",
"ts",
"[",
":",
"t",
"+",
"1",
"]",
")"
] | Compute the balance at either end. | [
"Compute",
"the",
"balance",
"at",
"either",
"end",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L47-L49 |
43,753 | viveksck/changepoint | changepoint/mean_shift_model.py | MeanShiftModel.compute_cusum_ts | def compute_cusum_ts(self, ts):
""" Compute the Cumulative Sum at each point 't' of the time series. """
mean = np.mean(ts)
cusums = np.zeros(len(ts))
cusum[0] = (ts[0] - mean)
for i in np.arange(1, len(ts)):
cusums[i] = cusums[i - 1] + (ts[i] - mean)
assert(... | python | def compute_cusum_ts(self, ts):
""" Compute the Cumulative Sum at each point 't' of the time series. """
mean = np.mean(ts)
cusums = np.zeros(len(ts))
cusum[0] = (ts[0] - mean)
for i in np.arange(1, len(ts)):
cusums[i] = cusums[i - 1] + (ts[i] - mean)
assert(... | [
"def",
"compute_cusum_ts",
"(",
"self",
",",
"ts",
")",
":",
"mean",
"=",
"np",
".",
"mean",
"(",
"ts",
")",
"cusums",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"ts",
")",
")",
"cusum",
"[",
"0",
"]",
"=",
"(",
"ts",
"[",
"0",
"]",
"-",
"me... | Compute the Cumulative Sum at each point 't' of the time series. | [
"Compute",
"the",
"Cumulative",
"Sum",
"at",
"each",
"point",
"t",
"of",
"the",
"time",
"series",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L56-L65 |
43,754 | viveksck/changepoint | changepoint/mean_shift_model.py | MeanShiftModel.detect_mean_shift | def detect_mean_shift(self, ts, B=1000):
""" Detect mean shift in a time series. B is number of bootstrapped
samples to draw.
"""
x = np.arange(0, len(ts))
stat_ts_func = self.compute_balance_mean_ts
null_ts_func = self.shuffle_timeseries
stats_ts, pvals, nums... | python | def detect_mean_shift(self, ts, B=1000):
""" Detect mean shift in a time series. B is number of bootstrapped
samples to draw.
"""
x = np.arange(0, len(ts))
stat_ts_func = self.compute_balance_mean_ts
null_ts_func = self.shuffle_timeseries
stats_ts, pvals, nums... | [
"def",
"detect_mean_shift",
"(",
"self",
",",
"ts",
",",
"B",
"=",
"1000",
")",
":",
"x",
"=",
"np",
".",
"arange",
"(",
"0",
",",
"len",
"(",
"ts",
")",
")",
"stat_ts_func",
"=",
"self",
".",
"compute_balance_mean_ts",
"null_ts_func",
"=",
"self",
"... | Detect mean shift in a time series. B is number of bootstrapped
samples to draw. | [
"Detect",
"mean",
"shift",
"in",
"a",
"time",
"series",
".",
"B",
"is",
"number",
"of",
"bootstrapped",
"samples",
"to",
"draw",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L67-L75 |
43,755 | viveksck/changepoint | changepoint/utils/ts_stats.py | parallelize_func | def parallelize_func(iterable, func, chunksz=1, n_jobs=16, *args, **kwargs):
""" Parallelize a function over each element of an iterable. """
chunker = func
chunks = more_itertools.chunked(iterable, chunksz)
chunks_results = Parallel(n_jobs=n_jobs, verbose=50)(
delayed(chunker)(chunk, *args, **k... | python | def parallelize_func(iterable, func, chunksz=1, n_jobs=16, *args, **kwargs):
""" Parallelize a function over each element of an iterable. """
chunker = func
chunks = more_itertools.chunked(iterable, chunksz)
chunks_results = Parallel(n_jobs=n_jobs, verbose=50)(
delayed(chunker)(chunk, *args, **k... | [
"def",
"parallelize_func",
"(",
"iterable",
",",
"func",
",",
"chunksz",
"=",
"1",
",",
"n_jobs",
"=",
"16",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"chunker",
"=",
"func",
"chunks",
"=",
"more_itertools",
".",
"chunked",
"(",
"iterable",
... | Parallelize a function over each element of an iterable. | [
"Parallelize",
"a",
"function",
"over",
"each",
"element",
"of",
"an",
"iterable",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/utils/ts_stats.py#L23-L30 |
43,756 | viveksck/changepoint | changepoint/utils/ts_stats.py | ts_stats_significance | def ts_stats_significance(ts, ts_stat_func, null_ts_func, B=1000, permute_fast=False):
""" Compute the statistical significance of a test statistic at each point
of the time series.
"""
stats_ts = ts_stat_func(ts)
if permute_fast:
# Permute it in 1 shot
null_ts = map(np.random.p... | python | def ts_stats_significance(ts, ts_stat_func, null_ts_func, B=1000, permute_fast=False):
""" Compute the statistical significance of a test statistic at each point
of the time series.
"""
stats_ts = ts_stat_func(ts)
if permute_fast:
# Permute it in 1 shot
null_ts = map(np.random.p... | [
"def",
"ts_stats_significance",
"(",
"ts",
",",
"ts_stat_func",
",",
"null_ts_func",
",",
"B",
"=",
"1000",
",",
"permute_fast",
"=",
"False",
")",
":",
"stats_ts",
"=",
"ts_stat_func",
"(",
"ts",
")",
"if",
"permute_fast",
":",
"# Permute it in 1 shot",
"null... | Compute the statistical significance of a test statistic at each point
of the time series. | [
"Compute",
"the",
"statistical",
"significance",
"of",
"a",
"test",
"statistic",
"at",
"each",
"point",
"of",
"the",
"time",
"series",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/utils/ts_stats.py#L54-L73 |
43,757 | viveksck/changepoint | changepoint/utils/ts_stats.py | get_ci | def get_ci(theta_star, blockratio=1.0):
""" Get the confidence interval. """
# get rid of nans while we sort
b_star = np.sort(theta_star[~np.isnan(theta_star)])
se = np.std(b_star) * np.sqrt(blockratio)
# bootstrap 95% CI based on empirical percentiles
ci = [b_star[int(len(b_star) * .025)], b_st... | python | def get_ci(theta_star, blockratio=1.0):
""" Get the confidence interval. """
# get rid of nans while we sort
b_star = np.sort(theta_star[~np.isnan(theta_star)])
se = np.std(b_star) * np.sqrt(blockratio)
# bootstrap 95% CI based on empirical percentiles
ci = [b_star[int(len(b_star) * .025)], b_st... | [
"def",
"get_ci",
"(",
"theta_star",
",",
"blockratio",
"=",
"1.0",
")",
":",
"# get rid of nans while we sort",
"b_star",
"=",
"np",
".",
"sort",
"(",
"theta_star",
"[",
"~",
"np",
".",
"isnan",
"(",
"theta_star",
")",
"]",
")",
"se",
"=",
"np",
".",
"... | Get the confidence interval. | [
"Get",
"the",
"confidence",
"interval",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/utils/ts_stats.py#L88-L95 |
43,758 | viveksck/changepoint | changepoint/utils/ts_stats.py | get_pvalue | def get_pvalue(value, ci):
""" Get the p-value from the confidence interval."""
from scipy.stats import norm
se = (ci[1] - ci[0]) / (2.0 * 1.96)
z = value / se
pvalue = -2 * norm.cdf(-np.abs(z))
return pvalue | python | def get_pvalue(value, ci):
""" Get the p-value from the confidence interval."""
from scipy.stats import norm
se = (ci[1] - ci[0]) / (2.0 * 1.96)
z = value / se
pvalue = -2 * norm.cdf(-np.abs(z))
return pvalue | [
"def",
"get_pvalue",
"(",
"value",
",",
"ci",
")",
":",
"from",
"scipy",
".",
"stats",
"import",
"norm",
"se",
"=",
"(",
"ci",
"[",
"1",
"]",
"-",
"ci",
"[",
"0",
"]",
")",
"/",
"(",
"2.0",
"*",
"1.96",
")",
"z",
"=",
"value",
"/",
"se",
"p... | Get the p-value from the confidence interval. | [
"Get",
"the",
"p",
"-",
"value",
"from",
"the",
"confidence",
"interval",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/utils/ts_stats.py#L98-L104 |
43,759 | viveksck/changepoint | changepoint/utils/ts_stats.py | ts_stats_significance_bootstrap | def ts_stats_significance_bootstrap(ts, stats_ts, stats_func, B=1000, b=3):
""" Compute the statistical significance of a test statistic at each point
of the time series by using timeseries boootstrap.
"""
pvals = []
for tp in np.arange(0, len(stats_ts)):
pf = partial(stats_func, t=tp)
... | python | def ts_stats_significance_bootstrap(ts, stats_ts, stats_func, B=1000, b=3):
""" Compute the statistical significance of a test statistic at each point
of the time series by using timeseries boootstrap.
"""
pvals = []
for tp in np.arange(0, len(stats_ts)):
pf = partial(stats_func, t=tp)
... | [
"def",
"ts_stats_significance_bootstrap",
"(",
"ts",
",",
"stats_ts",
",",
"stats_func",
",",
"B",
"=",
"1000",
",",
"b",
"=",
"3",
")",
":",
"pvals",
"=",
"[",
"]",
"for",
"tp",
"in",
"np",
".",
"arange",
"(",
"0",
",",
"len",
"(",
"stats_ts",
")"... | Compute the statistical significance of a test statistic at each point
of the time series by using timeseries boootstrap. | [
"Compute",
"the",
"statistical",
"significance",
"of",
"a",
"test",
"statistic",
"at",
"each",
"point",
"of",
"the",
"time",
"series",
"by",
"using",
"timeseries",
"boootstrap",
"."
] | 001792cb148c991ec704463d3213997ebb7171af | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/utils/ts_stats.py#L107-L118 |
43,760 | erikrose/nose-progressive | noseprogressive/tracebacks.py | format_traceback | def format_traceback(extracted_tb,
exc_type,
exc_value,
cwd='',
term=None,
function_color=12,
dim_color=8,
editor='vi',
template=DEFAULT_EDITOR_SHORTCUT... | python | def format_traceback(extracted_tb,
exc_type,
exc_value,
cwd='',
term=None,
function_color=12,
dim_color=8,
editor='vi',
template=DEFAULT_EDITOR_SHORTCUT... | [
"def",
"format_traceback",
"(",
"extracted_tb",
",",
"exc_type",
",",
"exc_value",
",",
"cwd",
"=",
"''",
",",
"term",
"=",
"None",
",",
"function_color",
"=",
"12",
",",
"dim_color",
"=",
"8",
",",
"editor",
"=",
"'vi'",
",",
"template",
"=",
"DEFAULT_E... | Return an iterable of formatted Unicode traceback frames.
Also include a pseudo-frame at the end representing the exception itself.
Format things more compactly than the stock formatter, and make every
frame an editor shortcut. | [
"Return",
"an",
"iterable",
"of",
"formatted",
"Unicode",
"traceback",
"frames",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/tracebacks.py#L21-L95 |
43,761 | erikrose/nose-progressive | noseprogressive/tracebacks.py | extract_relevant_tb | def extract_relevant_tb(tb, exctype, is_test_failure):
"""Return extracted traceback frame 4-tuples that aren't unittest ones.
This used to be _exc_info_to_string().
"""
# Skip test runner traceback levels:
while tb and _is_unittest_frame(tb):
tb = tb.tb_next
if is_test_failure:
... | python | def extract_relevant_tb(tb, exctype, is_test_failure):
"""Return extracted traceback frame 4-tuples that aren't unittest ones.
This used to be _exc_info_to_string().
"""
# Skip test runner traceback levels:
while tb and _is_unittest_frame(tb):
tb = tb.tb_next
if is_test_failure:
... | [
"def",
"extract_relevant_tb",
"(",
"tb",
",",
"exctype",
",",
"is_test_failure",
")",
":",
"# Skip test runner traceback levels:",
"while",
"tb",
"and",
"_is_unittest_frame",
"(",
"tb",
")",
":",
"tb",
"=",
"tb",
".",
"tb_next",
"if",
"is_test_failure",
":",
"# ... | Return extracted traceback frame 4-tuples that aren't unittest ones.
This used to be _exc_info_to_string(). | [
"Return",
"extracted",
"traceback",
"frame",
"4",
"-",
"tuples",
"that",
"aren",
"t",
"unittest",
"ones",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/tracebacks.py#L100-L113 |
43,762 | erikrose/nose-progressive | noseprogressive/tracebacks.py | _unicode_decode_extracted_tb | def _unicode_decode_extracted_tb(extracted_tb):
"""Return a traceback with the string elements translated into Unicode."""
return [(_decode(file), line_number, _decode(function), _decode(text))
for file, line_number, function, text in extracted_tb] | python | def _unicode_decode_extracted_tb(extracted_tb):
"""Return a traceback with the string elements translated into Unicode."""
return [(_decode(file), line_number, _decode(function), _decode(text))
for file, line_number, function, text in extracted_tb] | [
"def",
"_unicode_decode_extracted_tb",
"(",
"extracted_tb",
")",
":",
"return",
"[",
"(",
"_decode",
"(",
"file",
")",
",",
"line_number",
",",
"_decode",
"(",
"function",
")",
",",
"_decode",
"(",
"text",
")",
")",
"for",
"file",
",",
"line_number",
",",
... | Return a traceback with the string elements translated into Unicode. | [
"Return",
"a",
"traceback",
"with",
"the",
"string",
"elements",
"translated",
"into",
"Unicode",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/tracebacks.py#L131-L134 |
43,763 | erikrose/nose-progressive | noseprogressive/tracebacks.py | _count_relevant_tb_levels | def _count_relevant_tb_levels(tb):
"""Return the number of frames in ``tb`` before all that's left is unittest frames.
Unlike its namesake in unittest, this doesn't bail out as soon as it hits a
unittest frame, which means we don't bail out as soon as somebody uses the
mock library, which defines ``__u... | python | def _count_relevant_tb_levels(tb):
"""Return the number of frames in ``tb`` before all that's left is unittest frames.
Unlike its namesake in unittest, this doesn't bail out as soon as it hits a
unittest frame, which means we don't bail out as soon as somebody uses the
mock library, which defines ``__u... | [
"def",
"_count_relevant_tb_levels",
"(",
"tb",
")",
":",
"length",
"=",
"contiguous_unittest_frames",
"=",
"0",
"while",
"tb",
":",
"length",
"+=",
"1",
"if",
"_is_unittest_frame",
"(",
"tb",
")",
":",
"contiguous_unittest_frames",
"+=",
"1",
"else",
":",
"con... | Return the number of frames in ``tb`` before all that's left is unittest frames.
Unlike its namesake in unittest, this doesn't bail out as soon as it hits a
unittest frame, which means we don't bail out as soon as somebody uses the
mock library, which defines ``__unittest``. | [
"Return",
"the",
"number",
"of",
"frames",
"in",
"tb",
"before",
"all",
"that",
"s",
"left",
"is",
"unittest",
"frames",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/tracebacks.py#L142-L158 |
43,764 | erikrose/nose-progressive | noseprogressive/wrapping.py | cmdloop | def cmdloop(self, *args, **kwargs):
"""Call pdb's cmdloop, making readline work.
Patch raw_input so it sees the original stdin and stdout, lest
readline refuse to work.
The C implementation of raw_input uses readline functionality only if
both stdin and stdout are from a terminal AND are FILE*s (n... | python | def cmdloop(self, *args, **kwargs):
"""Call pdb's cmdloop, making readline work.
Patch raw_input so it sees the original stdin and stdout, lest
readline refuse to work.
The C implementation of raw_input uses readline functionality only if
both stdin and stdout are from a terminal AND are FILE*s (n... | [
"def",
"cmdloop",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"unwrapping_raw_input",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Call raw_input(), making sure it finds an unwrapped stdout.\"\"\"",
"wrapped_stdout",
"="... | Call pdb's cmdloop, making readline work.
Patch raw_input so it sees the original stdin and stdout, lest
readline refuse to work.
The C implementation of raw_input uses readline functionality only if
both stdin and stdout are from a terminal AND are FILE*s (not
PyObject*s): http://bugs.python.org/... | [
"Call",
"pdb",
"s",
"cmdloop",
"making",
"readline",
"work",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/wrapping.py#L10-L45 |
43,765 | erikrose/nose-progressive | noseprogressive/wrapping.py | set_trace | def set_trace(*args, **kwargs):
"""Call pdb.set_trace, making sure it receives the unwrapped stdout.
This is so we don't keep drawing progress bars over debugger output.
"""
# There's no stream attr if capture plugin is enabled:
out = sys.stdout.stream if hasattr(sys.stdout, 'stream') else None
... | python | def set_trace(*args, **kwargs):
"""Call pdb.set_trace, making sure it receives the unwrapped stdout.
This is so we don't keep drawing progress bars over debugger output.
"""
# There's no stream attr if capture plugin is enabled:
out = sys.stdout.stream if hasattr(sys.stdout, 'stream') else None
... | [
"def",
"set_trace",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# There's no stream attr if capture plugin is enabled:",
"out",
"=",
"sys",
".",
"stdout",
".",
"stream",
"if",
"hasattr",
"(",
"sys",
".",
"stdout",
",",
"'stream'",
")",
"else",
"Non... | Call pdb.set_trace, making sure it receives the unwrapped stdout.
This is so we don't keep drawing progress bars over debugger output. | [
"Call",
"pdb",
".",
"set_trace",
"making",
"sure",
"it",
"receives",
"the",
"unwrapped",
"stdout",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/wrapping.py#L48-L66 |
43,766 | erikrose/nose-progressive | noseprogressive/plugin.py | ProgressivePlugin.begin | def begin(self):
"""Make some monkeypatches to dodge progress bar.
Wrap stderr and stdout to keep other users of them from smearing the
progress bar. Wrap some pdb routines to stop showing the bar while in
the debugger.
"""
# The calls to begin/finalize end up like this... | python | def begin(self):
"""Make some monkeypatches to dodge progress bar.
Wrap stderr and stdout to keep other users of them from smearing the
progress bar. Wrap some pdb routines to stop showing the bar while in
the debugger.
"""
# The calls to begin/finalize end up like this... | [
"def",
"begin",
"(",
"self",
")",
":",
"# The calls to begin/finalize end up like this: a call to begin() on",
"# instance A of the plugin, then a paired begin/finalize for each test",
"# on instance B, then a final call to finalize() on instance A.",
"# TODO: Do only if isatty.",
"self",
".",... | Make some monkeypatches to dodge progress bar.
Wrap stderr and stdout to keep other users of them from smearing the
progress bar. Wrap some pdb routines to stop showing the bar while in
the debugger. | [
"Make",
"some",
"monkeypatches",
"to",
"dodge",
"progress",
"bar",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/plugin.py#L27-L54 |
43,767 | erikrose/nose-progressive | noseprogressive/plugin.py | ProgressivePlugin.finalize | def finalize(self, result):
"""Put monkeypatches back as we found them."""
sys.stderr = self._stderr.pop()
sys.stdout = self._stdout.pop()
pdb.set_trace = self._set_trace.pop()
pdb.Pdb.cmdloop = self._cmdloop.pop() | python | def finalize(self, result):
"""Put monkeypatches back as we found them."""
sys.stderr = self._stderr.pop()
sys.stdout = self._stdout.pop()
pdb.set_trace = self._set_trace.pop()
pdb.Pdb.cmdloop = self._cmdloop.pop() | [
"def",
"finalize",
"(",
"self",
",",
"result",
")",
":",
"sys",
".",
"stderr",
"=",
"self",
".",
"_stderr",
".",
"pop",
"(",
")",
"sys",
".",
"stdout",
"=",
"self",
".",
"_stdout",
".",
"pop",
"(",
")",
"pdb",
".",
"set_trace",
"=",
"self",
".",
... | Put monkeypatches back as we found them. | [
"Put",
"monkeypatches",
"back",
"as",
"we",
"found",
"them",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/plugin.py#L56-L61 |
43,768 | erikrose/nose-progressive | noseprogressive/plugin.py | ProgressivePlugin.configure | def configure(self, options, conf):
"""Turn style-forcing on if bar-forcing is on.
It'd be messy to position the bar but still have the rest of the
terminal capabilities emit ''.
"""
super(ProgressivePlugin, self).configure(options, conf)
if (getattr(options, 'verbosity... | python | def configure(self, options, conf):
"""Turn style-forcing on if bar-forcing is on.
It'd be messy to position the bar but still have the rest of the
terminal capabilities emit ''.
"""
super(ProgressivePlugin, self).configure(options, conf)
if (getattr(options, 'verbosity... | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"super",
"(",
"ProgressivePlugin",
",",
"self",
")",
".",
"configure",
"(",
"options",
",",
"conf",
")",
"if",
"(",
"getattr",
"(",
"options",
",",
"'verbosity'",
",",
"0",
")",
... | Turn style-forcing on if bar-forcing is on.
It'd be messy to position the bar but still have the rest of the
terminal capabilities emit ''. | [
"Turn",
"style",
"-",
"forcing",
"on",
"if",
"bar",
"-",
"forcing",
"is",
"on",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/plugin.py#L147-L162 |
43,769 | erikrose/nose-progressive | noseprogressive/bar.py | ProgressBar.update | def update(self, test_path, number):
"""Draw an updated progress bar.
At the moment, the graph takes a fixed width, and the test identifier
takes the rest of the row, truncated from the left to fit.
test_path -- the selector of the test being run
number -- how many tests have b... | python | def update(self, test_path, number):
"""Draw an updated progress bar.
At the moment, the graph takes a fixed width, and the test identifier
takes the rest of the row, truncated from the left to fit.
test_path -- the selector of the test being run
number -- how many tests have b... | [
"def",
"update",
"(",
"self",
",",
"test_path",
",",
"number",
")",
":",
"# TODO: Play nicely with absurdly narrow terminals. (OS X's won't even",
"# go small enough to hurt us.)",
"# Figure out graph:",
"GRAPH_WIDTH",
"=",
"14",
"# min() is in case we somehow get the total test coun... | Draw an updated progress bar.
At the moment, the graph takes a fixed width, and the test identifier
takes the rest of the row, truncated from the left to fit.
test_path -- the selector of the test being run
number -- how many tests have been run so far, including this one | [
"Draw",
"an",
"updated",
"progress",
"bar",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/bar.py#L41-L72 |
43,770 | erikrose/nose-progressive | noseprogressive/bar.py | ProgressBar.erase | def erase(self):
"""White out the progress bar."""
with self._at_last_line():
self.stream.write(self._term.clear_eol)
self.stream.flush() | python | def erase(self):
"""White out the progress bar."""
with self._at_last_line():
self.stream.write(self._term.clear_eol)
self.stream.flush() | [
"def",
"erase",
"(",
"self",
")",
":",
"with",
"self",
".",
"_at_last_line",
"(",
")",
":",
"self",
".",
"stream",
".",
"write",
"(",
"self",
".",
"_term",
".",
"clear_eol",
")",
"self",
".",
"stream",
".",
"flush",
"(",
")"
] | White out the progress bar. | [
"White",
"out",
"the",
"progress",
"bar",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/bar.py#L74-L78 |
43,771 | erikrose/nose-progressive | noseprogressive/bar.py | ProgressBar.dodging | def dodging(bar):
"""Return a context manager which erases the bar, lets you output things, and then redraws the bar.
It's reentrant.
"""
class ShyProgressBar(object):
"""Context manager that implements a progress bar that gets out of the way"""
def __enter__(s... | python | def dodging(bar):
"""Return a context manager which erases the bar, lets you output things, and then redraws the bar.
It's reentrant.
"""
class ShyProgressBar(object):
"""Context manager that implements a progress bar that gets out of the way"""
def __enter__(s... | [
"def",
"dodging",
"(",
"bar",
")",
":",
"class",
"ShyProgressBar",
"(",
"object",
")",
":",
"\"\"\"Context manager that implements a progress bar that gets out of the way\"\"\"",
"def",
"__enter__",
"(",
"self",
")",
":",
"\"\"\"Erase the progress bar so bits of disembodied pro... | Return a context manager which erases the bar, lets you output things, and then redraws the bar.
It's reentrant. | [
"Return",
"a",
"context",
"manager",
"which",
"erases",
"the",
"bar",
"lets",
"you",
"output",
"things",
"and",
"then",
"redraws",
"the",
"bar",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/bar.py#L84-L113 |
43,772 | erikrose/nose-progressive | noseprogressive/runner.py | ProgressiveRunner._makeResult | def _makeResult(self):
"""Return a Result that doesn't print dots.
Nose's ResultProxy will wrap it, and other plugins can still print
stuff---but without smashing into our progress bar, care of
ProgressivePlugin's stderr/out wrapping.
"""
return ProgressiveResult(self._... | python | def _makeResult(self):
"""Return a Result that doesn't print dots.
Nose's ResultProxy will wrap it, and other plugins can still print
stuff---but without smashing into our progress bar, care of
ProgressivePlugin's stderr/out wrapping.
"""
return ProgressiveResult(self._... | [
"def",
"_makeResult",
"(",
"self",
")",
":",
"return",
"ProgressiveResult",
"(",
"self",
".",
"_cwd",
",",
"self",
".",
"_totalTests",
",",
"self",
".",
"stream",
",",
"config",
"=",
"self",
".",
"config",
")"
] | Return a Result that doesn't print dots.
Nose's ResultProxy will wrap it, and other plugins can still print
stuff---but without smashing into our progress bar, care of
ProgressivePlugin's stderr/out wrapping. | [
"Return",
"a",
"Result",
"that",
"doesn",
"t",
"print",
"dots",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/runner.py#L16-L27 |
43,773 | erikrose/nose-progressive | noseprogressive/runner.py | ProgressiveRunner.run | def run(self, test):
"Run the given test case or test suite...quietly."
# These parts of Nose's pluggability are baked into
# nose.core.TextTestRunner. Reproduce them:
wrapper = self.config.plugins.prepareTest(test)
if wrapper is not None:
test = wrapper
wrapp... | python | def run(self, test):
"Run the given test case or test suite...quietly."
# These parts of Nose's pluggability are baked into
# nose.core.TextTestRunner. Reproduce them:
wrapper = self.config.plugins.prepareTest(test)
if wrapper is not None:
test = wrapper
wrapp... | [
"def",
"run",
"(",
"self",
",",
"test",
")",
":",
"# These parts of Nose's pluggability are baked into",
"# nose.core.TextTestRunner. Reproduce them:",
"wrapper",
"=",
"self",
".",
"config",
".",
"plugins",
".",
"prepareTest",
"(",
"test",
")",
"if",
"wrapper",
"is",
... | Run the given test case or test suite...quietly. | [
"Run",
"the",
"given",
"test",
"case",
"or",
"test",
"suite",
"...",
"quietly",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/runner.py#L29-L64 |
43,774 | erikrose/nose-progressive | noseprogressive/result.py | ProgressiveResult._printTraceback | def _printTraceback(self, test, err):
"""Print a nicely formatted traceback.
:arg err: exc_info()-style traceback triple
:arg test: the test that precipitated this call
"""
# Don't bind third item to a local var; that can create
# circular refs which are expensive to co... | python | def _printTraceback(self, test, err):
"""Print a nicely formatted traceback.
:arg err: exc_info()-style traceback triple
:arg test: the test that precipitated this call
"""
# Don't bind third item to a local var; that can create
# circular refs which are expensive to co... | [
"def",
"_printTraceback",
"(",
"self",
",",
"test",
",",
"err",
")",
":",
"# Don't bind third item to a local var; that can create",
"# circular refs which are expensive to collect. See the",
"# sys.exc_info() docs.",
"exception_type",
",",
"exception_value",
"=",
"err",
"[",
"... | Print a nicely formatted traceback.
:arg err: exc_info()-style traceback triple
:arg test: the test that precipitated this call | [
"Print",
"a",
"nicely",
"formatted",
"traceback",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/result.py#L46-L91 |
43,775 | erikrose/nose-progressive | noseprogressive/result.py | ProgressiveResult._printHeadline | def _printHeadline(self, kind, test, is_failure=True):
"""Output a 1-line error summary to the stream if appropriate.
The line contains the kind of error and the pathname of the test.
:arg kind: The (string) type of incident the precipitated this call
:arg test: The test that precipita... | python | def _printHeadline(self, kind, test, is_failure=True):
"""Output a 1-line error summary to the stream if appropriate.
The line contains the kind of error and the pathname of the test.
:arg kind: The (string) type of incident the precipitated this call
:arg test: The test that precipita... | [
"def",
"_printHeadline",
"(",
"self",
",",
"kind",
",",
"test",
",",
"is_failure",
"=",
"True",
")",
":",
"if",
"is_failure",
"or",
"self",
".",
"_options",
".",
"show_advisories",
":",
"with",
"self",
".",
"bar",
".",
"dodging",
"(",
")",
":",
"self",... | Output a 1-line error summary to the stream if appropriate.
The line contains the kind of error and the pathname of the test.
:arg kind: The (string) type of incident the precipitated this call
:arg test: The test that precipitated this call | [
"Output",
"a",
"1",
"-",
"line",
"error",
"summary",
"to",
"the",
"stream",
"if",
"appropriate",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/result.py#L93-L108 |
43,776 | erikrose/nose-progressive | noseprogressive/result.py | ProgressiveResult._recordAndPrintHeadline | def _recordAndPrintHeadline(self, test, error_class, artifact):
"""Record that an error-like thing occurred, and print a summary.
Store ``artifact`` with the record.
Return whether the test result is any sort of failure.
"""
# We duplicate the errorclass handling from super ra... | python | def _recordAndPrintHeadline(self, test, error_class, artifact):
"""Record that an error-like thing occurred, and print a summary.
Store ``artifact`` with the record.
Return whether the test result is any sort of failure.
"""
# We duplicate the errorclass handling from super ra... | [
"def",
"_recordAndPrintHeadline",
"(",
"self",
",",
"test",
",",
"error_class",
",",
"artifact",
")",
":",
"# We duplicate the errorclass handling from super rather than calling",
"# it and monkeying around with showAll flags to keep it from printing",
"# anything.",
"is_error_class",
... | Record that an error-like thing occurred, and print a summary.
Store ``artifact`` with the record.
Return whether the test result is any sort of failure. | [
"Record",
"that",
"an",
"error",
"-",
"like",
"thing",
"occurred",
"and",
"print",
"a",
"summary",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/result.py#L110-L136 |
43,777 | erikrose/nose-progressive | noseprogressive/result.py | ProgressiveResult.addSkip | def addSkip(self, test, reason):
"""Catch skipped tests in Python 2.7 and above.
Though ``addSkip()`` is deprecated in the nose plugin API, it is very
much not deprecated as a Python 2.7 ``TestResult`` method. In Python
2.7, this will get called instead of ``addError()`` for skips.
... | python | def addSkip(self, test, reason):
"""Catch skipped tests in Python 2.7 and above.
Though ``addSkip()`` is deprecated in the nose plugin API, it is very
much not deprecated as a Python 2.7 ``TestResult`` method. In Python
2.7, this will get called instead of ``addError()`` for skips.
... | [
"def",
"addSkip",
"(",
"self",
",",
"test",
",",
"reason",
")",
":",
"self",
".",
"_recordAndPrintHeadline",
"(",
"test",
",",
"SkipTest",
",",
"reason",
")",
"# Python 2.7 users get a little bonus: the reason the test was skipped.",
"if",
"isinstance",
"(",
"reason",... | Catch skipped tests in Python 2.7 and above.
Though ``addSkip()`` is deprecated in the nose plugin API, it is very
much not deprecated as a Python 2.7 ``TestResult`` method. In Python
2.7, this will get called instead of ``addError()`` for skips.
:arg reason: Text describing why the te... | [
"Catch",
"skipped",
"tests",
"in",
"Python",
"2",
".",
"7",
"and",
"above",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/result.py#L138-L155 |
43,778 | erikrose/nose-progressive | noseprogressive/result.py | ProgressiveResult.printSummary | def printSummary(self, start, stop):
"""As a final summary, print number of tests, broken down by result."""
def renderResultType(type, number, is_failure):
"""Return a rendering like '2 failures'.
:arg type: A singular label, like "failure"
:arg number: The number o... | python | def printSummary(self, start, stop):
"""As a final summary, print number of tests, broken down by result."""
def renderResultType(type, number, is_failure):
"""Return a rendering like '2 failures'.
:arg type: A singular label, like "failure"
:arg number: The number o... | [
"def",
"printSummary",
"(",
"self",
",",
"start",
",",
"stop",
")",
":",
"def",
"renderResultType",
"(",
"type",
",",
"number",
",",
"is_failure",
")",
":",
"\"\"\"Return a rendering like '2 failures'.\n\n :arg type: A singular label, like \"failure\"\n ... | As a final summary, print number of tests, broken down by result. | [
"As",
"a",
"final",
"summary",
"print",
"number",
"of",
"tests",
"broken",
"down",
"by",
"result",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/result.py#L170-L209 |
43,779 | erikrose/nose-progressive | noseprogressive/utils.py | nose_selector | def nose_selector(test):
"""Return the string you can pass to nose to run `test`, including argument
values if the test was made by a test generator.
Return "Unknown test" if it can't construct a decent path.
"""
address = test_address(test)
if address:
file, module, rest = address
... | python | def nose_selector(test):
"""Return the string you can pass to nose to run `test`, including argument
values if the test was made by a test generator.
Return "Unknown test" if it can't construct a decent path.
"""
address = test_address(test)
if address:
file, module, rest = address
... | [
"def",
"nose_selector",
"(",
"test",
")",
":",
"address",
"=",
"test_address",
"(",
"test",
")",
"if",
"address",
":",
"file",
",",
"module",
",",
"rest",
"=",
"address",
"if",
"module",
":",
"if",
"rest",
":",
"try",
":",
"return",
"'%s:%s%s'",
"%",
... | Return the string you can pass to nose to run `test`, including argument
values if the test was made by a test generator.
Return "Unknown test" if it can't construct a decent path. | [
"Return",
"the",
"string",
"you",
"can",
"pass",
"to",
"nose",
"to",
"run",
"test",
"including",
"argument",
"values",
"if",
"the",
"test",
"was",
"made",
"by",
"a",
"test",
"generator",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/utils.py#L17-L36 |
43,780 | erikrose/nose-progressive | noseprogressive/utils.py | human_path | def human_path(path, cwd):
"""Return the most human-readable representation of the given path.
If an absolute path is given that's within the current directory, convert
it to a relative path to shorten it. Otherwise, return the absolute path.
"""
# TODO: Canonicalize the path to remove /kitsune/..... | python | def human_path(path, cwd):
"""Return the most human-readable representation of the given path.
If an absolute path is given that's within the current directory, convert
it to a relative path to shorten it. Otherwise, return the absolute path.
"""
# TODO: Canonicalize the path to remove /kitsune/..... | [
"def",
"human_path",
"(",
"path",
",",
"cwd",
")",
":",
"# TODO: Canonicalize the path to remove /kitsune/../kitsune nonsense.",
"path",
"=",
"abspath",
"(",
"path",
")",
"if",
"cwd",
"and",
"path",
".",
"startswith",
"(",
"cwd",
")",
":",
"path",
"=",
"path",
... | Return the most human-readable representation of the given path.
If an absolute path is given that's within the current directory, convert
it to a relative path to shorten it. Otherwise, return the absolute path. | [
"Return",
"the",
"most",
"human",
"-",
"readable",
"representation",
"of",
"the",
"given",
"path",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/utils.py#L121-L132 |
43,781 | erikrose/nose-progressive | noseprogressive/utils.py | OneTrackMind.know | def know(self, what, confidence):
"""Know something with the given confidence, and return self for chaining.
If confidence is higher than that of what we already know, replace
what we already know with what you're telling us.
"""
if confidence > self.confidence:
sel... | python | def know(self, what, confidence):
"""Know something with the given confidence, and return self for chaining.
If confidence is higher than that of what we already know, replace
what we already know with what you're telling us.
"""
if confidence > self.confidence:
sel... | [
"def",
"know",
"(",
"self",
",",
"what",
",",
"confidence",
")",
":",
"if",
"confidence",
">",
"self",
".",
"confidence",
":",
"self",
".",
"best",
"=",
"what",
"self",
".",
"confidence",
"=",
"confidence",
"return",
"self"
] | Know something with the given confidence, and return self for chaining.
If confidence is higher than that of what we already know, replace
what we already know with what you're telling us. | [
"Know",
"something",
"with",
"the",
"given",
"confidence",
"and",
"return",
"self",
"for",
"chaining",
"."
] | 42853f11290cfaac8aa3d204714b71e27cc4ec07 | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/utils.py#L51-L61 |
43,782 | astropy/pyregion | pyregion/wcs_converter.py | _generate_arg_types | def _generate_arg_types(coordlist_length, shape_name):
"""Find coordinate types based on shape name and coordlist length
This function returns a list of coordinate types based on which
coordinates can be repeated for a given type of shap
Parameters
----------
coordlist_length : int
The... | python | def _generate_arg_types(coordlist_length, shape_name):
"""Find coordinate types based on shape name and coordlist length
This function returns a list of coordinate types based on which
coordinates can be repeated for a given type of shap
Parameters
----------
coordlist_length : int
The... | [
"def",
"_generate_arg_types",
"(",
"coordlist_length",
",",
"shape_name",
")",
":",
"from",
".",
"ds9_region_parser",
"import",
"ds9_shape_defs",
"from",
".",
"ds9_attr_parser",
"import",
"ds9_shape_in_comment_defs",
"if",
"shape_name",
"in",
"ds9_shape_defs",
":",
"sha... | Find coordinate types based on shape name and coordlist length
This function returns a list of coordinate types based on which
coordinates can be repeated for a given type of shap
Parameters
----------
coordlist_length : int
The number of coordinates or arguments used to define the shape.
... | [
"Find",
"coordinate",
"types",
"based",
"on",
"shape",
"name",
"and",
"coordlist",
"length"
] | 913af7ea4917855cb2e43d5086d1c8dd99c31363 | https://github.com/astropy/pyregion/blob/913af7ea4917855cb2e43d5086d1c8dd99c31363/pyregion/wcs_converter.py#L13-L55 |
43,783 | astropy/pyregion | pyregion/wcs_converter.py | convert_to_imagecoord | def convert_to_imagecoord(shape, header):
"""Convert the coordlist of `shape` to image coordinates
Parameters
----------
shape : `pyregion.parser_helper.Shape`
The `Shape` to convert coordinates
header : `~astropy.io.fits.Header`
Specifies what WCS transformations to use.
Retu... | python | def convert_to_imagecoord(shape, header):
"""Convert the coordlist of `shape` to image coordinates
Parameters
----------
shape : `pyregion.parser_helper.Shape`
The `Shape` to convert coordinates
header : `~astropy.io.fits.Header`
Specifies what WCS transformations to use.
Retu... | [
"def",
"convert_to_imagecoord",
"(",
"shape",
",",
"header",
")",
":",
"arg_types",
"=",
"_generate_arg_types",
"(",
"len",
"(",
"shape",
".",
"coord_list",
")",
",",
"shape",
".",
"name",
")",
"new_coordlist",
"=",
"[",
"]",
"is_even_distance",
"=",
"True",... | Convert the coordlist of `shape` to image coordinates
Parameters
----------
shape : `pyregion.parser_helper.Shape`
The `Shape` to convert coordinates
header : `~astropy.io.fits.Header`
Specifies what WCS transformations to use.
Returns
-------
new_coordlist : list
... | [
"Convert",
"the",
"coordlist",
"of",
"shape",
"to",
"image",
"coordinates"
] | 913af7ea4917855cb2e43d5086d1c8dd99c31363 | https://github.com/astropy/pyregion/blob/913af7ea4917855cb2e43d5086d1c8dd99c31363/pyregion/wcs_converter.py#L58-L115 |
43,784 | havardgulldahl/jottalib | src/jottalib/JFS.py | get_auth_info | def get_auth_info():
""" Get authentication details to jottacloud.
Will first check environment variables, then the .netrc file.
"""
env_username = os.environ.get('JOTTACLOUD_USERNAME')
env_password = os.environ.get('JOTTACLOUD_PASSWORD')
netrc_auth = None
try:
netrc_file = netrc.ne... | python | def get_auth_info():
""" Get authentication details to jottacloud.
Will first check environment variables, then the .netrc file.
"""
env_username = os.environ.get('JOTTACLOUD_USERNAME')
env_password = os.environ.get('JOTTACLOUD_PASSWORD')
netrc_auth = None
try:
netrc_file = netrc.ne... | [
"def",
"get_auth_info",
"(",
")",
":",
"env_username",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'JOTTACLOUD_USERNAME'",
")",
"env_password",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'JOTTACLOUD_PASSWORD'",
")",
"netrc_auth",
"=",
"None",
"try",
":",
... | Get authentication details to jottacloud.
Will first check environment variables, then the .netrc file. | [
"Get",
"authentication",
"details",
"to",
"jottacloud",
"."
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L67-L90 |
43,785 | havardgulldahl/jottalib | src/jottalib/JFS.py | calculate_md5 | def calculate_md5(fileobject, size=2**16):
"""Utility function to calculate md5 hashes while being light on memory usage.
By reading the fileobject piece by piece, we are able to process content that
is larger than available memory"""
fileobject.seek(0)
md5 = hashlib.md5()
for data in iter(lamb... | python | def calculate_md5(fileobject, size=2**16):
"""Utility function to calculate md5 hashes while being light on memory usage.
By reading the fileobject piece by piece, we are able to process content that
is larger than available memory"""
fileobject.seek(0)
md5 = hashlib.md5()
for data in iter(lamb... | [
"def",
"calculate_md5",
"(",
"fileobject",
",",
"size",
"=",
"2",
"**",
"16",
")",
":",
"fileobject",
".",
"seek",
"(",
"0",
")",
"md5",
"=",
"hashlib",
".",
"md5",
"(",
")",
"for",
"data",
"in",
"iter",
"(",
"lambda",
":",
"fileobject",
".",
"read... | Utility function to calculate md5 hashes while being light on memory usage.
By reading the fileobject piece by piece, we are able to process content that
is larger than available memory | [
"Utility",
"function",
"to",
"calculate",
"md5",
"hashes",
"while",
"being",
"light",
"on",
"memory",
"usage",
"."
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L92-L105 |
43,786 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.deleted | def deleted(self):
'Return datetime.datetime or None if the file isnt deleted'
_d = self.folder.attrib.get('deleted', None)
if _d is None: return None
return dateutil.parser.parse(str(_d)) | python | def deleted(self):
'Return datetime.datetime or None if the file isnt deleted'
_d = self.folder.attrib.get('deleted', None)
if _d is None: return None
return dateutil.parser.parse(str(_d)) | [
"def",
"deleted",
"(",
"self",
")",
":",
"_d",
"=",
"self",
".",
"folder",
".",
"attrib",
".",
"get",
"(",
"'deleted'",
",",
"None",
")",
"if",
"_d",
"is",
"None",
":",
"return",
"None",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"str"... | Return datetime.datetime or None if the file isnt deleted | [
"Return",
"datetime",
".",
"datetime",
"or",
"None",
"if",
"the",
"file",
"isnt",
"deleted"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L240-L244 |
43,787 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.sync | def sync(self):
'Update state of folder from Jottacloud server'
log.info("syncing %r" % self.path)
self.folder = self.jfs.get(self.path)
self.synced = True | python | def sync(self):
'Update state of folder from Jottacloud server'
log.info("syncing %r" % self.path)
self.folder = self.jfs.get(self.path)
self.synced = True | [
"def",
"sync",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"syncing %r\"",
"%",
"self",
".",
"path",
")",
"self",
".",
"folder",
"=",
"self",
".",
"jfs",
".",
"get",
"(",
"self",
".",
"path",
")",
"self",
".",
"synced",
"=",
"True"
] | Update state of folder from Jottacloud server | [
"Update",
"state",
"of",
"folder",
"from",
"Jottacloud",
"server"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L246-L250 |
43,788 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.mkdir | def mkdir(self, foldername):
'Create a new subfolder and return the new JFSFolder'
#url = '%s?mkDir=true' % posixpath.join(self.path, foldername)
url = posixpath.join(self.path, foldername)
params = {'mkDir':'true'}
r = self.jfs.post(url, params)
self.sync()
retur... | python | def mkdir(self, foldername):
'Create a new subfolder and return the new JFSFolder'
#url = '%s?mkDir=true' % posixpath.join(self.path, foldername)
url = posixpath.join(self.path, foldername)
params = {'mkDir':'true'}
r = self.jfs.post(url, params)
self.sync()
retur... | [
"def",
"mkdir",
"(",
"self",
",",
"foldername",
")",
":",
"#url = '%s?mkDir=true' % posixpath.join(self.path, foldername)",
"url",
"=",
"posixpath",
".",
"join",
"(",
"self",
".",
"path",
",",
"foldername",
")",
"params",
"=",
"{",
"'mkDir'",
":",
"'true'",
"}",... | Create a new subfolder and return the new JFSFolder | [
"Create",
"a",
"new",
"subfolder",
"and",
"return",
"the",
"new",
"JFSFolder"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L280-L287 |
43,789 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.delete | def delete(self):
'Delete this folder and return a deleted JFSFolder'
#url = '%s?dlDir=true' % self.path
params = {'dlDir':'true'}
r = self.jfs.post(self.path, params)
self.sync()
return r | python | def delete(self):
'Delete this folder and return a deleted JFSFolder'
#url = '%s?dlDir=true' % self.path
params = {'dlDir':'true'}
r = self.jfs.post(self.path, params)
self.sync()
return r | [
"def",
"delete",
"(",
"self",
")",
":",
"#url = '%s?dlDir=true' % self.path",
"params",
"=",
"{",
"'dlDir'",
":",
"'true'",
"}",
"r",
"=",
"self",
".",
"jfs",
".",
"post",
"(",
"self",
".",
"path",
",",
"params",
")",
"self",
".",
"sync",
"(",
")",
"... | Delete this folder and return a deleted JFSFolder | [
"Delete",
"this",
"folder",
"and",
"return",
"a",
"deleted",
"JFSFolder"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L315-L321 |
43,790 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.hard_delete | def hard_delete(self):
'Deletes without possibility to restore'
url = 'https://www.jottacloud.com/rest/webrest/%s/action/delete' % self.jfs.username
data = {'paths[]': self.path.replace(JFS_ROOT, ''),
'web': 'true',
'ts': int(time.time()),
'authTok... | python | def hard_delete(self):
'Deletes without possibility to restore'
url = 'https://www.jottacloud.com/rest/webrest/%s/action/delete' % self.jfs.username
data = {'paths[]': self.path.replace(JFS_ROOT, ''),
'web': 'true',
'ts': int(time.time()),
'authTok... | [
"def",
"hard_delete",
"(",
"self",
")",
":",
"url",
"=",
"'https://www.jottacloud.com/rest/webrest/%s/action/delete'",
"%",
"self",
".",
"jfs",
".",
"username",
"data",
"=",
"{",
"'paths[]'",
":",
"self",
".",
"path",
".",
"replace",
"(",
"JFS_ROOT",
",",
"''"... | Deletes without possibility to restore | [
"Deletes",
"without",
"possibility",
"to",
"restore"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L323-L331 |
43,791 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.rename | def rename(self, newpath):
"Move folder to a new name, possibly a whole new path"
# POST https://www.jottacloud.com/jfs/**USERNAME**/Jotta/Sync/Ny%20mappe?mvDir=/**USERNAME**/Jotta/Sync/testFolder
#url = '%s?mvDir=/%s%s' % (self.path, self.jfs.username, newpath)
params = {'mvDir':'/%s%s'... | python | def rename(self, newpath):
"Move folder to a new name, possibly a whole new path"
# POST https://www.jottacloud.com/jfs/**USERNAME**/Jotta/Sync/Ny%20mappe?mvDir=/**USERNAME**/Jotta/Sync/testFolder
#url = '%s?mvDir=/%s%s' % (self.path, self.jfs.username, newpath)
params = {'mvDir':'/%s%s'... | [
"def",
"rename",
"(",
"self",
",",
"newpath",
")",
":",
"# POST https://www.jottacloud.com/jfs/**USERNAME**/Jotta/Sync/Ny%20mappe?mvDir=/**USERNAME**/Jotta/Sync/testFolder",
"#url = '%s?mvDir=/%s%s' % (self.path, self.jfs.username, newpath)",
"params",
"=",
"{",
"'mvDir'",
":",
"'/%s%s... | Move folder to a new name, possibly a whole new path | [
"Move",
"folder",
"to",
"a",
"new",
"name",
"possibly",
"a",
"whole",
"new",
"path"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L334-L342 |
43,792 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFolder.up | def up(self, fileobj_or_path, filename=None, upload_callback=None):
'Upload a file to current folder and return the new JFSFile'
close_on_done = False
if isinstance(fileobj_or_path, six.string_types):
filename = filename or os.path.basename(fileobj_or_path)
fileobj_or_pa... | python | def up(self, fileobj_or_path, filename=None, upload_callback=None):
'Upload a file to current folder and return the new JFSFile'
close_on_done = False
if isinstance(fileobj_or_path, six.string_types):
filename = filename or os.path.basename(fileobj_or_path)
fileobj_or_pa... | [
"def",
"up",
"(",
"self",
",",
"fileobj_or_path",
",",
"filename",
"=",
"None",
",",
"upload_callback",
"=",
"None",
")",
":",
"close_on_done",
"=",
"False",
"if",
"isinstance",
"(",
"fileobj_or_path",
",",
"six",
".",
"string_types",
")",
":",
"filename",
... | Upload a file to current folder and return the new JFSFile | [
"Upload",
"a",
"file",
"to",
"current",
"folder",
"and",
"return",
"the",
"new",
"JFSFile"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L344-L370 |
43,793 | havardgulldahl/jottalib | src/jottalib/JFS.py | ProtoFile.factory | def factory(fileobject, jfs, parentpath): # fileobject from lxml.objectify
'Class method to get the correct file class instatiated'
if hasattr(fileobject, 'currentRevision'): # a normal file
return JFSFile(fileobject, jfs, parentpath)
elif str(fileobject.latestRevision.state) == Prot... | python | def factory(fileobject, jfs, parentpath): # fileobject from lxml.objectify
'Class method to get the correct file class instatiated'
if hasattr(fileobject, 'currentRevision'): # a normal file
return JFSFile(fileobject, jfs, parentpath)
elif str(fileobject.latestRevision.state) == Prot... | [
"def",
"factory",
"(",
"fileobject",
",",
"jfs",
",",
"parentpath",
")",
":",
"# fileobject from lxml.objectify",
"if",
"hasattr",
"(",
"fileobject",
",",
"'currentRevision'",
")",
":",
"# a normal file",
"return",
"JFSFile",
"(",
"fileobject",
",",
"jfs",
",",
... | Class method to get the correct file class instatiated | [
"Class",
"method",
"to",
"get",
"the",
"correct",
"file",
"class",
"instatiated"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L387-L396 |
43,794 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSIncompleteFile.resume | def resume(self, data):
'Resume uploading an incomplete file, after a previous upload was interrupted. Returns new file object'
if not hasattr(data, 'read'):
data = six.BytesIO(data)#StringIO(data)
#Check that we actually know from what byte to resume.
#If self.size === -1, ... | python | def resume(self, data):
'Resume uploading an incomplete file, after a previous upload was interrupted. Returns new file object'
if not hasattr(data, 'read'):
data = six.BytesIO(data)#StringIO(data)
#Check that we actually know from what byte to resume.
#If self.size === -1, ... | [
"def",
"resume",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"hasattr",
"(",
"data",
",",
"'read'",
")",
":",
"data",
"=",
"six",
".",
"BytesIO",
"(",
"data",
")",
"#StringIO(data)",
"#Check that we actually know from what byte to resume.",
"#If self.size =... | Resume uploading an incomplete file, after a previous upload was interrupted. Returns new file object | [
"Resume",
"uploading",
"an",
"incomplete",
"file",
"after",
"a",
"previous",
"upload",
"was",
"interrupted",
".",
"Returns",
"new",
"file",
"object"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L496-L514 |
43,795 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSIncompleteFile.size | def size(self):
"""Bytes uploaded of the file so far.
Note that we only have the file size if the file was requested directly,
not if it's part of a folder listing.
"""
if hasattr(self.f.latestRevision, 'size'):
return int(self.f.latestRevision.size)
return N... | python | def size(self):
"""Bytes uploaded of the file so far.
Note that we only have the file size if the file was requested directly,
not if it's part of a folder listing.
"""
if hasattr(self.f.latestRevision, 'size'):
return int(self.f.latestRevision.size)
return N... | [
"def",
"size",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"f",
".",
"latestRevision",
",",
"'size'",
")",
":",
"return",
"int",
"(",
"self",
".",
"f",
".",
"latestRevision",
".",
"size",
")",
"return",
"None"
] | Bytes uploaded of the file so far.
Note that we only have the file size if the file was requested directly,
not if it's part of a folder listing. | [
"Bytes",
"uploaded",
"of",
"the",
"file",
"so",
"far",
"."
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L517-L525 |
43,796 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFile.stream | def stream(self, chunk_size=64*1024):
'Returns a generator to iterate over the file contents'
#return self.jfs.stream(url='%s?mode=bin' % self.path, chunk_size=chunk_size)
return self.jfs.stream(url=self.path, params={'mode':'bin'}, chunk_size=chunk_size) | python | def stream(self, chunk_size=64*1024):
'Returns a generator to iterate over the file contents'
#return self.jfs.stream(url='%s?mode=bin' % self.path, chunk_size=chunk_size)
return self.jfs.stream(url=self.path, params={'mode':'bin'}, chunk_size=chunk_size) | [
"def",
"stream",
"(",
"self",
",",
"chunk_size",
"=",
"64",
"*",
"1024",
")",
":",
"#return self.jfs.stream(url='%s?mode=bin' % self.path, chunk_size=chunk_size)",
"return",
"self",
".",
"jfs",
".",
"stream",
"(",
"url",
"=",
"self",
".",
"path",
",",
"params",
... | Returns a generator to iterate over the file contents | [
"Returns",
"a",
"generator",
"to",
"iterate",
"over",
"the",
"file",
"contents"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L559-L562 |
43,797 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFile.restore | def restore(self):
'Restore the file'
#
#
# As of 2016-06-15, Jottacloud.com has changed their restore api
# To restore, this is what's done
#
# HTTP POST to https://www.jottacloud.com/web/restore/trash/list
# Data:
# hash:undefined
# ... | python | def restore(self):
'Restore the file'
#
#
# As of 2016-06-15, Jottacloud.com has changed their restore api
# To restore, this is what's done
#
# HTTP POST to https://www.jottacloud.com/web/restore/trash/list
# Data:
# hash:undefined
# ... | [
"def",
"restore",
"(",
"self",
")",
":",
"#",
"#",
"# As of 2016-06-15, Jottacloud.com has changed their restore api",
"# To restore, this is what's done",
"#",
"# HTTP POST to https://www.jottacloud.com/web/restore/trash/list",
"# Data:",
"# hash:undefined",
"# files:@0025d37be5... | Restore the file | [
"Restore",
"the",
"file"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L619-L643 |
43,798 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFile.delete | def delete(self):
'Delete this file and return the new, deleted JFSFile'
#url = '%s?dl=true' % self.path
r = self.jfs.post(url=self.path, params={'dl':'true'})
return r | python | def delete(self):
'Delete this file and return the new, deleted JFSFile'
#url = '%s?dl=true' % self.path
r = self.jfs.post(url=self.path, params={'dl':'true'})
return r | [
"def",
"delete",
"(",
"self",
")",
":",
"#url = '%s?dl=true' % self.path",
"r",
"=",
"self",
".",
"jfs",
".",
"post",
"(",
"url",
"=",
"self",
".",
"path",
",",
"params",
"=",
"{",
"'dl'",
":",
"'true'",
"}",
")",
"return",
"r"
] | Delete this file and return the new, deleted JFSFile | [
"Delete",
"this",
"file",
"and",
"return",
"the",
"new",
"deleted",
"JFSFile"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L655-L659 |
43,799 | havardgulldahl/jottalib | src/jottalib/JFS.py | JFSFile.thumb | def thumb(self, size=BIGTHUMB):
'''Get a thumbnail as string or None if the file isnt an image
size would be one of JFSFile.BIGTHUMB, .MEDIUMTHUMB, .SMALLTHUMB or .XLTHUMB'''
if not self.is_image():
return None
if not size in (self.BIGTHUMB, self.MEDIUMTHUMB, self.SMALLTHUMB... | python | def thumb(self, size=BIGTHUMB):
'''Get a thumbnail as string or None if the file isnt an image
size would be one of JFSFile.BIGTHUMB, .MEDIUMTHUMB, .SMALLTHUMB or .XLTHUMB'''
if not self.is_image():
return None
if not size in (self.BIGTHUMB, self.MEDIUMTHUMB, self.SMALLTHUMB... | [
"def",
"thumb",
"(",
"self",
",",
"size",
"=",
"BIGTHUMB",
")",
":",
"if",
"not",
"self",
".",
"is_image",
"(",
")",
":",
"return",
"None",
"if",
"not",
"size",
"in",
"(",
"self",
".",
"BIGTHUMB",
",",
"self",
".",
"MEDIUMTHUMB",
",",
"self",
".",
... | Get a thumbnail as string or None if the file isnt an image
size would be one of JFSFile.BIGTHUMB, .MEDIUMTHUMB, .SMALLTHUMB or .XLTHUMB | [
"Get",
"a",
"thumbnail",
"as",
"string",
"or",
"None",
"if",
"the",
"file",
"isnt",
"an",
"image"
] | 4d015e4309b1d9055e561ec757363fb2632b4eb7 | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L670-L680 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.