id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
245,000
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.dc_element
def dc_element(self, parent, name, text): """Add DC element `name` containing `text` to `parent`.""" if self.dc_uri in self.namespaces: dcel = SchemaNode(self.namespaces[self.dc_uri] + ":" + name, text=text) parent.children.insert(0,dcel)
python
def dc_element(self, parent, name, text): if self.dc_uri in self.namespaces: dcel = SchemaNode(self.namespaces[self.dc_uri] + ":" + name, text=text) parent.children.insert(0,dcel)
[ "def", "dc_element", "(", "self", ",", "parent", ",", "name", ",", "text", ")", ":", "if", "self", ".", "dc_uri", "in", "self", ".", "namespaces", ":", "dcel", "=", "SchemaNode", "(", "self", ".", "namespaces", "[", "self", ".", "dc_uri", "]", "+", ...
Add DC element `name` containing `text` to `parent`.
[ "Add", "DC", "element", "name", "containing", "text", "to", "parent", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L557-L562
245,001
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.get_default
def get_default(self, stmt, refd): """Return default value for `stmt` node. `refd` is a dictionary of applicable refinements that is constructed in the `process_patches` method. """ if refd["default"]: return refd["default"] defst = stmt.search_one("defau...
python
def get_default(self, stmt, refd): if refd["default"]: return refd["default"] defst = stmt.search_one("default") if defst: return defst.arg return None
[ "def", "get_default", "(", "self", ",", "stmt", ",", "refd", ")", ":", "if", "refd", "[", "\"default\"", "]", ":", "return", "refd", "[", "\"default\"", "]", "defst", "=", "stmt", ".", "search_one", "(", "\"default\"", ")", "if", "defst", ":", "return"...
Return default value for `stmt` node. `refd` is a dictionary of applicable refinements that is constructed in the `process_patches` method.
[ "Return", "default", "value", "for", "stmt", "node", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L564-L575
245,002
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.add_patch
def add_patch(self, pset, augref): """Add patch corresponding to `augref` to `pset`. `augref` must be either 'augment' or 'refine' statement. """ try: path = [ self.add_prefix(c, augref) for c in augref.arg.split("/") if c ] except KeyError: ...
python
def add_patch(self, pset, augref): try: path = [ self.add_prefix(c, augref) for c in augref.arg.split("/") if c ] except KeyError: # augment of a module that's not among input modules return car = path[0] patch = Patch(path[1:], au...
[ "def", "add_patch", "(", "self", ",", "pset", ",", "augref", ")", ":", "try", ":", "path", "=", "[", "self", ".", "add_prefix", "(", "c", ",", "augref", ")", "for", "c", "in", "augref", ".", "arg", ".", "split", "(", "\"/\"", ")", "if", "c", "]...
Add patch corresponding to `augref` to `pset`. `augref` must be either 'augment' or 'refine' statement.
[ "Add", "patch", "corresponding", "to", "augref", "to", "pset", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L598-L618
245,003
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.apply_augments
def apply_augments(self, auglist, p_elem, pset): """Handle substatements of augments from `auglist`. The augments are applied in the context of `p_elem`. `pset` is a patch set containing patches that may be applicable to descendants. """ for a in auglist: pa...
python
def apply_augments(self, auglist, p_elem, pset): for a in auglist: par = a.parent if a.search_one("when") is None: wel = p_elem else: if p_elem.interleave: kw = "interleave" else: kw = "gr...
[ "def", "apply_augments", "(", "self", ",", "auglist", ",", "p_elem", ",", "pset", ")", ":", "for", "a", "in", "auglist", ":", "par", "=", "a", ".", "parent", "if", "a", ".", "search_one", "(", "\"when\"", ")", "is", "None", ":", "wel", "=", "p_elem...
Handle substatements of augments from `auglist`. The augments are applied in the context of `p_elem`. `pset` is a patch set containing patches that may be applicable to descendants.
[ "Handle", "substatements", "of", "augments", "from", "auglist", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L620-L650
245,004
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.current_revision
def current_revision(self, r_stmts): """Pick the most recent revision date. `r_stmts` is a list of 'revision' statements. """ cur = max([[int(p) for p in r.arg.split("-")] for r in r_stmts]) return "%4d-%02d-%02d" % tuple(cur)
python
def current_revision(self, r_stmts): cur = max([[int(p) for p in r.arg.split("-")] for r in r_stmts]) return "%4d-%02d-%02d" % tuple(cur)
[ "def", "current_revision", "(", "self", ",", "r_stmts", ")", ":", "cur", "=", "max", "(", "[", "[", "int", "(", "p", ")", "for", "p", "in", "r", ".", "arg", ".", "split", "(", "\"-\"", ")", "]", "for", "r", "in", "r_stmts", "]", ")", "return", ...
Pick the most recent revision date. `r_stmts` is a list of 'revision' statements.
[ "Pick", "the", "most", "recent", "revision", "date", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L652-L658
245,005
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.install_def
def install_def(self, name, dstmt, def_map, interleave=False): """Install definition `name` into the appropriate dictionary. `dstmt` is the definition statement ('typedef' or 'grouping') that is to be mapped to a RELAX NG named pattern '<define name="`name`">'. `def_map` must be either ...
python
def install_def(self, name, dstmt, def_map, interleave=False): delem = SchemaNode.define(name, interleave=interleave) delem.attr["name"] = name def_map[name] = delem if def_map is self.global_defs: self.gg_level += 1 self.handle_substmts(dstmt, delem) if def_map is self.g...
[ "def", "install_def", "(", "self", ",", "name", ",", "dstmt", ",", "def_map", ",", "interleave", "=", "False", ")", ":", "delem", "=", "SchemaNode", ".", "define", "(", "name", ",", "interleave", "=", "interleave", ")", "delem", ".", "attr", "[", "\"na...
Install definition `name` into the appropriate dictionary. `dstmt` is the definition statement ('typedef' or 'grouping') that is to be mapped to a RELAX NG named pattern '<define name="`name`">'. `def_map` must be either `self.local_defs` or `self.global_defs`. `interleave` determines t...
[ "Install", "definition", "name", "into", "the", "appropriate", "dictionary", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L666-L680
245,006
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.rng_annotation
def rng_annotation(self, stmt, p_elem): """Append YIN representation of extension statement `stmt`.""" ext = stmt.i_extension prf, extkw = stmt.raw_keyword (modname,rev)=stmt.i_module.i_prefixes[prf] prefix = self.add_namespace( statements.modulename_to_module(self.mo...
python
def rng_annotation(self, stmt, p_elem): ext = stmt.i_extension prf, extkw = stmt.raw_keyword (modname,rev)=stmt.i_module.i_prefixes[prf] prefix = self.add_namespace( statements.modulename_to_module(self.module,modname,rev)) eel = SchemaNode(prefix + ":" + extkw, p_ele...
[ "def", "rng_annotation", "(", "self", ",", "stmt", ",", "p_elem", ")", ":", "ext", "=", "stmt", ".", "i_extension", "prf", ",", "extkw", "=", "stmt", ".", "raw_keyword", "(", "modname", ",", "rev", ")", "=", "stmt", ".", "i_module", ".", "i_prefixes", ...
Append YIN representation of extension statement `stmt`.
[ "Append", "YIN", "representation", "of", "extension", "statement", "stmt", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L682-L696
245,007
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.propagate_occur
def propagate_occur(self, node, value): """Propagate occurence `value` to `node` and its ancestors. Occurence values are defined and explained in the SchemaNode class. """ while node.occur < value: node.occur = value if node.name == "define": ...
python
def propagate_occur(self, node, value): while node.occur < value: node.occur = value if node.name == "define": break node = node.parent
[ "def", "propagate_occur", "(", "self", ",", "node", ",", "value", ")", ":", "while", "node", ".", "occur", "<", "value", ":", "node", ".", "occur", "=", "value", "if", "node", ".", "name", "==", "\"define\"", ":", "break", "node", "=", "node", ".", ...
Propagate occurence `value` to `node` and its ancestors. Occurence values are defined and explained in the SchemaNode class.
[ "Propagate", "occurence", "value", "to", "node", "and", "its", "ancestors", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L698-L708
245,008
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.process_patches
def process_patches(self, pset, stmt, elem, altname=None): """Process patches for data node `name` from `pset`. `stmt` provides the context in YANG and `elem` is the parent element in the output schema. Refinements adding documentation and changing the config status are immediately appl...
python
def process_patches(self, pset, stmt, elem, altname=None): if altname: name = altname else: name = stmt.arg new_pset = {} augments = [] refine_dict = dict.fromkeys(("presence", "default", "mandatory", "min-elements", "m...
[ "def", "process_patches", "(", "self", ",", "pset", ",", "stmt", ",", "elem", ",", "altname", "=", "None", ")", ":", "if", "altname", ":", "name", "=", "altname", "else", ":", "name", "=", "stmt", ".", "arg", "new_pset", "=", "{", "}", "augments", ...
Process patches for data node `name` from `pset`. `stmt` provides the context in YANG and `elem` is the parent element in the output schema. Refinements adding documentation and changing the config status are immediately applied. The returned tuple consists of: - a dictionary ...
[ "Process", "patches", "for", "data", "node", "name", "from", "pset", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L710-L757
245,009
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.lookup_expand
def lookup_expand(self, stmt, names): """Find schema nodes under `stmt`, also in used groupings. `names` is a list with qualified names of the schema nodes to look up. All 'uses'/'grouping' pairs between `stmt` and found schema nodes are marked for expansion. """ if not ...
python
def lookup_expand(self, stmt, names): if not names: return [] todo = [stmt] while todo: pst = todo.pop() for sub in pst.substmts: if sub.keyword in self.schema_nodes: qname = self.qname(sub) if qname in names: ...
[ "def", "lookup_expand", "(", "self", ",", "stmt", ",", "names", ")", ":", "if", "not", "names", ":", "return", "[", "]", "todo", "=", "[", "stmt", "]", "while", "todo", ":", "pst", "=", "todo", ".", "pop", "(", ")", "for", "sub", "in", "pst", "...
Find schema nodes under `stmt`, also in used groupings. `names` is a list with qualified names of the schema nodes to look up. All 'uses'/'grouping' pairs between `stmt` and found schema nodes are marked for expansion.
[ "Find", "schema", "nodes", "under", "stmt", "also", "in", "used", "groupings", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L780-L805
245,010
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.type_with_ranges
def type_with_ranges(self, tchain, p_elem, rangekw, gen_data): """Handle types with 'range' or 'length' restrictions. `tchain` is the chain of type definitions from which the ranges may need to be extracted. `rangekw` is the statement keyword determining the range type (either 'range' o...
python
def type_with_ranges(self, tchain, p_elem, rangekw, gen_data): ranges = self.get_ranges(tchain, rangekw) if not ranges: return p_elem.subnode(gen_data()) if len(ranges) > 1: p_elem = SchemaNode.choice(p_elem) p_elem.occur = 2 for r in ranges: d_elem = ...
[ "def", "type_with_ranges", "(", "self", ",", "tchain", ",", "p_elem", ",", "rangekw", ",", "gen_data", ")", ":", "ranges", "=", "self", ".", "get_ranges", "(", "tchain", ",", "rangekw", ")", "if", "not", "ranges", ":", "return", "p_elem", ".", "subnode",...
Handle types with 'range' or 'length' restrictions. `tchain` is the chain of type definitions from which the ranges may need to be extracted. `rangekw` is the statement keyword determining the range type (either 'range' or 'length'). `gen_data` is a function that generates the o...
[ "Handle", "types", "with", "range", "or", "length", "restrictions", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L807-L825
245,011
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.get_ranges
def get_ranges(self, tchain, kw): """Return list of ranges defined in `tchain`. `kw` is the statement keyword determining the type of the range, i.e. 'range' or 'length'. `tchain` is the chain of type definitions from which the resulting range is obtained. The returned value is...
python
def get_ranges(self, tchain, kw): (lo, hi) = ("min", "max") ran = None for t in tchain: rstmt = t.search_one(kw) if rstmt is None: continue parts = [ p.strip() for p in rstmt.arg.split("|") ] ran = [ [ i.strip() for i in p.split("..") ] for p in pa...
[ "def", "get_ranges", "(", "self", ",", "tchain", ",", "kw", ")", ":", "(", "lo", ",", "hi", ")", "=", "(", "\"min\"", ",", "\"max\"", ")", "ran", "=", "None", "for", "t", "in", "tchain", ":", "rstmt", "=", "t", ".", "search_one", "(", "kw", ")"...
Return list of ranges defined in `tchain`. `kw` is the statement keyword determining the type of the range, i.e. 'range' or 'length'. `tchain` is the chain of type definitions from which the resulting range is obtained. The returned value is a list of tuples containing the segments ...
[ "Return", "list", "of", "ranges", "defined", "in", "tchain", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L827-L850
245,012
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.handle_stmt
def handle_stmt(self, stmt, p_elem, pset={}): """ Run handler method for statement `stmt`. `p_elem` is the parent node in the output schema. `pset` is the current "patch set" - a dictionary with keys being QNames of schema nodes at the current level of hierarchy for which ...
python
def handle_stmt(self, stmt, p_elem, pset={}): if self.debug > 0: sys.stderr.write("Handling '%s %s'\n" % (util.keyword_to_str(stmt.raw_keyword), stmt.arg)) try: method = self.stmt_handler[stmt.keyword] except KeyError: if isinstanc...
[ "def", "handle_stmt", "(", "self", ",", "stmt", ",", "p_elem", ",", "pset", "=", "{", "}", ")", ":", "if", "self", ".", "debug", ">", "0", ":", "sys", ".", "stderr", ".", "write", "(", "\"Handling '%s %s'\\n\"", "%", "(", "util", ".", "keyword_to_str...
Run handler method for statement `stmt`. `p_elem` is the parent node in the output schema. `pset` is the current "patch set" - a dictionary with keys being QNames of schema nodes at the current level of hierarchy for which (or descendants thereof) any pending patches exist. The values ...
[ "Run", "handler", "method", "for", "statement", "stmt", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L882-L915
245,013
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.handle_substmts
def handle_substmts(self, stmt, p_elem, pset={}): """Handle all substatements of `stmt`.""" for sub in stmt.substmts: self.handle_stmt(sub, p_elem, pset)
python
def handle_substmts(self, stmt, p_elem, pset={}): for sub in stmt.substmts: self.handle_stmt(sub, p_elem, pset)
[ "def", "handle_substmts", "(", "self", ",", "stmt", ",", "p_elem", ",", "pset", "=", "{", "}", ")", ":", "for", "sub", "in", "stmt", ".", "substmts", ":", "self", ".", "handle_stmt", "(", "sub", ",", "p_elem", ",", "pset", ")" ]
Handle all substatements of `stmt`.
[ "Handle", "all", "substatements", "of", "stmt", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L917-L920
245,014
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.nma_attribute
def nma_attribute(self, stmt, p_elem, pset=None): """Map `stmt` to a NETMOD-specific attribute. The name of the attribute is the same as the 'keyword' of `stmt`. """ att = "nma:" + stmt.keyword if att not in p_elem.attr: p_elem.attr[att] = stmt.arg
python
def nma_attribute(self, stmt, p_elem, pset=None): att = "nma:" + stmt.keyword if att not in p_elem.attr: p_elem.attr[att] = stmt.arg
[ "def", "nma_attribute", "(", "self", ",", "stmt", ",", "p_elem", ",", "pset", "=", "None", ")", ":", "att", "=", "\"nma:\"", "+", "stmt", ".", "keyword", "if", "att", "not", "in", "p_elem", ".", "attr", ":", "p_elem", ".", "attr", "[", "att", "]", ...
Map `stmt` to a NETMOD-specific attribute. The name of the attribute is the same as the 'keyword' of `stmt`.
[ "Map", "stmt", "to", "a", "NETMOD", "-", "specific", "attribute", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L942-L950
245,015
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.type_stmt
def type_stmt(self, stmt, p_elem, pset): """Handle ``type`` statement. Built-in types are handled by one of the specific type callback methods defined below. """ typedef = stmt.i_typedef if typedef and not stmt.i_is_derived: # just ref uname, dic = self.uniqu...
python
def type_stmt(self, stmt, p_elem, pset): typedef = stmt.i_typedef if typedef and not stmt.i_is_derived: # just ref uname, dic = self.unique_def_name(typedef) if uname not in dic: self.install_def(uname, typedef, dic) SchemaNode("ref", p_elem).set_attr(...
[ "def", "type_stmt", "(", "self", ",", "stmt", ",", "p_elem", ",", "pset", ")", ":", "typedef", "=", "stmt", ".", "i_typedef", "if", "typedef", "and", "not", "stmt", ".", "i_is_derived", ":", "# just ref", "uname", ",", "dic", "=", "self", ".", "unique_...
Handle ``type`` statement. Built-in types are handled by one of the specific type callback methods defined below.
[ "Handle", "type", "statement", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L1119-L1152
245,016
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.choice_type
def choice_type(self, tchain, p_elem): """Handle ``enumeration`` and ``union`` types.""" elem = SchemaNode.choice(p_elem, occur=2) self.handle_substmts(tchain[0], elem)
python
def choice_type(self, tchain, p_elem): elem = SchemaNode.choice(p_elem, occur=2) self.handle_substmts(tchain[0], elem)
[ "def", "choice_type", "(", "self", ",", "tchain", ",", "p_elem", ")", ":", "elem", "=", "SchemaNode", ".", "choice", "(", "p_elem", ",", "occur", "=", "2", ")", "self", ".", "handle_substmts", "(", "tchain", "[", "0", "]", ",", "elem", ")" ]
Handle ``enumeration`` and ``union`` types.
[ "Handle", "enumeration", "and", "union", "types", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L1223-L1226
245,017
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.mapped_type
def mapped_type(self, tchain, p_elem): """Handle types that are simply mapped to RELAX NG.""" SchemaNode("data", p_elem).set_attr("type", self.datatype_map[tchain[0].arg])
python
def mapped_type(self, tchain, p_elem): SchemaNode("data", p_elem).set_attr("type", self.datatype_map[tchain[0].arg])
[ "def", "mapped_type", "(", "self", ",", "tchain", ",", "p_elem", ")", ":", "SchemaNode", "(", "\"data\"", ",", "p_elem", ")", ".", "set_attr", "(", "\"type\"", ",", "self", ".", "datatype_map", "[", "tchain", "[", "0", "]", ".", "arg", "]", ")" ]
Handle types that are simply mapped to RELAX NG.
[ "Handle", "types", "that", "are", "simply", "mapped", "to", "RELAX", "NG", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L1262-L1265
245,018
mbj4668/pyang
pyang/translators/dsdl.py
HybridDSDLSchema.numeric_type
def numeric_type(self, tchain, p_elem): """Handle numeric types.""" typ = tchain[0].arg def gen_data(): elem = SchemaNode("data").set_attr("type", self.datatype_map[typ]) if typ == "decimal64": fd = tchain[0].search_one("fraction-digits").arg ...
python
def numeric_type(self, tchain, p_elem): typ = tchain[0].arg def gen_data(): elem = SchemaNode("data").set_attr("type", self.datatype_map[typ]) if typ == "decimal64": fd = tchain[0].search_one("fraction-digits").arg SchemaNode("param",elem,"19").set...
[ "def", "numeric_type", "(", "self", ",", "tchain", ",", "p_elem", ")", ":", "typ", "=", "tchain", "[", "0", "]", ".", "arg", "def", "gen_data", "(", ")", ":", "elem", "=", "SchemaNode", "(", "\"data\"", ")", ".", "set_attr", "(", "\"type\"", ",", "...
Handle numeric types.
[ "Handle", "numeric", "types", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L1267-L1277
245,019
mbj4668/pyang
pyang/grammar.py
add_stmt
def add_stmt(stmt, arg_rules): """Use by plugins to add grammar for an extension statement.""" (arg, rules) = arg_rules stmt_map[stmt] = (arg, rules)
python
def add_stmt(stmt, arg_rules): (arg, rules) = arg_rules stmt_map[stmt] = (arg, rules)
[ "def", "add_stmt", "(", "stmt", ",", "arg_rules", ")", ":", "(", "arg", ",", "rules", ")", "=", "arg_rules", "stmt_map", "[", "stmt", "]", "=", "(", "arg", ",", "rules", ")" ]
Use by plugins to add grammar for an extension statement.
[ "Use", "by", "plugins", "to", "add", "grammar", "for", "an", "extension", "statement", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/grammar.py#L77-L80
245,020
mbj4668/pyang
pyang/grammar.py
add_to_stmts_rules
def add_to_stmts_rules(stmts, rules): """Use by plugins to add extra rules to the existing rules for a statement.""" def is_rule_less_than(ra, rb): rka = ra[0] rkb = rb[0] if not util.is_prefixed(rkb): # old rule is non-prefixed; append new rule after return F...
python
def add_to_stmts_rules(stmts, rules): def is_rule_less_than(ra, rb): rka = ra[0] rkb = rb[0] if not util.is_prefixed(rkb): # old rule is non-prefixed; append new rule after return False if not util.is_prefixed(rka): # old rule prefixed, but new rul...
[ "def", "add_to_stmts_rules", "(", "stmts", ",", "rules", ")", ":", "def", "is_rule_less_than", "(", "ra", ",", "rb", ")", ":", "rka", "=", "ra", "[", "0", "]", "rkb", "=", "rb", "[", "0", "]", "if", "not", "util", ".", "is_prefixed", "(", "rkb", ...
Use by plugins to add extra rules to the existing rules for a statement.
[ "Use", "by", "plugins", "to", "add", "extra", "rules", "to", "the", "existing", "rules", "for", "a", "statement", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/grammar.py#L82-L106
245,021
mbj4668/pyang
pyang/grammar.py
chk_module_statements
def chk_module_statements(ctx, module_stmt, canonical=False): """Validate the statement hierarchy according to the grammar. Return True if module is valid, False otherwise. """ return chk_statement(ctx, module_stmt, top_stmts, canonical)
python
def chk_module_statements(ctx, module_stmt, canonical=False): return chk_statement(ctx, module_stmt, top_stmts, canonical)
[ "def", "chk_module_statements", "(", "ctx", ",", "module_stmt", ",", "canonical", "=", "False", ")", ":", "return", "chk_statement", "(", "ctx", ",", "module_stmt", ",", "top_stmts", ",", "canonical", ")" ]
Validate the statement hierarchy according to the grammar. Return True if module is valid, False otherwise.
[ "Validate", "the", "statement", "hierarchy", "according", "to", "the", "grammar", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/grammar.py#L570-L575
245,022
mbj4668/pyang
pyang/grammar.py
chk_statement
def chk_statement(ctx, stmt, grammar, canonical=False): """Validate `stmt` according to `grammar`. Marks each statement in the hierearchy with stmt.is_grammatically_valid, which is a boolean. Return True if stmt is valid, False otherwise. """ n = len(ctx.errors) if canonical == True: ...
python
def chk_statement(ctx, stmt, grammar, canonical=False): n = len(ctx.errors) if canonical == True: canspec = grammar else: canspec = [] _chk_stmts(ctx, stmt.pos, [stmt], None, (grammar, canspec), canonical) return n == len(ctx.errors)
[ "def", "chk_statement", "(", "ctx", ",", "stmt", ",", "grammar", ",", "canonical", "=", "False", ")", ":", "n", "=", "len", "(", "ctx", ".", "errors", ")", "if", "canonical", "==", "True", ":", "canspec", "=", "grammar", "else", ":", "canspec", "=", ...
Validate `stmt` according to `grammar`. Marks each statement in the hierearchy with stmt.is_grammatically_valid, which is a boolean. Return True if stmt is valid, False otherwise.
[ "Validate", "stmt", "according", "to", "grammar", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/grammar.py#L577-L591
245,023
mbj4668/pyang
pyang/grammar.py
sort_canonical
def sort_canonical(keyword, stmts): """Sort all `stmts` in the canonical order defined by `keyword`. Return the sorted list. The `stmt` list is not modified. If `keyword` does not have a canonical order, the list is returned as is. """ try: (_arg_type, subspec) = stmt_map[keyword] ...
python
def sort_canonical(keyword, stmts): try: (_arg_type, subspec) = stmt_map[keyword] except KeyError: return stmts res = [] # keep the order of data definition statements and case keep = [s[0] for s in data_def_stmts] + ['case'] for (kw, _spec) in flatten_spec(subspec): # ke...
[ "def", "sort_canonical", "(", "keyword", ",", "stmts", ")", ":", "try", ":", "(", "_arg_type", ",", "subspec", ")", "=", "stmt_map", "[", "keyword", "]", "except", "KeyError", ":", "return", "stmts", "res", "=", "[", "]", "# keep the order of data definition...
Sort all `stmts` in the canonical order defined by `keyword`. Return the sorted list. The `stmt` list is not modified. If `keyword` does not have a canonical order, the list is returned as is.
[ "Sort", "all", "stmts", "in", "the", "canonical", "order", "defined", "by", "keyword", ".", "Return", "the", "sorted", "list", ".", "The", "stmt", "list", "is", "not", "modified", ".", "If", "keyword", "does", "not", "have", "a", "canonical", "order", "t...
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/grammar.py#L799-L828
245,024
mbj4668/pyang
pyang/xpath_lexer.py
scan
def scan(s): """Return a list of tokens, or throw SyntaxError on failure. """ line = 1 linepos = 1 pos = 0 toks = [] while pos < len(s): matched = False for (tokname, r) in patterns: m = r.match(s, pos) if m is not None: # found a match...
python
def scan(s): line = 1 linepos = 1 pos = 0 toks = [] while pos < len(s): matched = False for (tokname, r) in patterns: m = r.match(s, pos) if m is not None: # found a matching token v = m.group(0) prec = _precedin...
[ "def", "scan", "(", "s", ")", ":", "line", "=", "1", "linepos", "=", "1", "pos", "=", "0", "toks", "=", "[", "]", "while", "pos", "<", "len", "(", "s", ")", ":", "matched", "=", "False", "for", "(", "tokname", ",", "r", ")", "in", "patterns",...
Return a list of tokens, or throw SyntaxError on failure.
[ "Return", "a", "list", "of", "tokens", "or", "throw", "SyntaxError", "on", "failure", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/xpath_lexer.py#L112-L175
245,025
mbj4668/pyang
pyang/hello.py
HelloParser.yang_modules
def yang_modules(self): """ Return a list of advertised YANG module names with revisions. Avoid repeated modules. """ res = {} for c in self.capabilities: m = c.parameters.get("module") if m is None or m in res: continue res[m] = c.par...
python
def yang_modules(self): res = {} for c in self.capabilities: m = c.parameters.get("module") if m is None or m in res: continue res[m] = c.parameters.get("revision") return res.items()
[ "def", "yang_modules", "(", "self", ")", ":", "res", "=", "{", "}", "for", "c", "in", "self", ".", "capabilities", ":", "m", "=", "c", ".", "parameters", ".", "get", "(", "\"module\"", ")", "if", "m", "is", "None", "or", "m", "in", "res", ":", ...
Return a list of advertised YANG module names with revisions. Avoid repeated modules.
[ "Return", "a", "list", "of", "advertised", "YANG", "module", "names", "with", "revisions", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/hello.py#L75-L86
245,026
mbj4668/pyang
pyang/hello.py
HelloParser.get_features
def get_features(self, yam): """Return list of features declared for module `yam`.""" mcap = [ c for c in self.capabilities if c.parameters.get("module", None) == yam ][0] if not mcap.parameters.get("features"): return [] return mcap.parameters["features"].split(",")
python
def get_features(self, yam): mcap = [ c for c in self.capabilities if c.parameters.get("module", None) == yam ][0] if not mcap.parameters.get("features"): return [] return mcap.parameters["features"].split(",")
[ "def", "get_features", "(", "self", ",", "yam", ")", ":", "mcap", "=", "[", "c", "for", "c", "in", "self", ".", "capabilities", "if", "c", ".", "parameters", ".", "get", "(", "\"module\"", ",", "None", ")", "==", "yam", "]", "[", "0", "]", "if", ...
Return list of features declared for module `yam`.
[ "Return", "list", "of", "features", "declared", "for", "module", "yam", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/hello.py#L88-L93
245,027
mbj4668/pyang
pyang/hello.py
HelloParser.registered_capabilities
def registered_capabilities(self): """Return dictionary of non-YANG capabilities. Only capabilities from the `CAPABILITIES` dictionary are taken into account. """ return dict ([ (CAPABILITIES[c.id],c) for c in self.capabilities if c.id in CAPABILITIES ])
python
def registered_capabilities(self): return dict ([ (CAPABILITIES[c.id],c) for c in self.capabilities if c.id in CAPABILITIES ])
[ "def", "registered_capabilities", "(", "self", ")", ":", "return", "dict", "(", "[", "(", "CAPABILITIES", "[", "c", ".", "id", "]", ",", "c", ")", "for", "c", "in", "self", ".", "capabilities", "if", "c", ".", "id", "in", "CAPABILITIES", "]", ")" ]
Return dictionary of non-YANG capabilities. Only capabilities from the `CAPABILITIES` dictionary are taken into account.
[ "Return", "dictionary", "of", "non", "-", "YANG", "capabilities", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/hello.py#L95-L102
245,028
mbj4668/pyang
pyang/util.py
listsdelete
def listsdelete(x, xs): """Return a new list with x removed from xs""" i = xs.index(x) return xs[:i] + xs[(i+1):]
python
def listsdelete(x, xs): i = xs.index(x) return xs[:i] + xs[(i+1):]
[ "def", "listsdelete", "(", "x", ",", "xs", ")", ":", "i", "=", "xs", ".", "index", "(", "x", ")", "return", "xs", "[", ":", "i", "]", "+", "xs", "[", "(", "i", "+", "1", ")", ":", "]" ]
Return a new list with x removed from xs
[ "Return", "a", "new", "list", "with", "x", "removed", "from", "xs" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/util.py#L76-L79
245,029
mbj4668/pyang
pyang/util.py
unique_prefixes
def unique_prefixes(context): """Return a dictionary with unique prefixes for modules in `context`. Keys are 'module' statements and values are prefixes, disambiguated where necessary. """ res = {} for m in context.modules.values(): if m.keyword == "submodule": continue prf = ne...
python
def unique_prefixes(context): res = {} for m in context.modules.values(): if m.keyword == "submodule": continue prf = new = m.i_prefix suff = 0 while new in res.values(): suff += 1 new = "%s%x" % (prf, suff) res[m] = new return res
[ "def", "unique_prefixes", "(", "context", ")", ":", "res", "=", "{", "}", "for", "m", "in", "context", ".", "modules", ".", "values", "(", ")", ":", "if", "m", ".", "keyword", "==", "\"submodule\"", ":", "continue", "prf", "=", "new", "=", "m", "."...
Return a dictionary with unique prefixes for modules in `context`. Keys are 'module' statements and values are prefixes, disambiguated where necessary.
[ "Return", "a", "dictionary", "with", "unique", "prefixes", "for", "modules", "in", "context", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/util.py#L120-L135
245,030
mbj4668/pyang
setup.py
PyangDist.preprocess_files
def preprocess_files(self, prefix): """Change the installation prefix where necessary. """ if prefix is None: return files = ("bin/yang2dsdl", "man/man1/yang2dsdl.1", "pyang/plugins/jsonxsl.py") regex = re.compile("^(.*)/usr/local(.*)$") ...
python
def preprocess_files(self, prefix): if prefix is None: return files = ("bin/yang2dsdl", "man/man1/yang2dsdl.1", "pyang/plugins/jsonxsl.py") regex = re.compile("^(.*)/usr/local(.*)$") for f in files: inf = open(f) cn...
[ "def", "preprocess_files", "(", "self", ",", "prefix", ")", ":", "if", "prefix", "is", "None", ":", "return", "files", "=", "(", "\"bin/yang2dsdl\"", ",", "\"man/man1/yang2dsdl.1\"", ",", "\"pyang/plugins/jsonxsl.py\"", ")", "regex", "=", "re", ".", "compile", ...
Change the installation prefix where necessary.
[ "Change", "the", "installation", "prefix", "where", "necessary", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/setup.py#L26-L45
245,031
mbj4668/pyang
pyang/__init__.py
Context.add_module
def add_module(self, ref, text, format=None, expect_modulename=None, expect_revision=None, expect_failure_error=True): """Parse a module text and add the module data to the context `ref` is a string which is used to identify the source of the text for...
python
def add_module(self, ref, text, format=None, expect_modulename=None, expect_revision=None, expect_failure_error=True): if format == None: format = util.guess_format(text) if format == 'yin': p = yin_parser.YinParser() else: ...
[ "def", "add_module", "(", "self", ",", "ref", ",", "text", ",", "format", "=", "None", ",", "expect_modulename", "=", "None", ",", "expect_revision", "=", "None", ",", "expect_failure_error", "=", "True", ")", ":", "if", "format", "==", "None", ":", "for...
Parse a module text and add the module data to the context `ref` is a string which is used to identify the source of the text for the user. used in error messages `text` is the raw text data `format` is one of 'yang' or 'yin'. Returns the parsed and validated module on s...
[ "Parse", "a", "module", "text", "and", "add", "the", "module", "data", "to", "the", "context" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/__init__.py#L56-L113
245,032
mbj4668/pyang
pyang/__init__.py
Context.del_module
def del_module(self, module): """Remove a module from the context""" rev = util.get_latest_revision(module) del self.modules[(module.arg, rev)]
python
def del_module(self, module): rev = util.get_latest_revision(module) del self.modules[(module.arg, rev)]
[ "def", "del_module", "(", "self", ",", "module", ")", ":", "rev", "=", "util", ".", "get_latest_revision", "(", "module", ")", "del", "self", ".", "modules", "[", "(", "module", ".", "arg", ",", "rev", ")", "]" ]
Remove a module from the context
[ "Remove", "a", "module", "from", "the", "context" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/__init__.py#L138-L141
245,033
mbj4668/pyang
pyang/__init__.py
Context.get_module
def get_module(self, modulename, revision=None): """Return the module if it exists in the context""" if revision is None and modulename in self.revs: (revision, _handle) = self._get_latest_rev(self.revs[modulename]) if revision is not None: if (modulename,revision) in sel...
python
def get_module(self, modulename, revision=None): if revision is None and modulename in self.revs: (revision, _handle) = self._get_latest_rev(self.revs[modulename]) if revision is not None: if (modulename,revision) in self.modules: return self.modules[(modulename, ...
[ "def", "get_module", "(", "self", ",", "modulename", ",", "revision", "=", "None", ")", ":", "if", "revision", "is", "None", "and", "modulename", "in", "self", ".", "revs", ":", "(", "revision", ",", "_handle", ")", "=", "self", ".", "_get_latest_rev", ...
Return the module if it exists in the context
[ "Return", "the", "module", "if", "it", "exists", "in", "the", "context" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/__init__.py#L143-L151
245,034
mbj4668/pyang
pyang/plugin.py
init
def init(plugindirs=[]): """Initialize the plugin framework""" # initialize the builtin plugins from .translators import yang,yin,dsdl yang.pyang_plugin_init() yin.pyang_plugin_init() dsdl.pyang_plugin_init() # initialize installed plugins for ep in pkg_resources.iter_entry_points(grou...
python
def init(plugindirs=[]): # initialize the builtin plugins from .translators import yang,yin,dsdl yang.pyang_plugin_init() yin.pyang_plugin_init() dsdl.pyang_plugin_init() # initialize installed plugins for ep in pkg_resources.iter_entry_points(group='pyang.plugin'): plugin_init = ep...
[ "def", "init", "(", "plugindirs", "=", "[", "]", ")", ":", "# initialize the builtin plugins", "from", ".", "translators", "import", "yang", ",", "yin", ",", "dsdl", "yang", ".", "pyang_plugin_init", "(", ")", "yin", ".", "pyang_plugin_init", "(", ")", "dsdl...
Initialize the plugin framework
[ "Initialize", "the", "plugin", "framework" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugin.py#L10-L63
245,035
mbj4668/pyang
pyang/yin_parser.py
YinParser.split_qname
def split_qname(qname): """Split `qname` into namespace URI and local name Return namespace and local name as a tuple. This is a static method.""" res = qname.split(YinParser.ns_sep) if len(res) == 1: # no namespace return None, res[0] else: ...
python
def split_qname(qname): res = qname.split(YinParser.ns_sep) if len(res) == 1: # no namespace return None, res[0] else: return res
[ "def", "split_qname", "(", "qname", ")", ":", "res", "=", "qname", ".", "split", "(", "YinParser", ".", "ns_sep", ")", "if", "len", "(", "res", ")", "==", "1", ":", "# no namespace", "return", "None", ",", "res", "[", "0", "]", "else", ":", "return...
Split `qname` into namespace URI and local name Return namespace and local name as a tuple. This is a static method.
[ "Split", "qname", "into", "namespace", "URI", "and", "local", "name" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/yin_parser.py#L55-L64
245,036
mbj4668/pyang
pyang/yin_parser.py
YinParser.check_attr
def check_attr(self, pos, attrs): """Check for unknown attributes.""" for at in attrs: (ns, local_name) = self.split_qname(at) if ns is None: error.err_add(self.ctx.errors, pos, 'UNEXPECTED_ATTRIBUTE', local_name) elif ns...
python
def check_attr(self, pos, attrs): for at in attrs: (ns, local_name) = self.split_qname(at) if ns is None: error.err_add(self.ctx.errors, pos, 'UNEXPECTED_ATTRIBUTE', local_name) elif ns == yin_namespace: error.err_...
[ "def", "check_attr", "(", "self", ",", "pos", ",", "attrs", ")", ":", "for", "at", "in", "attrs", ":", "(", "ns", ",", "local_name", ")", "=", "self", ".", "split_qname", "(", "at", ")", "if", "ns", "is", "None", ":", "error", ".", "err_add", "("...
Check for unknown attributes.
[ "Check", "for", "unknown", "attributes", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/yin_parser.py#L220-L230
245,037
mbj4668/pyang
pyang/yin_parser.py
YinParser.search_definition
def search_definition(self, module, keyword, arg): """Search for a defintion with `keyword` `name` Search the module and its submodules.""" r = module.search_one(keyword, arg) if r is not None: return r for i in module.search('include'): modulename = i.arg...
python
def search_definition(self, module, keyword, arg): r = module.search_one(keyword, arg) if r is not None: return r for i in module.search('include'): modulename = i.arg m = self.ctx.search_module(i.pos, modulename) if m is not None: ...
[ "def", "search_definition", "(", "self", ",", "module", ",", "keyword", ",", "arg", ")", ":", "r", "=", "module", ".", "search_one", "(", "keyword", ",", "arg", ")", "if", "r", "is", "not", "None", ":", "return", "r", "for", "i", "in", "module", "....
Search for a defintion with `keyword` `name` Search the module and its submodules.
[ "Search", "for", "a", "defintion", "with", "keyword", "name", "Search", "the", "module", "and", "its", "submodules", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/yin_parser.py#L377-L390
245,038
mbj4668/pyang
pyang/translators/yang.py
emit_path_arg
def emit_path_arg(keywordstr, arg, fd, indent, max_line_len, line_len, eol): """Heuristically pretty print a path argument""" quote = '"' arg = escape_str(arg) if not(need_new_line(max_line_len, line_len, arg)): fd.write(" " + quote + arg + quote) return False ## FIXME: we should...
python
def emit_path_arg(keywordstr, arg, fd, indent, max_line_len, line_len, eol): quote = '"' arg = escape_str(arg) if not(need_new_line(max_line_len, line_len, arg)): fd.write(" " + quote + arg + quote) return False ## FIXME: we should split the path on '/' and '[]' into multiple lines ...
[ "def", "emit_path_arg", "(", "keywordstr", ",", "arg", ",", "fd", ",", "indent", ",", "max_line_len", ",", "line_len", ",", "eol", ")", ":", "quote", "=", "'\"'", "arg", "=", "escape_str", "(", "arg", ")", "if", "not", "(", "need_new_line", "(", "max_l...
Heuristically pretty print a path argument
[ "Heuristically", "pretty", "print", "a", "path", "argument" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/yang.py#L323-L356
245,039
mbj4668/pyang
pyang/translators/yang.py
emit_arg
def emit_arg(keywordstr, stmt, fd, indent, indentstep, max_line_len, line_len): """Heuristically pretty print the argument string with double quotes""" arg = escape_str(stmt.arg) lines = arg.splitlines(True) if len(lines) <= 1: if len(arg) > 0 and arg[-1] == '\n': arg = arg[:-1] + r'...
python
def emit_arg(keywordstr, stmt, fd, indent, indentstep, max_line_len, line_len): arg = escape_str(stmt.arg) lines = arg.splitlines(True) if len(lines) <= 1: if len(arg) > 0 and arg[-1] == '\n': arg = arg[:-1] + r'\n' if (stmt.keyword in _force_newline_arg or need_new_l...
[ "def", "emit_arg", "(", "keywordstr", ",", "stmt", ",", "fd", ",", "indent", ",", "indentstep", ",", "max_line_len", ",", "line_len", ")", ":", "arg", "=", "escape_str", "(", "stmt", ".", "arg", ")", "lines", "=", "arg", ".", "splitlines", "(", "True",...
Heuristically pretty print the argument string with double quotes
[ "Heuristically", "pretty", "print", "the", "argument", "string", "with", "double", "quotes" ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/yang.py#L358-L404
245,040
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.process_children
def process_children(self, node, elem, module, path, omit=[]): """Proceed with all children of `node`.""" for ch in node.i_children: if ch not in omit and (ch.i_config or self.doctype == "data"): self.node_handler.get(ch.keyword, self.ignore)( ch, elem, mo...
python
def process_children(self, node, elem, module, path, omit=[]): for ch in node.i_children: if ch not in omit and (ch.i_config or self.doctype == "data"): self.node_handler.get(ch.keyword, self.ignore)( ch, elem, module, path)
[ "def", "process_children", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ",", "omit", "=", "[", "]", ")", ":", "for", "ch", "in", "node", ".", "i_children", ":", "if", "ch", "not", "in", "omit", "and", "(", "ch", ".", "i_conf...
Proceed with all children of `node`.
[ "Proceed", "with", "all", "children", "of", "node", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L135-L140
245,041
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.container
def container(self, node, elem, module, path): """Create a sample container element and proceed with its children.""" nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: pres = node.search_one("presence") ...
python
def container(self, node, elem, module, path): nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: pres = node.search_one("presence") if pres is not None: nel.append(etree.Comment(" presence: ...
[ "def", "container", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ")", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "module", ",", "path", ")", "if", "path", "is", "...
Create a sample container element and proceed with its children.
[ "Create", "a", "sample", "container", "element", "and", "proceed", "with", "its", "children", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L142-L151
245,042
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.leaf
def leaf(self, node, elem, module, path): """Create a sample leaf element.""" if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( ...
python
def leaf(self, node, elem, module, path): if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( " type: %s " % node.searc...
[ "def", "leaf", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ")", ":", "if", "node", ".", "i_default", "is", "None", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "mo...
Create a sample leaf element.
[ "Create", "a", "sample", "leaf", "element", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L153-L166
245,043
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.anyxml
def anyxml(self, node, elem, module, path): """Create a sample anyxml element.""" nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment(" anyxml "))
python
def anyxml(self, node, elem, module, path): nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment(" anyxml "))
[ "def", "anyxml", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ")", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "module", ",", "path", ")", "if", "path", "is", "Non...
Create a sample anyxml element.
[ "Create", "a", "sample", "anyxml", "element", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L168-L174
245,044
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.list
def list(self, node, elem, module, path): """Create sample entries of a list.""" nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return for kn in node.i_key: self.node_handler.get(kn.keyword, self.ignore)( kn, nel, ...
python
def list(self, node, elem, module, path): nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return for kn in node.i_key: self.node_handler.get(kn.keyword, self.ignore)( kn, nel, newm, path) self.process_children(node,...
[ "def", "list", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ")", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "module", ",", "path", ")", "if", "path", "is", "None"...
Create sample entries of a list.
[ "Create", "sample", "entries", "of", "a", "list", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L176-L188
245,045
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.leaf_list
def leaf_list(self, node, elem, module, path): """Create sample entries of a leaf-list.""" nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return minel = node.search_one("min-elements") self.add_copies(node, elem, nel, minel) s...
python
def leaf_list(self, node, elem, module, path): nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return minel = node.search_one("min-elements") self.add_copies(node, elem, nel, minel) self.list_comment(node, nel, minel)
[ "def", "leaf_list", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ")", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "module", ",", "path", ")", "if", "path", "is", "...
Create sample entries of a leaf-list.
[ "Create", "sample", "entries", "of", "a", "leaf", "-", "list", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L190-L197
245,046
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.sample_element
def sample_element(self, node, parent, module, path): """Create element under `parent`. Declare new namespace if necessary. """ if path is None: return parent, module, None elif path == []: # GO ON pass else: if node.arg ==...
python
def sample_element(self, node, parent, module, path): if path is None: return parent, module, None elif path == []: # GO ON pass else: if node.arg == path[0]: path = path[1:] else: return parent, module, ...
[ "def", "sample_element", "(", "self", ",", "node", ",", "parent", ",", "module", ",", "path", ")", ":", "if", "path", "is", "None", ":", "return", "parent", ",", "module", ",", "None", "elif", "path", "==", "[", "]", ":", "# GO ON", "pass", "else", ...
Create element under `parent`. Declare new namespace if necessary.
[ "Create", "element", "under", "parent", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L199-L220
245,047
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.add_copies
def add_copies(self, node, parent, elem, minel): """Add appropriate number of `elem` copies to `parent`.""" rep = 0 if minel is None else int(minel.arg) - 1 for i in range(rep): parent.append(copy.deepcopy(elem))
python
def add_copies(self, node, parent, elem, minel): rep = 0 if minel is None else int(minel.arg) - 1 for i in range(rep): parent.append(copy.deepcopy(elem))
[ "def", "add_copies", "(", "self", ",", "node", ",", "parent", ",", "elem", ",", "minel", ")", ":", "rep", "=", "0", "if", "minel", "is", "None", "else", "int", "(", "minel", ".", "arg", ")", "-", "1", "for", "i", "in", "range", "(", "rep", ")",...
Add appropriate number of `elem` copies to `parent`.
[ "Add", "appropriate", "number", "of", "elem", "copies", "to", "parent", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L222-L226
245,048
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.list_comment
def list_comment(self, node, elem, minel): """Add list annotation to `elem`.""" lo = "0" if minel is None else minel.arg maxel = node.search_one("max-elements") hi = "" if maxel is None else maxel.arg elem.insert(0, etree.Comment( " # entries: %s..%s " % (lo, hi))) ...
python
def list_comment(self, node, elem, minel): lo = "0" if minel is None else minel.arg maxel = node.search_one("max-elements") hi = "" if maxel is None else maxel.arg elem.insert(0, etree.Comment( " # entries: %s..%s " % (lo, hi))) if node.keyword == 'list': ...
[ "def", "list_comment", "(", "self", ",", "node", ",", "elem", ",", "minel", ")", ":", "lo", "=", "\"0\"", "if", "minel", "is", "None", "else", "minel", ".", "arg", "maxel", "=", "node", ".", "search_one", "(", "\"max-elements\"", ")", "hi", "=", "\"\...
Add list annotation to `elem`.
[ "Add", "list", "annotation", "to", "elem", "." ]
f2a5cc3142162e5b9ee4e18d154568d939ff63dd
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L228-L237
245,049
quantmind/pulsar
pulsar/utils/slugify.py
slugify
def slugify(value, separator='-', max_length=0, word_boundary=False, entities=True, decimal=True, hexadecimal=True): '''Normalizes string, removes non-alpha characters, and converts spaces to ``separator`` character ''' value = normalize('NFKD', to_string(value, 'utf-8', 'ignore')) if un...
python
def slugify(value, separator='-', max_length=0, word_boundary=False, entities=True, decimal=True, hexadecimal=True): '''Normalizes string, removes non-alpha characters, and converts spaces to ``separator`` character ''' value = normalize('NFKD', to_string(value, 'utf-8', 'ignore')) if un...
[ "def", "slugify", "(", "value", ",", "separator", "=", "'-'", ",", "max_length", "=", "0", ",", "word_boundary", "=", "False", ",", "entities", "=", "True", ",", "decimal", "=", "True", ",", "hexadecimal", "=", "True", ")", ":", "value", "=", "normaliz...
Normalizes string, removes non-alpha characters, and converts spaces to ``separator`` character
[ "Normalizes", "string", "removes", "non", "-", "alpha", "characters", "and", "converts", "spaces", "to", "separator", "character" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/slugify.py#L32-L75
245,050
quantmind/pulsar
pulsar/utils/slugify.py
smart_truncate
def smart_truncate(value, max_length=0, word_boundaries=False, separator=' '): """ Truncate a string """ value = value.strip(separator) if not max_length: return value if len(value) < max_length: return value if not word_boundaries: return value[:max_length].strip(separat...
python
def smart_truncate(value, max_length=0, word_boundaries=False, separator=' '): value = value.strip(separator) if not max_length: return value if len(value) < max_length: return value if not word_boundaries: return value[:max_length].strip(separator) if separator not in va...
[ "def", "smart_truncate", "(", "value", ",", "max_length", "=", "0", ",", "word_boundaries", "=", "False", ",", "separator", "=", "' '", ")", ":", "value", "=", "value", ".", "strip", "(", "separator", ")", "if", "not", "max_length", ":", "return", "value...
Truncate a string
[ "Truncate", "a", "string" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/slugify.py#L78-L103
245,051
quantmind/pulsar
pulsar/utils/pylib/redisparser.py
RedisParser.get
def get(self): '''Called by the protocol consumer''' if self._current: return self._resume(self._current, False) else: return self._get(None)
python
def get(self): '''Called by the protocol consumer''' if self._current: return self._resume(self._current, False) else: return self._get(None)
[ "def", "get", "(", "self", ")", ":", "if", "self", ".", "_current", ":", "return", "self", ".", "_resume", "(", "self", ".", "_current", ",", "False", ")", "else", ":", "return", "self", ".", "_get", "(", "None", ")" ]
Called by the protocol consumer
[ "Called", "by", "the", "protocol", "consumer" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/redisparser.py#L86-L91
245,052
quantmind/pulsar
pulsar/utils/pylib/redisparser.py
RedisParser.pack_pipeline
def pack_pipeline(self, commands): '''Packs pipeline commands into bytes.''' return b''.join( starmap(lambda *args: b''.join(self._pack_command(args)), (a for a, _ in commands)))
python
def pack_pipeline(self, commands): '''Packs pipeline commands into bytes.''' return b''.join( starmap(lambda *args: b''.join(self._pack_command(args)), (a for a, _ in commands)))
[ "def", "pack_pipeline", "(", "self", ",", "commands", ")", ":", "return", "b''", ".", "join", "(", "starmap", "(", "lambda", "*", "args", ":", "b''", ".", "join", "(", "self", ".", "_pack_command", "(", "args", ")", ")", ",", "(", "a", "for", "a", ...
Packs pipeline commands into bytes.
[ "Packs", "pipeline", "commands", "into", "bytes", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/redisparser.py#L114-L118
245,053
quantmind/pulsar
pulsar/cmds/pypi_version.py
PyPi.pypi_release
def pypi_release(self): """Get the latest pypi release """ meta = self.distribution.metadata pypi = ServerProxy(self.pypi_index_url) releases = pypi.package_releases(meta.name) if releases: return next(iter(sorted(releases, reverse=True)))
python
def pypi_release(self): meta = self.distribution.metadata pypi = ServerProxy(self.pypi_index_url) releases = pypi.package_releases(meta.name) if releases: return next(iter(sorted(releases, reverse=True)))
[ "def", "pypi_release", "(", "self", ")", ":", "meta", "=", "self", ".", "distribution", ".", "metadata", "pypi", "=", "ServerProxy", "(", "self", ".", "pypi_index_url", ")", "releases", "=", "pypi", ".", "package_releases", "(", "meta", ".", "name", ")", ...
Get the latest pypi release
[ "Get", "the", "latest", "pypi", "release" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/cmds/pypi_version.py#L48-L55
245,054
quantmind/pulsar
pulsar/async/access.py
is_mainthread
def is_mainthread(thread=None): '''Check if thread is the main thread. If ``thread`` is not supplied check the current thread ''' thread = thread if thread is not None else current_thread() return isinstance(thread, threading._MainThread)
python
def is_mainthread(thread=None): '''Check if thread is the main thread. If ``thread`` is not supplied check the current thread ''' thread = thread if thread is not None else current_thread() return isinstance(thread, threading._MainThread)
[ "def", "is_mainthread", "(", "thread", "=", "None", ")", ":", "thread", "=", "thread", "if", "thread", "is", "not", "None", "else", "current_thread", "(", ")", "return", "isinstance", "(", "thread", ",", "threading", ".", "_MainThread", ")" ]
Check if thread is the main thread. If ``thread`` is not supplied check the current thread
[ "Check", "if", "thread", "is", "the", "main", "thread", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/access.py#L113-L119
245,055
quantmind/pulsar
pulsar/async/access.py
process_data
def process_data(name=None): '''Fetch the current process local data dictionary. If ``name`` is not ``None`` it returns the value at``name``, otherwise it return the process data dictionary ''' ct = current_process() if not hasattr(ct, '_pulsar_local'): ct._pulsar_local = {} loc = c...
python
def process_data(name=None): '''Fetch the current process local data dictionary. If ``name`` is not ``None`` it returns the value at``name``, otherwise it return the process data dictionary ''' ct = current_process() if not hasattr(ct, '_pulsar_local'): ct._pulsar_local = {} loc = c...
[ "def", "process_data", "(", "name", "=", "None", ")", ":", "ct", "=", "current_process", "(", ")", "if", "not", "hasattr", "(", "ct", ",", "'_pulsar_local'", ")", ":", "ct", ".", "_pulsar_local", "=", "{", "}", "loc", "=", "ct", ".", "_pulsar_local", ...
Fetch the current process local data dictionary. If ``name`` is not ``None`` it returns the value at``name``, otherwise it return the process data dictionary
[ "Fetch", "the", "current", "process", "local", "data", "dictionary", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/access.py#L126-L136
245,056
quantmind/pulsar
pulsar/async/access.py
thread_data
def thread_data(name, value=NOTHING, ct=None): '''Set or retrieve an attribute ``name`` from thread ``ct``. If ``ct`` is not given used the current thread. If ``value`` is None, it will get the value otherwise it will set the value. ''' ct = ct or current_thread() if is_mainthread(ct): ...
python
def thread_data(name, value=NOTHING, ct=None): '''Set or retrieve an attribute ``name`` from thread ``ct``. If ``ct`` is not given used the current thread. If ``value`` is None, it will get the value otherwise it will set the value. ''' ct = ct or current_thread() if is_mainthread(ct): ...
[ "def", "thread_data", "(", "name", ",", "value", "=", "NOTHING", ",", "ct", "=", "None", ")", ":", "ct", "=", "ct", "or", "current_thread", "(", ")", "if", "is_mainthread", "(", "ct", ")", ":", "loc", "=", "process_data", "(", ")", "elif", "not", "...
Set or retrieve an attribute ``name`` from thread ``ct``. If ``ct`` is not given used the current thread. If ``value`` is None, it will get the value otherwise it will set the value.
[ "Set", "or", "retrieve", "an", "attribute", "name", "from", "thread", "ct", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/access.py#L139-L159
245,057
quantmind/pulsar
pulsar/utils/internet.py
parse_address
def parse_address(netloc, default_port=8000): '''Parse an internet address ``netloc`` and return a tuple with ``host`` and ``port``.''' if isinstance(netloc, tuple): if len(netloc) != 2: raise ValueError('Invalid address %s' % str(netloc)) return netloc # netloc = native_str(...
python
def parse_address(netloc, default_port=8000): '''Parse an internet address ``netloc`` and return a tuple with ``host`` and ``port``.''' if isinstance(netloc, tuple): if len(netloc) != 2: raise ValueError('Invalid address %s' % str(netloc)) return netloc # netloc = native_str(...
[ "def", "parse_address", "(", "netloc", ",", "default_port", "=", "8000", ")", ":", "if", "isinstance", "(", "netloc", ",", "tuple", ")", ":", "if", "len", "(", "netloc", ")", "!=", "2", ":", "raise", "ValueError", "(", "'Invalid address %s'", "%", "str",...
Parse an internet address ``netloc`` and return a tuple with ``host`` and ``port``.
[ "Parse", "an", "internet", "address", "netloc", "and", "return", "a", "tuple", "with", "host", "and", "port", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/internet.py#L17-L51
245,058
quantmind/pulsar
pulsar/utils/internet.py
is_socket_closed
def is_socket_closed(sock): # pragma nocover """Check if socket ``sock`` is closed.""" if not sock: return True try: if not poll: # pragma nocover if not select: return False try: return bool(select([sock], [], [], 0.0)[0]) ...
python
def is_socket_closed(sock): # pragma nocover if not sock: return True try: if not poll: # pragma nocover if not select: return False try: return bool(select([sock], [], [], 0.0)[0]) except socket.error: ...
[ "def", "is_socket_closed", "(", "sock", ")", ":", "# pragma nocover", "if", "not", "sock", ":", "return", "True", "try", ":", "if", "not", "poll", ":", "# pragma nocover", "if", "not", "select", ":", "return", "False", "try", ":", "return", "bool", "(",...
Check if socket ``sock`` is closed.
[ "Check", "if", "socket", "sock", "is", "closed", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/internet.py#L101-L121
245,059
quantmind/pulsar
pulsar/utils/internet.py
close_socket
def close_socket(sock): '''Shutdown and close the socket.''' if sock: try: sock.shutdown(socket.SHUT_RDWR) except Exception: pass try: sock.close() except Exception: pass
python
def close_socket(sock): '''Shutdown and close the socket.''' if sock: try: sock.shutdown(socket.SHUT_RDWR) except Exception: pass try: sock.close() except Exception: pass
[ "def", "close_socket", "(", "sock", ")", ":", "if", "sock", ":", "try", ":", "sock", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "except", "Exception", ":", "pass", "try", ":", "sock", ".", "close", "(", ")", "except", "Exception", ":", "p...
Shutdown and close the socket.
[ "Shutdown", "and", "close", "the", "socket", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/internet.py#L124-L134
245,060
quantmind/pulsar
pulsar/apps/rpc/mixins.py
PulsarServerCommands.rpc_server_info
async def rpc_server_info(self, request): '''Return a dictionary of information regarding the server and workers. It invokes the :meth:`extra_server_info` for adding custom information. ''' info = await send('arbiter', 'info') info = self.extra_server_info(request, info)...
python
async def rpc_server_info(self, request): '''Return a dictionary of information regarding the server and workers. It invokes the :meth:`extra_server_info` for adding custom information. ''' info = await send('arbiter', 'info') info = self.extra_server_info(request, info)...
[ "async", "def", "rpc_server_info", "(", "self", ",", "request", ")", ":", "info", "=", "await", "send", "(", "'arbiter'", ",", "'info'", ")", "info", "=", "self", ".", "extra_server_info", "(", "request", ",", "info", ")", "try", ":", "info", "=", "awa...
Return a dictionary of information regarding the server and workers. It invokes the :meth:`extra_server_info` for adding custom information.
[ "Return", "a", "dictionary", "of", "information", "regarding", "the", "server", "and", "workers", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/rpc/mixins.py#L18-L30
245,061
quantmind/pulsar
pulsar/utils/pylib/events.py
Event.bind
def bind(self, callback): """Bind a ``callback`` to this event. """ handlers = self._handlers if self._self is None: raise RuntimeError('%s already fired, cannot add callbacks' % self) if handlers is None: handlers = [] self._handlers = handler...
python
def bind(self, callback): handlers = self._handlers if self._self is None: raise RuntimeError('%s already fired, cannot add callbacks' % self) if handlers is None: handlers = [] self._handlers = handlers handlers.append(callback)
[ "def", "bind", "(", "self", ",", "callback", ")", ":", "handlers", "=", "self", ".", "_handlers", "if", "self", ".", "_self", "is", "None", ":", "raise", "RuntimeError", "(", "'%s already fired, cannot add callbacks'", "%", "self", ")", "if", "handlers", "is...
Bind a ``callback`` to this event.
[ "Bind", "a", "callback", "to", "this", "event", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L41-L50
245,062
quantmind/pulsar
pulsar/utils/pylib/events.py
Event.unbind
def unbind(self, callback): """Remove a callback from the list """ handlers = self._handlers if handlers: filtered_callbacks = [f for f in handlers if f != callback] removed_count = len(handlers) - len(filtered_callbacks) if removed_count: ...
python
def unbind(self, callback): handlers = self._handlers if handlers: filtered_callbacks = [f for f in handlers if f != callback] removed_count = len(handlers) - len(filtered_callbacks) if removed_count: self._handlers = filtered_callbacks ret...
[ "def", "unbind", "(", "self", ",", "callback", ")", ":", "handlers", "=", "self", ".", "_handlers", "if", "handlers", ":", "filtered_callbacks", "=", "[", "f", "for", "f", "in", "handlers", "if", "f", "!=", "callback", "]", "removed_count", "=", "len", ...
Remove a callback from the list
[ "Remove", "a", "callback", "from", "the", "list" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L56-L66
245,063
quantmind/pulsar
pulsar/utils/pylib/events.py
Event.fire
def fire(self, exc=None, data=None): """Fire the event :param exc: fire the event with an exception :param data: fire an event with data """ o = self._self if o is not None: handlers = self._handlers if self._onetime: self._handle...
python
def fire(self, exc=None, data=None): o = self._self if o is not None: handlers = self._handlers if self._onetime: self._handlers = None self._self = None if handlers: if exc is not None: for hnd in ...
[ "def", "fire", "(", "self", ",", "exc", "=", "None", ",", "data", "=", "None", ")", ":", "o", "=", "self", ".", "_self", "if", "o", "is", "not", "None", ":", "handlers", "=", "self", ".", "_handlers", "if", "self", ".", "_onetime", ":", "self", ...
Fire the event :param exc: fire the event with an exception :param data: fire an event with data
[ "Fire", "the", "event" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L68-L98
245,064
quantmind/pulsar
pulsar/utils/pylib/events.py
EventHandler.fire_event
def fire_event(self, name, exc=None, data=None): """Fire event at ``name`` if it is registered """ if self._events and name in self._events: self._events[name].fire(exc=exc, data=data)
python
def fire_event(self, name, exc=None, data=None): if self._events and name in self._events: self._events[name].fire(exc=exc, data=data)
[ "def", "fire_event", "(", "self", ",", "name", ",", "exc", "=", "None", ",", "data", "=", "None", ")", ":", "if", "self", ".", "_events", "and", "name", "in", "self", ".", "_events", ":", "self", ".", "_events", "[", "name", "]", ".", "fire", "("...
Fire event at ``name`` if it is registered
[ "Fire", "event", "at", "name", "if", "it", "is", "registered" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L141-L145
245,065
quantmind/pulsar
pulsar/utils/pylib/events.py
EventHandler.bind_events
def bind_events(self, events): '''Register all known events found in ``events`` key-valued parameters. ''' evs = self._events if evs and events: for event in evs.values(): if event.name in events: event.bind(events[event.name])
python
def bind_events(self, events): '''Register all known events found in ``events`` key-valued parameters. ''' evs = self._events if evs and events: for event in evs.values(): if event.name in events: event.bind(events[event.name])
[ "def", "bind_events", "(", "self", ",", "events", ")", ":", "evs", "=", "self", ".", "_events", "if", "evs", "and", "events", ":", "for", "event", "in", "evs", ".", "values", "(", ")", ":", "if", "event", ".", "name", "in", "events", ":", "event", ...
Register all known events found in ``events`` key-valued parameters.
[ "Register", "all", "known", "events", "found", "in", "events", "key", "-", "valued", "parameters", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L147-L154
245,066
quantmind/pulsar
pulsar/utils/autoreload.py
_get_args_for_reloading
def _get_args_for_reloading(): """Returns the executable. This contains a workaround for windows if the executable is incorrectly reported to not have the .exe extension which can cause bugs on reloading. """ rv = [sys.executable] py_script = sys.argv[0] if os.name == 'nt' and not os.path.ex...
python
def _get_args_for_reloading(): rv = [sys.executable] py_script = sys.argv[0] if os.name == 'nt' and not os.path.exists(py_script) and \ os.path.exists(py_script + '.exe'): py_script += '.exe' rv.append(py_script) rv.extend(sys.argv[1:]) return rv
[ "def", "_get_args_for_reloading", "(", ")", ":", "rv", "=", "[", "sys", ".", "executable", "]", "py_script", "=", "sys", ".", "argv", "[", "0", "]", "if", "os", ".", "name", "==", "'nt'", "and", "not", "os", ".", "path", ".", "exists", "(", "py_scr...
Returns the executable. This contains a workaround for windows if the executable is incorrectly reported to not have the .exe extension which can cause bugs on reloading.
[ "Returns", "the", "executable", ".", "This", "contains", "a", "workaround", "for", "windows", "if", "the", "executable", "is", "incorrectly", "reported", "to", "not", "have", "the", ".", "exe", "extension", "which", "can", "cause", "bugs", "on", "reloading", ...
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/autoreload.py#L103-L115
245,067
quantmind/pulsar
pulsar/utils/autoreload.py
Reloader.restart_with_reloader
def restart_with_reloader(self): """Spawn a new Python interpreter with the same arguments as this one """ while True: LOGGER.info('Restarting with %s reloader' % self.name) args = _get_args_for_reloading() new_environ = os.environ.copy() new_envir...
python
def restart_with_reloader(self): while True: LOGGER.info('Restarting with %s reloader' % self.name) args = _get_args_for_reloading() new_environ = os.environ.copy() new_environ[PULSAR_RUN_MAIN] = 'true' exit_code = subprocess.call(args, env=new_environ...
[ "def", "restart_with_reloader", "(", "self", ")", ":", "while", "True", ":", "LOGGER", ".", "info", "(", "'Restarting with %s reloader'", "%", "self", ".", "name", ")", "args", "=", "_get_args_for_reloading", "(", ")", "new_environ", "=", "os", ".", "environ",...
Spawn a new Python interpreter with the same arguments as this one
[ "Spawn", "a", "new", "Python", "interpreter", "with", "the", "same", "arguments", "as", "this", "one" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/autoreload.py#L35-L45
245,068
quantmind/pulsar
pulsar/async/threads.py
Thread.kill
def kill(self, sig): '''Invoke the stop on the event loop method.''' if self.is_alive() and self._loop: self._loop.call_soon_threadsafe(self._loop.stop)
python
def kill(self, sig): '''Invoke the stop on the event loop method.''' if self.is_alive() and self._loop: self._loop.call_soon_threadsafe(self._loop.stop)
[ "def", "kill", "(", "self", ",", "sig", ")", ":", "if", "self", ".", "is_alive", "(", ")", "and", "self", ".", "_loop", ":", "self", ".", "_loop", ".", "call_soon_threadsafe", "(", "self", ".", "_loop", ".", "stop", ")" ]
Invoke the stop on the event loop method.
[ "Invoke", "the", "stop", "on", "the", "event", "loop", "method", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/threads.py#L12-L15
245,069
quantmind/pulsar
pulsar/apps/http/auth.py
HTTPDigestAuth.encode
def encode(self, method, uri): '''Called by the client to encode Authentication header.''' if not self.username or not self.password: return o = self.options qop = o.get('qop') realm = o.get('realm') nonce = o.get('nonce') entdig = None p_parse...
python
def encode(self, method, uri): '''Called by the client to encode Authentication header.''' if not self.username or not self.password: return o = self.options qop = o.get('qop') realm = o.get('realm') nonce = o.get('nonce') entdig = None p_parse...
[ "def", "encode", "(", "self", ",", "method", ",", "uri", ")", ":", "if", "not", "self", ".", "username", "or", "not", "self", ".", "password", ":", "return", "o", "=", "self", ".", "options", "qop", "=", "o", ".", "get", "(", "'qop'", ")", "realm...
Called by the client to encode Authentication header.
[ "Called", "by", "the", "client", "to", "encode", "Authentication", "header", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/http/auth.py#L78-L121
245,070
quantmind/pulsar
pulsar/apps/wsgi/utils.py
handle_wsgi_error
def handle_wsgi_error(environ, exc): '''The default error handler while serving a WSGI request. :param environ: The WSGI environment. :param exc: the exception :return: a :class:`.WsgiResponse` ''' if isinstance(exc, tuple): exc_info = exc exc = exc[1] else: exc_info...
python
def handle_wsgi_error(environ, exc): '''The default error handler while serving a WSGI request. :param environ: The WSGI environment. :param exc: the exception :return: a :class:`.WsgiResponse` ''' if isinstance(exc, tuple): exc_info = exc exc = exc[1] else: exc_info...
[ "def", "handle_wsgi_error", "(", "environ", ",", "exc", ")", ":", "if", "isinstance", "(", "exc", ",", "tuple", ")", ":", "exc_info", "=", "exc", "exc", "=", "exc", "[", "1", "]", "else", ":", "exc_info", "=", "True", "request", "=", "wsgi_request", ...
The default error handler while serving a WSGI request. :param environ: The WSGI environment. :param exc: the exception :return: a :class:`.WsgiResponse`
[ "The", "default", "error", "handler", "while", "serving", "a", "WSGI", "request", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/utils.py#L155-L200
245,071
quantmind/pulsar
pulsar/apps/wsgi/utils.py
render_error
def render_error(request, exc): '''Default renderer for errors.''' cfg = request.get('pulsar.cfg') debug = cfg.debug if cfg else False response = request.response if not response.content_type: content_type = request.get('default.content_type') response.content_type = request.content_...
python
def render_error(request, exc): '''Default renderer for errors.''' cfg = request.get('pulsar.cfg') debug = cfg.debug if cfg else False response = request.response if not response.content_type: content_type = request.get('default.content_type') response.content_type = request.content_...
[ "def", "render_error", "(", "request", ",", "exc", ")", ":", "cfg", "=", "request", ".", "get", "(", "'pulsar.cfg'", ")", "debug", "=", "cfg", ".", "debug", "if", "cfg", "else", "False", "response", "=", "request", ".", "response", "if", "not", "respon...
Default renderer for errors.
[ "Default", "renderer", "for", "errors", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/utils.py#L203-L239
245,072
quantmind/pulsar
pulsar/apps/wsgi/utils.py
render_error_debug
def render_error_debug(request, exception, is_html): '''Render the ``exception`` traceback ''' error = Html('div', cn='well well-lg') if is_html else [] for trace in format_traceback(exception): counter = 0 for line in trace.split('\n'): if line.startswith(' '): ...
python
def render_error_debug(request, exception, is_html): '''Render the ``exception`` traceback ''' error = Html('div', cn='well well-lg') if is_html else [] for trace in format_traceback(exception): counter = 0 for line in trace.split('\n'): if line.startswith(' '): ...
[ "def", "render_error_debug", "(", "request", ",", "exception", ",", "is_html", ")", ":", "error", "=", "Html", "(", "'div'", ",", "cn", "=", "'well well-lg'", ")", "if", "is_html", "else", "[", "]", "for", "trace", "in", "format_traceback", "(", "exception...
Render the ``exception`` traceback
[ "Render", "the", "exception", "traceback" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/utils.py#L242-L260
245,073
quantmind/pulsar
pulsar/async/monitor.py
arbiter
def arbiter(**params): '''Obtain the ``arbiter``. It returns the arbiter instance only if we are on the arbiter context domain, otherwise it returns nothing. ''' arbiter = get_actor() if arbiter is None: # Create the arbiter return set_actor(_spawn_actor('arbiter', None, **param...
python
def arbiter(**params): '''Obtain the ``arbiter``. It returns the arbiter instance only if we are on the arbiter context domain, otherwise it returns nothing. ''' arbiter = get_actor() if arbiter is None: # Create the arbiter return set_actor(_spawn_actor('arbiter', None, **param...
[ "def", "arbiter", "(", "*", "*", "params", ")", ":", "arbiter", "=", "get_actor", "(", ")", "if", "arbiter", "is", "None", ":", "# Create the arbiter", "return", "set_actor", "(", "_spawn_actor", "(", "'arbiter'", ",", "None", ",", "*", "*", "params", ")...
Obtain the ``arbiter``. It returns the arbiter instance only if we are on the arbiter context domain, otherwise it returns nothing.
[ "Obtain", "the", "arbiter", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/monitor.py#L24-L35
245,074
quantmind/pulsar
pulsar/async/monitor.py
MonitorMixin.manage_actor
def manage_actor(self, monitor, actor, stop=False): '''If an actor failed to notify itself to the arbiter for more than the timeout, stop the actor. :param actor: the :class:`Actor` to manage. :param stop: if ``True``, stop the actor. :return: if the actor is alive 0 if it is no...
python
def manage_actor(self, monitor, actor, stop=False): '''If an actor failed to notify itself to the arbiter for more than the timeout, stop the actor. :param actor: the :class:`Actor` to manage. :param stop: if ``True``, stop the actor. :return: if the actor is alive 0 if it is no...
[ "def", "manage_actor", "(", "self", ",", "monitor", ",", "actor", ",", "stop", "=", "False", ")", ":", "if", "not", "monitor", ".", "is_running", "(", ")", ":", "stop", "=", "True", "if", "not", "actor", ".", "is_alive", "(", ")", ":", "if", "not",...
If an actor failed to notify itself to the arbiter for more than the timeout, stop the actor. :param actor: the :class:`Actor` to manage. :param stop: if ``True``, stop the actor. :return: if the actor is alive 0 if it is not.
[ "If", "an", "actor", "failed", "to", "notify", "itself", "to", "the", "arbiter", "for", "more", "than", "the", "timeout", "stop", "the", "actor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/monitor.py#L102-L143
245,075
quantmind/pulsar
pulsar/async/monitor.py
MonitorMixin.spawn_actors
def spawn_actors(self, monitor): '''Spawn new actors if needed. ''' to_spawn = monitor.cfg.workers - len(self.managed_actors) if monitor.cfg.workers and to_spawn > 0: for _ in range(to_spawn): monitor.spawn()
python
def spawn_actors(self, monitor): '''Spawn new actors if needed. ''' to_spawn = monitor.cfg.workers - len(self.managed_actors) if monitor.cfg.workers and to_spawn > 0: for _ in range(to_spawn): monitor.spawn()
[ "def", "spawn_actors", "(", "self", ",", "monitor", ")", ":", "to_spawn", "=", "monitor", ".", "cfg", ".", "workers", "-", "len", "(", "self", ".", "managed_actors", ")", "if", "monitor", ".", "cfg", ".", "workers", "and", "to_spawn", ">", "0", ":", ...
Spawn new actors if needed.
[ "Spawn", "new", "actors", "if", "needed", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/monitor.py#L145-L151
245,076
quantmind/pulsar
pulsar/async/monitor.py
MonitorMixin.stop_actors
def stop_actors(self, monitor): """Maintain the number of workers by spawning or killing as required """ if monitor.cfg.workers: num_to_kill = len(self.managed_actors) - monitor.cfg.workers for i in range(num_to_kill, 0, -1): w, kage = 0, sys.maxsize ...
python
def stop_actors(self, monitor): if monitor.cfg.workers: num_to_kill = len(self.managed_actors) - monitor.cfg.workers for i in range(num_to_kill, 0, -1): w, kage = 0, sys.maxsize for worker in self.managed_actors.values(): age = worker.i...
[ "def", "stop_actors", "(", "self", ",", "monitor", ")", ":", "if", "monitor", ".", "cfg", ".", "workers", ":", "num_to_kill", "=", "len", "(", "self", ".", "managed_actors", ")", "-", "monitor", ".", "cfg", ".", "workers", "for", "i", "in", "range", ...
Maintain the number of workers by spawning or killing as required
[ "Maintain", "the", "number", "of", "workers", "by", "spawning", "or", "killing", "as", "required" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/monitor.py#L153-L164
245,077
quantmind/pulsar
pulsar/async/monitor.py
ArbiterMixin.add_monitor
def add_monitor(self, actor, monitor_name, **params): '''Add a new ``monitor``. :param monitor_class: a :class:`.Monitor` class. :param monitor_name: a unique name for the monitor. :param kwargs: dictionary of key-valued parameters for the monitor. :return: the :class:`.Monitor`...
python
def add_monitor(self, actor, monitor_name, **params): '''Add a new ``monitor``. :param monitor_class: a :class:`.Monitor` class. :param monitor_name: a unique name for the monitor. :param kwargs: dictionary of key-valued parameters for the monitor. :return: the :class:`.Monitor`...
[ "def", "add_monitor", "(", "self", ",", "actor", ",", "monitor_name", ",", "*", "*", "params", ")", ":", "if", "monitor_name", "in", "self", ".", "registered", ":", "raise", "KeyError", "(", "'Monitor \"%s\" already available'", "%", "monitor_name", ")", "para...
Add a new ``monitor``. :param monitor_class: a :class:`.Monitor` class. :param monitor_name: a unique name for the monitor. :param kwargs: dictionary of key-valued parameters for the monitor. :return: the :class:`.Monitor` added.
[ "Add", "a", "new", "monitor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/monitor.py#L202-L215
245,078
quantmind/pulsar
pulsar/apps/data/store.py
PubSub.publish_event
def publish_event(self, channel, event, message): '''Publish a new event ``message`` to a ``channel``. ''' assert self.protocol is not None, "Protocol required" msg = {'event': event, 'channel': channel} if message: msg['data'] = message return self.publish(ch...
python
def publish_event(self, channel, event, message): '''Publish a new event ``message`` to a ``channel``. ''' assert self.protocol is not None, "Protocol required" msg = {'event': event, 'channel': channel} if message: msg['data'] = message return self.publish(ch...
[ "def", "publish_event", "(", "self", ",", "channel", ",", "event", ",", "message", ")", ":", "assert", "self", ".", "protocol", "is", "not", "None", ",", "\"Protocol required\"", "msg", "=", "{", "'event'", ":", "event", ",", "'channel'", ":", "channel", ...
Publish a new event ``message`` to a ``channel``.
[ "Publish", "a", "new", "event", "message", "to", "a", "channel", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/store.py#L303-L310
245,079
quantmind/pulsar
pulsar/async/concurrency.py
Concurrency.spawn
def spawn(self, actor, aid=None, **params): '''Spawn a new actor from ``actor``. ''' aid = aid or create_aid() future = actor.send('arbiter', 'spawn', aid=aid, **params) return actor_proxy_future(aid, future)
python
def spawn(self, actor, aid=None, **params): '''Spawn a new actor from ``actor``. ''' aid = aid or create_aid() future = actor.send('arbiter', 'spawn', aid=aid, **params) return actor_proxy_future(aid, future)
[ "def", "spawn", "(", "self", ",", "actor", ",", "aid", "=", "None", ",", "*", "*", "params", ")", ":", "aid", "=", "aid", "or", "create_aid", "(", ")", "future", "=", "actor", ".", "send", "(", "'arbiter'", ",", "'spawn'", ",", "aid", "=", "aid",...
Spawn a new actor from ``actor``.
[ "Spawn", "a", "new", "actor", "from", "actor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/concurrency.py#L90-L95
245,080
quantmind/pulsar
pulsar/async/concurrency.py
Concurrency.run_actor
def run_actor(self, actor): '''Start running the ``actor``. ''' set_actor(actor) if not actor.mailbox.address: address = ('127.0.0.1', 0) actor._loop.create_task( actor.mailbox.start_serving(address=address) ) actor._loop.run_fo...
python
def run_actor(self, actor): '''Start running the ``actor``. ''' set_actor(actor) if not actor.mailbox.address: address = ('127.0.0.1', 0) actor._loop.create_task( actor.mailbox.start_serving(address=address) ) actor._loop.run_fo...
[ "def", "run_actor", "(", "self", ",", "actor", ")", ":", "set_actor", "(", "actor", ")", "if", "not", "actor", ".", "mailbox", ".", "address", ":", "address", "=", "(", "'127.0.0.1'", ",", "0", ")", "actor", ".", "_loop", ".", "create_task", "(", "ac...
Start running the ``actor``.
[ "Start", "running", "the", "actor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/concurrency.py#L97-L106
245,081
quantmind/pulsar
pulsar/async/concurrency.py
Concurrency.setup_event_loop
def setup_event_loop(self, actor): '''Set up the event loop for ``actor``. ''' actor.logger = self.cfg.configured_logger('pulsar.%s' % actor.name) try: loop = asyncio.get_event_loop() except RuntimeError: if self.cfg and self.cfg.concurrency == 'thread': ...
python
def setup_event_loop(self, actor): '''Set up the event loop for ``actor``. ''' actor.logger = self.cfg.configured_logger('pulsar.%s' % actor.name) try: loop = asyncio.get_event_loop() except RuntimeError: if self.cfg and self.cfg.concurrency == 'thread': ...
[ "def", "setup_event_loop", "(", "self", ",", "actor", ")", ":", "actor", ".", "logger", "=", "self", ".", "cfg", ".", "configured_logger", "(", "'pulsar.%s'", "%", "actor", ".", "name", ")", "try", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(",...
Set up the event loop for ``actor``.
[ "Set", "up", "the", "event", "loop", "for", "actor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/concurrency.py#L111-L126
245,082
quantmind/pulsar
pulsar/async/concurrency.py
Concurrency.hand_shake
def hand_shake(self, actor, run=True): '''Perform the hand shake for ``actor`` The hand shake occurs when the ``actor`` is in starting state. It performs the following actions: * set the ``actor`` as the actor of the current thread * bind two additional callbacks to the ``start...
python
def hand_shake(self, actor, run=True): '''Perform the hand shake for ``actor`` The hand shake occurs when the ``actor`` is in starting state. It performs the following actions: * set the ``actor`` as the actor of the current thread * bind two additional callbacks to the ``start...
[ "def", "hand_shake", "(", "self", ",", "actor", ",", "run", "=", "True", ")", ":", "try", ":", "assert", "actor", ".", "state", "==", "ACTOR_STATES", ".", "STARTING", "if", "actor", ".", "cfg", ".", "debug", ":", "actor", ".", "logger", ".", "debug",...
Perform the hand shake for ``actor`` The hand shake occurs when the ``actor`` is in starting state. It performs the following actions: * set the ``actor`` as the actor of the current thread * bind two additional callbacks to the ``start`` event * fire the ``start`` event ...
[ "Perform", "the", "hand", "shake", "for", "actor" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/concurrency.py#L128-L149
245,083
quantmind/pulsar
pulsar/async/concurrency.py
Concurrency.create_mailbox
def create_mailbox(self, actor, loop): '''Create the mailbox for ``actor``.''' client = MailboxClient(actor.monitor.address, actor, loop) loop.call_soon_threadsafe(self.hand_shake, actor) return client
python
def create_mailbox(self, actor, loop): '''Create the mailbox for ``actor``.''' client = MailboxClient(actor.monitor.address, actor, loop) loop.call_soon_threadsafe(self.hand_shake, actor) return client
[ "def", "create_mailbox", "(", "self", ",", "actor", ",", "loop", ")", ":", "client", "=", "MailboxClient", "(", "actor", ".", "monitor", ".", "address", ",", "actor", ",", "loop", ")", "loop", ".", "call_soon_threadsafe", "(", "self", ".", "hand_shake", ...
Create the mailbox for ``actor``.
[ "Create", "the", "mailbox", "for", "actor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/concurrency.py#L156-L160
245,084
quantmind/pulsar
pulsar/async/concurrency.py
Concurrency.stop
def stop(self, actor, exc=None, exit_code=None): """Gracefully stop the ``actor``. """ if actor.state <= ACTOR_STATES.RUN: # The actor has not started the stopping process. Starts it now. actor.state = ACTOR_STATES.STOPPING actor.event('start').clear() ...
python
def stop(self, actor, exc=None, exit_code=None): if actor.state <= ACTOR_STATES.RUN: # The actor has not started the stopping process. Starts it now. actor.state = ACTOR_STATES.STOPPING actor.event('start').clear() if exc: if not exit_code: ...
[ "def", "stop", "(", "self", ",", "actor", ",", "exc", "=", "None", ",", "exit_code", "=", "None", ")", ":", "if", "actor", ".", "state", "<=", "ACTOR_STATES", ".", "RUN", ":", "# The actor has not started the stopping process. Starts it now.", "actor", ".", "s...
Gracefully stop the ``actor``.
[ "Gracefully", "stop", "the", "actor", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/concurrency.py#L179-L218
245,085
quantmind/pulsar
pulsar/apps/wsgi/auth.py
DigestAuth.authenticated
def authenticated(self, environ, username=None, password=None, **params): '''Called by the server to check if client is authenticated.''' if username != self.username: return False o = self.options qop = o.get('qop') method = environ['REQUEST_METHOD'] uri = en...
python
def authenticated(self, environ, username=None, password=None, **params): '''Called by the server to check if client is authenticated.''' if username != self.username: return False o = self.options qop = o.get('qop') method = environ['REQUEST_METHOD'] uri = en...
[ "def", "authenticated", "(", "self", ",", "environ", ",", "username", "=", "None", ",", "password", "=", "None", ",", "*", "*", "params", ")", ":", "if", "username", "!=", "self", ".", "username", ":", "return", "False", "o", "=", "self", ".", "optio...
Called by the server to check if client is authenticated.
[ "Called", "by", "the", "server", "to", "check", "if", "client", "is", "authenticated", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/auth.py#L103-L120
245,086
quantmind/pulsar
pulsar/apps/data/channels.py
Channels.register
async def register(self, channel, event, callback): """Register a callback to ``channel_name`` and ``event``. A prefix will be added to the channel name if not already available or the prefix is an empty string :param channel: channel name :param event: event name :para...
python
async def register(self, channel, event, callback): channel = self.channel(channel) event = channel.register(event, callback) await channel.connect(event.name) return channel
[ "async", "def", "register", "(", "self", ",", "channel", ",", "event", ",", "callback", ")", ":", "channel", "=", "self", ".", "channel", "(", "channel", ")", "event", "=", "channel", ".", "register", "(", "event", ",", "callback", ")", "await", "chann...
Register a callback to ``channel_name`` and ``event``. A prefix will be added to the channel name if not already available or the prefix is an empty string :param channel: channel name :param event: event name :param callback: callback to execute when event on channel occurs ...
[ "Register", "a", "callback", "to", "channel_name", "and", "event", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/channels.py#L135-L150
245,087
quantmind/pulsar
pulsar/apps/data/channels.py
Channels.unregister
async def unregister(self, channel, event, callback): """Safely unregister a callback from the list of ``event`` callbacks for ``channel_name``. :param channel: channel name :param event: event name :param callback: callback to execute when event on channel occurs :retur...
python
async def unregister(self, channel, event, callback): channel = self.channel(channel, create=False) if channel: channel.unregister(event, callback) if not channel: await channel.disconnect() self.channels.pop(channel.name) return channel
[ "async", "def", "unregister", "(", "self", ",", "channel", ",", "event", ",", "callback", ")", ":", "channel", "=", "self", ".", "channel", "(", "channel", ",", "create", "=", "False", ")", "if", "channel", ":", "channel", ".", "unregister", "(", "even...
Safely unregister a callback from the list of ``event`` callbacks for ``channel_name``. :param channel: channel name :param event: event name :param callback: callback to execute when event on channel occurs :return: a coroutine which results in the channel object where the ...
[ "Safely", "unregister", "a", "callback", "from", "the", "list", "of", "event", "callbacks", "for", "channel_name", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/channels.py#L152-L168
245,088
quantmind/pulsar
pulsar/apps/data/channels.py
Channels.connect
async def connect(self, next_time=None): """Connect with store :return: a coroutine and therefore it must be awaited """ if self.status in can_connect: loop = self._loop if loop.is_running(): self.status = StatusType.connecting awa...
python
async def connect(self, next_time=None): if self.status in can_connect: loop = self._loop if loop.is_running(): self.status = StatusType.connecting await self._connect(next_time)
[ "async", "def", "connect", "(", "self", ",", "next_time", "=", "None", ")", ":", "if", "self", ".", "status", "in", "can_connect", ":", "loop", "=", "self", ".", "_loop", "if", "loop", ".", "is_running", "(", ")", ":", "self", ".", "status", "=", "...
Connect with store :return: a coroutine and therefore it must be awaited
[ "Connect", "with", "store" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/channels.py#L170-L179
245,089
quantmind/pulsar
pulsar/apps/data/channels.py
Channel.register
def register(self, event, callback): """Register a ``callback`` for ``event`` """ pattern = self.channels.event_pattern(event) entry = self.callbacks.get(pattern) if not entry: entry = event_callbacks(event, pattern, re.compile(pattern), []) self.callbacks...
python
def register(self, event, callback): pattern = self.channels.event_pattern(event) entry = self.callbacks.get(pattern) if not entry: entry = event_callbacks(event, pattern, re.compile(pattern), []) self.callbacks[entry.pattern] = entry if callback not in entry.cal...
[ "def", "register", "(", "self", ",", "event", ",", "callback", ")", ":", "pattern", "=", "self", ".", "channels", ".", "event_pattern", "(", "event", ")", "entry", "=", "self", ".", "callbacks", ".", "get", "(", "pattern", ")", "if", "not", "entry", ...
Register a ``callback`` for ``event``
[ "Register", "a", "callback", "for", "event" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/channels.py#L329-L341
245,090
quantmind/pulsar
pulsar/async/futures.py
add_errback
def add_errback(future, callback, loop=None): '''Add a ``callback`` to a ``future`` executed only if an exception or cancellation has occurred.''' def _error_back(fut): if fut._exception: callback(fut.exception()) elif fut.cancelled(): callback(CancelledError()) ...
python
def add_errback(future, callback, loop=None): '''Add a ``callback`` to a ``future`` executed only if an exception or cancellation has occurred.''' def _error_back(fut): if fut._exception: callback(fut.exception()) elif fut.cancelled(): callback(CancelledError()) ...
[ "def", "add_errback", "(", "future", ",", "callback", ",", "loop", "=", "None", ")", ":", "def", "_error_back", "(", "fut", ")", ":", "if", "fut", ".", "_exception", ":", "callback", "(", "fut", ".", "exception", "(", ")", ")", "elif", "fut", ".", ...
Add a ``callback`` to a ``future`` executed only if an exception or cancellation has occurred.
[ "Add", "a", "callback", "to", "a", "future", "executed", "only", "if", "an", "exception", "or", "cancellation", "has", "occurred", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/futures.py#L58-L69
245,091
quantmind/pulsar
pulsar/async/futures.py
AsyncObject.timeit
def timeit(self, method, times, *args, **kwargs): '''Useful utility for benchmarking an asynchronous ``method``. :param method: the name of the ``method`` to execute :param times: number of times to execute the ``method`` :param args: positional arguments to pass to the ``method`` ...
python
def timeit(self, method, times, *args, **kwargs): '''Useful utility for benchmarking an asynchronous ``method``. :param method: the name of the ``method`` to execute :param times: number of times to execute the ``method`` :param args: positional arguments to pass to the ``method`` ...
[ "def", "timeit", "(", "self", ",", "method", ",", "times", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "bench", "=", "Bench", "(", "times", ",", "loop", "=", "self", ".", "_loop", ")", "return", "bench", "(", "getattr", "(", "self", ",",...
Useful utility for benchmarking an asynchronous ``method``. :param method: the name of the ``method`` to execute :param times: number of times to execute the ``method`` :param args: positional arguments to pass to the ``method`` :param kwargs: key-valued arguments to pass to the ``metho...
[ "Useful", "utility", "for", "benchmarking", "an", "asynchronous", "method", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/futures.py#L194-L209
245,092
quantmind/pulsar
pulsar/apps/http/stream.py
HttpStream.read
async def read(self, n=None): """Read all content """ if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer)
python
async def read(self, n=None): if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer)
[ "async", "def", "read", "(", "self", ",", "n", "=", "None", ")", ":", "if", "self", ".", "_streamed", ":", "return", "b''", "buffer", "=", "[", "]", "async", "for", "body", "in", "self", ":", "buffer", ".", "append", "(", "body", ")", "return", "...
Read all content
[ "Read", "all", "content" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/http/stream.py#L27-L35
245,093
quantmind/pulsar
pulsar/async/commands.py
notify
def notify(request, info): '''The actor notify itself with a dictionary of information. The command perform the following actions: * Update the mailbox to the current consumer of the actor connection * Update the info dictionary * Returns the time of the update ''' t = time() actor = r...
python
def notify(request, info): '''The actor notify itself with a dictionary of information. The command perform the following actions: * Update the mailbox to the current consumer of the actor connection * Update the info dictionary * Returns the time of the update ''' t = time() actor = r...
[ "def", "notify", "(", "request", ",", "info", ")", ":", "t", "=", "time", "(", ")", "actor", "=", "request", ".", "actor", "remote_actor", "=", "request", ".", "caller", "if", "isinstance", "(", "remote_actor", ",", "ActorProxyMonitor", ")", ":", "remote...
The actor notify itself with a dictionary of information. The command perform the following actions: * Update the mailbox to the current consumer of the actor connection * Update the info dictionary * Returns the time of the update
[ "The", "actor", "notify", "itself", "with", "a", "dictionary", "of", "information", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/commands.py#L49-L78
245,094
quantmind/pulsar
pulsar/async/mixins.py
FlowControl.write
def write(self, data): """Write ``data`` into the wire. Returns an empty tuple or a :class:`~asyncio.Future` if this protocol has paused writing. """ if self.closed: raise ConnectionResetError( 'Transport closed - cannot write on %s' % self ...
python
def write(self, data): if self.closed: raise ConnectionResetError( 'Transport closed - cannot write on %s' % self ) else: t = self.transport if self._paused or self._buffer: self._buffer.appendleft(data) self...
[ "def", "write", "(", "self", ",", "data", ")", ":", "if", "self", ".", "closed", ":", "raise", "ConnectionResetError", "(", "'Transport closed - cannot write on %s'", "%", "self", ")", "else", ":", "t", "=", "self", ".", "transport", "if", "self", ".", "_p...
Write ``data`` into the wire. Returns an empty tuple or a :class:`~asyncio.Future` if this protocol has paused writing.
[ "Write", "data", "into", "the", "wire", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/mixins.py#L20-L48
245,095
quantmind/pulsar
pulsar/async/mixins.py
Pipeline.pipeline
def pipeline(self, consumer): """Add a consumer to the pipeline """ if self._pipeline is None: self._pipeline = ResponsePipeline(self) self.event('connection_lost').bind(self._close_pipeline) self._pipeline.put(consumer)
python
def pipeline(self, consumer): if self._pipeline is None: self._pipeline = ResponsePipeline(self) self.event('connection_lost').bind(self._close_pipeline) self._pipeline.put(consumer)
[ "def", "pipeline", "(", "self", ",", "consumer", ")", ":", "if", "self", ".", "_pipeline", "is", "None", ":", "self", ".", "_pipeline", "=", "ResponsePipeline", "(", "self", ")", "self", ".", "event", "(", "'connection_lost'", ")", ".", "bind", "(", "s...
Add a consumer to the pipeline
[ "Add", "a", "consumer", "to", "the", "pipeline" ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/mixins.py#L157-L163
245,096
quantmind/pulsar
pulsar/utils/pylib/websocket.py
FrameParser.encode
def encode(self, message, final=True, masking_key=None, opcode=None, rsv1=0, rsv2=0, rsv3=0): '''Encode a ``message`` for writing into the wire. To produce several frames for a given large message use :meth:`multi_encode` method. ''' fin = 1 if final else 0 ...
python
def encode(self, message, final=True, masking_key=None, opcode=None, rsv1=0, rsv2=0, rsv3=0): '''Encode a ``message`` for writing into the wire. To produce several frames for a given large message use :meth:`multi_encode` method. ''' fin = 1 if final else 0 ...
[ "def", "encode", "(", "self", ",", "message", ",", "final", "=", "True", ",", "masking_key", "=", "None", ",", "opcode", "=", "None", ",", "rsv1", "=", "0", ",", "rsv2", "=", "0", ",", "rsv3", "=", "0", ")", ":", "fin", "=", "1", "if", "final",...
Encode a ``message`` for writing into the wire. To produce several frames for a given large message use :meth:`multi_encode` method.
[ "Encode", "a", "message", "for", "writing", "into", "the", "wire", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/websocket.py#L140-L150
245,097
quantmind/pulsar
pulsar/utils/pylib/websocket.py
FrameParser.multi_encode
def multi_encode(self, message, masking_key=None, opcode=None, rsv1=0, rsv2=0, rsv3=0, max_payload=0): '''Encode a ``message`` into several frames depending on size. Returns a generator of bytes to be sent over the wire. ''' max_payload = max(2, max_payload or self....
python
def multi_encode(self, message, masking_key=None, opcode=None, rsv1=0, rsv2=0, rsv3=0, max_payload=0): '''Encode a ``message`` into several frames depending on size. Returns a generator of bytes to be sent over the wire. ''' max_payload = max(2, max_payload or self....
[ "def", "multi_encode", "(", "self", ",", "message", ",", "masking_key", "=", "None", ",", "opcode", "=", "None", ",", "rsv1", "=", "0", ",", "rsv2", "=", "0", ",", "rsv3", "=", "0", ",", "max_payload", "=", "0", ")", ":", "max_payload", "=", "max",...
Encode a ``message`` into several frames depending on size. Returns a generator of bytes to be sent over the wire.
[ "Encode", "a", "message", "into", "several", "frames", "depending", "on", "size", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/websocket.py#L152-L168
245,098
quantmind/pulsar
pulsar/apps/data/redis/client.py
RedisClient.sort
def sort(self, key, start=None, num=None, by=None, get=None, desc=False, alpha=False, store=None, groups=False): '''Sort and return the list, set or sorted set at ``key``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight ...
python
def sort(self, key, start=None, num=None, by=None, get=None, desc=False, alpha=False, store=None, groups=False): '''Sort and return the list, set or sorted set at ``key``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight ...
[ "def", "sort", "(", "self", ",", "key", ",", "start", "=", "None", ",", "num", "=", "None", ",", "by", "=", "None", ",", "get", "=", "None", ",", "desc", "=", "False", ",", "alpha", "=", "False", ",", "store", "=", "None", ",", "groups", "=", ...
Sort and return the list, set or sorted set at ``key``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight and sort the items. Use an "*" to indicate where in the key the item value is located ``get`` allows for returning i...
[ "Sort", "and", "return", "the", "list", "set", "or", "sorted", "set", "at", "key", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/redis/client.py#L434-L498
245,099
quantmind/pulsar
pulsar/apps/data/redis/client.py
Pipeline.commit
def commit(self, raise_on_error=True): '''Send commands to redis. ''' cmds = list(chain([(('multi',), {})], self.command_stack, [(('exec',), {})])) self.reset() return self.store.execute_pipeline(cmds, raise_on_error)
python
def commit(self, raise_on_error=True): '''Send commands to redis. ''' cmds = list(chain([(('multi',), {})], self.command_stack, [(('exec',), {})])) self.reset() return self.store.execute_pipeline(cmds, raise_on_error)
[ "def", "commit", "(", "self", ",", "raise_on_error", "=", "True", ")", ":", "cmds", "=", "list", "(", "chain", "(", "[", "(", "(", "'multi'", ",", ")", ",", "{", "}", ")", "]", ",", "self", ".", "command_stack", ",", "[", "(", "(", "'exec'", ",...
Send commands to redis.
[ "Send", "commands", "to", "redis", "." ]
fee44e871954aa6ca36d00bb5a3739abfdb89b26
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/redis/client.py#L533-L539