partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Var.find_in_ns | Return the value current bound to the name `name_sym` in the namespace
specified by `ns_sym`. | src/basilisp/lang/runtime.py | def find_in_ns(ns_sym: sym.Symbol, name_sym: sym.Symbol) -> "Optional[Var]":
"""Return the value current bound to the name `name_sym` in the namespace
specified by `ns_sym`."""
ns = Namespace.get(ns_sym)
if ns:
return ns.find(name_sym)
return None | def find_in_ns(ns_sym: sym.Symbol, name_sym: sym.Symbol) -> "Optional[Var]":
"""Return the value current bound to the name `name_sym` in the namespace
specified by `ns_sym`."""
ns = Namespace.get(ns_sym)
if ns:
return ns.find(name_sym)
return None | [
"Return",
"the",
"value",
"current",
"bound",
"to",
"the",
"name",
"name_sym",
"in",
"the",
"namespace",
"specified",
"by",
"ns_sym",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L251-L257 | [
"def",
"find_in_ns",
"(",
"ns_sym",
":",
"sym",
".",
"Symbol",
",",
"name_sym",
":",
"sym",
".",
"Symbol",
")",
"->",
"\"Optional[Var]\"",
":",
"ns",
"=",
"Namespace",
".",
"get",
"(",
"ns_sym",
")",
"if",
"ns",
":",
"return",
"ns",
".",
"find",
"(",... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Var.find | Return the value currently bound to the name in the namespace specified
by `ns_qualified_sym`. | src/basilisp/lang/runtime.py | def find(ns_qualified_sym: sym.Symbol) -> "Optional[Var]":
"""Return the value currently bound to the name in the namespace specified
by `ns_qualified_sym`."""
ns = Maybe(ns_qualified_sym.ns).or_else_raise(
lambda: ValueError(
f"Namespace must be specified in Symbol {... | def find(ns_qualified_sym: sym.Symbol) -> "Optional[Var]":
"""Return the value currently bound to the name in the namespace specified
by `ns_qualified_sym`."""
ns = Maybe(ns_qualified_sym.ns).or_else_raise(
lambda: ValueError(
f"Namespace must be specified in Symbol {... | [
"Return",
"the",
"value",
"currently",
"bound",
"to",
"the",
"name",
"in",
"the",
"namespace",
"specified",
"by",
"ns_qualified_sym",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L260-L270 | [
"def",
"find",
"(",
"ns_qualified_sym",
":",
"sym",
".",
"Symbol",
")",
"->",
"\"Optional[Var]\"",
":",
"ns",
"=",
"Maybe",
"(",
"ns_qualified_sym",
".",
"ns",
")",
".",
"or_else_raise",
"(",
"lambda",
":",
"ValueError",
"(",
"f\"Namespace must be specified in S... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Var.find_safe | Return the Var currently bound to the name in the namespace specified
by `ns_qualified_sym`. If no Var is bound to that name, raise an exception.
This is a utility method to return useful debugging information when code
refers to an invalid symbol at runtime. | src/basilisp/lang/runtime.py | def find_safe(ns_qualified_sym: sym.Symbol) -> "Var":
"""Return the Var currently bound to the name in the namespace specified
by `ns_qualified_sym`. If no Var is bound to that name, raise an exception.
This is a utility method to return useful debugging information when code
refers to ... | def find_safe(ns_qualified_sym: sym.Symbol) -> "Var":
"""Return the Var currently bound to the name in the namespace specified
by `ns_qualified_sym`. If no Var is bound to that name, raise an exception.
This is a utility method to return useful debugging information when code
refers to ... | [
"Return",
"the",
"Var",
"currently",
"bound",
"to",
"the",
"name",
"in",
"the",
"namespace",
"specified",
"by",
"ns_qualified_sym",
".",
"If",
"no",
"Var",
"is",
"bound",
"to",
"that",
"name",
"raise",
"an",
"exception",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L273-L284 | [
"def",
"find_safe",
"(",
"ns_qualified_sym",
":",
"sym",
".",
"Symbol",
")",
"->",
"\"Var\"",
":",
"v",
"=",
"Var",
".",
"find",
"(",
"ns_qualified_sym",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"RuntimeException",
"(",
"f\"Unable to resolve symbol {ns_qual... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.add_default_import | Add a gated default import to the default imports.
In particular, we need to avoid importing 'basilisp.core' before we have
finished macro-expanding. | src/basilisp/lang/runtime.py | def add_default_import(cls, module: str):
"""Add a gated default import to the default imports.
In particular, we need to avoid importing 'basilisp.core' before we have
finished macro-expanding."""
if module in cls.GATED_IMPORTS:
cls.DEFAULT_IMPORTS.swap(lambda s: s.cons(sym... | def add_default_import(cls, module: str):
"""Add a gated default import to the default imports.
In particular, we need to avoid importing 'basilisp.core' before we have
finished macro-expanding."""
if module in cls.GATED_IMPORTS:
cls.DEFAULT_IMPORTS.swap(lambda s: s.cons(sym... | [
"Add",
"a",
"gated",
"default",
"import",
"to",
"the",
"default",
"imports",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L383-L389 | [
"def",
"add_default_import",
"(",
"cls",
",",
"module",
":",
"str",
")",
":",
"if",
"module",
"in",
"cls",
".",
"GATED_IMPORTS",
":",
"cls",
".",
"DEFAULT_IMPORTS",
".",
"swap",
"(",
"lambda",
"s",
":",
"s",
".",
"cons",
"(",
"sym",
".",
"symbol",
"(... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.add_alias | Add a Symbol alias for the given Namespace. | src/basilisp/lang/runtime.py | def add_alias(self, alias: sym.Symbol, namespace: "Namespace") -> None:
"""Add a Symbol alias for the given Namespace."""
self._aliases.swap(lambda m: m.assoc(alias, namespace)) | def add_alias(self, alias: sym.Symbol, namespace: "Namespace") -> None:
"""Add a Symbol alias for the given Namespace."""
self._aliases.swap(lambda m: m.assoc(alias, namespace)) | [
"Add",
"a",
"Symbol",
"alias",
"for",
"the",
"given",
"Namespace",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L445-L447 | [
"def",
"add_alias",
"(",
"self",
",",
"alias",
":",
"sym",
".",
"Symbol",
",",
"namespace",
":",
"\"Namespace\"",
")",
"->",
"None",
":",
"self",
".",
"_aliases",
".",
"swap",
"(",
"lambda",
"m",
":",
"m",
".",
"assoc",
"(",
"alias",
",",
"namespace"... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.intern | Intern the Var given in this namespace mapped by the given Symbol.
If the Symbol already maps to a Var, this method _will not overwrite_
the existing Var mapping unless the force keyword argument is given
and is True. | src/basilisp/lang/runtime.py | def intern(self, sym: sym.Symbol, var: Var, force: bool = False) -> Var:
"""Intern the Var given in this namespace mapped by the given Symbol.
If the Symbol already maps to a Var, this method _will not overwrite_
the existing Var mapping unless the force keyword argument is given
and is ... | def intern(self, sym: sym.Symbol, var: Var, force: bool = False) -> Var:
"""Intern the Var given in this namespace mapped by the given Symbol.
If the Symbol already maps to a Var, this method _will not overwrite_
the existing Var mapping unless the force keyword argument is given
and is ... | [
"Intern",
"the",
"Var",
"given",
"in",
"this",
"namespace",
"mapped",
"by",
"the",
"given",
"Symbol",
".",
"If",
"the",
"Symbol",
"already",
"maps",
"to",
"a",
"Var",
"this",
"method",
"_will",
"not",
"overwrite_",
"the",
"existing",
"Var",
"mapping",
"unl... | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L453-L459 | [
"def",
"intern",
"(",
"self",
",",
"sym",
":",
"sym",
".",
"Symbol",
",",
"var",
":",
"Var",
",",
"force",
":",
"bool",
"=",
"False",
")",
"->",
"Var",
":",
"m",
":",
"lmap",
".",
"Map",
"=",
"self",
".",
"_interns",
".",
"swap",
"(",
"Namespac... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace._intern | Swap function used by intern to atomically intern a new variable in
the symbol mapping for this Namespace. | src/basilisp/lang/runtime.py | def _intern(
m: lmap.Map, sym: sym.Symbol, new_var: Var, force: bool = False
) -> lmap.Map:
"""Swap function used by intern to atomically intern a new variable in
the symbol mapping for this Namespace."""
var = m.entry(sym, None)
if var is None or force:
return m.... | def _intern(
m: lmap.Map, sym: sym.Symbol, new_var: Var, force: bool = False
) -> lmap.Map:
"""Swap function used by intern to atomically intern a new variable in
the symbol mapping for this Namespace."""
var = m.entry(sym, None)
if var is None or force:
return m.... | [
"Swap",
"function",
"used",
"by",
"intern",
"to",
"atomically",
"intern",
"a",
"new",
"variable",
"in",
"the",
"symbol",
"mapping",
"for",
"this",
"Namespace",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L462-L470 | [
"def",
"_intern",
"(",
"m",
":",
"lmap",
".",
"Map",
",",
"sym",
":",
"sym",
".",
"Symbol",
",",
"new_var",
":",
"Var",
",",
"force",
":",
"bool",
"=",
"False",
")",
"->",
"lmap",
".",
"Map",
":",
"var",
"=",
"m",
".",
"entry",
"(",
"sym",
",... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.find | Find Vars mapped by the given Symbol input or None if no Vars are
mapped by that Symbol. | src/basilisp/lang/runtime.py | def find(self, sym: sym.Symbol) -> Optional[Var]:
"""Find Vars mapped by the given Symbol input or None if no Vars are
mapped by that Symbol."""
v = self.interns.entry(sym, None)
if v is None:
return self.refers.entry(sym, None)
return v | def find(self, sym: sym.Symbol) -> Optional[Var]:
"""Find Vars mapped by the given Symbol input or None if no Vars are
mapped by that Symbol."""
v = self.interns.entry(sym, None)
if v is None:
return self.refers.entry(sym, None)
return v | [
"Find",
"Vars",
"mapped",
"by",
"the",
"given",
"Symbol",
"input",
"or",
"None",
"if",
"no",
"Vars",
"are",
"mapped",
"by",
"that",
"Symbol",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L472-L478 | [
"def",
"find",
"(",
"self",
",",
"sym",
":",
"sym",
".",
"Symbol",
")",
"->",
"Optional",
"[",
"Var",
"]",
":",
"v",
"=",
"self",
".",
"interns",
".",
"entry",
"(",
"sym",
",",
"None",
")",
"if",
"v",
"is",
"None",
":",
"return",
"self",
".",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.add_import | Add the Symbol as an imported Symbol in this Namespace. If aliases are given,
the aliases will be applied to the | src/basilisp/lang/runtime.py | def add_import(
self, sym: sym.Symbol, module: types.ModuleType, *aliases: sym.Symbol
) -> None:
"""Add the Symbol as an imported Symbol in this Namespace. If aliases are given,
the aliases will be applied to the """
self._imports.swap(lambda m: m.assoc(sym, module))
if alias... | def add_import(
self, sym: sym.Symbol, module: types.ModuleType, *aliases: sym.Symbol
) -> None:
"""Add the Symbol as an imported Symbol in this Namespace. If aliases are given,
the aliases will be applied to the """
self._imports.swap(lambda m: m.assoc(sym, module))
if alias... | [
"Add",
"the",
"Symbol",
"as",
"an",
"imported",
"Symbol",
"in",
"this",
"Namespace",
".",
"If",
"aliases",
"are",
"given",
"the",
"aliases",
"will",
"be",
"applied",
"to",
"the"
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L480-L491 | [
"def",
"add_import",
"(",
"self",
",",
"sym",
":",
"sym",
".",
"Symbol",
",",
"module",
":",
"types",
".",
"ModuleType",
",",
"*",
"aliases",
":",
"sym",
".",
"Symbol",
")",
"->",
"None",
":",
"self",
".",
"_imports",
".",
"swap",
"(",
"lambda",
"m... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.get_import | Return the module if a moduled named by sym has been imported into
this Namespace, None otherwise.
First try to resolve a module directly with the given name. If no module
can be resolved, attempt to resolve the module using import aliases. | src/basilisp/lang/runtime.py | def get_import(self, sym: sym.Symbol) -> Optional[types.ModuleType]:
"""Return the module if a moduled named by sym has been imported into
this Namespace, None otherwise.
First try to resolve a module directly with the given name. If no module
can be resolved, attempt to resolve the mod... | def get_import(self, sym: sym.Symbol) -> Optional[types.ModuleType]:
"""Return the module if a moduled named by sym has been imported into
this Namespace, None otherwise.
First try to resolve a module directly with the given name. If no module
can be resolved, attempt to resolve the mod... | [
"Return",
"the",
"module",
"if",
"a",
"moduled",
"named",
"by",
"sym",
"has",
"been",
"imported",
"into",
"this",
"Namespace",
"None",
"otherwise",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L493-L505 | [
"def",
"get_import",
"(",
"self",
",",
"sym",
":",
"sym",
".",
"Symbol",
")",
"->",
"Optional",
"[",
"types",
".",
"ModuleType",
"]",
":",
"mod",
"=",
"self",
".",
"imports",
".",
"entry",
"(",
"sym",
",",
"None",
")",
"if",
"mod",
"is",
"None",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.add_refer | Refer var in this namespace under the name sym. | src/basilisp/lang/runtime.py | def add_refer(self, sym: sym.Symbol, var: Var) -> None:
"""Refer var in this namespace under the name sym."""
if not var.is_private:
self._refers.swap(lambda s: s.assoc(sym, var)) | def add_refer(self, sym: sym.Symbol, var: Var) -> None:
"""Refer var in this namespace under the name sym."""
if not var.is_private:
self._refers.swap(lambda s: s.assoc(sym, var)) | [
"Refer",
"var",
"in",
"this",
"namespace",
"under",
"the",
"name",
"sym",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L507-L510 | [
"def",
"add_refer",
"(",
"self",
",",
"sym",
":",
"sym",
".",
"Symbol",
",",
"var",
":",
"Var",
")",
"->",
"None",
":",
"if",
"not",
"var",
".",
"is_private",
":",
"self",
".",
"_refers",
".",
"swap",
"(",
"lambda",
"s",
":",
"s",
".",
"assoc",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.get_refer | Get the Var referred by Symbol or None if it does not exist. | src/basilisp/lang/runtime.py | def get_refer(self, sym: sym.Symbol) -> Optional[Var]:
"""Get the Var referred by Symbol or None if it does not exist."""
return self.refers.entry(sym, None) | def get_refer(self, sym: sym.Symbol) -> Optional[Var]:
"""Get the Var referred by Symbol or None if it does not exist."""
return self.refers.entry(sym, None) | [
"Get",
"the",
"Var",
"referred",
"by",
"Symbol",
"or",
"None",
"if",
"it",
"does",
"not",
"exist",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L512-L514 | [
"def",
"get_refer",
"(",
"self",
",",
"sym",
":",
"sym",
".",
"Symbol",
")",
"->",
"Optional",
"[",
"Var",
"]",
":",
"return",
"self",
".",
"refers",
".",
"entry",
"(",
"sym",
",",
"None",
")"
] | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__refer_all | Refer all _public_ interns from another namespace. | src/basilisp/lang/runtime.py | def __refer_all(cls, refers: lmap.Map, other_ns_interns: lmap.Map) -> lmap.Map:
"""Refer all _public_ interns from another namespace."""
final_refers = refers
for entry in other_ns_interns:
s: sym.Symbol = entry.key
var: Var = entry.value
if not var.is_private... | def __refer_all(cls, refers: lmap.Map, other_ns_interns: lmap.Map) -> lmap.Map:
"""Refer all _public_ interns from another namespace."""
final_refers = refers
for entry in other_ns_interns:
s: sym.Symbol = entry.key
var: Var = entry.value
if not var.is_private... | [
"Refer",
"all",
"_public_",
"interns",
"from",
"another",
"namespace",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L517-L525 | [
"def",
"__refer_all",
"(",
"cls",
",",
"refers",
":",
"lmap",
".",
"Map",
",",
"other_ns_interns",
":",
"lmap",
".",
"Map",
")",
"->",
"lmap",
".",
"Map",
":",
"final_refers",
"=",
"refers",
"for",
"entry",
"in",
"other_ns_interns",
":",
"s",
":",
"sym... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.refer_all | Refer all the Vars in the other namespace. | src/basilisp/lang/runtime.py | def refer_all(self, other_ns: "Namespace"):
"""Refer all the Vars in the other namespace."""
self._refers.swap(Namespace.__refer_all, other_ns.interns) | def refer_all(self, other_ns: "Namespace"):
"""Refer all the Vars in the other namespace."""
self._refers.swap(Namespace.__refer_all, other_ns.interns) | [
"Refer",
"all",
"the",
"Vars",
"in",
"the",
"other",
"namespace",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L527-L529 | [
"def",
"refer_all",
"(",
"self",
",",
"other_ns",
":",
"\"Namespace\"",
")",
":",
"self",
".",
"_refers",
".",
"swap",
"(",
"Namespace",
".",
"__refer_all",
",",
"other_ns",
".",
"interns",
")"
] | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__get_or_create | Private swap function used by `get_or_create` to atomically swap
the new namespace map into the global cache. | src/basilisp/lang/runtime.py | def __get_or_create(
ns_cache: NamespaceMap,
name: sym.Symbol,
module: types.ModuleType = None,
core_ns_name=CORE_NS,
) -> lmap.Map:
"""Private swap function used by `get_or_create` to atomically swap
the new namespace map into the global cache."""
ns = ns_cac... | def __get_or_create(
ns_cache: NamespaceMap,
name: sym.Symbol,
module: types.ModuleType = None,
core_ns_name=CORE_NS,
) -> lmap.Map:
"""Private swap function used by `get_or_create` to atomically swap
the new namespace map into the global cache."""
ns = ns_cac... | [
"Private",
"swap",
"function",
"used",
"by",
"get_or_create",
"to",
"atomically",
"swap",
"the",
"new",
"namespace",
"map",
"into",
"the",
"global",
"cache",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L537-L553 | [
"def",
"__get_or_create",
"(",
"ns_cache",
":",
"NamespaceMap",
",",
"name",
":",
"sym",
".",
"Symbol",
",",
"module",
":",
"types",
".",
"ModuleType",
"=",
"None",
",",
"core_ns_name",
"=",
"CORE_NS",
",",
")",
"->",
"lmap",
".",
"Map",
":",
"ns",
"="... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.get_or_create | Get the namespace bound to the symbol `name` in the global namespace
cache, creating it if it does not exist.
Return the namespace. | src/basilisp/lang/runtime.py | def get_or_create(
cls, name: sym.Symbol, module: types.ModuleType = None
) -> "Namespace":
"""Get the namespace bound to the symbol `name` in the global namespace
cache, creating it if it does not exist.
Return the namespace."""
return cls._NAMESPACES.swap(Namespace.__get_or... | def get_or_create(
cls, name: sym.Symbol, module: types.ModuleType = None
) -> "Namespace":
"""Get the namespace bound to the symbol `name` in the global namespace
cache, creating it if it does not exist.
Return the namespace."""
return cls._NAMESPACES.swap(Namespace.__get_or... | [
"Get",
"the",
"namespace",
"bound",
"to",
"the",
"symbol",
"name",
"in",
"the",
"global",
"namespace",
"cache",
"creating",
"it",
"if",
"it",
"does",
"not",
"exist",
".",
"Return",
"the",
"namespace",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L556-L564 | [
"def",
"get_or_create",
"(",
"cls",
",",
"name",
":",
"sym",
".",
"Symbol",
",",
"module",
":",
"types",
".",
"ModuleType",
"=",
"None",
")",
"->",
"\"Namespace\"",
":",
"return",
"cls",
".",
"_NAMESPACES",
".",
"swap",
"(",
"Namespace",
".",
"__get_or_c... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.get | Get the namespace bound to the symbol `name` in the global namespace
cache. Return the namespace if it exists or None otherwise.. | src/basilisp/lang/runtime.py | def get(cls, name: sym.Symbol) -> "Optional[Namespace]":
"""Get the namespace bound to the symbol `name` in the global namespace
cache. Return the namespace if it exists or None otherwise.."""
return cls._NAMESPACES.deref().entry(name, None) | def get(cls, name: sym.Symbol) -> "Optional[Namespace]":
"""Get the namespace bound to the symbol `name` in the global namespace
cache. Return the namespace if it exists or None otherwise.."""
return cls._NAMESPACES.deref().entry(name, None) | [
"Get",
"the",
"namespace",
"bound",
"to",
"the",
"symbol",
"name",
"in",
"the",
"global",
"namespace",
"cache",
".",
"Return",
"the",
"namespace",
"if",
"it",
"exists",
"or",
"None",
"otherwise",
".."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L567-L570 | [
"def",
"get",
"(",
"cls",
",",
"name",
":",
"sym",
".",
"Symbol",
")",
"->",
"\"Optional[Namespace]\"",
":",
"return",
"cls",
".",
"_NAMESPACES",
".",
"deref",
"(",
")",
".",
"entry",
"(",
"name",
",",
"None",
")"
] | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.remove | Remove the namespace bound to the symbol `name` in the global
namespace cache and return that namespace.
Return None if the namespace did not exist in the cache. | src/basilisp/lang/runtime.py | def remove(cls, name: sym.Symbol) -> Optional["Namespace"]:
"""Remove the namespace bound to the symbol `name` in the global
namespace cache and return that namespace.
Return None if the namespace did not exist in the cache."""
while True:
oldval: lmap.Map = cls._NAMESPACES.d... | def remove(cls, name: sym.Symbol) -> Optional["Namespace"]:
"""Remove the namespace bound to the symbol `name` in the global
namespace cache and return that namespace.
Return None if the namespace did not exist in the cache."""
while True:
oldval: lmap.Map = cls._NAMESPACES.d... | [
"Remove",
"the",
"namespace",
"bound",
"to",
"the",
"symbol",
"name",
"in",
"the",
"global",
"namespace",
"cache",
"and",
"return",
"that",
"namespace",
".",
"Return",
"None",
"if",
"the",
"namespace",
"did",
"not",
"exist",
"in",
"the",
"cache",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L573-L584 | [
"def",
"remove",
"(",
"cls",
",",
"name",
":",
"sym",
".",
"Symbol",
")",
"->",
"Optional",
"[",
"\"Namespace\"",
"]",
":",
"while",
"True",
":",
"oldval",
":",
"lmap",
".",
"Map",
"=",
"cls",
".",
"_NAMESPACES",
".",
"deref",
"(",
")",
"ns",
":",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__completion_matcher | Return a function which matches any symbol keys from map entries
against the given text. | src/basilisp/lang/runtime.py | def __completion_matcher(text: str) -> CompletionMatcher:
"""Return a function which matches any symbol keys from map entries
against the given text."""
def is_match(entry: Tuple[sym.Symbol, Any]) -> bool:
return entry[0].name.startswith(text)
return is_match | def __completion_matcher(text: str) -> CompletionMatcher:
"""Return a function which matches any symbol keys from map entries
against the given text."""
def is_match(entry: Tuple[sym.Symbol, Any]) -> bool:
return entry[0].name.startswith(text)
return is_match | [
"Return",
"a",
"function",
"which",
"matches",
"any",
"symbol",
"keys",
"from",
"map",
"entries",
"against",
"the",
"given",
"text",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L589-L596 | [
"def",
"__completion_matcher",
"(",
"text",
":",
"str",
")",
"->",
"CompletionMatcher",
":",
"def",
"is_match",
"(",
"entry",
":",
"Tuple",
"[",
"sym",
".",
"Symbol",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"return",
"entry",
"[",
"0",
"]",
".",
"na... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__complete_alias | Return an iterable of possible completions matching the given
prefix from the list of aliased namespaces. If name_in_ns is given,
further attempt to refine the list to matching names in that namespace. | src/basilisp/lang/runtime.py | def __complete_alias(
self, prefix: str, name_in_ns: Optional[str] = None
) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of aliased namespaces. If name_in_ns is given,
further attempt to refine the list to matching names in t... | def __complete_alias(
self, prefix: str, name_in_ns: Optional[str] = None
) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of aliased namespaces. If name_in_ns is given,
further attempt to refine the list to matching names in t... | [
"Return",
"an",
"iterable",
"of",
"possible",
"completions",
"matching",
"the",
"given",
"prefix",
"from",
"the",
"list",
"of",
"aliased",
"namespaces",
".",
"If",
"name_in_ns",
"is",
"given",
"further",
"attempt",
"to",
"refine",
"the",
"list",
"to",
"matchin... | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L598-L615 | [
"def",
"__complete_alias",
"(",
"self",
",",
"prefix",
":",
"str",
",",
"name_in_ns",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"candidates",
"=",
"filter",
"(",
"Namespace",
".",
"__completion_matcher",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__complete_imports_and_aliases | Return an iterable of possible completions matching the given
prefix from the list of imports and aliased imports. If name_in_module
is given, further attempt to refine the list to matching names in that
namespace. | src/basilisp/lang/runtime.py | def __complete_imports_and_aliases(
self, prefix: str, name_in_module: Optional[str] = None
) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of imports and aliased imports. If name_in_module
is given, further attempt to refine ... | def __complete_imports_and_aliases(
self, prefix: str, name_in_module: Optional[str] = None
) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of imports and aliased imports. If name_in_module
is given, further attempt to refine ... | [
"Return",
"an",
"iterable",
"of",
"possible",
"completions",
"matching",
"the",
"given",
"prefix",
"from",
"the",
"list",
"of",
"imports",
"and",
"aliased",
"imports",
".",
"If",
"name_in_module",
"is",
"given",
"further",
"attempt",
"to",
"refine",
"the",
"li... | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L617-L642 | [
"def",
"__complete_imports_and_aliases",
"(",
"self",
",",
"prefix",
":",
"str",
",",
"name_in_module",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"imports",
"=",
"self",
".",
"imports",
"aliases",
"=",
"l... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__complete_interns | Return an iterable of possible completions matching the given
prefix from the list of interned Vars. | src/basilisp/lang/runtime.py | def __complete_interns(
self, value: str, include_private_vars: bool = True
) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of interned Vars."""
if include_private_vars:
is_match = Namespace.__completion_matcher(va... | def __complete_interns(
self, value: str, include_private_vars: bool = True
) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of interned Vars."""
if include_private_vars:
is_match = Namespace.__completion_matcher(va... | [
"Return",
"an",
"iterable",
"of",
"possible",
"completions",
"matching",
"the",
"given",
"prefix",
"from",
"the",
"list",
"of",
"interned",
"Vars",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L644-L660 | [
"def",
"__complete_interns",
"(",
"self",
",",
"value",
":",
"str",
",",
"include_private_vars",
":",
"bool",
"=",
"True",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"if",
"include_private_vars",
":",
"is_match",
"=",
"Namespace",
".",
"__completion_matcher"... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.__complete_refers | Return an iterable of possible completions matching the given
prefix from the list of referred Vars. | src/basilisp/lang/runtime.py | def __complete_refers(self, value: str) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of referred Vars."""
return map(
lambda entry: f"{entry[0].name}",
filter(
Namespace.__completion_matcher(value)... | def __complete_refers(self, value: str) -> Iterable[str]:
"""Return an iterable of possible completions matching the given
prefix from the list of referred Vars."""
return map(
lambda entry: f"{entry[0].name}",
filter(
Namespace.__completion_matcher(value)... | [
"Return",
"an",
"iterable",
"of",
"possible",
"completions",
"matching",
"the",
"given",
"prefix",
"from",
"the",
"list",
"of",
"referred",
"Vars",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L662-L670 | [
"def",
"__complete_refers",
"(",
"self",
",",
"value",
":",
"str",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"return",
"map",
"(",
"lambda",
"entry",
":",
"f\"{entry[0].name}\"",
",",
"filter",
"(",
"Namespace",
".",
"__completion_matcher",
"(",
"value",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | Namespace.complete | Return an iterable of possible completions for the given text in
this namespace. | src/basilisp/lang/runtime.py | def complete(self, text: str) -> Iterable[str]:
"""Return an iterable of possible completions for the given text in
this namespace."""
assert not text.startswith(":")
if "/" in text:
prefix, suffix = text.split("/", maxsplit=1)
results = itertools.chain(
... | def complete(self, text: str) -> Iterable[str]:
"""Return an iterable of possible completions for the given text in
this namespace."""
assert not text.startswith(":")
if "/" in text:
prefix, suffix = text.split("/", maxsplit=1)
results = itertools.chain(
... | [
"Return",
"an",
"iterable",
"of",
"possible",
"completions",
"for",
"the",
"given",
"text",
"in",
"this",
"namespace",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L672-L691 | [
"def",
"complete",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"assert",
"not",
"text",
".",
"startswith",
"(",
"\":\"",
")",
"if",
"\"/\"",
"in",
"text",
":",
"prefix",
",",
"suffix",
"=",
"text",
".",
"split... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | _TrampolineArgs.args | Return the arguments for a trampolined function. If the function
that is being trampolined has varargs, unroll the final argument if
it is a sequence. | src/basilisp/lang/runtime.py | def args(self) -> Tuple:
"""Return the arguments for a trampolined function. If the function
that is being trampolined has varargs, unroll the final argument if
it is a sequence."""
if not self._has_varargs:
return self._args
try:
final = self._args[-1]
... | def args(self) -> Tuple:
"""Return the arguments for a trampolined function. If the function
that is being trampolined has varargs, unroll the final argument if
it is a sequence."""
if not self._has_varargs:
return self._args
try:
final = self._args[-1]
... | [
"Return",
"the",
"arguments",
"for",
"a",
"trampolined",
"function",
".",
"If",
"the",
"function",
"that",
"is",
"being",
"trampolined",
"has",
"varargs",
"unroll",
"the",
"final",
"argument",
"if",
"it",
"is",
"a",
"sequence",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1168-L1182 | [
"def",
"args",
"(",
"self",
")",
"->",
"Tuple",
":",
"if",
"not",
"self",
".",
"_has_varargs",
":",
"return",
"self",
".",
"_args",
"try",
":",
"final",
"=",
"self",
".",
"_args",
"[",
"-",
"1",
"]",
"if",
"isinstance",
"(",
"final",
",",
"ISeq",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | list | Creates a new list. | src/basilisp/lang/list.py | def list(members, meta=None) -> List: # pylint:disable=redefined-builtin
"""Creates a new list."""
return List( # pylint: disable=abstract-class-instantiated
plist(iterable=members), meta=meta
) | def list(members, meta=None) -> List: # pylint:disable=redefined-builtin
"""Creates a new list."""
return List( # pylint: disable=abstract-class-instantiated
plist(iterable=members), meta=meta
) | [
"Creates",
"a",
"new",
"list",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/list.py#L86-L90 | [
"def",
"list",
"(",
"members",
",",
"meta",
"=",
"None",
")",
"->",
"List",
":",
"# pylint:disable=redefined-builtin",
"return",
"List",
"(",
"# pylint: disable=abstract-class-instantiated",
"plist",
"(",
"iterable",
"=",
"members",
")",
",",
"meta",
"=",
"meta",
... | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | l | Creates a new list from members. | src/basilisp/lang/list.py | def l(*members, meta=None) -> List:
"""Creates a new list from members."""
return List( # pylint: disable=abstract-class-instantiated
plist(iterable=members), meta=meta
) | def l(*members, meta=None) -> List:
"""Creates a new list from members."""
return List( # pylint: disable=abstract-class-instantiated
plist(iterable=members), meta=meta
) | [
"Creates",
"a",
"new",
"list",
"from",
"members",
"."
] | chrisrink10/basilisp | python | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/list.py#L93-L97 | [
"def",
"l",
"(",
"*",
"members",
",",
"meta",
"=",
"None",
")",
"->",
"List",
":",
"return",
"List",
"(",
"# pylint: disable=abstract-class-instantiated",
"plist",
"(",
"iterable",
"=",
"members",
")",
",",
"meta",
"=",
"meta",
")"
] | 3d82670ee218ec64eb066289c82766d14d18cc92 |
test | change_style | This function is used to format the key value as a multi-line string maintaining the line breaks | sdc/crypto/scripts/generate_keys.py | def change_style(style, representer):
"""
This function is used to format the key value as a multi-line string maintaining the line breaks
"""
def new_representer(dumper, data):
scalar = representer(dumper, data)
scalar.style = style
return scalar
return new_representer | def change_style(style, representer):
"""
This function is used to format the key value as a multi-line string maintaining the line breaks
"""
def new_representer(dumper, data):
scalar = representer(dumper, data)
scalar.style = style
return scalar
return new_representer | [
"This",
"function",
"is",
"used",
"to",
"format",
"the",
"key",
"value",
"as",
"a",
"multi",
"-",
"line",
"string",
"maintaining",
"the",
"line",
"breaks"
] | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/scripts/generate_keys.py#L64-L74 | [
"def",
"change_style",
"(",
"style",
",",
"representer",
")",
":",
"def",
"new_representer",
"(",
"dumper",
",",
"data",
")",
":",
"scalar",
"=",
"representer",
"(",
"dumper",
",",
"data",
")",
"scalar",
".",
"style",
"=",
"style",
"return",
"scalar",
"r... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | get_public_key | Loads a public key from the file system and adds it to a dict of keys
:param keys: A dict of keys
:param platform the platform the key is for
:param service the service the key is for
:param key_use what the key is used for
:param version the version of the key
:param purpose: The purpose of the... | sdc/crypto/scripts/generate_keys.py | def get_public_key(platform, service, purpose, key_use, version, public_key, keys_folder):
'''
Loads a public key from the file system and adds it to a dict of keys
:param keys: A dict of keys
:param platform the platform the key is for
:param service the service the key is for
:param key_use wh... | def get_public_key(platform, service, purpose, key_use, version, public_key, keys_folder):
'''
Loads a public key from the file system and adds it to a dict of keys
:param keys: A dict of keys
:param platform the platform the key is for
:param service the service the key is for
:param key_use wh... | [
"Loads",
"a",
"public",
"key",
"from",
"the",
"file",
"system",
"and",
"adds",
"it",
"to",
"a",
"dict",
"of",
"keys",
":",
"param",
"keys",
":",
"A",
"dict",
"of",
"keys",
":",
"param",
"platform",
"the",
"platform",
"the",
"key",
"is",
"for",
":",
... | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/scripts/generate_keys.py#L110-L134 | [
"def",
"get_public_key",
"(",
"platform",
",",
"service",
",",
"purpose",
",",
"key_use",
",",
"version",
",",
"public_key",
",",
"keys_folder",
")",
":",
"public_key_data",
"=",
"get_file_contents",
"(",
"keys_folder",
",",
"public_key",
")",
"pub_key",
"=",
... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | get_private_key | Loads a private key from the file system and adds it to a dict of keys
:param keys: A dict of keys
:param platform the platform the key is for
:param service the service the key is for
:param key_use what the key is used for
:param version the version of the key
:param purpose: The purpose of th... | sdc/crypto/scripts/generate_keys.py | def get_private_key(platform, service, purpose, key_use, version, private_key, keys_folder):
'''
Loads a private key from the file system and adds it to a dict of keys
:param keys: A dict of keys
:param platform the platform the key is for
:param service the service the key is for
:param key_use... | def get_private_key(platform, service, purpose, key_use, version, private_key, keys_folder):
'''
Loads a private key from the file system and adds it to a dict of keys
:param keys: A dict of keys
:param platform the platform the key is for
:param service the service the key is for
:param key_use... | [
"Loads",
"a",
"private",
"key",
"from",
"the",
"file",
"system",
"and",
"adds",
"it",
"to",
"a",
"dict",
"of",
"keys",
":",
"param",
"keys",
":",
"A",
"dict",
"of",
"keys",
":",
"param",
"platform",
"the",
"platform",
"the",
"key",
"is",
"for",
":",
... | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/scripts/generate_keys.py#L137-L164 | [
"def",
"get_private_key",
"(",
"platform",
",",
"service",
",",
"purpose",
",",
"key_use",
",",
"version",
",",
"private_key",
",",
"keys_folder",
")",
":",
"private_key_data",
"=",
"get_file_contents",
"(",
"keys_folder",
",",
"private_key",
")",
"private_key",
... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | JWEHelper.decrypt_with_key | Decrypts JWE token with supplied key
:param encrypted_token:
:param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password
:returns: The payload of the decrypted token | sdc/crypto/jwe_helper.py | def decrypt_with_key(encrypted_token, key):
"""
Decrypts JWE token with supplied key
:param encrypted_token:
:param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password
:returns: The payload of the decrypted token
"""
try:
jwe_token = jwe.JW... | def decrypt_with_key(encrypted_token, key):
"""
Decrypts JWE token with supplied key
:param encrypted_token:
:param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password
:returns: The payload of the decrypted token
"""
try:
jwe_token = jwe.JW... | [
"Decrypts",
"JWE",
"token",
"with",
"supplied",
"key",
":",
"param",
"encrypted_token",
":",
":",
"param",
"key",
":",
"A",
"(",
":",
"class",
":",
"jwcrypto",
".",
"jwk",
".",
"JWK",
")",
"decryption",
"key",
"or",
"a",
"password",
":",
"returns",
":"... | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/jwe_helper.py#L36-L51 | [
"def",
"decrypt_with_key",
"(",
"encrypted_token",
",",
"key",
")",
":",
"try",
":",
"jwe_token",
"=",
"jwe",
".",
"JWE",
"(",
"algs",
"=",
"[",
"'RSA-OAEP'",
",",
"'A256GCM'",
"]",
")",
"jwe_token",
".",
"deserialize",
"(",
"encrypted_token",
")",
"jwe_to... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | decrypt | This decrypts the provided jwe token, then decodes resulting jwt token and returns
the payload.
:param str token: The jwe token.
:param key_store: The key store.
:param str key_purpose: Context for the key.
:param int leeway: Extra allowed time in seconds after expiration to account for clock skew.... | sdc/crypto/decrypter.py | def decrypt(token, key_store, key_purpose, leeway=120):
"""This decrypts the provided jwe token, then decodes resulting jwt token and returns
the payload.
:param str token: The jwe token.
:param key_store: The key store.
:param str key_purpose: Context for the key.
:param int leeway: Extra allo... | def decrypt(token, key_store, key_purpose, leeway=120):
"""This decrypts the provided jwe token, then decodes resulting jwt token and returns
the payload.
:param str token: The jwe token.
:param key_store: The key store.
:param str key_purpose: Context for the key.
:param int leeway: Extra allo... | [
"This",
"decrypts",
"the",
"provided",
"jwe",
"token",
"then",
"decodes",
"resulting",
"jwt",
"token",
"and",
"returns",
"the",
"payload",
"."
] | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/decrypter.py#L6-L25 | [
"def",
"decrypt",
"(",
"token",
",",
"key_store",
",",
"key_purpose",
",",
"leeway",
"=",
"120",
")",
":",
"tokens",
"=",
"token",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"tokens",
")",
"!=",
"5",
":",
"raise",
"InvalidTokenException",
"(",
... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | encrypt | This encrypts the supplied json and returns a jwe token.
:param str json: The json to be encrypted.
:param key_store: The key store.
:param str key_purpose: Context for the key.
:return: A jwe token. | sdc/crypto/encrypter.py | def encrypt(json, key_store, key_purpose):
"""This encrypts the supplied json and returns a jwe token.
:param str json: The json to be encrypted.
:param key_store: The key store.
:param str key_purpose: Context for the key.
:return: A jwe token.
"""
jwt_key = key_store.get_key_for_purpose_... | def encrypt(json, key_store, key_purpose):
"""This encrypts the supplied json and returns a jwe token.
:param str json: The json to be encrypted.
:param key_store: The key store.
:param str key_purpose: Context for the key.
:return: A jwe token.
"""
jwt_key = key_store.get_key_for_purpose_... | [
"This",
"encrypts",
"the",
"supplied",
"json",
"and",
"returns",
"a",
"jwe",
"token",
"."
] | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/encrypter.py#L5-L20 | [
"def",
"encrypt",
"(",
"json",
",",
"key_store",
",",
"key_purpose",
")",
":",
"jwt_key",
"=",
"key_store",
".",
"get_key_for_purpose_and_type",
"(",
"key_purpose",
",",
"\"private\"",
")",
"payload",
"=",
"JWTHelper",
".",
"encode",
"(",
"json",
",",
"jwt_key... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | KeyStore.get_key_for_purpose_and_type | Gets a list of keys that match the purpose and key_type, and returns the first key in that list
Note, if there are many keys that match the criteria, the one you get back will be random from that list
:returns: A key object that matches the criteria | sdc/crypto/key_store.py | def get_key_for_purpose_and_type(self, purpose, key_type):
"""
Gets a list of keys that match the purpose and key_type, and returns the first key in that list
Note, if there are many keys that match the criteria, the one you get back will be random from that list
:returns: A key object t... | def get_key_for_purpose_and_type(self, purpose, key_type):
"""
Gets a list of keys that match the purpose and key_type, and returns the first key in that list
Note, if there are many keys that match the criteria, the one you get back will be random from that list
:returns: A key object t... | [
"Gets",
"a",
"list",
"of",
"keys",
"that",
"match",
"the",
"purpose",
"and",
"key_type",
"and",
"returns",
"the",
"first",
"key",
"in",
"that",
"list",
"Note",
"if",
"there",
"are",
"many",
"keys",
"that",
"match",
"the",
"criteria",
"the",
"one",
"you",... | ONSdigital/sdc-cryptography | python | https://github.com/ONSdigital/sdc-cryptography/blob/846feb2b27b1c62d35ff2c290c05abcead68b23c/sdc/crypto/key_store.py#L62-L72 | [
"def",
"get_key_for_purpose_and_type",
"(",
"self",
",",
"purpose",
",",
"key_type",
")",
":",
"key",
"=",
"[",
"key",
"for",
"key",
"in",
"self",
".",
"keys",
".",
"values",
"(",
")",
"if",
"key",
".",
"purpose",
"==",
"purpose",
"and",
"key",
".",
... | 846feb2b27b1c62d35ff2c290c05abcead68b23c |
test | get_default_args | returns a dictionary of arg_name:default_values for the input function | multiget_cache/function_tools.py | def get_default_args(func):
"""
returns a dictionary of arg_name:default_values for the input function
"""
args, _, _, defaults, *rest = inspect.getfullargspec(func)
return dict(zip(reversed(args), reversed(defaults))) | def get_default_args(func):
"""
returns a dictionary of arg_name:default_values for the input function
"""
args, _, _, defaults, *rest = inspect.getfullargspec(func)
return dict(zip(reversed(args), reversed(defaults))) | [
"returns",
"a",
"dictionary",
"of",
"arg_name",
":",
"default_values",
"for",
"the",
"input",
"function"
] | Patreon/multiget-cache-py | python | https://github.com/Patreon/multiget-cache-py/blob/824ec4809c97cc7e0035810bd9fefd1262de3318/multiget_cache/function_tools.py#L15-L20 | [
"def",
"get_default_args",
"(",
"func",
")",
":",
"args",
",",
"_",
",",
"_",
",",
"defaults",
",",
"",
"*",
"rest",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"return",
"dict",
"(",
"zip",
"(",
"reversed",
"(",
"args",
")",
",",
"rev... | 824ec4809c97cc7e0035810bd9fefd1262de3318 |
test | map_arguments_to_objects | :param kwargs: kwargs used to call the multiget function
:param objects: objects returned from the inner function
:param object_key: field or set of fields that map to the kwargs provided
:param object_tuple_key: A temporary shortcut until we allow dot.path traversal for object_key.
Will call getattr(ge... | multiget_cache/function_tools.py | def map_arguments_to_objects(kwargs, objects, object_key, object_tuple_key, argument_key, result_value, default_result):
"""
:param kwargs: kwargs used to call the multiget function
:param objects: objects returned from the inner function
:param object_key: field or set of fields that map to the kwargs ... | def map_arguments_to_objects(kwargs, objects, object_key, object_tuple_key, argument_key, result_value, default_result):
"""
:param kwargs: kwargs used to call the multiget function
:param objects: objects returned from the inner function
:param object_key: field or set of fields that map to the kwargs ... | [
":",
"param",
"kwargs",
":",
"kwargs",
"used",
"to",
"call",
"the",
"multiget",
"function",
":",
"param",
"objects",
":",
"objects",
"returned",
"from",
"the",
"inner",
"function",
":",
"param",
"object_key",
":",
"field",
"or",
"set",
"of",
"fields",
"tha... | Patreon/multiget-cache-py | python | https://github.com/Patreon/multiget-cache-py/blob/824ec4809c97cc7e0035810bd9fefd1262de3318/multiget_cache/function_tools.py#L105-L124 | [
"def",
"map_arguments_to_objects",
"(",
"kwargs",
",",
"objects",
",",
"object_key",
",",
"object_tuple_key",
",",
"argument_key",
",",
"result_value",
",",
"default_result",
")",
":",
"# Map each object to the set of desired result data using a key",
"# that corresponds to the... | 824ec4809c97cc7e0035810bd9fefd1262de3318 |
test | BaseCacheWrapper.delete | Remove the key from the request cache and from memcache. | multiget_cache/base_cache_wrapper.py | def delete(self, *args):
"""Remove the key from the request cache and from memcache."""
cache = get_cache()
key = self.get_cache_key(*args)
if key in cache:
del cache[key] | def delete(self, *args):
"""Remove the key from the request cache and from memcache."""
cache = get_cache()
key = self.get_cache_key(*args)
if key in cache:
del cache[key] | [
"Remove",
"the",
"key",
"from",
"the",
"request",
"cache",
"and",
"from",
"memcache",
"."
] | Patreon/multiget-cache-py | python | https://github.com/Patreon/multiget-cache-py/blob/824ec4809c97cc7e0035810bd9fefd1262de3318/multiget_cache/base_cache_wrapper.py#L55-L60 | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
")",
":",
"cache",
"=",
"get_cache",
"(",
")",
"key",
"=",
"self",
".",
"get_cache_key",
"(",
"*",
"args",
")",
"if",
"key",
"in",
"cache",
":",
"del",
"cache",
"[",
"key",
"]"
] | 824ec4809c97cc7e0035810bd9fefd1262de3318 |
test | multiget_cached | :param object_key: the names of the attributes on the result object that are meant to match the function parameters
:param argument_key: the function parameter names you wish to match with the `object_key`s.
By default, this will be all of your wrapped function's arguments, in order.
So, you'd really only u... | multiget_cache/multiget_cache_wrapper.py | def multiget_cached(object_key, argument_key=None, default_result=None,
result_fields=None, join_table_name=None, coerce_args_to_strings=False):
"""
:param object_key: the names of the attributes on the result object that are meant to match the function parameters
:param argument_key: th... | def multiget_cached(object_key, argument_key=None, default_result=None,
result_fields=None, join_table_name=None, coerce_args_to_strings=False):
"""
:param object_key: the names of the attributes on the result object that are meant to match the function parameters
:param argument_key: th... | [
":",
"param",
"object_key",
":",
"the",
"names",
"of",
"the",
"attributes",
"on",
"the",
"result",
"object",
"that",
"are",
"meant",
"to",
"match",
"the",
"function",
"parameters",
":",
"param",
"argument_key",
":",
"the",
"function",
"parameter",
"names",
"... | Patreon/multiget-cache-py | python | https://github.com/Patreon/multiget-cache-py/blob/824ec4809c97cc7e0035810bd9fefd1262de3318/multiget_cache/multiget_cache_wrapper.py#L86-L110 | [
"def",
"multiget_cached",
"(",
"object_key",
",",
"argument_key",
"=",
"None",
",",
"default_result",
"=",
"None",
",",
"result_fields",
"=",
"None",
",",
"join_table_name",
"=",
"None",
",",
"coerce_args_to_strings",
"=",
"False",
")",
":",
"def",
"create_wrapp... | 824ec4809c97cc7e0035810bd9fefd1262de3318 |
test | get_dot_target_name | Returns the current version/module in -dot- notation which is used by `target:` parameters. | gaek/environ.py | def get_dot_target_name(version=None, module=None):
"""Returns the current version/module in -dot- notation which is used by `target:` parameters."""
version = version or get_current_version_name()
module = module or get_current_module_name()
return '-dot-'.join((version, module)) | def get_dot_target_name(version=None, module=None):
"""Returns the current version/module in -dot- notation which is used by `target:` parameters."""
version = version or get_current_version_name()
module = module or get_current_module_name()
return '-dot-'.join((version, module)) | [
"Returns",
"the",
"current",
"version",
"/",
"module",
"in",
"-",
"dot",
"-",
"notation",
"which",
"is",
"used",
"by",
"target",
":",
"parameters",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/environ.py#L160-L164 | [
"def",
"get_dot_target_name",
"(",
"version",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"version",
"=",
"version",
"or",
"get_current_version_name",
"(",
")",
"module",
"=",
"module",
"or",
"get_current_module_name",
"(",
")",
"return",
"'-dot-'",
"."... | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | get_dot_target_name_safe | Returns the current version/module in -dot- notation which is used by `target:` parameters.
If there is no current version or module then None is returned. | gaek/environ.py | def get_dot_target_name_safe(version=None, module=None):
"""
Returns the current version/module in -dot- notation which is used by `target:` parameters.
If there is no current version or module then None is returned.
"""
version = version or get_current_version_name_safe()
module = module or get_current_mod... | def get_dot_target_name_safe(version=None, module=None):
"""
Returns the current version/module in -dot- notation which is used by `target:` parameters.
If there is no current version or module then None is returned.
"""
version = version or get_current_version_name_safe()
module = module or get_current_mod... | [
"Returns",
"the",
"current",
"version",
"/",
"module",
"in",
"-",
"dot",
"-",
"notation",
"which",
"is",
"used",
"by",
"target",
":",
"parameters",
".",
"If",
"there",
"is",
"no",
"current",
"version",
"or",
"module",
"then",
"None",
"is",
"returned",
".... | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/environ.py#L167-L176 | [
"def",
"get_dot_target_name_safe",
"(",
"version",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"version",
"=",
"version",
"or",
"get_current_version_name_safe",
"(",
")",
"module",
"=",
"module",
"or",
"get_current_module_name_safe",
"(",
")",
"if",
"vers... | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | _get_os_environ_dict | Return a dictionary of key/values from os.environ. | gaek/environ.py | def _get_os_environ_dict(keys):
"""Return a dictionary of key/values from os.environ."""
return {k: os.environ.get(k, _UNDEFINED) for k in keys} | def _get_os_environ_dict(keys):
"""Return a dictionary of key/values from os.environ."""
return {k: os.environ.get(k, _UNDEFINED) for k in keys} | [
"Return",
"a",
"dictionary",
"of",
"key",
"/",
"values",
"from",
"os",
".",
"environ",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/environ.py#L179-L181 | [
"def",
"_get_os_environ_dict",
"(",
"keys",
")",
":",
"return",
"{",
"k",
":",
"os",
".",
"environ",
".",
"get",
"(",
"k",
",",
"_UNDEFINED",
")",
"for",
"k",
"in",
"keys",
"}"
] | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | name | This helper function attempts to resolve the dot-colon import path for a given object.
Specifically searches for classes and methods, it should be able to find nearly anything at either the module
level or nested one level deep. Uses ``__qualname__`` if available. | marrow/package/canonical.py | def name(obj) -> str:
"""This helper function attempts to resolve the dot-colon import path for a given object.
Specifically searches for classes and methods, it should be able to find nearly anything at either the module
level or nested one level deep. Uses ``__qualname__`` if available.
"""
if not isroutine... | def name(obj) -> str:
"""This helper function attempts to resolve the dot-colon import path for a given object.
Specifically searches for classes and methods, it should be able to find nearly anything at either the module
level or nested one level deep. Uses ``__qualname__`` if available.
"""
if not isroutine... | [
"This",
"helper",
"function",
"attempts",
"to",
"resolve",
"the",
"dot",
"-",
"colon",
"import",
"path",
"for",
"a",
"given",
"object",
".",
"Specifically",
"searches",
"for",
"classes",
"and",
"methods",
"it",
"should",
"be",
"able",
"to",
"find",
"nearly",... | marrow/package | python | https://github.com/marrow/package/blob/133d4bf67cc857d1b2423695938a00ff2dfa8af2/marrow/package/canonical.py#L7-L19 | [
"def",
"name",
"(",
"obj",
")",
"->",
"str",
":",
"if",
"not",
"isroutine",
"(",
"obj",
")",
"and",
"not",
"hasattr",
"(",
"obj",
",",
"'__name__'",
")",
"and",
"hasattr",
"(",
"obj",
",",
"'__class__'",
")",
":",
"obj",
"=",
"obj",
".",
"__class__... | 133d4bf67cc857d1b2423695938a00ff2dfa8af2 |
test | Constraint.to_python | Deconstruct the ``Constraint`` instance to a tuple.
Returns:
tuple: The deconstructed ``Constraint``. | fiql_parser/constraint.py | def to_python(self):
"""Deconstruct the ``Constraint`` instance to a tuple.
Returns:
tuple: The deconstructed ``Constraint``.
"""
return (
self.selector,
COMPARISON_MAP.get(self.comparison, self.comparison),
self.argument
) | def to_python(self):
"""Deconstruct the ``Constraint`` instance to a tuple.
Returns:
tuple: The deconstructed ``Constraint``.
"""
return (
self.selector,
COMPARISON_MAP.get(self.comparison, self.comparison),
self.argument
) | [
"Deconstruct",
"the",
"Constraint",
"instance",
"to",
"a",
"tuple",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/constraint.py#L105-L115 | [
"def",
"to_python",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"selector",
",",
"COMPARISON_MAP",
".",
"get",
"(",
"self",
".",
"comparison",
",",
"self",
".",
"comparison",
")",
",",
"self",
".",
"argument",
")"
] | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | AsyncCAM.connect | Connect to LASAF through a CAM-socket. | leicacam/async_cam.py | async def connect(self):
"""Connect to LASAF through a CAM-socket."""
self.reader, self.writer = await asyncio.open_connection(
self.host, self.port, loop=self.loop)
self.welcome_msg = await self.reader.read(self.buffer_size) | async def connect(self):
"""Connect to LASAF through a CAM-socket."""
self.reader, self.writer = await asyncio.open_connection(
self.host, self.port, loop=self.loop)
self.welcome_msg = await self.reader.read(self.buffer_size) | [
"Connect",
"to",
"LASAF",
"through",
"a",
"CAM",
"-",
"socket",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/async_cam.py#L21-L25 | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"reader",
",",
"self",
".",
"writer",
"=",
"await",
"asyncio",
".",
"open_connection",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"loop",
"=",
"self",
".",
"loop",
")",
"s... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | AsyncCAM.send | Send commands to LASAF through CAM-socket.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
-------
int
Bytes sent.... | leicacam/async_cam.py | async def send(self, commands):
"""Send commands to LASAF through CAM-socket.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
... | async def send(self, commands):
"""Send commands to LASAF through CAM-socket.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
... | [
"Send",
"commands",
"to",
"LASAF",
"through",
"CAM",
"-",
"socket",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/async_cam.py#L27-L54 | [
"async",
"def",
"send",
"(",
"self",
",",
"commands",
")",
":",
"msg",
"=",
"self",
".",
"_prepare_send",
"(",
"commands",
")",
"self",
".",
"writer",
".",
"write",
"(",
"msg",
")",
"await",
"self",
".",
"writer",
".",
"drain",
"(",
")"
] | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | AsyncCAM.receive | Receive message from socket interface as list of OrderedDict. | leicacam/async_cam.py | async def receive(self):
"""Receive message from socket interface as list of OrderedDict."""
try:
incomming = await self.reader.read(self.buffer_size)
except OSError:
return []
return _parse_receive(incomming) | async def receive(self):
"""Receive message from socket interface as list of OrderedDict."""
try:
incomming = await self.reader.read(self.buffer_size)
except OSError:
return []
return _parse_receive(incomming) | [
"Receive",
"message",
"from",
"socket",
"interface",
"as",
"list",
"of",
"OrderedDict",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/async_cam.py#L56-L63 | [
"async",
"def",
"receive",
"(",
"self",
")",
":",
"try",
":",
"incomming",
"=",
"await",
"self",
".",
"reader",
".",
"read",
"(",
"self",
".",
"buffer_size",
")",
"except",
"OSError",
":",
"return",
"[",
"]",
"return",
"_parse_receive",
"(",
"incomming",... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | AsyncCAM.wait_for | Hang until command is received.
If value is supplied, it will hang until ``cmd:value`` is received.
Parameters
----------
cmd : string
Command to wait for in bytestring from microscope CAM interface. If
``value`` is falsey, value of received command does not mat... | leicacam/async_cam.py | async def wait_for(self, cmd, value=None, timeout=60):
"""Hang until command is received.
If value is supplied, it will hang until ``cmd:value`` is received.
Parameters
----------
cmd : string
Command to wait for in bytestring from microscope CAM interface. If
... | async def wait_for(self, cmd, value=None, timeout=60):
"""Hang until command is received.
If value is supplied, it will hang until ``cmd:value`` is received.
Parameters
----------
cmd : string
Command to wait for in bytestring from microscope CAM interface. If
... | [
"Hang",
"until",
"command",
"is",
"received",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/async_cam.py#L65-L95 | [
"async",
"def",
"wait_for",
"(",
"self",
",",
"cmd",
",",
"value",
"=",
"None",
",",
"timeout",
"=",
"60",
")",
":",
"try",
":",
"async",
"with",
"async_timeout",
"(",
"timeout",
"*",
"60",
")",
":",
"while",
"True",
":",
"msgs",
"=",
"await",
"sel... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | AsyncCAM.close | Close stream. | leicacam/async_cam.py | def close(self):
"""Close stream."""
if self.writer.can_write_eof():
self.writer.write_eof()
self.writer.close() | def close(self):
"""Close stream."""
if self.writer.can_write_eof():
self.writer.write_eof()
self.writer.close() | [
"Close",
"stream",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/async_cam.py#L97-L101 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"writer",
".",
"can_write_eof",
"(",
")",
":",
"self",
".",
"writer",
".",
"write_eof",
"(",
")",
"self",
".",
"writer",
".",
"close",
"(",
")"
] | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | lazyload | Lazily load and cache an object reference upon dereferencing.
Assign the result of calling this function with either an object reference passed in positionally:
class MyClass:
debug = lazyload('logging:debug')
Or the attribute path to traverse (using `marrow.package.loader:traverse`) prefixed by a period.
... | marrow/package/lazy.py | def lazyload(reference: str, *args, **kw):
"""Lazily load and cache an object reference upon dereferencing.
Assign the result of calling this function with either an object reference passed in positionally:
class MyClass:
debug = lazyload('logging:debug')
Or the attribute path to traverse (using `marrow.p... | def lazyload(reference: str, *args, **kw):
"""Lazily load and cache an object reference upon dereferencing.
Assign the result of calling this function with either an object reference passed in positionally:
class MyClass:
debug = lazyload('logging:debug')
Or the attribute path to traverse (using `marrow.p... | [
"Lazily",
"load",
"and",
"cache",
"an",
"object",
"reference",
"upon",
"dereferencing",
".",
"Assign",
"the",
"result",
"of",
"calling",
"this",
"function",
"with",
"either",
"an",
"object",
"reference",
"passed",
"in",
"positionally",
":",
"class",
"MyClass",
... | marrow/package | python | https://github.com/marrow/package/blob/133d4bf67cc857d1b2423695938a00ff2dfa8af2/marrow/package/lazy.py#L57-L84 | [
"def",
"lazyload",
"(",
"reference",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"assert",
"check_argument_types",
"(",
")",
"def",
"lazily_load_reference",
"(",
"self",
")",
":",
"ref",
"=",
"reference",
"if",
"ref",
".",
"startswith",
... | 133d4bf67cc857d1b2423695938a00ff2dfa8af2 |
test | iter_parse | Iterate through the FIQL string. Yield a tuple containing the
following FIQL components for each iteration:
- preamble: Any operator or opening/closing paranthesis preceding a
constraint or at the very end of the FIQL string.
- selector: The selector portion of a FIQL constraint or ``None`` if
... | fiql_parser/parser.py | def iter_parse(fiql_str):
"""Iterate through the FIQL string. Yield a tuple containing the
following FIQL components for each iteration:
- preamble: Any operator or opening/closing paranthesis preceding a
constraint or at the very end of the FIQL string.
- selector: The selector portion of ... | def iter_parse(fiql_str):
"""Iterate through the FIQL string. Yield a tuple containing the
following FIQL components for each iteration:
- preamble: Any operator or opening/closing paranthesis preceding a
constraint or at the very end of the FIQL string.
- selector: The selector portion of ... | [
"Iterate",
"through",
"the",
"FIQL",
"string",
".",
"Yield",
"a",
"tuple",
"containing",
"the",
"following",
"FIQL",
"components",
"for",
"each",
"iteration",
":"
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/parser.py#L27-L60 | [
"def",
"iter_parse",
"(",
"fiql_str",
")",
":",
"while",
"len",
"(",
"fiql_str",
")",
":",
"constraint_match",
"=",
"CONSTRAINT_COMP",
".",
"split",
"(",
"fiql_str",
",",
"1",
")",
"if",
"len",
"(",
"constraint_match",
")",
"<",
"2",
":",
"yield",
"(",
... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | parse_str_to_expression | Parse a FIQL formatted string into an ``Expression``.
Args:
fiql_str (string): The FIQL formatted string we want to parse.
Returns:
Expression: An ``Expression`` object representing the parsed FIQL
string.
Raises:
FiqlFormatException: Unable to parse string due to incorrec... | fiql_parser/parser.py | def parse_str_to_expression(fiql_str):
"""Parse a FIQL formatted string into an ``Expression``.
Args:
fiql_str (string): The FIQL formatted string we want to parse.
Returns:
Expression: An ``Expression`` object representing the parsed FIQL
string.
Raises:
FiqlFormatExc... | def parse_str_to_expression(fiql_str):
"""Parse a FIQL formatted string into an ``Expression``.
Args:
fiql_str (string): The FIQL formatted string we want to parse.
Returns:
Expression: An ``Expression`` object representing the parsed FIQL
string.
Raises:
FiqlFormatExc... | [
"Parse",
"a",
"FIQL",
"formatted",
"string",
"into",
"an",
"Expression",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/parser.py#L62-L123 | [
"def",
"parse_str_to_expression",
"(",
"fiql_str",
")",
":",
"#pylint: disable=too-many-branches",
"nesting_lvl",
"=",
"0",
"last_element",
"=",
"None",
"expression",
"=",
"Expression",
"(",
")",
"for",
"(",
"preamble",
",",
"selector",
",",
"comparison",
",",
"ar... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | encode_model | Encode objects like ndb.Model which have a `.to_dict()` method. | gaek/ndb_json.py | def encode_model(obj):
"""Encode objects like ndb.Model which have a `.to_dict()` method."""
obj_dict = obj.to_dict()
for key, val in obj_dict.iteritems():
if isinstance(val, types.StringType):
try:
unicode(val)
except UnicodeDecodeError:
# Encode binary strings (blobs) to base64.
... | def encode_model(obj):
"""Encode objects like ndb.Model which have a `.to_dict()` method."""
obj_dict = obj.to_dict()
for key, val in obj_dict.iteritems():
if isinstance(val, types.StringType):
try:
unicode(val)
except UnicodeDecodeError:
# Encode binary strings (blobs) to base64.
... | [
"Encode",
"objects",
"like",
"ndb",
".",
"Model",
"which",
"have",
"a",
".",
"to_dict",
"()",
"method",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/ndb_json.py#L53-L63 | [
"def",
"encode_model",
"(",
"obj",
")",
":",
"obj_dict",
"=",
"obj",
".",
"to_dict",
"(",
")",
"for",
"key",
",",
"val",
"in",
"obj_dict",
".",
"iteritems",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"types",
".",
"StringType",
")",
":",
"... | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | dump | Custom json dump using the custom encoder above. | gaek/ndb_json.py | def dump(ndb_model, fp, **kwargs):
"""Custom json dump using the custom encoder above."""
for chunk in NdbEncoder(**kwargs).iterencode(ndb_model):
fp.write(chunk) | def dump(ndb_model, fp, **kwargs):
"""Custom json dump using the custom encoder above."""
for chunk in NdbEncoder(**kwargs).iterencode(ndb_model):
fp.write(chunk) | [
"Custom",
"json",
"dump",
"using",
"the",
"custom",
"encoder",
"above",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/ndb_json.py#L226-L229 | [
"def",
"dump",
"(",
"ndb_model",
",",
"fp",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"chunk",
"in",
"NdbEncoder",
"(",
"*",
"*",
"kwargs",
")",
".",
"iterencode",
"(",
"ndb_model",
")",
":",
"fp",
".",
"write",
"(",
"chunk",
")"
] | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | NdbDecoder.object_hook_handler | Handles decoding of nested date strings. | gaek/ndb_json.py | def object_hook_handler(self, val):
"""Handles decoding of nested date strings."""
return {k: self.decode_date(v) for k, v in val.iteritems()} | def object_hook_handler(self, val):
"""Handles decoding of nested date strings."""
return {k: self.decode_date(v) for k, v in val.iteritems()} | [
"Handles",
"decoding",
"of",
"nested",
"date",
"strings",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/ndb_json.py#L144-L146 | [
"def",
"object_hook_handler",
"(",
"self",
",",
"val",
")",
":",
"return",
"{",
"k",
":",
"self",
".",
"decode_date",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"val",
".",
"iteritems",
"(",
")",
"}"
] | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | NdbDecoder.decode_date | Tries to decode strings that look like dates into datetime objects. | gaek/ndb_json.py | def decode_date(self, val):
"""Tries to decode strings that look like dates into datetime objects."""
if isinstance(val, basestring) and val.count('-') == 2 and len(val) > 9:
try:
dt = dateutil.parser.parse(val)
# Check for UTC.
if val.endswith(('+00:00', '-00:00', 'Z')):
... | def decode_date(self, val):
"""Tries to decode strings that look like dates into datetime objects."""
if isinstance(val, basestring) and val.count('-') == 2 and len(val) > 9:
try:
dt = dateutil.parser.parse(val)
# Check for UTC.
if val.endswith(('+00:00', '-00:00', 'Z')):
... | [
"Tries",
"to",
"decode",
"strings",
"that",
"look",
"like",
"dates",
"into",
"datetime",
"objects",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/ndb_json.py#L148-L160 | [
"def",
"decode_date",
"(",
"self",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"basestring",
")",
"and",
"val",
".",
"count",
"(",
"'-'",
")",
"==",
"2",
"and",
"len",
"(",
"val",
")",
">",
"9",
":",
"try",
":",
"dt",
"=",
"dateu... | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | NdbDecoder.decode | Override of the default decode method that also uses decode_date. | gaek/ndb_json.py | def decode(self, val):
"""Override of the default decode method that also uses decode_date."""
# First try the date decoder.
new_val = self.decode_date(val)
if val != new_val:
return new_val
# Fall back to the default decoder.
return json.JSONDecoder.decode(self, val) | def decode(self, val):
"""Override of the default decode method that also uses decode_date."""
# First try the date decoder.
new_val = self.decode_date(val)
if val != new_val:
return new_val
# Fall back to the default decoder.
return json.JSONDecoder.decode(self, val) | [
"Override",
"of",
"the",
"default",
"decode",
"method",
"that",
"also",
"uses",
"decode_date",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/ndb_json.py#L162-L169 | [
"def",
"decode",
"(",
"self",
",",
"val",
")",
":",
"# First try the date decoder.",
"new_val",
"=",
"self",
".",
"decode_date",
"(",
"val",
")",
"if",
"val",
"!=",
"new_val",
":",
"return",
"new_val",
"# Fall back to the default decoder.",
"return",
"json",
"."... | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | NdbEncoder.default | Overriding the default JSONEncoder.default for NDB support. | gaek/ndb_json.py | def default(self, obj):
"""Overriding the default JSONEncoder.default for NDB support."""
obj_type = type(obj)
# NDB Models return a repr to calls from type().
if obj_type not in self._ndb_type_encoding:
if hasattr(obj, '__metaclass__'):
obj_type = obj.__metaclass__
else:
# T... | def default(self, obj):
"""Overriding the default JSONEncoder.default for NDB support."""
obj_type = type(obj)
# NDB Models return a repr to calls from type().
if obj_type not in self._ndb_type_encoding:
if hasattr(obj, '__metaclass__'):
obj_type = obj.__metaclass__
else:
# T... | [
"Overriding",
"the",
"default",
"JSONEncoder",
".",
"default",
"for",
"NDB",
"support",
"."
] | erichiggins/gaek | python | https://github.com/erichiggins/gaek/blob/eb6bbc2d2688302834f97fd97891592e8b9659f2/gaek/ndb_json.py#L199-L218 | [
"def",
"default",
"(",
"self",
",",
"obj",
")",
":",
"obj_type",
"=",
"type",
"(",
"obj",
")",
"# NDB Models return a repr to calls from type().",
"if",
"obj_type",
"not",
"in",
"self",
".",
"_ndb_type_encoding",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'__meta... | eb6bbc2d2688302834f97fd97891592e8b9659f2 |
test | traverse | Traverse down an object, using getattr or getitem.
If ``executable`` is ``True`` any executable function encountered will be, with no arguments. Traversal will
continue on the result of that call. You can change the separator as desired, i.e. to a '/'.
By default attributes (but not array elements) prefixed wit... | marrow/package/loader.py | def traverse(obj, target:str, default=nodefault, executable:bool=False, separator:str='.', protect:bool=True):
"""Traverse down an object, using getattr or getitem.
If ``executable`` is ``True`` any executable function encountered will be, with no arguments. Traversal will
continue on the result of that call. You... | def traverse(obj, target:str, default=nodefault, executable:bool=False, separator:str='.', protect:bool=True):
"""Traverse down an object, using getattr or getitem.
If ``executable`` is ``True`` any executable function encountered will be, with no arguments. Traversal will
continue on the result of that call. You... | [
"Traverse",
"down",
"an",
"object",
"using",
"getattr",
"or",
"getitem",
".",
"If",
"executable",
"is",
"True",
"any",
"executable",
"function",
"encountered",
"will",
"be",
"with",
"no",
"arguments",
".",
"Traversal",
"will",
"continue",
"on",
"the",
"result"... | marrow/package | python | https://github.com/marrow/package/blob/133d4bf67cc857d1b2423695938a00ff2dfa8af2/marrow/package/loader.py#L8-L54 | [
"def",
"traverse",
"(",
"obj",
",",
"target",
":",
"str",
",",
"default",
"=",
"nodefault",
",",
"executable",
":",
"bool",
"=",
"False",
",",
"separator",
":",
"str",
"=",
"'.'",
",",
"protect",
":",
"bool",
"=",
"True",
")",
":",
"# TODO: Support num... | 133d4bf67cc857d1b2423695938a00ff2dfa8af2 |
test | load | This helper function loads an object identified by a dotted-notation string.
For example::
# Load class Foo from example.objects
load('example.objects:Foo')
# Load the result of the class method ``new`` of the Foo object
load('example.objects:Foo.new', executable=True)
If a plugin namespace is provid... | marrow/package/loader.py | def load(target:str, namespace:str=None, default=nodefault, executable:bool=False, separators:Sequence[str]=('.', ':'),
protect:bool=True):
"""This helper function loads an object identified by a dotted-notation string.
For example::
# Load class Foo from example.objects
load('example.objects:Foo')
# L... | def load(target:str, namespace:str=None, default=nodefault, executable:bool=False, separators:Sequence[str]=('.', ':'),
protect:bool=True):
"""This helper function loads an object identified by a dotted-notation string.
For example::
# Load class Foo from example.objects
load('example.objects:Foo')
# L... | [
"This",
"helper",
"function",
"loads",
"an",
"object",
"identified",
"by",
"a",
"dotted",
"-",
"notation",
"string",
".",
"For",
"example",
"::",
"#",
"Load",
"class",
"Foo",
"from",
"example",
".",
"objects",
"load",
"(",
"example",
".",
"objects",
":",
... | marrow/package | python | https://github.com/marrow/package/blob/133d4bf67cc857d1b2423695938a00ff2dfa8af2/marrow/package/loader.py#L57-L104 | [
"def",
"load",
"(",
"target",
":",
"str",
",",
"namespace",
":",
"str",
"=",
"None",
",",
"default",
"=",
"nodefault",
",",
"executable",
":",
"bool",
"=",
"False",
",",
"separators",
":",
"Sequence",
"[",
"str",
"]",
"=",
"(",
"'.'",
",",
"':'",
"... | 133d4bf67cc857d1b2423695938a00ff2dfa8af2 |
test | run | Run client. | client.py | def run():
"""Run client."""
cam = CAM()
print(cam.welcome_msg)
print(cam.send(b'/cmd:deletelist'))
sleep(0.1)
print(cam.receive())
print(cam.send(b'/cmd:deletelist'))
sleep(0.1)
print(cam.wait_for(cmd='cmd', timeout=0.1))
cam.close() | def run():
"""Run client."""
cam = CAM()
print(cam.welcome_msg)
print(cam.send(b'/cmd:deletelist'))
sleep(0.1)
print(cam.receive())
print(cam.send(b'/cmd:deletelist'))
sleep(0.1)
print(cam.wait_for(cmd='cmd', timeout=0.1))
cam.close() | [
"Run",
"client",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/client.py#L7-L17 | [
"def",
"run",
"(",
")",
":",
"cam",
"=",
"CAM",
"(",
")",
"print",
"(",
"cam",
".",
"welcome_msg",
")",
"print",
"(",
"cam",
".",
"send",
"(",
"b'/cmd:deletelist'",
")",
")",
"sleep",
"(",
"0.1",
")",
"print",
"(",
"cam",
".",
"receive",
"(",
")"... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | validate_version | Validate version before release. | scripts/gen_changelog.py | def validate_version():
"""Validate version before release."""
import leicacam
version_string = leicacam.__version__
versions = version_string.split('.', 3)
try:
for ver in versions:
int(ver)
except ValueError:
print(
'Only integers are allowed in release ... | def validate_version():
"""Validate version before release."""
import leicacam
version_string = leicacam.__version__
versions = version_string.split('.', 3)
try:
for ver in versions:
int(ver)
except ValueError:
print(
'Only integers are allowed in release ... | [
"Validate",
"version",
"before",
"release",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/scripts/gen_changelog.py#L8-L21 | [
"def",
"validate_version",
"(",
")",
":",
"import",
"leicacam",
"version_string",
"=",
"leicacam",
".",
"__version__",
"versions",
"=",
"version_string",
".",
"split",
"(",
"'.'",
",",
"3",
")",
"try",
":",
"for",
"ver",
"in",
"versions",
":",
"int",
"(",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | generate | Generate changelog. | scripts/gen_changelog.py | def generate():
"""Generate changelog."""
old_dir = os.getcwd()
proj_dir = os.path.join(os.path.dirname(__file__), os.pardir)
os.chdir(proj_dir)
version = validate_version()
if not version:
os.chdir(old_dir)
return
print('Generating changelog for version {}'.format(version))
... | def generate():
"""Generate changelog."""
old_dir = os.getcwd()
proj_dir = os.path.join(os.path.dirname(__file__), os.pardir)
os.chdir(proj_dir)
version = validate_version()
if not version:
os.chdir(old_dir)
return
print('Generating changelog for version {}'.format(version))
... | [
"Generate",
"changelog",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/scripts/gen_changelog.py#L24-L39 | [
"def",
"generate",
"(",
")",
":",
"old_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"proj_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"os",
".",
"pardir",
")",
"os",
".",
"chdir",
"... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | strongly_connected_components | Find the strongly connected components in a graph using Tarjan's algorithm.
The `graph` argument should be a dictionary mapping node names to sequences of successor nodes. | marrow/package/tarjan.py | def strongly_connected_components(graph: Graph) -> List:
"""Find the strongly connected components in a graph using Tarjan's algorithm.
The `graph` argument should be a dictionary mapping node names to sequences of successor nodes.
"""
assert check_argument_types()
result = []
stack = []
low = {}
def vi... | def strongly_connected_components(graph: Graph) -> List:
"""Find the strongly connected components in a graph using Tarjan's algorithm.
The `graph` argument should be a dictionary mapping node names to sequences of successor nodes.
"""
assert check_argument_types()
result = []
stack = []
low = {}
def vi... | [
"Find",
"the",
"strongly",
"connected",
"components",
"in",
"a",
"graph",
"using",
"Tarjan",
"s",
"algorithm",
".",
"The",
"graph",
"argument",
"should",
"be",
"a",
"dictionary",
"mapping",
"node",
"names",
"to",
"sequences",
"of",
"successor",
"nodes",
"."
] | marrow/package | python | https://github.com/marrow/package/blob/133d4bf67cc857d1b2423695938a00ff2dfa8af2/marrow/package/tarjan.py#L19-L55 | [
"def",
"strongly_connected_components",
"(",
"graph",
":",
"Graph",
")",
"->",
"List",
":",
"assert",
"check_argument_types",
"(",
")",
"result",
"=",
"[",
"]",
"stack",
"=",
"[",
"]",
"low",
"=",
"{",
"}",
"def",
"visit",
"(",
"node",
":",
"str",
")",... | 133d4bf67cc857d1b2423695938a00ff2dfa8af2 |
test | robust_topological_sort | Identify strongly connected components then perform a topological sort of those components. | marrow/package/tarjan.py | def robust_topological_sort(graph: Graph) -> list:
"""Identify strongly connected components then perform a topological sort of those components."""
assert check_argument_types()
components = strongly_connected_components(graph)
node_component = {}
for component in components:
for node in component:
nod... | def robust_topological_sort(graph: Graph) -> list:
"""Identify strongly connected components then perform a topological sort of those components."""
assert check_argument_types()
components = strongly_connected_components(graph)
node_component = {}
for component in components:
for node in component:
nod... | [
"Identify",
"strongly",
"connected",
"components",
"then",
"perform",
"a",
"topological",
"sort",
"of",
"those",
"components",
"."
] | marrow/package | python | https://github.com/marrow/package/blob/133d4bf67cc857d1b2423695938a00ff2dfa8af2/marrow/package/tarjan.py#L82-L105 | [
"def",
"robust_topological_sort",
"(",
"graph",
":",
"Graph",
")",
"->",
"list",
":",
"assert",
"check_argument_types",
"(",
")",
"components",
"=",
"strongly_connected_components",
"(",
"graph",
")",
"node_component",
"=",
"{",
"}",
"for",
"component",
"in",
"c... | 133d4bf67cc857d1b2423695938a00ff2dfa8af2 |
test | BaseExpression.set_parent | Set parent ``Expression`` for this object.
Args:
parent (Expression): The ``Expression`` which contains this object.
Raises:
FiqlObjectException: Parent must be of type ``Expression``. | fiql_parser/expression.py | def set_parent(self, parent):
"""Set parent ``Expression`` for this object.
Args:
parent (Expression): The ``Expression`` which contains this object.
Raises:
FiqlObjectException: Parent must be of type ``Expression``.
"""
if not isinstance(parent, Expres... | def set_parent(self, parent):
"""Set parent ``Expression`` for this object.
Args:
parent (Expression): The ``Expression`` which contains this object.
Raises:
FiqlObjectException: Parent must be of type ``Expression``.
"""
if not isinstance(parent, Expres... | [
"Set",
"parent",
"Expression",
"for",
"this",
"object",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L44-L56 | [
"def",
"set_parent",
"(",
"self",
",",
"parent",
")",
":",
"if",
"not",
"isinstance",
"(",
"parent",
",",
"Expression",
")",
":",
"raise",
"FiqlObjectException",
"(",
"\"Parent must be of %s not %s\"",
"%",
"(",
"Expression",
",",
"type",
"(",
"parent",
")",
... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | BaseExpression.get_parent | Get the parent ``Expression`` for this object.
Returns:
Expression: The ``Expression`` which contains this object.
Raises:
FiqlObjectException: Parent is ``None``. | fiql_parser/expression.py | def get_parent(self):
"""Get the parent ``Expression`` for this object.
Returns:
Expression: The ``Expression`` which contains this object.
Raises:
FiqlObjectException: Parent is ``None``.
"""
if not isinstance(self.parent, Expression):
raise... | def get_parent(self):
"""Get the parent ``Expression`` for this object.
Returns:
Expression: The ``Expression`` which contains this object.
Raises:
FiqlObjectException: Parent is ``None``.
"""
if not isinstance(self.parent, Expression):
raise... | [
"Get",
"the",
"parent",
"Expression",
"for",
"this",
"object",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L58-L70 | [
"def",
"get_parent",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"parent",
",",
"Expression",
")",
":",
"raise",
"FiqlObjectException",
"(",
"\"Parent must be of %s not %s\"",
"%",
"(",
"Expression",
",",
"type",
"(",
"self",
".",
"pa... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | Expression.add_operator | Add an ``Operator`` to the ``Expression``.
The ``Operator`` may result in a new ``Expression`` if an ``Operator``
already exists and is of a different precedence.
There are three possibilities when adding an ``Operator`` to an
``Expression`` depending on whether or not an ``Operator`` ... | fiql_parser/expression.py | def add_operator(self, operator):
"""Add an ``Operator`` to the ``Expression``.
The ``Operator`` may result in a new ``Expression`` if an ``Operator``
already exists and is of a different precedence.
There are three possibilities when adding an ``Operator`` to an
``Expression``... | def add_operator(self, operator):
"""Add an ``Operator`` to the ``Expression``.
The ``Operator`` may result in a new ``Expression`` if an ``Operator``
already exists and is of a different precedence.
There are three possibilities when adding an ``Operator`` to an
``Expression``... | [
"Add",
"an",
"Operator",
"to",
"the",
"Expression",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L118-L166 | [
"def",
"add_operator",
"(",
"self",
",",
"operator",
")",
":",
"if",
"not",
"isinstance",
"(",
"operator",
",",
"Operator",
")",
":",
"raise",
"FiqlObjectException",
"(",
"\"%s is not a valid element type\"",
"%",
"(",
"operator",
".",
"__class__",
")",
")",
"... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | Expression.add_element | Add an element of type ``Operator``, ``Constraint``, or
``Expression`` to the ``Expression``.
Args:
element: ``Constraint``, ``Expression``, or ``Operator``.
Returns:
Expression: ``self``
Raises:
FiqlObjectException: Element is not a valid type. | fiql_parser/expression.py | def add_element(self, element):
"""Add an element of type ``Operator``, ``Constraint``, or
``Expression`` to the ``Expression``.
Args:
element: ``Constraint``, ``Expression``, or ``Operator``.
Returns:
Expression: ``self``
Raises:
FiqlObject... | def add_element(self, element):
"""Add an element of type ``Operator``, ``Constraint``, or
``Expression`` to the ``Expression``.
Args:
element: ``Constraint``, ``Expression``, or ``Operator``.
Returns:
Expression: ``self``
Raises:
FiqlObject... | [
"Add",
"an",
"element",
"of",
"type",
"Operator",
"Constraint",
"or",
"Expression",
"to",
"the",
"Expression",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L168-L186 | [
"def",
"add_element",
"(",
"self",
",",
"element",
")",
":",
"if",
"isinstance",
"(",
"element",
",",
"BaseExpression",
")",
":",
"element",
".",
"set_parent",
"(",
"self",
".",
"_working_fragment",
")",
"self",
".",
"_working_fragment",
".",
"elements",
"."... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | Expression.op_and | Update the ``Expression`` by joining the specified additional
``elements`` using an "AND" ``Operator``
Args:
*elements (BaseExpression): The ``Expression`` and/or
``Constraint`` elements which the "AND" ``Operator`` applies
to.
Returns:
E... | fiql_parser/expression.py | def op_and(self, *elements):
"""Update the ``Expression`` by joining the specified additional
``elements`` using an "AND" ``Operator``
Args:
*elements (BaseExpression): The ``Expression`` and/or
``Constraint`` elements which the "AND" ``Operator`` applies
... | def op_and(self, *elements):
"""Update the ``Expression`` by joining the specified additional
``elements`` using an "AND" ``Operator``
Args:
*elements (BaseExpression): The ``Expression`` and/or
``Constraint`` elements which the "AND" ``Operator`` applies
... | [
"Update",
"the",
"Expression",
"by",
"joining",
"the",
"specified",
"additional",
"elements",
"using",
"an",
"AND",
"Operator"
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L199-L214 | [
"def",
"op_and",
"(",
"self",
",",
"*",
"elements",
")",
":",
"expression",
"=",
"self",
".",
"add_operator",
"(",
"Operator",
"(",
"';'",
")",
")",
"for",
"element",
"in",
"elements",
":",
"expression",
".",
"add_element",
"(",
"element",
")",
"return",... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | Expression.op_or | Update the ``Expression`` by joining the specified additional
``elements`` using an "OR" ``Operator``
Args:
*elements (BaseExpression): The ``Expression`` and/or
``Constraint`` elements which the "OR" ``Operator`` applies
to.
Returns:
Exp... | fiql_parser/expression.py | def op_or(self, *elements):
"""Update the ``Expression`` by joining the specified additional
``elements`` using an "OR" ``Operator``
Args:
*elements (BaseExpression): The ``Expression`` and/or
``Constraint`` elements which the "OR" ``Operator`` applies
... | def op_or(self, *elements):
"""Update the ``Expression`` by joining the specified additional
``elements`` using an "OR" ``Operator``
Args:
*elements (BaseExpression): The ``Expression`` and/or
``Constraint`` elements which the "OR" ``Operator`` applies
... | [
"Update",
"the",
"Expression",
"by",
"joining",
"the",
"specified",
"additional",
"elements",
"using",
"an",
"OR",
"Operator"
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L216-L231 | [
"def",
"op_or",
"(",
"self",
",",
"*",
"elements",
")",
":",
"expression",
"=",
"self",
".",
"add_operator",
"(",
"Operator",
"(",
"','",
")",
")",
"for",
"element",
"in",
"elements",
":",
"expression",
".",
"add_element",
"(",
"element",
")",
"return",
... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | Expression.to_python | Deconstruct the ``Expression`` instance to a list or tuple
(If ``Expression`` contains only one ``Constraint``).
Returns:
list or tuple: The deconstructed ``Expression``. | fiql_parser/expression.py | def to_python(self):
"""Deconstruct the ``Expression`` instance to a list or tuple
(If ``Expression`` contains only one ``Constraint``).
Returns:
list or tuple: The deconstructed ``Expression``.
"""
if len(self.elements) == 0:
return None
if len(s... | def to_python(self):
"""Deconstruct the ``Expression`` instance to a list or tuple
(If ``Expression`` contains only one ``Constraint``).
Returns:
list or tuple: The deconstructed ``Expression``.
"""
if len(self.elements) == 0:
return None
if len(s... | [
"Deconstruct",
"the",
"Expression",
"instance",
"to",
"a",
"list",
"or",
"tuple",
"(",
"If",
"Expression",
"contains",
"only",
"one",
"Constraint",
")",
"."
] | sergedomk/fiql_parser | python | https://github.com/sergedomk/fiql_parser/blob/499dd7cd0741603530ce5f3803d92813e74ac9c3/fiql_parser/expression.py#L233-L246 | [
"def",
"to_python",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"elements",
")",
"==",
"0",
":",
"return",
"None",
"if",
"len",
"(",
"self",
".",
"elements",
")",
"==",
"1",
":",
"return",
"self",
".",
"elements",
"[",
"0",
"]",
".",
... | 499dd7cd0741603530ce5f3803d92813e74ac9c3 |
test | run | Run client. | async_client.py | async def run(loop):
"""Run client."""
cam = AsyncCAM(loop=loop)
await cam.connect()
print(cam.welcome_msg)
await cam.send(b'/cmd:deletelist')
print(await cam.receive())
await cam.send(b'/cmd:deletelist')
print(await cam.wait_for(cmd='cmd', timeout=0.1))
await cam.send(b'/cmd:deletel... | async def run(loop):
"""Run client."""
cam = AsyncCAM(loop=loop)
await cam.connect()
print(cam.welcome_msg)
await cam.send(b'/cmd:deletelist')
print(await cam.receive())
await cam.send(b'/cmd:deletelist')
print(await cam.wait_for(cmd='cmd', timeout=0.1))
await cam.send(b'/cmd:deletel... | [
"Run",
"client",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/async_client.py#L7-L20 | [
"async",
"def",
"run",
"(",
"loop",
")",
":",
"cam",
"=",
"AsyncCAM",
"(",
"loop",
"=",
"loop",
")",
"await",
"cam",
".",
"connect",
"(",
")",
"print",
"(",
"cam",
".",
"welcome_msg",
")",
"await",
"cam",
".",
"send",
"(",
"b'/cmd:deletelist'",
")",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | logger | Decorate passed in function and log message to module logger. | leicacam/cam.py | def logger(function):
"""Decorate passed in function and log message to module logger."""
@functools.wraps(function)
def wrapper(*args, **kwargs):
"""Wrap function."""
sep = kwargs.get('sep', ' ')
end = kwargs.get('end', '') # do not add newline by default
out = sep.join([re... | def logger(function):
"""Decorate passed in function and log message to module logger."""
@functools.wraps(function)
def wrapper(*args, **kwargs):
"""Wrap function."""
sep = kwargs.get('sep', ' ')
end = kwargs.get('end', '') # do not add newline by default
out = sep.join([re... | [
"Decorate",
"passed",
"in",
"function",
"and",
"log",
"message",
"to",
"module",
"logger",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L17-L28 | [
"def",
"logger",
"(",
"function",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wrap function.\"\"\"",
"sep",
"=",
"kwargs",
".",
"get",
"(",
"'sep'",
",",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | _parse_receive | Parse received response.
Parameters
----------
incomming : bytes string
Incomming bytes from socket server.
Returns
-------
list of OrderedDict
Received message as a list of OrderedDict. | leicacam/cam.py | def _parse_receive(incomming):
"""Parse received response.
Parameters
----------
incomming : bytes string
Incomming bytes from socket server.
Returns
-------
list of OrderedDict
Received message as a list of OrderedDict.
"""
debug(b'< ' + incomming)
# remove te... | def _parse_receive(incomming):
"""Parse received response.
Parameters
----------
incomming : bytes string
Incomming bytes from socket server.
Returns
-------
list of OrderedDict
Received message as a list of OrderedDict.
"""
debug(b'< ' + incomming)
# remove te... | [
"Parse",
"received",
"response",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L141-L161 | [
"def",
"_parse_receive",
"(",
"incomming",
")",
":",
"debug",
"(",
"b'< '",
"+",
"incomming",
")",
"# remove terminating null byte",
"incomming",
"=",
"incomming",
".",
"rstrip",
"(",
"b'\\x00'",
")",
"# split received messages",
"# return as list of several messages rece... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | tuples_as_bytes | Format list of tuples to CAM message with format /key:val.
Parameters
----------
cmds : list of tuples
List of commands as tuples.
Returns
-------
bytes
Sequence of /key:val.
Example
-------
::
>>> tuples_as_bytes([('cmd', 'val'), ('cmd2', 'val2')])
... | leicacam/cam.py | def tuples_as_bytes(cmds):
"""Format list of tuples to CAM message with format /key:val.
Parameters
----------
cmds : list of tuples
List of commands as tuples.
Returns
-------
bytes
Sequence of /key:val.
Example
-------
::
>>> tuples_as_bytes([('cmd',... | def tuples_as_bytes(cmds):
"""Format list of tuples to CAM message with format /key:val.
Parameters
----------
cmds : list of tuples
List of commands as tuples.
Returns
-------
bytes
Sequence of /key:val.
Example
-------
::
>>> tuples_as_bytes([('cmd',... | [
"Format",
"list",
"of",
"tuples",
"to",
"CAM",
"message",
"with",
"format",
"/",
"key",
":",
"val",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L403-L430 | [
"def",
"tuples_as_bytes",
"(",
"cmds",
")",
":",
"cmds",
"=",
"OrderedDict",
"(",
"cmds",
")",
"# override equal keys",
"tmp",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"cmds",
".",
"items",
"(",
")",
":",
"key",
"=",
"str",
"(",
"key",
")",
"... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | tuples_as_dict | Translate a list of tuples to OrderedDict with key and val as strings.
Parameters
----------
_list : list of tuples
Returns
-------
collections.OrderedDict
Example
-------
::
>>> tuples_as_dict([('cmd', 'val'), ('cmd2', 'val2')])
OrderedDict([('cmd', 'val'), ('cmd... | leicacam/cam.py | def tuples_as_dict(_list):
"""Translate a list of tuples to OrderedDict with key and val as strings.
Parameters
----------
_list : list of tuples
Returns
-------
collections.OrderedDict
Example
-------
::
>>> tuples_as_dict([('cmd', 'val'), ('cmd2', 'val2')])
... | def tuples_as_dict(_list):
"""Translate a list of tuples to OrderedDict with key and val as strings.
Parameters
----------
_list : list of tuples
Returns
-------
collections.OrderedDict
Example
-------
::
>>> tuples_as_dict([('cmd', 'val'), ('cmd2', 'val2')])
... | [
"Translate",
"a",
"list",
"of",
"tuples",
"to",
"OrderedDict",
"with",
"key",
"and",
"val",
"as",
"strings",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L433-L457 | [
"def",
"tuples_as_dict",
"(",
"_list",
")",
":",
"_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"val",
"in",
"_list",
":",
"key",
"=",
"str",
"(",
"key",
")",
"val",
"=",
"str",
"(",
"val",
")",
"_dict",
"[",
"key",
"]",
"=",
"val",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | bytes_as_dict | Parse CAM message to OrderedDict based on format /key:val.
Parameters
----------
msg : bytes
Sequence of /key:val.
Returns
-------
collections.OrderedDict
With /key:val => dict[key] = val. | leicacam/cam.py | def bytes_as_dict(msg):
"""Parse CAM message to OrderedDict based on format /key:val.
Parameters
----------
msg : bytes
Sequence of /key:val.
Returns
-------
collections.OrderedDict
With /key:val => dict[key] = val.
"""
# decode bytes, assume '/' in start
cmd_s... | def bytes_as_dict(msg):
"""Parse CAM message to OrderedDict based on format /key:val.
Parameters
----------
msg : bytes
Sequence of /key:val.
Returns
-------
collections.OrderedDict
With /key:val => dict[key] = val.
"""
# decode bytes, assume '/' in start
cmd_s... | [
"Parse",
"CAM",
"message",
"to",
"OrderedDict",
"based",
"on",
"format",
"/",
"key",
":",
"val",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L460-L488 | [
"def",
"bytes_as_dict",
"(",
"msg",
")",
":",
"# decode bytes, assume '/' in start",
"cmd_strings",
"=",
"msg",
".",
"decode",
"(",
")",
"[",
"1",
":",
"]",
".",
"split",
"(",
"r' /'",
")",
"cmds",
"=",
"OrderedDict",
"(",
")",
"for",
"cmd",
"in",
"cmd_s... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | check_messages | Check if specific message is present.
Parameters
----------
cmd : string
Command to check for in bytestring from microscope CAM interface. If
``value`` is falsey, value of received command does not matter.
value : string
Check if ``cmd:value`` is received.
Returns
-----... | leicacam/cam.py | def check_messages(msgs, cmd, value=None):
"""Check if specific message is present.
Parameters
----------
cmd : string
Command to check for in bytestring from microscope CAM interface. If
``value`` is falsey, value of received command does not matter.
value : string
Check if... | def check_messages(msgs, cmd, value=None):
"""Check if specific message is present.
Parameters
----------
cmd : string
Command to check for in bytestring from microscope CAM interface. If
``value`` is falsey, value of received command does not matter.
value : string
Check if... | [
"Check",
"if",
"specific",
"message",
"is",
"present",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L491-L513 | [
"def",
"check_messages",
"(",
"msgs",
",",
"cmd",
",",
"value",
"=",
"None",
")",
":",
"for",
"msg",
"in",
"msgs",
":",
"if",
"value",
"and",
"msg",
".",
"get",
"(",
"cmd",
")",
"==",
"value",
":",
"return",
"msg",
"if",
"not",
"value",
"and",
"m... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | BaseCAM._prepare_send | Prepare message to be sent.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
-------
string
Message to be sent. | leicacam/cam.py | def _prepare_send(self, commands):
"""Prepare message to be sent.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
-------
... | def _prepare_send(self, commands):
"""Prepare message to be sent.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
-------
... | [
"Prepare",
"message",
"to",
"be",
"sent",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L118-L138 | [
"def",
"_prepare_send",
"(",
"self",
",",
"commands",
")",
":",
"if",
"isinstance",
"(",
"commands",
",",
"bytes",
")",
":",
"msg",
"=",
"self",
".",
"prefix_bytes",
"+",
"commands",
"else",
":",
"msg",
"=",
"tuples_as_bytes",
"(",
"self",
".",
"prefix",... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.connect | Connect to LASAF through a CAM-socket. | leicacam/cam.py | def connect(self):
"""Connect to LASAF through a CAM-socket."""
self.socket = socket.socket()
self.socket.connect((self.host, self.port))
self.socket.settimeout(False) # non-blocking
sleep(self.delay) # wait for response
self.welcome_msg = self.socket.recv(
... | def connect(self):
"""Connect to LASAF through a CAM-socket."""
self.socket = socket.socket()
self.socket.connect((self.host, self.port))
self.socket.settimeout(False) # non-blocking
sleep(self.delay) # wait for response
self.welcome_msg = self.socket.recv(
... | [
"Connect",
"to",
"LASAF",
"through",
"a",
"CAM",
"-",
"socket",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L174-L181 | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"socket",
"=",
"socket",
".",
"socket",
"(",
")",
"self",
".",
"socket",
".",
"connect",
"(",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
")",
"self",
".",
"socket",
".",
"settime... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.flush | Flush incomming socket messages. | leicacam/cam.py | def flush(self):
"""Flush incomming socket messages."""
debug('flushing incomming socket messages')
try:
while True:
msg = self.socket.recv(self.buffer_size)
debug(b'< ' + msg)
except socket.error:
pass | def flush(self):
"""Flush incomming socket messages."""
debug('flushing incomming socket messages')
try:
while True:
msg = self.socket.recv(self.buffer_size)
debug(b'< ' + msg)
except socket.error:
pass | [
"Flush",
"incomming",
"socket",
"messages",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L183-L191 | [
"def",
"flush",
"(",
"self",
")",
":",
"debug",
"(",
"'flushing incomming socket messages'",
")",
"try",
":",
"while",
"True",
":",
"msg",
"=",
"self",
".",
"socket",
".",
"recv",
"(",
"self",
".",
"buffer_size",
")",
"debug",
"(",
"b'< '",
"+",
"msg",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.send | Send commands to LASAF through CAM-socket.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
-------
int
Bytes sent.... | leicacam/cam.py | def send(self, commands):
"""Send commands to LASAF through CAM-socket.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
------... | def send(self, commands):
"""Send commands to LASAF through CAM-socket.
Parameters
----------
commands : list of tuples or bytes string
Commands as a list of tuples or a bytes string. cam.prefix is
allways prepended before sending.
Returns
------... | [
"Send",
"commands",
"to",
"LASAF",
"through",
"CAM",
"-",
"socket",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L193-L220 | [
"def",
"send",
"(",
"self",
",",
"commands",
")",
":",
"self",
".",
"flush",
"(",
")",
"# discard any waiting messages",
"msg",
"=",
"self",
".",
"_prepare_send",
"(",
"commands",
")",
"return",
"self",
".",
"socket",
".",
"send",
"(",
"msg",
")"
] | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.receive | Receive message from socket interface as list of OrderedDict. | leicacam/cam.py | def receive(self):
"""Receive message from socket interface as list of OrderedDict."""
try:
incomming = self.socket.recv(self.buffer_size)
except socket.error:
return []
return _parse_receive(incomming) | def receive(self):
"""Receive message from socket interface as list of OrderedDict."""
try:
incomming = self.socket.recv(self.buffer_size)
except socket.error:
return []
return _parse_receive(incomming) | [
"Receive",
"message",
"from",
"socket",
"interface",
"as",
"list",
"of",
"OrderedDict",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L222-L229 | [
"def",
"receive",
"(",
"self",
")",
":",
"try",
":",
"incomming",
"=",
"self",
".",
"socket",
".",
"recv",
"(",
"self",
".",
"buffer_size",
")",
"except",
"socket",
".",
"error",
":",
"return",
"[",
"]",
"return",
"_parse_receive",
"(",
"incomming",
")... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.wait_for | Hang until command is received.
If value is supplied, it will hang until ``cmd:value`` is received.
Parameters
----------
cmd : string
Command to wait for in bytestring from microscope CAM interface. If
``value`` is falsey, value of received command does not mat... | leicacam/cam.py | def wait_for(self, cmd, value=None, timeout=60):
"""Hang until command is received.
If value is supplied, it will hang until ``cmd:value`` is received.
Parameters
----------
cmd : string
Command to wait for in bytestring from microscope CAM interface. If
... | def wait_for(self, cmd, value=None, timeout=60):
"""Hang until command is received.
If value is supplied, it will hang until ``cmd:value`` is received.
Parameters
----------
cmd : string
Command to wait for in bytestring from microscope CAM interface. If
... | [
"Hang",
"until",
"command",
"is",
"received",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L231-L261 | [
"def",
"wait_for",
"(",
"self",
",",
"cmd",
",",
"value",
"=",
"None",
",",
"timeout",
"=",
"60",
")",
":",
"wait",
"=",
"time",
"(",
")",
"+",
"timeout",
"*",
"60",
"while",
"True",
":",
"if",
"time",
"(",
")",
">",
"wait",
":",
"return",
"Ord... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.enable | Enable a given scan field. | leicacam/cam.py | def enable(self, slide=0, wellx=1, welly=1, fieldx=1, fieldy=1):
"""Enable a given scan field."""
# pylint: disable=too-many-arguments
cmd = [
('cmd', 'enable'),
('slide', str(slide)),
('wellx', str(wellx)),
('welly', str(welly)),
('fie... | def enable(self, slide=0, wellx=1, welly=1, fieldx=1, fieldy=1):
"""Enable a given scan field."""
# pylint: disable=too-many-arguments
cmd = [
('cmd', 'enable'),
('slide', str(slide)),
('wellx', str(wellx)),
('welly', str(welly)),
('fie... | [
"Enable",
"a",
"given",
"scan",
"field",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L292-L305 | [
"def",
"enable",
"(",
"self",
",",
"slide",
"=",
"0",
",",
"wellx",
"=",
"1",
",",
"welly",
"=",
"1",
",",
"fieldx",
"=",
"1",
",",
"fieldy",
"=",
"1",
")",
":",
"# pylint: disable=too-many-arguments",
"cmd",
"=",
"[",
"(",
"'cmd'",
",",
"'enable'",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.save_template | Save scanning template to filename. | leicacam/cam.py | def save_template(self, filename="{ScanningTemplate}leicacam.xml"):
"""Save scanning template to filename."""
cmd = [
('sys', '0'),
('cmd', 'save'),
('fil', str(filename))
]
self.send(cmd)
return self.wait_for(*cmd[0]) | def save_template(self, filename="{ScanningTemplate}leicacam.xml"):
"""Save scanning template to filename."""
cmd = [
('sys', '0'),
('cmd', 'save'),
('fil', str(filename))
]
self.send(cmd)
return self.wait_for(*cmd[0]) | [
"Save",
"scanning",
"template",
"to",
"filename",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L334-L342 | [
"def",
"save_template",
"(",
"self",
",",
"filename",
"=",
"\"{ScanningTemplate}leicacam.xml\"",
")",
":",
"cmd",
"=",
"[",
"(",
"'sys'",
",",
"'0'",
")",
",",
"(",
"'cmd'",
",",
"'save'",
")",
",",
"(",
"'fil'",
",",
"str",
"(",
"filename",
")",
")",
... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.load_template | Load scanning template from filename.
Template needs to exist in database, otherwise it will not load.
Parameters
----------
filename : str
Filename to template to load. Filename may contain path also, in
such case, the basename will be used. '.xml' will be stri... | leicacam/cam.py | def load_template(self, filename="{ScanningTemplate}leicacam.xml"):
"""Load scanning template from filename.
Template needs to exist in database, otherwise it will not load.
Parameters
----------
filename : str
Filename to template to load. Filename may contain path... | def load_template(self, filename="{ScanningTemplate}leicacam.xml"):
"""Load scanning template from filename.
Template needs to exist in database, otherwise it will not load.
Parameters
----------
filename : str
Filename to template to load. Filename may contain path... | [
"Load",
"scanning",
"template",
"from",
"filename",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L344-L387 | [
"def",
"load_template",
"(",
"self",
",",
"filename",
"=",
"\"{ScanningTemplate}leicacam.xml\"",
")",
":",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"if",
"basename",
"[",
"-",
"4",
":",
"]",
"==",
"'.xml'",
":",
"basename"... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | CAM.get_information | Get information about given keyword. Defaults to stage. | leicacam/cam.py | def get_information(self, about='stage'):
"""Get information about given keyword. Defaults to stage."""
cmd = [
('cmd', 'getinfo'),
('dev', str(about))
]
self.send(cmd)
return self.wait_for(*cmd[1]) | def get_information(self, about='stage'):
"""Get information about given keyword. Defaults to stage."""
cmd = [
('cmd', 'getinfo'),
('dev', str(about))
]
self.send(cmd)
return self.wait_for(*cmd[1]) | [
"Get",
"information",
"about",
"given",
"keyword",
".",
"Defaults",
"to",
"stage",
"."
] | MartinHjelmare/leicacam | python | https://github.com/MartinHjelmare/leicacam/blob/1df37bccd34884737d3b5e169fae71dd2f21f1e2/leicacam/cam.py#L389-L396 | [
"def",
"get_information",
"(",
"self",
",",
"about",
"=",
"'stage'",
")",
":",
"cmd",
"=",
"[",
"(",
"'cmd'",
",",
"'getinfo'",
")",
",",
"(",
"'dev'",
",",
"str",
"(",
"about",
")",
")",
"]",
"self",
".",
"send",
"(",
"cmd",
")",
"return",
"self... | 1df37bccd34884737d3b5e169fae71dd2f21f1e2 |
test | incfile | r"""
Include a Python source file in a docstring formatted in reStructuredText.
:param fname: File name, relative to environment variable
:bash:`${TRACER_DIR}`
:type fname: string
:param fpointer: Output function pointer. Normally is :code:`cog.out` but
:code:`p... | docs/support/incfile.py | def incfile(fname, fpointer, lrange="1,6-", sdir=None):
r"""
Include a Python source file in a docstring formatted in reStructuredText.
:param fname: File name, relative to environment variable
:bash:`${TRACER_DIR}`
:type fname: string
:param fpointer: Output function pointer. N... | def incfile(fname, fpointer, lrange="1,6-", sdir=None):
r"""
Include a Python source file in a docstring formatted in reStructuredText.
:param fname: File name, relative to environment variable
:bash:`${TRACER_DIR}`
:type fname: string
:param fpointer: Output function pointer. N... | [
"r",
"Include",
"a",
"Python",
"source",
"file",
"in",
"a",
"docstring",
"formatted",
"in",
"reStructuredText",
"."
] | pmacosta/peng | python | https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/docs/support/incfile.py#L9-L84 | [
"def",
"incfile",
"(",
"fname",
",",
"fpointer",
",",
"lrange",
"=",
"\"1,6-\"",
",",
"sdir",
"=",
"None",
")",
":",
"# Read file",
"file_dir",
"=",
"(",
"sdir",
"if",
"sdir",
"else",
"os",
".",
"environ",
".",
"get",
"(",
"\"TRACER_DIR\"",
",",
"os",
... | 976935377adaa3de26fc5677aceb2cdfbd6f93a7 |
test | locate_package_json | Find and return the location of package.json. | systemjs/jspm.py | def locate_package_json():
"""
Find and return the location of package.json.
"""
directory = settings.SYSTEMJS_PACKAGE_JSON_DIR
if not directory:
raise ImproperlyConfigured(
"Could not locate 'package.json'. Set SYSTEMJS_PACKAGE_JSON_DIR "
"to the directory that holds... | def locate_package_json():
"""
Find and return the location of package.json.
"""
directory = settings.SYSTEMJS_PACKAGE_JSON_DIR
if not directory:
raise ImproperlyConfigured(
"Could not locate 'package.json'. Set SYSTEMJS_PACKAGE_JSON_DIR "
"to the directory that holds... | [
"Find",
"and",
"return",
"the",
"location",
"of",
"package",
".",
"json",
"."
] | sergei-maertens/django-systemjs | python | https://github.com/sergei-maertens/django-systemjs/blob/efd4a3862a39d9771609a25a5556f36023cf6e5c/systemjs/jspm.py#L8-L21 | [
"def",
"locate_package_json",
"(",
")",
":",
"directory",
"=",
"settings",
".",
"SYSTEMJS_PACKAGE_JSON_DIR",
"if",
"not",
"directory",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"Could not locate 'package.json'. Set SYSTEMJS_PACKAGE_JSON_DIR \"",
"\"to the directory that holds ... | efd4a3862a39d9771609a25a5556f36023cf6e5c |
test | parse_package_json | Extract the JSPM configuration from package.json. | systemjs/jspm.py | def parse_package_json():
"""
Extract the JSPM configuration from package.json.
"""
with open(locate_package_json()) as pjson:
data = json.loads(pjson.read())
return data | def parse_package_json():
"""
Extract the JSPM configuration from package.json.
"""
with open(locate_package_json()) as pjson:
data = json.loads(pjson.read())
return data | [
"Extract",
"the",
"JSPM",
"configuration",
"from",
"package",
".",
"json",
"."
] | sergei-maertens/django-systemjs | python | https://github.com/sergei-maertens/django-systemjs/blob/efd4a3862a39d9771609a25a5556f36023cf6e5c/systemjs/jspm.py#L24-L30 | [
"def",
"parse_package_json",
"(",
")",
":",
"with",
"open",
"(",
"locate_package_json",
"(",
")",
")",
"as",
"pjson",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"pjson",
".",
"read",
"(",
")",
")",
"return",
"data"
] | efd4a3862a39d9771609a25a5556f36023cf6e5c |
test | find_systemjs_location | Figure out where `jspm_packages/system.js` will be put by JSPM. | systemjs/jspm.py | def find_systemjs_location():
"""
Figure out where `jspm_packages/system.js` will be put by JSPM.
"""
location = os.path.abspath(os.path.dirname(locate_package_json()))
conf = parse_package_json()
if 'jspm' in conf:
conf = conf['jspm']
try:
conf = conf['directories']
ex... | def find_systemjs_location():
"""
Figure out where `jspm_packages/system.js` will be put by JSPM.
"""
location = os.path.abspath(os.path.dirname(locate_package_json()))
conf = parse_package_json()
if 'jspm' in conf:
conf = conf['jspm']
try:
conf = conf['directories']
ex... | [
"Figure",
"out",
"where",
"jspm_packages",
"/",
"system",
".",
"js",
"will",
"be",
"put",
"by",
"JSPM",
"."
] | sergei-maertens/django-systemjs | python | https://github.com/sergei-maertens/django-systemjs/blob/efd4a3862a39d9771609a25a5556f36023cf6e5c/systemjs/jspm.py#L33-L56 | [
"def",
"find_systemjs_location",
"(",
")",
":",
"location",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"locate_package_json",
"(",
")",
")",
")",
"conf",
"=",
"parse_package_json",
"(",
")",
"if",
"'jspm'",
"in",... | efd4a3862a39d9771609a25a5556f36023cf6e5c |
test | _handle_api_error_with_json | Handle YOURLS API errors.
requests' raise_for_status doesn't show the user the YOURLS json response,
so we parse that here and raise nicer exceptions. | yourls/data.py | def _handle_api_error_with_json(http_exc, jsondata, response):
"""Handle YOURLS API errors.
requests' raise_for_status doesn't show the user the YOURLS json response,
so we parse that here and raise nicer exceptions.
"""
if 'code' in jsondata and 'message' in jsondata:
code = jsondata['code... | def _handle_api_error_with_json(http_exc, jsondata, response):
"""Handle YOURLS API errors.
requests' raise_for_status doesn't show the user the YOURLS json response,
so we parse that here and raise nicer exceptions.
"""
if 'code' in jsondata and 'message' in jsondata:
code = jsondata['code... | [
"Handle",
"YOURLS",
"API",
"errors",
"."
] | RazerM/yourls-python | python | https://github.com/RazerM/yourls-python/blob/716845562a2bbb430de3c379c9481b195e451ccf/yourls/data.py#L103-L123 | [
"def",
"_handle_api_error_with_json",
"(",
"http_exc",
",",
"jsondata",
",",
"response",
")",
":",
"if",
"'code'",
"in",
"jsondata",
"and",
"'message'",
"in",
"jsondata",
":",
"code",
"=",
"jsondata",
"[",
"'code'",
"]",
"message",
"=",
"jsondata",
"[",
"'me... | 716845562a2bbb430de3c379c9481b195e451ccf |
test | _validate_yourls_response | Validate response from YOURLS server. | yourls/data.py | def _validate_yourls_response(response, data):
"""Validate response from YOURLS server."""
try:
response.raise_for_status()
except HTTPError as http_exc:
# Collect full HTTPError information so we can reraise later if required.
http_error_info = sys.exc_info()
# We will rera... | def _validate_yourls_response(response, data):
"""Validate response from YOURLS server."""
try:
response.raise_for_status()
except HTTPError as http_exc:
# Collect full HTTPError information so we can reraise later if required.
http_error_info = sys.exc_info()
# We will rera... | [
"Validate",
"response",
"from",
"YOURLS",
"server",
"."
] | RazerM/yourls-python | python | https://github.com/RazerM/yourls-python/blob/716845562a2bbb430de3c379c9481b195e451ccf/yourls/data.py#L126-L174 | [
"def",
"_validate_yourls_response",
"(",
"response",
",",
"data",
")",
":",
"try",
":",
"response",
".",
"raise_for_status",
"(",
")",
"except",
"HTTPError",
"as",
"http_exc",
":",
"# Collect full HTTPError information so we can reraise later if required.",
"http_error_info... | 716845562a2bbb430de3c379c9481b195e451ccf |
test | _homogenize_waves | Generate combined independent variable vector.
The combination is from two waveforms and the (possibly interpolated)
dependent variable vectors of these two waveforms | peng/wave_core.py | def _homogenize_waves(wave_a, wave_b):
"""
Generate combined independent variable vector.
The combination is from two waveforms and the (possibly interpolated)
dependent variable vectors of these two waveforms
"""
indep_vector = _get_indep_vector(wave_a, wave_b)
dep_vector_a = _interp_dep_v... | def _homogenize_waves(wave_a, wave_b):
"""
Generate combined independent variable vector.
The combination is from two waveforms and the (possibly interpolated)
dependent variable vectors of these two waveforms
"""
indep_vector = _get_indep_vector(wave_a, wave_b)
dep_vector_a = _interp_dep_v... | [
"Generate",
"combined",
"independent",
"variable",
"vector",
"."
] | pmacosta/peng | python | https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_core.py#L87-L97 | [
"def",
"_homogenize_waves",
"(",
"wave_a",
",",
"wave_b",
")",
":",
"indep_vector",
"=",
"_get_indep_vector",
"(",
"wave_a",
",",
"wave_b",
")",
"dep_vector_a",
"=",
"_interp_dep_vector",
"(",
"wave_a",
",",
"indep_vector",
")",
"dep_vector_b",
"=",
"_interp_dep_v... | 976935377adaa3de26fc5677aceb2cdfbd6f93a7 |
test | _interp_dep_vector | Create new dependent variable vector. | peng/wave_core.py | def _interp_dep_vector(wave, indep_vector):
"""Create new dependent variable vector."""
dep_vector_is_int = wave.dep_vector.dtype.name.startswith("int")
dep_vector_is_complex = wave.dep_vector.dtype.name.startswith("complex")
if (wave.interp, wave.indep_scale) == ("CONTINUOUS", "LOG"):
wave_inte... | def _interp_dep_vector(wave, indep_vector):
"""Create new dependent variable vector."""
dep_vector_is_int = wave.dep_vector.dtype.name.startswith("int")
dep_vector_is_complex = wave.dep_vector.dtype.name.startswith("complex")
if (wave.interp, wave.indep_scale) == ("CONTINUOUS", "LOG"):
wave_inte... | [
"Create",
"new",
"dependent",
"variable",
"vector",
"."
] | pmacosta/peng | python | https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_core.py#L100-L134 | [
"def",
"_interp_dep_vector",
"(",
"wave",
",",
"indep_vector",
")",
":",
"dep_vector_is_int",
"=",
"wave",
".",
"dep_vector",
".",
"dtype",
".",
"name",
".",
"startswith",
"(",
"\"int\"",
")",
"dep_vector_is_complex",
"=",
"wave",
".",
"dep_vector",
".",
"dtyp... | 976935377adaa3de26fc5677aceb2cdfbd6f93a7 |
test | _get_indep_vector | Create new independent variable vector. | peng/wave_core.py | def _get_indep_vector(wave_a, wave_b):
"""Create new independent variable vector."""
exobj = pexdoc.exh.addex(RuntimeError, "Independent variable ranges do not overlap")
min_bound = max(np.min(wave_a.indep_vector), np.min(wave_b.indep_vector))
max_bound = min(np.max(wave_a.indep_vector), np.max(wave_b.i... | def _get_indep_vector(wave_a, wave_b):
"""Create new independent variable vector."""
exobj = pexdoc.exh.addex(RuntimeError, "Independent variable ranges do not overlap")
min_bound = max(np.min(wave_a.indep_vector), np.min(wave_b.indep_vector))
max_bound = min(np.max(wave_a.indep_vector), np.max(wave_b.i... | [
"Create",
"new",
"independent",
"variable",
"vector",
"."
] | pmacosta/peng | python | https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_core.py#L137-L144 | [
"def",
"_get_indep_vector",
"(",
"wave_a",
",",
"wave_b",
")",
":",
"exobj",
"=",
"pexdoc",
".",
"exh",
".",
"addex",
"(",
"RuntimeError",
",",
"\"Independent variable ranges do not overlap\"",
")",
"min_bound",
"=",
"max",
"(",
"np",
".",
"min",
"(",
"wave_a"... | 976935377adaa3de26fc5677aceb2cdfbd6f93a7 |
test | _verify_compatibility | Verify that two waveforms can be combined with various mathematical functions. | peng/wave_core.py | def _verify_compatibility(wave_a, wave_b, check_dep_units=True):
"""Verify that two waveforms can be combined with various mathematical functions."""
exobj = pexdoc.exh.addex(RuntimeError, "Waveforms are not compatible")
ctuple = (
bool(wave_a.indep_scale != wave_b.indep_scale),
bool(wave_a.... | def _verify_compatibility(wave_a, wave_b, check_dep_units=True):
"""Verify that two waveforms can be combined with various mathematical functions."""
exobj = pexdoc.exh.addex(RuntimeError, "Waveforms are not compatible")
ctuple = (
bool(wave_a.indep_scale != wave_b.indep_scale),
bool(wave_a.... | [
"Verify",
"that",
"two",
"waveforms",
"can",
"be",
"combined",
"with",
"various",
"mathematical",
"functions",
"."
] | pmacosta/peng | python | https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_core.py#L147-L157 | [
"def",
"_verify_compatibility",
"(",
"wave_a",
",",
"wave_b",
",",
"check_dep_units",
"=",
"True",
")",
":",
"exobj",
"=",
"pexdoc",
".",
"exh",
".",
"addex",
"(",
"RuntimeError",
",",
"\"Waveforms are not compatible\"",
")",
"ctuple",
"=",
"(",
"bool",
"(",
... | 976935377adaa3de26fc5677aceb2cdfbd6f93a7 |
test | SystemJSManifestStaticFilesMixin.load_systemjs_manifest | Load the existing systemjs manifest and remove any entries that no longer
exist on the storage. | systemjs/storage.py | def load_systemjs_manifest(self):
"""
Load the existing systemjs manifest and remove any entries that no longer
exist on the storage.
"""
# backup the original name
_manifest_name = self.manifest_name
# load the custom bundle manifest
self.manifest_name =... | def load_systemjs_manifest(self):
"""
Load the existing systemjs manifest and remove any entries that no longer
exist on the storage.
"""
# backup the original name
_manifest_name = self.manifest_name
# load the custom bundle manifest
self.manifest_name =... | [
"Load",
"the",
"existing",
"systemjs",
"manifest",
"and",
"remove",
"any",
"entries",
"that",
"no",
"longer",
"exist",
"on",
"the",
"storage",
"."
] | sergei-maertens/django-systemjs | python | https://github.com/sergei-maertens/django-systemjs/blob/efd4a3862a39d9771609a25a5556f36023cf6e5c/systemjs/storage.py#L23-L41 | [
"def",
"load_systemjs_manifest",
"(",
"self",
")",
":",
"# backup the original name",
"_manifest_name",
"=",
"self",
".",
"manifest_name",
"# load the custom bundle manifest",
"self",
".",
"manifest_name",
"=",
"self",
".",
"systemjs_manifest_name",
"bundle_files",
"=",
"... | efd4a3862a39d9771609a25a5556f36023cf6e5c |
test | trace_pars | Define trace parameters. | docs/support/trace_support.py | def trace_pars(mname):
"""Define trace parameters."""
pickle_fname = os.path.join(os.path.dirname(__file__), "{0}.pkl".format(mname))
ddir = os.path.dirname(os.path.dirname(__file__))
moddb_fname = os.path.join(ddir, "moddb.json")
in_callables_fname = moddb_fname if os.path.exists(moddb_fname) else ... | def trace_pars(mname):
"""Define trace parameters."""
pickle_fname = os.path.join(os.path.dirname(__file__), "{0}.pkl".format(mname))
ddir = os.path.dirname(os.path.dirname(__file__))
moddb_fname = os.path.join(ddir, "moddb.json")
in_callables_fname = moddb_fname if os.path.exists(moddb_fname) else ... | [
"Define",
"trace",
"parameters",
"."
] | pmacosta/peng | python | https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/docs/support/trace_support.py#L27-L48 | [
"def",
"trace_pars",
"(",
"mname",
")",
":",
"pickle_fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"{0}.pkl\"",
".",
"format",
"(",
"mname",
")",
")",
"ddir",
"=",
"os",
".",
"path... | 976935377adaa3de26fc5677aceb2cdfbd6f93a7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.