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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
miyakogi/wdom
wdom/window.py
CustomElementsRegistry.define
def define(self, *args: Any, **kwargs: Any) -> None: """Add new custom element.""" if isinstance(args[0], str): self._define_orig(*args, **kwargs) elif isinstance(args[0], type): self._define_class(*args, **kwargs) else: raise TypeError( ...
python
def define(self, *args: Any, **kwargs: Any) -> None: """Add new custom element.""" if isinstance(args[0], str): self._define_orig(*args, **kwargs) elif isinstance(args[0], type): self._define_class(*args, **kwargs) else: raise TypeError( ...
[ "def", "define", "(", "self", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "if", "isinstance", "(", "args", "[", "0", "]", ",", "str", ")", ":", "self", ".", "_define_orig", "(", "*", "args", ",", ...
Add new custom element.
[ "Add", "new", "custom", "element", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/window.py#L75-L83
train
60,600
miyakogi/wdom
wdom/server/handler.py
event_handler
def event_handler(msg: EventMsgDict) -> Event: """Handle events emitted on browser.""" e = create_event_from_msg(msg) if e.currentTarget is None: if e.type not in ['mount', 'unmount']: id = msg['currentTarget']['id'] logger.warning('No such element: wdom_id={}'.format(id)) ...
python
def event_handler(msg: EventMsgDict) -> Event: """Handle events emitted on browser.""" e = create_event_from_msg(msg) if e.currentTarget is None: if e.type not in ['mount', 'unmount']: id = msg['currentTarget']['id'] logger.warning('No such element: wdom_id={}'.format(id)) ...
[ "def", "event_handler", "(", "msg", ":", "EventMsgDict", ")", "->", "Event", ":", "e", "=", "create_event_from_msg", "(", "msg", ")", "if", "e", ".", "currentTarget", "is", "None", ":", "if", "e", ".", "type", "not", "in", "[", "'mount'", ",", "'unmoun...
Handle events emitted on browser.
[ "Handle", "events", "emitted", "on", "browser", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/handler.py#L49-L59
train
60,601
miyakogi/wdom
wdom/server/handler.py
response_handler
def response_handler(msg: Dict[str, str]) -> None: """Handle response sent by browser.""" from wdom.document import getElementByWdomId id = msg['id'] elm = getElementByWdomId(id) if elm: elm.on_response(msg) else: logger.warning('No such element: wdom_id={}'.format(id))
python
def response_handler(msg: Dict[str, str]) -> None: """Handle response sent by browser.""" from wdom.document import getElementByWdomId id = msg['id'] elm = getElementByWdomId(id) if elm: elm.on_response(msg) else: logger.warning('No such element: wdom_id={}'.format(id))
[ "def", "response_handler", "(", "msg", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "None", ":", "from", "wdom", ".", "document", "import", "getElementByWdomId", "id", "=", "msg", "[", "'id'", "]", "elm", "=", "getElementByWdomId", "(", "id", "...
Handle response sent by browser.
[ "Handle", "response", "sent", "by", "browser", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/handler.py#L62-L70
train
60,602
miyakogi/wdom
wdom/server/handler.py
on_websocket_message
def on_websocket_message(message: str) -> None: """Handle messages from browser.""" msgs = json.loads(message) for msg in msgs: if not isinstance(msg, dict): logger.error('Invalid WS message format: {}'.format(message)) continue _type = msg.get('type') if _typ...
python
def on_websocket_message(message: str) -> None: """Handle messages from browser.""" msgs = json.loads(message) for msg in msgs: if not isinstance(msg, dict): logger.error('Invalid WS message format: {}'.format(message)) continue _type = msg.get('type') if _typ...
[ "def", "on_websocket_message", "(", "message", ":", "str", ")", "->", "None", ":", "msgs", "=", "json", ".", "loads", "(", "message", ")", "for", "msg", "in", "msgs", ":", "if", "not", "isinstance", "(", "msg", ",", "dict", ")", ":", "logger", ".", ...
Handle messages from browser.
[ "Handle", "messages", "from", "browser", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/handler.py#L73-L88
train
60,603
miyakogi/wdom
wdom/parser.py
parse_html
def parse_html(html: str, parser: FragmentParser = None) -> Node: """Parse HTML fragment and return DocumentFragment object. DocumentFragment object has parsed Node objects as its child nodes. """ parser = parser or FragmentParser() parser.feed(html) return parser.root
python
def parse_html(html: str, parser: FragmentParser = None) -> Node: """Parse HTML fragment and return DocumentFragment object. DocumentFragment object has parsed Node objects as its child nodes. """ parser = parser or FragmentParser() parser.feed(html) return parser.root
[ "def", "parse_html", "(", "html", ":", "str", ",", "parser", ":", "FragmentParser", "=", "None", ")", "->", "Node", ":", "parser", "=", "parser", "or", "FragmentParser", "(", ")", "parser", ".", "feed", "(", "html", ")", "return", "parser", ".", "root"...
Parse HTML fragment and return DocumentFragment object. DocumentFragment object has parsed Node objects as its child nodes.
[ "Parse", "HTML", "fragment", "and", "return", "DocumentFragment", "object", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/parser.py#L68-L75
train
60,604
miyakogi/wdom
wdom/element.py
getElementsBy
def getElementsBy(start_node: ParentNode, cond: Callable[['Element'], bool]) -> NodeList: """Return list of child elements of start_node which matches ``cond``. ``cond`` must be a function which gets a single argument ``Element``, and returns boolean. If the node matches requested conditi...
python
def getElementsBy(start_node: ParentNode, cond: Callable[['Element'], bool]) -> NodeList: """Return list of child elements of start_node which matches ``cond``. ``cond`` must be a function which gets a single argument ``Element``, and returns boolean. If the node matches requested conditi...
[ "def", "getElementsBy", "(", "start_node", ":", "ParentNode", ",", "cond", ":", "Callable", "[", "[", "'Element'", "]", ",", "bool", "]", ")", "->", "NodeList", ":", "elements", "=", "[", "]", "for", "child", "in", "start_node", ".", "children", ":", "...
Return list of child elements of start_node which matches ``cond``. ``cond`` must be a function which gets a single argument ``Element``, and returns boolean. If the node matches requested condition, ``cond`` should return True. This searches all child elements recursively. :arg ParentNode start_n...
[ "Return", "list", "of", "child", "elements", "of", "start_node", "which", "matches", "cond", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L375-L393
train
60,605
miyakogi/wdom
wdom/element.py
getElementsByTagName
def getElementsByTagName(start_node: ParentNode, tag: str) -> NodeList: """Get child nodes which tag name is ``tag``.""" _tag = tag.upper() return getElementsBy(start_node, lambda node: node.tagName == _tag)
python
def getElementsByTagName(start_node: ParentNode, tag: str) -> NodeList: """Get child nodes which tag name is ``tag``.""" _tag = tag.upper() return getElementsBy(start_node, lambda node: node.tagName == _tag)
[ "def", "getElementsByTagName", "(", "start_node", ":", "ParentNode", ",", "tag", ":", "str", ")", "->", "NodeList", ":", "_tag", "=", "tag", ".", "upper", "(", ")", "return", "getElementsBy", "(", "start_node", ",", "lambda", "node", ":", "node", ".", "t...
Get child nodes which tag name is ``tag``.
[ "Get", "child", "nodes", "which", "tag", "name", "is", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L396-L399
train
60,606
miyakogi/wdom
wdom/element.py
getElementsByClassName
def getElementsByClassName(start_node: ParentNode, class_name: str ) -> NodeList: """Get child nodes which has ``class_name`` class attribute.""" classes = set(class_name.split(' ')) return getElementsBy( start_node, lambda node: classes.issubset(set(node.classList...
python
def getElementsByClassName(start_node: ParentNode, class_name: str ) -> NodeList: """Get child nodes which has ``class_name`` class attribute.""" classes = set(class_name.split(' ')) return getElementsBy( start_node, lambda node: classes.issubset(set(node.classList...
[ "def", "getElementsByClassName", "(", "start_node", ":", "ParentNode", ",", "class_name", ":", "str", ")", "->", "NodeList", ":", "classes", "=", "set", "(", "class_name", ".", "split", "(", "' '", ")", ")", "return", "getElementsBy", "(", "start_node", ",",...
Get child nodes which has ``class_name`` class attribute.
[ "Get", "child", "nodes", "which", "has", "class_name", "class", "attribute", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L402-L409
train
60,607
miyakogi/wdom
wdom/element.py
DOMTokenList.add
def add(self, *tokens: str) -> None: """Add new tokens to list.""" from wdom.web_node import WdomElement _new_tokens = [] for token in tokens: self._validate_token(token) if token and token not in self: self._list.append(token) _new...
python
def add(self, *tokens: str) -> None: """Add new tokens to list.""" from wdom.web_node import WdomElement _new_tokens = [] for token in tokens: self._validate_token(token) if token and token not in self: self._list.append(token) _new...
[ "def", "add", "(", "self", ",", "*", "tokens", ":", "str", ")", "->", "None", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "_new_tokens", "=", "[", "]", "for", "token", "in", "tokens", ":", "self", ".", "_validate_token", "(", "token"...
Add new tokens to list.
[ "Add", "new", "tokens", "to", "list", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L93-L103
train
60,608
miyakogi/wdom
wdom/element.py
DOMTokenList.remove
def remove(self, *tokens: str) -> None: """Remove tokens from list.""" from wdom.web_node import WdomElement _removed_tokens = [] for token in tokens: self._validate_token(token) if token in self: self._list.remove(token) _removed_t...
python
def remove(self, *tokens: str) -> None: """Remove tokens from list.""" from wdom.web_node import WdomElement _removed_tokens = [] for token in tokens: self._validate_token(token) if token in self: self._list.remove(token) _removed_t...
[ "def", "remove", "(", "self", ",", "*", "tokens", ":", "str", ")", "->", "None", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "_removed_tokens", "=", "[", "]", "for", "token", "in", "tokens", ":", "self", ".", "_validate_token", "(", ...
Remove tokens from list.
[ "Remove", "tokens", "from", "list", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L105-L115
train
60,609
miyakogi/wdom
wdom/element.py
DOMTokenList.contains
def contains(self, token: str) -> bool: """Return if the token is in the list or not.""" self._validate_token(token) return token in self
python
def contains(self, token: str) -> bool: """Return if the token is in the list or not.""" self._validate_token(token) return token in self
[ "def", "contains", "(", "self", ",", "token", ":", "str", ")", "->", "bool", ":", "self", ".", "_validate_token", "(", "token", ")", "return", "token", "in", "self" ]
Return if the token is in the list or not.
[ "Return", "if", "the", "token", "is", "in", "the", "list", "or", "not", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L141-L144
train
60,610
miyakogi/wdom
wdom/element.py
Attr.html
def html(self) -> str: """Return string representation of this. Used in start tag of HTML representation of the Element node. """ if self._owner and self.name in self._owner._special_attr_boolean: return self.name else: value = self.value if i...
python
def html(self) -> str: """Return string representation of this. Used in start tag of HTML representation of the Element node. """ if self._owner and self.name in self._owner._special_attr_boolean: return self.name else: value = self.value if i...
[ "def", "html", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_owner", "and", "self", ".", "name", "in", "self", ".", "_owner", ".", "_special_attr_boolean", ":", "return", "self", ".", "name", "else", ":", "value", "=", "self", ".", "value"...
Return string representation of this. Used in start tag of HTML representation of the Element node.
[ "Return", "string", "representation", "of", "this", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L175-L186
train
60,611
miyakogi/wdom
wdom/element.py
DraggableAttr.html
def html(self) -> str: """Return html representation.""" if isinstance(self.value, bool): val = 'true' if self.value else 'false' else: val = str(self.value) return 'draggable="{}"'.format(val)
python
def html(self) -> str: """Return html representation.""" if isinstance(self.value, bool): val = 'true' if self.value else 'false' else: val = str(self.value) return 'draggable="{}"'.format(val)
[ "def", "html", "(", "self", ")", "->", "str", ":", "if", "isinstance", "(", "self", ".", "value", ",", "bool", ")", ":", "val", "=", "'true'", "if", "self", ".", "value", "else", "'false'", "else", ":", "val", "=", "str", "(", "self", ".", "value...
Return html representation.
[ "Return", "html", "representation", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L212-L218
train
60,612
miyakogi/wdom
wdom/element.py
NamedNodeMap.getNamedItem
def getNamedItem(self, name: str) -> Optional[Attr]: """Get ``Attr`` object which has ``name``. If does not have ``name`` attr, return None. """ return self._dict.get(name, None)
python
def getNamedItem(self, name: str) -> Optional[Attr]: """Get ``Attr`` object which has ``name``. If does not have ``name`` attr, return None. """ return self._dict.get(name, None)
[ "def", "getNamedItem", "(", "self", ",", "name", ":", "str", ")", "->", "Optional", "[", "Attr", "]", ":", "return", "self", ".", "_dict", ".", "get", "(", "name", ",", "None", ")" ]
Get ``Attr`` object which has ``name``. If does not have ``name`` attr, return None.
[ "Get", "Attr", "object", "which", "has", "name", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L258-L263
train
60,613
miyakogi/wdom
wdom/element.py
NamedNodeMap.setNamedItem
def setNamedItem(self, item: Attr) -> None: """Set ``Attr`` object in this collection.""" from wdom.web_node import WdomElement if not isinstance(item, Attr): raise TypeError('item must be an instance of Attr') if isinstance(self._owner, WdomElement): self._owner....
python
def setNamedItem(self, item: Attr) -> None: """Set ``Attr`` object in this collection.""" from wdom.web_node import WdomElement if not isinstance(item, Attr): raise TypeError('item must be an instance of Attr') if isinstance(self._owner, WdomElement): self._owner....
[ "def", "setNamedItem", "(", "self", ",", "item", ":", "Attr", ")", "->", "None", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "if", "not", "isinstance", "(", "item", ",", "Attr", ")", ":", "raise", "TypeError", "(", "'item must be an inst...
Set ``Attr`` object in this collection.
[ "Set", "Attr", "object", "in", "this", "collection", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L265-L274
train
60,614
miyakogi/wdom
wdom/element.py
NamedNodeMap.item
def item(self, index: int) -> Optional[Attr]: """Return ``index``-th attr node.""" if 0 <= index < len(self): return self._dict[tuple(self._dict.keys())[index]] return None
python
def item(self, index: int) -> Optional[Attr]: """Return ``index``-th attr node.""" if 0 <= index < len(self): return self._dict[tuple(self._dict.keys())[index]] return None
[ "def", "item", "(", "self", ",", "index", ":", "int", ")", "->", "Optional", "[", "Attr", "]", ":", "if", "0", "<=", "index", "<", "len", "(", "self", ")", ":", "return", "self", ".", "_dict", "[", "tuple", "(", "self", ".", "_dict", ".", "keys...
Return ``index``-th attr node.
[ "Return", "index", "-", "th", "attr", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L288-L292
train
60,615
miyakogi/wdom
wdom/element.py
NamedNodeMap.toString
def toString(self) -> str: """Return string representation of collections.""" return ' '.join(attr.html for attr in self._dict.values())
python
def toString(self) -> str: """Return string representation of collections.""" return ' '.join(attr.html for attr in self._dict.values())
[ "def", "toString", "(", "self", ")", "->", "str", ":", "return", "' '", ".", "join", "(", "attr", ".", "html", "for", "attr", "in", "self", ".", "_dict", ".", "values", "(", ")", ")" ]
Return string representation of collections.
[ "Return", "string", "representation", "of", "collections", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L294-L296
train
60,616
miyakogi/wdom
wdom/element.py
Element.start_tag
def start_tag(self) -> str: """Return HTML start tag.""" tag = '<' + self.tag attrs = self._get_attrs_by_string() if attrs: tag = ' '.join((tag, attrs)) return tag + '>'
python
def start_tag(self) -> str: """Return HTML start tag.""" tag = '<' + self.tag attrs = self._get_attrs_by_string() if attrs: tag = ' '.join((tag, attrs)) return tag + '>'
[ "def", "start_tag", "(", "self", ")", "->", "str", ":", "tag", "=", "'<'", "+", "self", ".", "tag", "attrs", "=", "self", ".", "_get_attrs_by_string", "(", ")", "if", "attrs", ":", "tag", "=", "' '", ".", "join", "(", "(", "tag", ",", "attrs", ")...
Return HTML start tag.
[ "Return", "HTML", "start", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L480-L486
train
60,617
miyakogi/wdom
wdom/element.py
Element.insertAdjacentHTML
def insertAdjacentHTML(self, position: str, html: str) -> None: """Parse ``html`` to DOM and insert to ``position``. ``position`` is a case-insensive string, and must be one of "beforeBegin", "afterBegin", "beforeEnd", or "afterEnd". """ df = self._parse_html(html) pos =...
python
def insertAdjacentHTML(self, position: str, html: str) -> None: """Parse ``html`` to DOM and insert to ``position``. ``position`` is a case-insensive string, and must be one of "beforeBegin", "afterBegin", "beforeEnd", or "afterEnd". """ df = self._parse_html(html) pos =...
[ "def", "insertAdjacentHTML", "(", "self", ",", "position", ":", "str", ",", "html", ":", "str", ")", "->", "None", ":", "df", "=", "self", ".", "_parse_html", "(", "html", ")", "pos", "=", "position", ".", "lower", "(", ")", "if", "pos", "==", "'be...
Parse ``html`` to DOM and insert to ``position``. ``position`` is a case-insensive string, and must be one of "beforeBegin", "afterBegin", "beforeEnd", or "afterEnd".
[ "Parse", "html", "to", "DOM", "and", "insert", "to", "position", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L523-L543
train
60,618
miyakogi/wdom
wdom/element.py
Element.getAttribute
def getAttribute(self, attr: str) -> _AttrValueType: """Get attribute of this node as string format. If this node does not have ``attr``, return None. """ if attr == 'class': if self.classList: return self.classList.toString() return None ...
python
def getAttribute(self, attr: str) -> _AttrValueType: """Get attribute of this node as string format. If this node does not have ``attr``, return None. """ if attr == 'class': if self.classList: return self.classList.toString() return None ...
[ "def", "getAttribute", "(", "self", ",", "attr", ":", "str", ")", "->", "_AttrValueType", ":", "if", "attr", "==", "'class'", ":", "if", "self", ".", "classList", ":", "return", "self", ".", "classList", ".", "toString", "(", ")", "return", "None", "at...
Get attribute of this node as string format. If this node does not have ``attr``, return None.
[ "Get", "attribute", "of", "this", "node", "as", "string", "format", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L579-L591
train
60,619
miyakogi/wdom
wdom/element.py
Element.getAttributeNode
def getAttributeNode(self, attr: str) -> Optional[Attr]: """Get attribute of this node as Attr format. If this node does not have ``attr``, return None. """ return self.attributes.getNamedItem(attr)
python
def getAttributeNode(self, attr: str) -> Optional[Attr]: """Get attribute of this node as Attr format. If this node does not have ``attr``, return None. """ return self.attributes.getNamedItem(attr)
[ "def", "getAttributeNode", "(", "self", ",", "attr", ":", "str", ")", "->", "Optional", "[", "Attr", "]", ":", "return", "self", ".", "attributes", ".", "getNamedItem", "(", "attr", ")" ]
Get attribute of this node as Attr format. If this node does not have ``attr``, return None.
[ "Get", "attribute", "of", "this", "node", "as", "Attr", "format", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L593-L598
train
60,620
miyakogi/wdom
wdom/element.py
Element.hasAttribute
def hasAttribute(self, attr: str) -> bool: """Return True if this node has ``attr``.""" if attr == 'class': return bool(self.classList) return attr in self.attributes
python
def hasAttribute(self, attr: str) -> bool: """Return True if this node has ``attr``.""" if attr == 'class': return bool(self.classList) return attr in self.attributes
[ "def", "hasAttribute", "(", "self", ",", "attr", ":", "str", ")", "->", "bool", ":", "if", "attr", "==", "'class'", ":", "return", "bool", "(", "self", ".", "classList", ")", "return", "attr", "in", "self", ".", "attributes" ]
Return True if this node has ``attr``.
[ "Return", "True", "if", "this", "node", "has", "attr", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L600-L604
train
60,621
miyakogi/wdom
wdom/element.py
Element.setAttribute
def setAttribute(self, attr: str, value: _AttrValueType) -> None: """Set ``attr`` and ``value`` in this node.""" self._set_attribute(attr, value)
python
def setAttribute(self, attr: str, value: _AttrValueType) -> None: """Set ``attr`` and ``value`` in this node.""" self._set_attribute(attr, value)
[ "def", "setAttribute", "(", "self", ",", "attr", ":", "str", ",", "value", ":", "_AttrValueType", ")", "->", "None", ":", "self", ".", "_set_attribute", "(", "attr", ",", "value", ")" ]
Set ``attr`` and ``value`` in this node.
[ "Set", "attr", "and", "value", "in", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L646-L648
train
60,622
miyakogi/wdom
wdom/element.py
Element.removeAttributeNode
def removeAttributeNode(self, attr: Attr) -> Optional[Attr]: """Remove ``Attr`` node from this node.""" return self.attributes.removeNamedItem(attr)
python
def removeAttributeNode(self, attr: Attr) -> Optional[Attr]: """Remove ``Attr`` node from this node.""" return self.attributes.removeNamedItem(attr)
[ "def", "removeAttributeNode", "(", "self", ",", "attr", ":", "Attr", ")", "->", "Optional", "[", "Attr", "]", ":", "return", "self", ".", "attributes", ".", "removeNamedItem", "(", "attr", ")" ]
Remove ``Attr`` node from this node.
[ "Remove", "Attr", "node", "from", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L668-L670
train
60,623
miyakogi/wdom
wdom/element.py
HTMLElement.style
def style(self, style: _AttrValueType) -> None: """Set style attribute of this node. If argument ``style`` is string, it will be parsed to ``CSSStyleDeclaration``. """ if isinstance(style, str): self.__style._parse_str(style) elif style is None: s...
python
def style(self, style: _AttrValueType) -> None: """Set style attribute of this node. If argument ``style`` is string, it will be parsed to ``CSSStyleDeclaration``. """ if isinstance(style, str): self.__style._parse_str(style) elif style is None: s...
[ "def", "style", "(", "self", ",", "style", ":", "_AttrValueType", ")", "->", "None", ":", "if", "isinstance", "(", "style", ",", "str", ")", ":", "self", ".", "__style", ".", "_parse_str", "(", "style", ")", "elif", "style", "is", "None", ":", "self"...
Set style attribute of this node. If argument ``style`` is string, it will be parsed to ``CSSStyleDeclaration``.
[ "Set", "style", "attribute", "of", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L735-L756
train
60,624
miyakogi/wdom
wdom/element.py
HTMLElement.draggable
def draggable(self) -> Union[bool, str]: """Get ``draggable`` property.""" if not self.hasAttribute('draggable'): return False return self.getAttribute('draggable')
python
def draggable(self) -> Union[bool, str]: """Get ``draggable`` property.""" if not self.hasAttribute('draggable'): return False return self.getAttribute('draggable')
[ "def", "draggable", "(", "self", ")", "->", "Union", "[", "bool", ",", "str", "]", ":", "if", "not", "self", ".", "hasAttribute", "(", "'draggable'", ")", ":", "return", "False", "return", "self", ".", "getAttribute", "(", "'draggable'", ")" ]
Get ``draggable`` property.
[ "Get", "draggable", "property", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L759-L763
train
60,625
miyakogi/wdom
wdom/element.py
HTMLElement.draggable
def draggable(self, value: Union[bool, str]) -> None: """Set ``draggable`` property. ``value`` is boolean or string. """ if value is False: self.removeAttribute('draggable') else: self.setAttribute('draggable', value)
python
def draggable(self, value: Union[bool, str]) -> None: """Set ``draggable`` property. ``value`` is boolean or string. """ if value is False: self.removeAttribute('draggable') else: self.setAttribute('draggable', value)
[ "def", "draggable", "(", "self", ",", "value", ":", "Union", "[", "bool", ",", "str", "]", ")", "->", "None", ":", "if", "value", "is", "False", ":", "self", ".", "removeAttribute", "(", "'draggable'", ")", "else", ":", "self", ".", "setAttribute", "...
Set ``draggable`` property. ``value`` is boolean or string.
[ "Set", "draggable", "property", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L766-L774
train
60,626
miyakogi/wdom
wdom/element.py
FormControlMixin.form
def form(self) -> Optional['HTMLFormElement']: """Get ``HTMLFormElement`` object related to this node.""" if self.__form: return self.__form parent = self.parentNode while parent: if isinstance(parent, HTMLFormElement): return parent el...
python
def form(self) -> Optional['HTMLFormElement']: """Get ``HTMLFormElement`` object related to this node.""" if self.__form: return self.__form parent = self.parentNode while parent: if isinstance(parent, HTMLFormElement): return parent el...
[ "def", "form", "(", "self", ")", "->", "Optional", "[", "'HTMLFormElement'", "]", ":", "if", "self", ".", "__form", ":", "return", "self", ".", "__form", "parent", "=", "self", ".", "parentNode", "while", "parent", ":", "if", "isinstance", "(", "parent",...
Get ``HTMLFormElement`` object related to this node.
[ "Get", "HTMLFormElement", "object", "related", "to", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L818-L828
train
60,627
miyakogi/wdom
wdom/element.py
HTMLLabelElement.control
def control(self) -> Optional[HTMLElement]: """Return related HTMLElement object.""" id = self.getAttribute('for') if id: if self.ownerDocument: return self.ownerDocument.getElementById(id) elif isinstance(id, str): from wdom.document impor...
python
def control(self) -> Optional[HTMLElement]: """Return related HTMLElement object.""" id = self.getAttribute('for') if id: if self.ownerDocument: return self.ownerDocument.getElementById(id) elif isinstance(id, str): from wdom.document impor...
[ "def", "control", "(", "self", ")", "->", "Optional", "[", "HTMLElement", "]", ":", "id", "=", "self", ".", "getAttribute", "(", "'for'", ")", "if", "id", ":", "if", "self", ".", "ownerDocument", ":", "return", "self", ".", "ownerDocument", ".", "getEl...
Return related HTMLElement object.
[ "Return", "related", "HTMLElement", "object", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L933-L944
train
60,628
miyakogi/wdom
wdom/element.py
HTMLSelectElement.selectedOptions
def selectedOptions(self) -> NodeList: """Return all selected option nodes.""" return NodeList(list(opt for opt in self.options if opt.selected))
python
def selectedOptions(self) -> NodeList: """Return all selected option nodes.""" return NodeList(list(opt for opt in self.options if opt.selected))
[ "def", "selectedOptions", "(", "self", ")", "->", "NodeList", ":", "return", "NodeList", "(", "list", "(", "opt", "for", "opt", "in", "self", ".", "options", "if", "opt", ".", "selected", ")", ")" ]
Return all selected option nodes.
[ "Return", "all", "selected", "option", "nodes", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L1005-L1007
train
60,629
miyakogi/wdom
wdom/tag.py
NewTagClass
def NewTagClass(class_name: str, tag: str = None, bases: Union[type, Iterable] = (Tag, ), **kwargs: Any) -> type: """Generate and return new ``Tag`` class. If ``tag`` is empty, lower case of ``class_name`` is used for a tag name of the new class. ``bases`` should be a tuple ...
python
def NewTagClass(class_name: str, tag: str = None, bases: Union[type, Iterable] = (Tag, ), **kwargs: Any) -> type: """Generate and return new ``Tag`` class. If ``tag`` is empty, lower case of ``class_name`` is used for a tag name of the new class. ``bases`` should be a tuple ...
[ "def", "NewTagClass", "(", "class_name", ":", "str", ",", "tag", ":", "str", "=", "None", ",", "bases", ":", "Union", "[", "type", ",", "Iterable", "]", "=", "(", "Tag", ",", ")", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "type", ":", "if...
Generate and return new ``Tag`` class. If ``tag`` is empty, lower case of ``class_name`` is used for a tag name of the new class. ``bases`` should be a tuple of base classes. If it is empty, use ``Tag`` class for a base class. Other keyword arguments are used for class variables of the new class. ...
[ "Generate", "and", "return", "new", "Tag", "class", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L170-L203
train
60,630
miyakogi/wdom
wdom/tag.py
Tag._clone_node
def _clone_node(self) -> 'Tag': """Need to copy class, not tag. So need to re-implement copy. """ clone = type(self)() for attr in self.attributes: clone.setAttribute(attr, self.getAttribute(attr)) for c in self.classList: clone.addClass(c) ...
python
def _clone_node(self) -> 'Tag': """Need to copy class, not tag. So need to re-implement copy. """ clone = type(self)() for attr in self.attributes: clone.setAttribute(attr, self.getAttribute(attr)) for c in self.classList: clone.addClass(c) ...
[ "def", "_clone_node", "(", "self", ")", "->", "'Tag'", ":", "clone", "=", "type", "(", "self", ")", "(", ")", "for", "attr", "in", "self", ".", "attributes", ":", "clone", ".", "setAttribute", "(", "attr", ",", "self", ".", "getAttribute", "(", "attr...
Need to copy class, not tag. So need to re-implement copy.
[ "Need", "to", "copy", "class", "not", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L63-L75
train
60,631
miyakogi/wdom
wdom/tag.py
NestedTag.textContent
def textContent(self, text: str) -> None: # type: ignore """Set text content to inner node.""" if self._inner_element: self._inner_element.textContent = text else: # Need a trick to call property of super-class super().textContent = text
python
def textContent(self, text: str) -> None: # type: ignore """Set text content to inner node.""" if self._inner_element: self._inner_element.textContent = text else: # Need a trick to call property of super-class super().textContent = text
[ "def", "textContent", "(", "self", ",", "text", ":", "str", ")", "->", "None", ":", "# type: ignore", "if", "self", ".", "_inner_element", ":", "self", ".", "_inner_element", ".", "textContent", "=", "text", "else", ":", "# Need a trick to call property of super...
Set text content to inner node.
[ "Set", "text", "content", "to", "inner", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L139-L145
train
60,632
miyakogi/wdom
wdom/tag.py
NestedTag.html
def html(self) -> str: """Get whole html representation of this node.""" if self._inner_element: return self.start_tag + self._inner_element.html + self.end_tag return super().html
python
def html(self) -> str: """Get whole html representation of this node.""" if self._inner_element: return self.start_tag + self._inner_element.html + self.end_tag return super().html
[ "def", "html", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_inner_element", ":", "return", "self", ".", "start_tag", "+", "self", ".", "_inner_element", ".", "html", "+", "self", ".", "end_tag", "return", "super", "(", ")", ".", "html" ]
Get whole html representation of this node.
[ "Get", "whole", "html", "representation", "of", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L148-L152
train
60,633
miyakogi/wdom
wdom/tag.py
NestedTag.innerHTML
def innerHTML(self) -> str: """Get innerHTML of the inner node.""" if self._inner_element: return self._inner_element.innerHTML return super().innerHTML
python
def innerHTML(self) -> str: """Get innerHTML of the inner node.""" if self._inner_element: return self._inner_element.innerHTML return super().innerHTML
[ "def", "innerHTML", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_inner_element", ":", "return", "self", ".", "_inner_element", ".", "innerHTML", "return", "super", "(", ")", ".", "innerHTML" ]
Get innerHTML of the inner node.
[ "Get", "innerHTML", "of", "the", "inner", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L155-L159
train
60,634
miyakogi/wdom
wdom/server/_tornado.py
MainHandler.get
def get(self) -> None: """Return whole html representation of the root document.""" from wdom.document import get_document logger.info('connected') self.write(get_document().build())
python
def get(self) -> None: """Return whole html representation of the root document.""" from wdom.document import get_document logger.info('connected') self.write(get_document().build())
[ "def", "get", "(", "self", ")", "->", "None", ":", "from", "wdom", ".", "document", "import", "get_document", "logger", ".", "info", "(", "'connected'", ")", "self", ".", "write", "(", "get_document", "(", ")", ".", "build", "(", ")", ")" ]
Return whole html representation of the root document.
[ "Return", "whole", "html", "representation", "of", "the", "root", "document", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L35-L39
train
60,635
miyakogi/wdom
wdom/server/_tornado.py
WSHandler.terminate
async def terminate(self) -> None: """Terminate server if no more connection exists.""" await asyncio.sleep(config.shutdown_wait) # stop server and close loop if no more connection exists if not is_connected(): stop_server(self.application.server) self.application...
python
async def terminate(self) -> None: """Terminate server if no more connection exists.""" await asyncio.sleep(config.shutdown_wait) # stop server and close loop if no more connection exists if not is_connected(): stop_server(self.application.server) self.application...
[ "async", "def", "terminate", "(", "self", ")", "->", "None", ":", "await", "asyncio", ".", "sleep", "(", "config", ".", "shutdown_wait", ")", "# stop server and close loop if no more connection exists", "if", "not", "is_connected", "(", ")", ":", "stop_server", "(...
Terminate server if no more connection exists.
[ "Terminate", "server", "if", "no", "more", "connection", "exists", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L54-L60
train
60,636
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
train
60,637
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
train
60,638
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
train
60,639
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
train
60,640
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
train
60,641
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
train
60,642
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
train
60,643
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
train
60,644
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
train
60,645
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
train
60,646
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
train
60,647
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
train
60,648
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
train
60,649
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
train
60,650
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
train
60,651
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
train
60,652
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
train
60,653
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
train
60,654
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
train
60,655
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
train
60,656
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
train
60,657
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
train
60,658
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
train
60,659
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
train
60,660
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
train
60,661
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
train
60,662
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
train
60,663
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
train
60,664
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
train
60,665
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
train
60,666
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
train
60,667
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
train
60,668
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
train
60,669
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
train
60,670
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
train
60,671
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
train
60,672
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
train
60,673
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
train
60,674
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
train
60,675
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
train
60,676
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
train
60,677
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
train
60,678
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
train
60,679
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
train
60,680
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
train
60,681
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
train
60,682
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
train
60,683
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
train
60,684
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
train
60,685
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
train
60,686
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
train
60,687
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
train
60,688
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
train
60,689
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
train
60,690
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
train
60,691
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
train
60,692
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
train
60,693
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
train
60,694
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
train
60,695
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
train
60,696
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
train
60,697
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
train
60,698
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
train
60,699