repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
klen/zeta-library
zetalibrary/scss/__init__.py
_image_url
def _image_url(image, dst_color=None, src_color=None): """ Generates a path to an asset found relative to the project's images directory. """ if src_color and dst_color: if not Image: raise Exception("Images manipulation require PIL") file = StringValue(image).value path ...
python
def _image_url(image, dst_color=None, src_color=None): """ Generates a path to an asset found relative to the project's images directory. """ if src_color and dst_color: if not Image: raise Exception("Images manipulation require PIL") file = StringValue(image).value path ...
[ "def", "_image_url", "(", "image", ",", "dst_color", "=", "None", ",", "src_color", "=", "None", ")", ":", "if", "src_color", "and", "dst_color", ":", "if", "not", "Image", ":", "raise", "Exception", "(", "\"Images manipulation require PIL\"", ")", "file", "...
Generates a path to an asset found relative to the project's images directory.
[ "Generates", "a", "path", "to", "an", "asset", "found", "relative", "to", "the", "project", "s", "images", "directory", "." ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3003-L3064
train
Generates a path to an image found relative to the project s images directory.
klen/zeta-library
zetalibrary/scss/__init__.py
_image_width
def _image_width(image): """ Returns the width of the image found at the path supplied by `image` relative to your project's images directory. """ if not Image: raise Exception("Images manipulation require PIL") file = StringValue(image).value path = None try: width = spr...
python
def _image_width(image): """ Returns the width of the image found at the path supplied by `image` relative to your project's images directory. """ if not Image: raise Exception("Images manipulation require PIL") file = StringValue(image).value path = None try: width = spr...
[ "def", "_image_width", "(", "image", ")", ":", "if", "not", "Image", ":", "raise", "Exception", "(", "\"Images manipulation require PIL\"", ")", "file", "=", "StringValue", "(", "image", ")", ".", "value", "path", "=", "None", "try", ":", "width", "=", "sp...
Returns the width of the image found at the path supplied by `image` relative to your project's images directory.
[ "Returns", "the", "width", "of", "the", "image", "found", "at", "the", "path", "supplied", "by", "image", "relative", "to", "your", "project", "s", "images", "directory", "." ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3067-L3095
train
Returns the width of the image found at the path supplied by image.
klen/zeta-library
zetalibrary/scss/__init__.py
_blank
def _blank(*objs): """Returns true when the object is false, an empty string, or an empty list""" for o in objs: if bool(o): return BooleanValue(False) return BooleanValue(True)
python
def _blank(*objs): """Returns true when the object is false, an empty string, or an empty list""" for o in objs: if bool(o): return BooleanValue(False) return BooleanValue(True)
[ "def", "_blank", "(", "*", "objs", ")", ":", "for", "o", "in", "objs", ":", "if", "bool", "(", "o", ")", ":", "return", "BooleanValue", "(", "False", ")", "return", "BooleanValue", "(", "True", ")" ]
Returns true when the object is false, an empty string, or an empty list
[ "Returns", "true", "when", "the", "object", "is", "false", "an", "empty", "string", "or", "an", "empty", "list" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3197-L3202
train
Returns true when the object is false an empty string or an empty list
klen/zeta-library
zetalibrary/scss/__init__.py
_compact
def _compact(*args): """Returns a new list after removing any non-true values""" ret = {} if len(args) == 1: args = args[0] if isinstance(args, ListValue): args = args.value if isinstance(args, dict): for i, item in args.items(): if bool(item):...
python
def _compact(*args): """Returns a new list after removing any non-true values""" ret = {} if len(args) == 1: args = args[0] if isinstance(args, ListValue): args = args.value if isinstance(args, dict): for i, item in args.items(): if bool(item):...
[ "def", "_compact", "(", "*", "args", ")", ":", "ret", "=", "{", "}", "if", "len", "(", "args", ")", "==", "1", ":", "args", "=", "args", "[", "0", "]", "if", "isinstance", "(", "args", ",", "ListValue", ")", ":", "args", "=", "args", ".", "va...
Returns a new list after removing any non-true values
[ "Returns", "a", "new", "list", "after", "removing", "any", "non", "-", "true", "values" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3205-L3222
train
Returns a new list after removing any non - true values
klen/zeta-library
zetalibrary/scss/__init__.py
_nth
def _nth(lst, n=1): """ Return the Nth item in the string """ n = StringValue(n).value lst = ListValue(lst).value try: n = int(float(n)) - 1 n = n % len(lst) except: if n.lower() == 'first': n = 0 elif n.lower() == 'last': n = -1 tr...
python
def _nth(lst, n=1): """ Return the Nth item in the string """ n = StringValue(n).value lst = ListValue(lst).value try: n = int(float(n)) - 1 n = n % len(lst) except: if n.lower() == 'first': n = 0 elif n.lower() == 'last': n = -1 tr...
[ "def", "_nth", "(", "lst", ",", "n", "=", "1", ")", ":", "n", "=", "StringValue", "(", "n", ")", ".", "value", "lst", "=", "ListValue", "(", "lst", ")", ".", "value", "try", ":", "n", "=", "int", "(", "float", "(", "n", ")", ")", "-", "1", ...
Return the Nth item in the string
[ "Return", "the", "Nth", "item", "in", "the", "string" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3246-L3268
train
Return the Nth item in the string
klen/zeta-library
zetalibrary/scss/__init__.py
Scss.locate_blocks
def locate_blocks(self, codestr): """ Returns all code blocks between `{` and `}` and a proper key that can be multilined as long as it's joined by `,` or enclosed in `(` and `)`. Returns the "lose" code that's not part of the block as a third item. """ def _strip...
python
def locate_blocks(self, codestr): """ Returns all code blocks between `{` and `}` and a proper key that can be multilined as long as it's joined by `,` or enclosed in `(` and `)`. Returns the "lose" code that's not part of the block as a third item. """ def _strip...
[ "def", "locate_blocks", "(", "self", ",", "codestr", ")", ":", "def", "_strip_selprop", "(", "selprop", ",", "lineno", ")", ":", "_lineno", ",", "_sep", ",", "selprop", "=", "selprop", ".", "partition", "(", "SEPARATOR", ")", "if", "_sep", "==", "SEPARAT...
Returns all code blocks between `{` and `}` and a proper key that can be multilined as long as it's joined by `,` or enclosed in `(` and `)`. Returns the "lose" code that's not part of the block as a third item.
[ "Returns", "all", "code", "blocks", "between", "{", "and", "}", "and", "a", "proper", "key", "that", "can", "be", "multilined", "as", "long", "as", "it", "s", "joined", "by", "or", "enclosed", "in", "(", "and", ")", ".", "Returns", "the", "lose", "co...
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L566-L682
train
Locate all code blocks between a proper keycoat and a proper keycoat.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss.normalize_selectors
def normalize_selectors(self, _selectors, extra_selectors=None, extra_parents=None): """ Normalizes or extends selectors in a string. An optional extra parameter that can be a list of extra selectors to be added to the final normalized selectors string. """ # Fixe tabs an...
python
def normalize_selectors(self, _selectors, extra_selectors=None, extra_parents=None): """ Normalizes or extends selectors in a string. An optional extra parameter that can be a list of extra selectors to be added to the final normalized selectors string. """ # Fixe tabs an...
[ "def", "normalize_selectors", "(", "self", ",", "_selectors", ",", "extra_selectors", "=", "None", ",", "extra_parents", "=", "None", ")", ":", "# Fixe tabs and spaces in selectors", "_selectors", "=", "_spaces_re", ".", "sub", "(", "' '", ",", "_selectors", ")", ...
Normalizes or extends selectors in a string. An optional extra parameter that can be a list of extra selectors to be added to the final normalized selectors string.
[ "Normalizes", "or", "extends", "selectors", "in", "a", "string", ".", "An", "optional", "extra", "parameter", "that", "can", "be", "a", "list", "of", "extra", "selectors", "to", "be", "added", "to", "the", "final", "normalized", "selectors", "string", "." ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L684-L722
train
Normalizes or extends selectors in a string.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_functions
def _do_functions(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @mixin and @function """ if name: funct, params, _ = name.partition('(') funct = funct.strip() params = split_p...
python
def _do_functions(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @mixin and @function """ if name: funct, params, _ = name.partition('(') funct = funct.strip() params = split_p...
[ "def", "_do_functions", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "if", "name", ":", "funct", ...
Implements @mixin and @function
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1019-L1072
train
Handles functions in the hierarchy.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_include
def _do_include(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @include, for @mixins """ funct, params, _ = name.partition('(') funct = funct.strip() funct = self.do_glob_math( funct, ...
python
def _do_include(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @include, for @mixins """ funct, params, _ = name.partition('(') funct = funct.strip() funct = self.do_glob_math( funct, ...
[ "def", "_do_include", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "funct", ",", "params", ",", ...
Implements @include, for @mixins
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1075-L1130
train
Implements include for include rule
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_import
def _do_import(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @import Load and import mixins and functions and rules """ i_codestr = None if '..' not in name and '://' not in name and 'url(' not i...
python
def _do_import(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @import Load and import mixins and functions and rules """ i_codestr = None if '..' not in name and '://' not in name and 'url(' not i...
[ "def", "_do_import", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "i_codestr", "=", "None", "if", ...
Implements @import Load and import mixins and functions and rules
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1133-L1202
train
Internal function that handles the import of the current rule.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_magic_import
def _do_magic_import(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @import for sprite-maps Imports magic sprite map directories """ if callable(STATIC_ROOT): files = sorted(STATIC_ROOT(name))...
python
def _do_magic_import(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @import for sprite-maps Imports magic sprite map directories """ if callable(STATIC_ROOT): files = sorted(STATIC_ROOT(name))...
[ "def", "_do_magic_import", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "if", "callable", "(", "ST...
Implements @import for sprite-maps Imports magic sprite map directories
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1205-L1282
train
Implements @import for sprite - maps directories
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_if
def _do_if(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @if and @else if """ if code != '@if': if '@if' not in rule[OPTIONS]: log.error("@else with no @if (%s)", rule[INDEX][rule[LIN...
python
def _do_if(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @if and @else if """ if code != '@if': if '@if' not in rule[OPTIONS]: log.error("@else with no @if (%s)", rule[INDEX][rule[LIN...
[ "def", "_do_if", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "if", "code", "!=", "'@if'", ":", ...
Implements @if and @else if
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1285-L1304
train
Handles the if - rule.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_else
def _do_else(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @else """ if '@if' not in rule[OPTIONS]: log.error("@else with no @if (%s", rule[INDEX][rule[LINENO]]) val = rule[OPTIONS].pop('@if'...
python
def _do_else(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @else """ if '@if' not in rule[OPTIONS]: log.error("@else with no @if (%s", rule[INDEX][rule[LINENO]]) val = rule[OPTIONS].pop('@if'...
[ "def", "_do_else", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "if", "'@if'", "not", "in", "rul...
Implements @else
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1307-L1317
train
Handles the else rule.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_for
def _do_for(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @for """ var, _, name = name.partition('from') frm, _, through = name.partition('through') if not through: frm, _, through = ...
python
def _do_for(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @for """ var, _, name = name.partition('from') frm, _, through = name.partition('through') if not through: frm, _, through = ...
[ "def", "_do_for", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "var", ",", "_", ",", "name", "...
Implements @for
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1320-L1349
train
Implements @for
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._do_each
def _do_each(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @each """ var, _, name = name.partition('in') name = self.calculate(name, rule[CONTEXT], rule[OPTIONS], rule) if name: name ...
python
def _do_each(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @each """ var, _, name = name.partition('in') name = self.calculate(name, rule[CONTEXT], rule[OPTIONS], rule) if name: name ...
[ "def", "_do_each", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "var", ",", "_", ",", "name", ...
Implements @each
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1352-L1371
train
Implements @each
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._get_variables
def _get_variables(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): """ Implements @variables and @vars """ _rule = list(rule) _rule[CODESTR] = c_codestr _rule[PROPERTIES] = rule[CONTEXT] self.manage_children( ...
python
def _get_variables(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): """ Implements @variables and @vars """ _rule = list(rule) _rule[CODESTR] = c_codestr _rule[PROPERTIES] = rule[CONTEXT] self.manage_children( ...
[ "def", "_get_variables", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ")", ":", "_rule", "=", "list", "(", "rule", ")", "_rule", "[", ...
Implements @variables and @vars
[ "Implements" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1396-L1404
train
Get variables from a rule.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._get_properties
def _get_properties(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): """ Implements properties and variables extraction """ prop, value = (_prop_split_re.split(c_property, 1) + [None])[:2] try: is_var = (c_property[len(pr...
python
def _get_properties(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): """ Implements properties and variables extraction """ prop, value = (_prop_split_re.split(c_property, 1) + [None])[:2] try: is_var = (c_property[len(pr...
[ "def", "_get_properties", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ")", ":", "prop", ",", "value", "=", "(", "_prop_split_re", ".", ...
Implements properties and variables extraction
[ "Implements", "properties", "and", "variables", "extraction" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1407-L1450
train
Implements properties and variables extraction
klen/zeta-library
zetalibrary/scss/__init__.py
Scss._nest_rules
def _nest_rules(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): """ Implements Nested CSS rules """ if c_property == self.construct and rule[MEDIA] == media: rule[CODESTR] = c_codestr self.manage_children( ...
python
def _nest_rules(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): """ Implements Nested CSS rules """ if c_property == self.construct and rule[MEDIA] == media: rule[CODESTR] = c_codestr self.manage_children( ...
[ "def", "_nest_rules", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ")", ":", "if", "c_property", "==", "self", ".", "construct", "and", ...
Implements Nested CSS rules
[ "Implements", "Nested", "CSS", "rules" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1453-L1491
train
Implements Nested CSS rules
klen/zeta-library
zetalibrary/scss/__init__.py
Scss.link_with_parents
def link_with_parents(self, parent, c_selectors, c_rules): """ Link with a parent for the current child rule. If parents found, returns a list of parent rules to the child """ parent_found = None for p_selectors, p_rules in self.parts.items(): _p_selectors, _,...
python
def link_with_parents(self, parent, c_selectors, c_rules): """ Link with a parent for the current child rule. If parents found, returns a list of parent rules to the child """ parent_found = None for p_selectors, p_rules in self.parts.items(): _p_selectors, _,...
[ "def", "link_with_parents", "(", "self", ",", "parent", ",", "c_selectors", ",", "c_rules", ")", ":", "parent_found", "=", "None", "for", "p_selectors", ",", "p_rules", "in", "self", ".", "parts", ".", "items", "(", ")", ":", "_p_selectors", ",", "_", ",...
Link with a parent for the current child rule. If parents found, returns a list of parent rules to the child
[ "Link", "with", "a", "parent", "for", "the", "current", "child", "rule", ".", "If", "parents", "found", "returns", "a", "list", "of", "parent", "rules", "to", "the", "child" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1494-L1567
train
Link with a parent for the current child rule.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss.parse_extends
def parse_extends(self): """ For each part, create the inheritance parts from the ' extends ' """ # To be able to manage multiple extends, you need to # destroy the actual node and create many nodes that have # mono extend. The first one gets all the css rules for...
python
def parse_extends(self): """ For each part, create the inheritance parts from the ' extends ' """ # To be able to manage multiple extends, you need to # destroy the actual node and create many nodes that have # mono extend. The first one gets all the css rules for...
[ "def", "parse_extends", "(", "self", ")", ":", "# To be able to manage multiple extends, you need to", "# destroy the actual node and create many nodes that have", "# mono extend. The first one gets all the css rules", "for", "_selectors", ",", "rules", "in", "self", ".", "parts", ...
For each part, create the inheritance parts from the ' extends '
[ "For", "each", "part", "create", "the", "inheritance", "parts", "from", "the", "extends" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1570-L1624
train
Parse the extends part of the css file.
klen/zeta-library
zetalibrary/scss/__init__.py
Scss.create_css
def create_css(self, fileid=None): """ Generate the final CSS string """ if fileid: rules = self._rules.get(fileid) or [] else: rules = self.rules compress = self._scss_opts.get('compress', True) if compress: sc, sp, tb, nl = F...
python
def create_css(self, fileid=None): """ Generate the final CSS string """ if fileid: rules = self._rules.get(fileid) or [] else: rules = self.rules compress = self._scss_opts.get('compress', True) if compress: sc, sp, tb, nl = F...
[ "def", "create_css", "(", "self", ",", "fileid", "=", "None", ")", ":", "if", "fileid", ":", "rules", "=", "self", ".", "_rules", ".", "get", "(", "fileid", ")", "or", "[", "]", "else", ":", "rules", "=", "self", ".", "rules", "compress", "=", "s...
Generate the final CSS string
[ "Generate", "the", "final", "CSS", "string" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1658-L1674
train
Generate the final CSS string
klen/zeta-library
zetalibrary/scss/__init__.py
Value._operatorOperands
def _operatorOperands(tokenlist): "generator to extract operators and operands in pairs" it = iter(tokenlist) while 1: try: yield (it.next(), it.next()) except StopIteration: break
python
def _operatorOperands(tokenlist): "generator to extract operators and operands in pairs" it = iter(tokenlist) while 1: try: yield (it.next(), it.next()) except StopIteration: break
[ "def", "_operatorOperands", "(", "tokenlist", ")", ":", "it", "=", "iter", "(", "tokenlist", ")", "while", "1", ":", "try", ":", "yield", "(", "it", ".", "next", "(", ")", ",", "it", ".", "next", "(", ")", ")", "except", "StopIteration", ":", "brea...
generator to extract operators and operands in pairs
[ "generator", "to", "extract", "operators", "and", "operands", "in", "pairs" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3582-L3589
train
generator to extract operators and operands in pairs
klen/zeta-library
zetalibrary/scss/__init__.py
Value._wrap
def _wrap(fn): """ Wrapper function to allow calling any function using Value objects as parameters. """ def _func(*args): merged = None _args = [] for arg in args: if merged.__class__ != arg.__class__: if me...
python
def _wrap(fn): """ Wrapper function to allow calling any function using Value objects as parameters. """ def _func(*args): merged = None _args = [] for arg in args: if merged.__class__ != arg.__class__: if me...
[ "def", "_wrap", "(", "fn", ")", ":", "def", "_func", "(", "*", "args", ")", ":", "merged", "=", "None", "_args", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "merged", ".", "__class__", "!=", "arg", ".", "__class__", ":", "if", "merged",...
Wrapper function to allow calling any function using Value objects as parameters.
[ "Wrapper", "function", "to", "allow", "calling", "any", "function", "using", "Value", "objects", "as", "parameters", "." ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L3600-L3620
train
Wrap a function to allow calling any function with any arguments as parameters.
klen/zeta-library
zetalibrary/scss/__init__.py
Scanner.token
def token(self, i, restrict=None): """ Get the i'th token, and if i is one past the end, then scan for another token; restrict is a list of tokens that are allowed, or 0 for any token. """ tokens_len = len(self.tokens) if i == tokens_len: # We are at the end, ge ...
python
def token(self, i, restrict=None): """ Get the i'th token, and if i is one past the end, then scan for another token; restrict is a list of tokens that are allowed, or 0 for any token. """ tokens_len = len(self.tokens) if i == tokens_len: # We are at the end, ge ...
[ "def", "token", "(", "self", ",", "i", ",", "restrict", "=", "None", ")", ":", "tokens_len", "=", "len", "(", "self", ".", "tokens", ")", "if", "i", "==", "tokens_len", ":", "# We are at the end, ge the next...", "tokens_len", "+=", "self", ".", "scan", ...
Get the i'th token, and if i is one past the end, then scan for another token; restrict is a list of tokens that are allowed, or 0 for any token.
[ "Get", "the", "i", "th", "token", "and", "if", "i", "is", "one", "past", "the", "end", "then", "scan", "for", "another", "token", ";", "restrict", "is", "a", "list", "of", "tokens", "that", "are", "allowed", "or", "0", "for", "any", "token", "." ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L4563-L4577
train
Get the i'th token and return it.
klen/zeta-library
zetalibrary/scss/__init__.py
Scanner.scan
def scan(self, restrict): """ Should scan another token and add it to the list, self.tokens, and add the restriction to self.restrictions """ # Keep looking for a token, ignoring any in self.ignore while True: # Search the patterns for a match, with earlier ...
python
def scan(self, restrict): """ Should scan another token and add it to the list, self.tokens, and add the restriction to self.restrictions """ # Keep looking for a token, ignoring any in self.ignore while True: # Search the patterns for a match, with earlier ...
[ "def", "scan", "(", "self", ",", "restrict", ")", ":", "# Keep looking for a token, ignoring any in self.ignore", "while", "True", ":", "# Search the patterns for a match, with earlier", "# tokens in the list having preference", "best_pat", "=", "None", "best_pat_len", "=", "0"...
Should scan another token and add it to the list, self.tokens, and add the restriction to self.restrictions
[ "Should", "scan", "another", "token", "and", "add", "it", "to", "the", "list", "self", ".", "tokens", "and", "add", "the", "restriction", "to", "self", ".", "restrictions" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L4587-L4637
train
Scan another token and add it to the list self. tokens self. restrictions and self. restrictions Returns 1 if the token was found and 0 if not found
klen/zeta-library
zetalibrary/scss/__init__.py
Parser._scan
def _scan(self, type): """ Returns the matched text, and moves to the next token """ tok = self._scanner.token(self._pos, set([type])) if tok[2] != type: raise SyntaxError(tok[0], "Trying to find " + type) self._pos += 1 return tok[3]
python
def _scan(self, type): """ Returns the matched text, and moves to the next token """ tok = self._scanner.token(self._pos, set([type])) if tok[2] != type: raise SyntaxError(tok[0], "Trying to find " + type) self._pos += 1 return tok[3]
[ "def", "_scan", "(", "self", ",", "type", ")", ":", "tok", "=", "self", ".", "_scanner", ".", "token", "(", "self", ".", "_pos", ",", "set", "(", "[", "type", "]", ")", ")", "if", "tok", "[", "2", "]", "!=", "type", ":", "raise", "SyntaxError",...
Returns the matched text, and moves to the next token
[ "Returns", "the", "matched", "text", "and", "moves", "to", "the", "next", "token" ]
b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L4657-L4665
train
Scan for a specific type of entry.
davidfokkema/artist
demo/demo_event_display.py
main
def main(): """Event display for an event of station 503 Date Time Timestamp Nanoseconds 2012-03-29 10:51:36 1333018296 870008589 Number of MIPs 35.0 51.9 35.8 78.9 Arrival time 15.0 17.5 20.0 27.5 """ # Detector positions in ENU relative to the station GPS...
python
def main(): """Event display for an event of station 503 Date Time Timestamp Nanoseconds 2012-03-29 10:51:36 1333018296 870008589 Number of MIPs 35.0 51.9 35.8 78.9 Arrival time 15.0 17.5 20.0 27.5 """ # Detector positions in ENU relative to the station GPS...
[ "def", "main", "(", ")", ":", "# Detector positions in ENU relative to the station GPS", "x", "=", "[", "-", "6.34", ",", "-", "2.23", ",", "-", "3.6", ",", "3.46", "]", "y", "=", "[", "6.34", ",", "2.23", ",", "-", "3.6", ",", "3.46", "]", "# Scale mi...
Event display for an event of station 503 Date Time Timestamp Nanoseconds 2012-03-29 10:51:36 1333018296 870008589 Number of MIPs 35.0 51.9 35.8 78.9 Arrival time 15.0 17.5 20.0 27.5
[ "Event", "display", "for", "an", "event", "of", "station", "503" ]
26ae7987522622710f2910980770c50012fda47d
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/demo/demo_event_display.py#L4-L83
train
This function is used to display an event of station 503
alexhayes/django-cereal
django_cereal/pickle.py
_model_unpickle
def _model_unpickle(cls, data): """Unpickle a model by retrieving it from the database.""" auto_field_value = data['pk'] try: obj = cls.objects.get(pk=auto_field_value) except Exception as e: if isinstance(e, OperationalError): # Attempt reconnect, we've probably hit; ...
python
def _model_unpickle(cls, data): """Unpickle a model by retrieving it from the database.""" auto_field_value = data['pk'] try: obj = cls.objects.get(pk=auto_field_value) except Exception as e: if isinstance(e, OperationalError): # Attempt reconnect, we've probably hit; ...
[ "def", "_model_unpickle", "(", "cls", ",", "data", ")", ":", "auto_field_value", "=", "data", "[", "'pk'", "]", "try", ":", "obj", "=", "cls", ".", "objects", ".", "get", "(", "pk", "=", "auto_field_value", ")", "except", "Exception", "as", "e", ":", ...
Unpickle a model by retrieving it from the database.
[ "Unpickle", "a", "model", "by", "retrieving", "it", "from", "the", "database", "." ]
ab5b7f0283c6604c4df658542f7381262e600e5d
https://github.com/alexhayes/django-cereal/blob/ab5b7f0283c6604c4df658542f7381262e600e5d/django_cereal/pickle.py#L27-L42
train
Unpickle a model by retrieving it from the database.
alexhayes/django-cereal
django_cereal/pickle.py
patched_model
def patched_model(): """Context Manager that safely patches django.db.Model.__reduce__().""" patched = ('__reduce__', '__getstate__', '__setstate__') originals = {} for patch in patched: try: originals[patch] = getattr(models.Model, patch) except: pass try: ...
python
def patched_model(): """Context Manager that safely patches django.db.Model.__reduce__().""" patched = ('__reduce__', '__getstate__', '__setstate__') originals = {} for patch in patched: try: originals[patch] = getattr(models.Model, patch) except: pass try: ...
[ "def", "patched_model", "(", ")", ":", "patched", "=", "(", "'__reduce__'", ",", "'__getstate__'", ",", "'__setstate__'", ")", "originals", "=", "{", "}", "for", "patch", "in", "patched", ":", "try", ":", "originals", "[", "patch", "]", "=", "getattr", "...
Context Manager that safely patches django.db.Model.__reduce__().
[ "Context", "Manager", "that", "safely", "patches", "django", ".", "db", ".", "Model", ".", "__reduce__", "()", "." ]
ab5b7f0283c6604c4df658542f7381262e600e5d
https://github.com/alexhayes/django-cereal/blob/ab5b7f0283c6604c4df658542f7381262e600e5d/django_cereal/pickle.py#L53-L87
train
Context Manager that safely patches django. db. Model.
alexhayes/django-cereal
django_cereal/pickle.py
task
def task(func, *args, **kwargs): """ A task decorator that uses the django-cereal pickler as the default serializer. """ # Note we must import here to avoid recursion issue with kombu entry points registration from celery import shared_task if 'serializer' not in kwargs: kwargs['serial...
python
def task(func, *args, **kwargs): """ A task decorator that uses the django-cereal pickler as the default serializer. """ # Note we must import here to avoid recursion issue with kombu entry points registration from celery import shared_task if 'serializer' not in kwargs: kwargs['serial...
[ "def", "task", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Note we must import here to avoid recursion issue with kombu entry points registration", "from", "celery", "import", "shared_task", "if", "'serializer'", "not", "in", "kwargs", ":", "k...
A task decorator that uses the django-cereal pickler as the default serializer.
[ "A", "task", "decorator", "that", "uses", "the", "django", "-", "cereal", "pickler", "as", "the", "default", "serializer", "." ]
ab5b7f0283c6604c4df658542f7381262e600e5d
https://github.com/alexhayes/django-cereal/blob/ab5b7f0283c6604c4df658542f7381262e600e5d/django_cereal/pickle.py#L106-L116
train
A task decorator that uses the django - cereal pickler as the default serializer.
PythonOptimizers/cygenja
cygenja/helpers/file_helpers.py
find_files
def find_files(directory, pattern, recursively=True): """ Yield a list of files with their base directories, recursively or not. Returns: A list of (base_directory, filename) Args: directory: base directory to start the search. pattern: fnmatch pattern for filenames. co...
python
def find_files(directory, pattern, recursively=True): """ Yield a list of files with their base directories, recursively or not. Returns: A list of (base_directory, filename) Args: directory: base directory to start the search. pattern: fnmatch pattern for filenames. co...
[ "def", "find_files", "(", "directory", ",", "pattern", ",", "recursively", "=", "True", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "directory", ")", ":", "for", "basename", "in", "files", ":", "if", "fnmatch", "...
Yield a list of files with their base directories, recursively or not. Returns: A list of (base_directory, filename) Args: directory: base directory to start the search. pattern: fnmatch pattern for filenames. complete_filename: return complete filename or not? recursiv...
[ "Yield", "a", "list", "of", "files", "with", "their", "base", "directories", "recursively", "or", "not", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/helpers/file_helpers.py#L6-L25
train
Find files in a directory and return their base directories recursively or not.
stevelittlefish/easyforms
easyforms/form.py
Field.validate
def validate(self): """Run the form value through the validators, and update the error field if needed""" if self.error: return False for v in self.validators: self.error = v(self.value) if self.error: return False return True
python
def validate(self): """Run the form value through the validators, and update the error field if needed""" if self.error: return False for v in self.validators: self.error = v(self.value) if self.error: return False return True
[ "def", "validate", "(", "self", ")", ":", "if", "self", ".", "error", ":", "return", "False", "for", "v", "in", "self", ".", "validators", ":", "self", ".", "error", "=", "v", "(", "self", ".", "value", ")", "if", "self", ".", "error", ":", "retu...
Run the form value through the validators, and update the error field if needed
[ "Run", "the", "form", "value", "through", "the", "validators", "and", "update", "the", "error", "field", "if", "needed" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L203-L213
train
Validate the form value.
stevelittlefish/easyforms
easyforms/form.py
Field.extract_value
def extract_value(self, data): """ Extract the data from the request :param data: A mult-dict with either the post or get query """ if self.name not in data and not self.allow_missing: raise exceptions.FieldNotFound('Field {} is missing from request'.format(self.name)...
python
def extract_value(self, data): """ Extract the data from the request :param data: A mult-dict with either the post or get query """ if self.name not in data and not self.allow_missing: raise exceptions.FieldNotFound('Field {} is missing from request'.format(self.name)...
[ "def", "extract_value", "(", "self", ",", "data", ")", ":", "if", "self", ".", "name", "not", "in", "data", "and", "not", "self", ".", "allow_missing", ":", "raise", "exceptions", ".", "FieldNotFound", "(", "'Field {} is missing from request'", ".", "format", ...
Extract the data from the request :param data: A mult-dict with either the post or get query
[ "Extract", "the", "data", "from", "the", "request", ":", "param", "data", ":", "A", "mult", "-", "dict", "with", "either", "the", "post", "or", "get", "query" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L215-L241
train
Extracts the value of the attribute from the request.
stevelittlefish/easyforms
easyforms/form.py
Field.get_input_column_attributes
def get_input_column_attributes(self, extra_classes=None): """ :param extra_classes: String with space separated list of classes or None """ all_classes = [] css_class = self.input_column_class if css_class: all_classes.append(css_class) if extra_class...
python
def get_input_column_attributes(self, extra_classes=None): """ :param extra_classes: String with space separated list of classes or None """ all_classes = [] css_class = self.input_column_class if css_class: all_classes.append(css_class) if extra_class...
[ "def", "get_input_column_attributes", "(", "self", ",", "extra_classes", "=", "None", ")", ":", "all_classes", "=", "[", "]", "css_class", "=", "self", ".", "input_column_class", "if", "css_class", ":", "all_classes", ".", "append", "(", "css_class", ")", "if"...
:param extra_classes: String with space separated list of classes or None
[ ":", "param", "extra_classes", ":", "String", "with", "space", "separated", "list", "of", "classes", "or", "None" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L330-L350
train
Returns the input column attributes.
stevelittlefish/easyforms
easyforms/form.py
Field.form_group_classes
def form_group_classes(self): """ Full list of classes for the class attribute of the form group. Returned as a string with spaces separating each class, ready for insertion into the class attribute. This will generally look like the following: 'form-group has-error custom-clas...
python
def form_group_classes(self): """ Full list of classes for the class attribute of the form group. Returned as a string with spaces separating each class, ready for insertion into the class attribute. This will generally look like the following: 'form-group has-error custom-clas...
[ "def", "form_group_classes", "(", "self", ")", ":", "classes", "=", "[", "'form-group'", "]", "if", "self", ".", "style", "==", "styles", ".", "BOOTSTRAP_4", "and", "self", ".", "form_type", "==", "formtype", ".", "HORIZONTAL", ":", "classes", ".", "append...
Full list of classes for the class attribute of the form group. Returned as a string with spaces separating each class, ready for insertion into the class attribute. This will generally look like the following: 'form-group has-error custom-class'
[ "Full", "list", "of", "classes", "for", "the", "class", "attribute", "of", "the", "form", "group", ".", "Returned", "as", "a", "string", "with", "spaces", "separating", "each", "class", "ready", "for", "insertion", "into", "the", "class", "attribute", "." ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L367-L384
train
Returns the full list of classes for the form group.
stevelittlefish/easyforms
easyforms/form.py
Field.input_classes
def input_classes(self): """ Full list of classes for the class attribute of the input, returned as a string with spaces separating each class. """ classes = [self.base_input_css_class] if self.css_class: classes.append(self.css_class) if self.style =...
python
def input_classes(self): """ Full list of classes for the class attribute of the input, returned as a string with spaces separating each class. """ classes = [self.base_input_css_class] if self.css_class: classes.append(self.css_class) if self.style =...
[ "def", "input_classes", "(", "self", ")", ":", "classes", "=", "[", "self", ".", "base_input_css_class", "]", "if", "self", ".", "css_class", ":", "classes", ".", "append", "(", "self", ".", "css_class", ")", "if", "self", ".", "style", "==", "styles", ...
Full list of classes for the class attribute of the input, returned as a string with spaces separating each class.
[ "Full", "list", "of", "classes", "for", "the", "class", "attribute", "of", "the", "input", "returned", "as", "a", "string", "with", "spaces", "separating", "each", "class", "." ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L387-L399
train
Returns the full list of classes for the class attribute of the input.
stevelittlefish/easyforms
easyforms/form.py
Form.render
def render(self): """Render the form and all sections to HTML""" return Markup(env.get_template('form.html').render(form=self, render_open_tag=True, render_close_tag=True, ...
python
def render(self): """Render the form and all sections to HTML""" return Markup(env.get_template('form.html').render(form=self, render_open_tag=True, render_close_tag=True, ...
[ "def", "render", "(", "self", ")", ":", "return", "Markup", "(", "env", ".", "get_template", "(", "'form.html'", ")", ".", "render", "(", "form", "=", "self", ",", "render_open_tag", "=", "True", ",", "render_close_tag", "=", "True", ",", "render_before", ...
Render the form and all sections to HTML
[ "Render", "the", "form", "and", "all", "sections", "to", "HTML" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L591-L599
train
Render the form and all sections to HTML
stevelittlefish/easyforms
easyforms/form.py
Form.render_before_sections
def render_before_sections(self): """Render the form up to the first section. This will open the form tag but not close it.""" return Markup(env.get_template('form.html').render(form=self, render_open_tag=True, ...
python
def render_before_sections(self): """Render the form up to the first section. This will open the form tag but not close it.""" return Markup(env.get_template('form.html').render(form=self, render_open_tag=True, ...
[ "def", "render_before_sections", "(", "self", ")", ":", "return", "Markup", "(", "env", ".", "get_template", "(", "'form.html'", ")", ".", "render", "(", "form", "=", "self", ",", "render_open_tag", "=", "True", ",", "render_close_tag", "=", "False", ",", ...
Render the form up to the first section. This will open the form tag but not close it.
[ "Render", "the", "form", "up", "to", "the", "first", "section", ".", "This", "will", "open", "the", "form", "tag", "but", "not", "close", "it", "." ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L601-L609
train
Render the form up to the first section.
stevelittlefish/easyforms
easyforms/form.py
Form.read_form_data
def read_form_data(self): """Attempt to read the form data from the request""" if self.processed_data: raise exceptions.AlreadyProcessed('The data has already been processed for this form') if self.readonly: return if request.method == self.method: ...
python
def read_form_data(self): """Attempt to read the form data from the request""" if self.processed_data: raise exceptions.AlreadyProcessed('The data has already been processed for this form') if self.readonly: return if request.method == self.method: ...
[ "def", "read_form_data", "(", "self", ")", ":", "if", "self", ".", "processed_data", ":", "raise", "exceptions", ".", "AlreadyProcessed", "(", "'The data has already been processed for this form'", ")", "if", "self", ".", "readonly", ":", "return", "if", "request", ...
Attempt to read the form data from the request
[ "Attempt", "to", "read", "the", "form", "data", "from", "the", "request" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L679-L707
train
Attempt to read the form data from the request
stevelittlefish/easyforms
easyforms/form.py
Form.get_if_present
def get_if_present(self, name, default=None): """ Returns the value for a field, but if the field doesn't exist will return default instead """ if not self.processed_data: raise exceptions.FormNotProcessed('The form data has not been processed yet') if name in self.f...
python
def get_if_present(self, name, default=None): """ Returns the value for a field, but if the field doesn't exist will return default instead """ if not self.processed_data: raise exceptions.FormNotProcessed('The form data has not been processed yet') if name in self.f...
[ "def", "get_if_present", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "not", "self", ".", "processed_data", ":", "raise", "exceptions", ".", "FormNotProcessed", "(", "'The form data has not been processed yet'", ")", "if", "name", "in",...
Returns the value for a field, but if the field doesn't exist will return default instead
[ "Returns", "the", "value", "for", "a", "field", "but", "if", "the", "field", "doesn", "t", "exist", "will", "return", "default", "instead" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L724-L734
train
Returns the value for a field if it exists otherwise returns default
stevelittlefish/easyforms
easyforms/form.py
Form.disable_validation
def disable_validation(self, field_name): """Disable the validation rules for a field""" field = self.field_dict.get(field_name) if not field: raise exceptions.FieldNotFound('Field not found: \'%s\' when trying to disable validation' % field_name) field.validators =...
python
def disable_validation(self, field_name): """Disable the validation rules for a field""" field = self.field_dict.get(field_name) if not field: raise exceptions.FieldNotFound('Field not found: \'%s\' when trying to disable validation' % field_name) field.validators =...
[ "def", "disable_validation", "(", "self", ",", "field_name", ")", ":", "field", "=", "self", ".", "field_dict", ".", "get", "(", "field_name", ")", "if", "not", "field", ":", "raise", "exceptions", ".", "FieldNotFound", "(", "'Field not found: \\'%s\\' when tryi...
Disable the validation rules for a field
[ "Disable", "the", "validation", "rules", "for", "a", "field" ]
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L763-L770
train
Disable the validation rules for a field
stevelittlefish/easyforms
easyforms/form.py
Form.create_single_button_clone
def create_single_button_clone(self, submit_text='Submit', submit_css_class='btn-primary', read_form_data=True, form_type=None): """ This will create a copy of this form, with all of inputs replaced with hidden inputs, and with a single submit button. This all...
python
def create_single_button_clone(self, submit_text='Submit', submit_css_class='btn-primary', read_form_data=True, form_type=None): """ This will create a copy of this form, with all of inputs replaced with hidden inputs, and with a single submit button. This all...
[ "def", "create_single_button_clone", "(", "self", ",", "submit_text", "=", "'Submit'", ",", "submit_css_class", "=", "'btn-primary'", ",", "read_form_data", "=", "True", ",", "form_type", "=", "None", ")", ":", "from", ".", "basicfields", "import", "BooleanCheckbo...
This will create a copy of this form, with all of inputs replaced with hidden inputs, and with a single submit button. This allows you to easily create a "button" that will submit a post request which is identical to the current state of the form. You could then, if required, change some of the...
[ "This", "will", "create", "a", "copy", "of", "this", "form", "with", "all", "of", "inputs", "replaced", "with", "hidden", "inputs", "and", "with", "a", "single", "submit", "button", ".", "This", "allows", "you", "to", "easily", "create", "a", "button", "...
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L805-L838
train
This method creates a copy of this form with all of inputs replaced with hidden inputs and a single submit button.
stevelittlefish/easyforms
easyforms/form.py
Form.set_type
def set_type(self, form_type, css_class=None): """ Maybe you have a site where you're not allowed to change the python code, and for some reason you need to change the form_type in a template, not because you want to (because it seems like a bit of a hack) but maybe you don't rea...
python
def set_type(self, form_type, css_class=None): """ Maybe you have a site where you're not allowed to change the python code, and for some reason you need to change the form_type in a template, not because you want to (because it seems like a bit of a hack) but maybe you don't rea...
[ "def", "set_type", "(", "self", ",", "form_type", ",", "css_class", "=", "None", ")", ":", "self", ".", "form_type", "=", "form_type", "if", "css_class", "is", "None", ":", "self", ".", "css_class", "=", "self", ".", "get_default_css_class", "(", "form_typ...
Maybe you have a site where you're not allowed to change the python code, and for some reason you need to change the form_type in a template, not because you want to (because it seems like a bit of a hack) but maybe you don't really have a choice. Then this function was made for you. S...
[ "Maybe", "you", "have", "a", "site", "where", "you", "re", "not", "allowed", "to", "change", "the", "python", "code", "and", "for", "some", "reason", "you", "need", "to", "change", "the", "form_type", "in", "a", "template", "not", "because", "you", "want...
f5dd2635b045beec9af970b249909f8429cedc57
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L840-L861
train
This function is used to set the form type and css class for the current locale.
ckcollab/polished
polished/main.py
load_class
def load_class(full_class_string): """ dynamically load a class from a string http://thomassileo.com/blog/2012/12/21/dynamically-load-python-modules-or-classes/ """ class_parts = full_class_string.split(".") module_path = ".".join(class_parts[:-1]) class_name = class_parts[-1] module =...
python
def load_class(full_class_string): """ dynamically load a class from a string http://thomassileo.com/blog/2012/12/21/dynamically-load-python-modules-or-classes/ """ class_parts = full_class_string.split(".") module_path = ".".join(class_parts[:-1]) class_name = class_parts[-1] module =...
[ "def", "load_class", "(", "full_class_string", ")", ":", "class_parts", "=", "full_class_string", ".", "split", "(", "\".\"", ")", "module_path", "=", "\".\"", ".", "join", "(", "class_parts", "[", ":", "-", "1", "]", ")", "class_name", "=", "class_parts", ...
dynamically load a class from a string http://thomassileo.com/blog/2012/12/21/dynamically-load-python-modules-or-classes/
[ "dynamically", "load", "a", "class", "from", "a", "string" ]
5a00b2fbe569bc957d1647c0849fd344db29b644
https://github.com/ckcollab/polished/blob/5a00b2fbe569bc957d1647c0849fd344db29b644/polished/main.py#L6-L18
train
dynamically load a class from a string
ckcollab/polished
polished/decorators.py
polish
def polish(commit_indexes=None, urls=None): ''' Apply certain behaviors to commits or URLs that need polishing before they are ready for screenshots For example, if you have 10 commits in a row where static file links were broken, you could re-write the html in memory as it is interpreted. Keyword...
python
def polish(commit_indexes=None, urls=None): ''' Apply certain behaviors to commits or URLs that need polishing before they are ready for screenshots For example, if you have 10 commits in a row where static file links were broken, you could re-write the html in memory as it is interpreted. Keyword...
[ "def", "polish", "(", "commit_indexes", "=", "None", ",", "urls", "=", "None", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "commit_indexes", ":", "f", ".", "polish_commit_indexes", "=", "commit_indexes", "if", "urls", ":", "f", ".", "polish_u...
Apply certain behaviors to commits or URLs that need polishing before they are ready for screenshots For example, if you have 10 commits in a row where static file links were broken, you could re-write the html in memory as it is interpreted. Keyword arguments: commit_indexes -- A list of indexes to a...
[ "Apply", "certain", "behaviors", "to", "commits", "or", "URLs", "that", "need", "polishing", "before", "they", "are", "ready", "for", "screenshots" ]
5a00b2fbe569bc957d1647c0849fd344db29b644
https://github.com/ckcollab/polished/blob/5a00b2fbe569bc957d1647c0849fd344db29b644/polished/decorators.py#L5-L28
train
A decorator that makes a new object with the given arguments polishing the current state of the current object.
iLampard/x-utils
xutils/date_utils/convert.py
localize
def localize(date_time, time_zone): """Returns a datetime adjusted to a timezone: * If dateTime is a naive datetime (datetime with no timezone information), timezone information is added but date and time remains the same. * If dateTime is not a naive datetime, a datetime object with new tzinfo att...
python
def localize(date_time, time_zone): """Returns a datetime adjusted to a timezone: * If dateTime is a naive datetime (datetime with no timezone information), timezone information is added but date and time remains the same. * If dateTime is not a naive datetime, a datetime object with new tzinfo att...
[ "def", "localize", "(", "date_time", ",", "time_zone", ")", ":", "if", "datetime_is_naive", "(", "date_time", ")", ":", "ret", "=", "time_zone", ".", "localize", "(", "date_time", ")", "else", ":", "ret", "=", "date_time", ".", "astimezone", "(", "time_zon...
Returns a datetime adjusted to a timezone: * If dateTime is a naive datetime (datetime with no timezone information), timezone information is added but date and time remains the same. * If dateTime is not a naive datetime, a datetime object with new tzinfo attribute is returned, adjusting the date ...
[ "Returns", "a", "datetime", "adjusted", "to", "a", "timezone", ":", "*", "If", "dateTime", "is", "a", "naive", "datetime", "(", "datetime", "with", "no", "timezone", "information", ")", "timezone", "information", "is", "added", "but", "date", "and", "time", ...
291d92832ee0e0c89bc22e10ecf2f44445e0d300
https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/date_utils/convert.py#L15-L27
train
Returns a datetime adjusted to a timezone
iLampard/x-utils
xutils/date_utils/convert.py
DatetimeConverter.timestamp_to_datetime
def timestamp_to_datetime(cls, time_stamp, localized=True): """ Converts a UTC timestamp to a datetime.datetime.""" ret = datetime.datetime.utcfromtimestamp(time_stamp) if localized: ret = localize(ret, pytz.utc) return ret
python
def timestamp_to_datetime(cls, time_stamp, localized=True): """ Converts a UTC timestamp to a datetime.datetime.""" ret = datetime.datetime.utcfromtimestamp(time_stamp) if localized: ret = localize(ret, pytz.utc) return ret
[ "def", "timestamp_to_datetime", "(", "cls", ",", "time_stamp", ",", "localized", "=", "True", ")", ":", "ret", "=", "datetime", ".", "datetime", ".", "utcfromtimestamp", "(", "time_stamp", ")", "if", "localized", ":", "ret", "=", "localize", "(", "ret", ",...
Converts a UTC timestamp to a datetime.datetime.
[ "Converts", "a", "UTC", "timestamp", "to", "a", "datetime", ".", "datetime", "." ]
291d92832ee0e0c89bc22e10ecf2f44445e0d300
https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/date_utils/convert.py#L45-L50
train
Converts a UTC timestamp to a datetime. datetime.
noahbenson/pimms
pimms/immutable.py
_imm_default_init
def _imm_default_init(self, *args, **kwargs): ''' An immutable's defalt initialization function is to accept any number of dictionaries followed by any number of keyword args and to turn them all into the parameters of the immutable that is being created. ''' for (k,v) in six.iteritems({k:v for ...
python
def _imm_default_init(self, *args, **kwargs): ''' An immutable's defalt initialization function is to accept any number of dictionaries followed by any number of keyword args and to turn them all into the parameters of the immutable that is being created. ''' for (k,v) in six.iteritems({k:v for ...
[ "def", "_imm_default_init", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "(", "k", ",", "v", ")", "in", "six", ".", "iteritems", "(", "{", "k", ":", "v", "for", "dct", "in", "(", "args", "+", "(", "kwargs", ",", ")...
An immutable's defalt initialization function is to accept any number of dictionaries followed by any number of keyword args and to turn them all into the parameters of the immutable that is being created.
[ "An", "immutable", "s", "defalt", "initialization", "function", "is", "to", "accept", "any", "number", "of", "dictionaries", "followed", "by", "any", "number", "of", "keyword", "args", "and", "to", "turn", "them", "all", "into", "the", "parameters", "of", "t...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L94-L101
train
An immutable s default initialization function is to accept any number of dictionaries followed by any number of keyword args followed by any number of parameters of the immutable that is being created.
noahbenson/pimms
pimms/immutable.py
_imm_init_getattribute
def _imm_init_getattribute(self, name): ''' During the initial transient state, getattribute works on params; as soon as a non-param is requested, all checks are forced and the getattr switches to standard transient form. ''' values = _imm_value_data(self) params = _imm_param_data(self) if n...
python
def _imm_init_getattribute(self, name): ''' During the initial transient state, getattribute works on params; as soon as a non-param is requested, all checks are forced and the getattr switches to standard transient form. ''' values = _imm_value_data(self) params = _imm_param_data(self) if n...
[ "def", "_imm_init_getattribute", "(", "self", ",", "name", ")", ":", "values", "=", "_imm_value_data", "(", "self", ")", "params", "=", "_imm_param_data", "(", "self", ")", "if", "name", "in", "values", ":", "_imm_init_to_trans", "(", "self", ")", "return", ...
During the initial transient state, getattribute works on params; as soon as a non-param is requested, all checks are forced and the getattr switches to standard transient form.
[ "During", "the", "initial", "transient", "state", "getattribute", "works", "on", "params", ";", "as", "soon", "as", "a", "non", "-", "param", "is", "requested", "all", "checks", "are", "forced", "and", "the", "getattr", "switches", "to", "standard", "transie...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L102-L118
train
Internal method to perform getattribute on immutable parameters.
noahbenson/pimms
pimms/immutable.py
_imm_getattribute
def _imm_getattribute(self, name): ''' An immutable's getattribute calculates lazy values when not yet cached in the object then adds them as attributes. ''' if _imm_is_init(self): return _imm_init_getattribute(self, name) else: dd = object.__getattribute__(self, '__dict__') ...
python
def _imm_getattribute(self, name): ''' An immutable's getattribute calculates lazy values when not yet cached in the object then adds them as attributes. ''' if _imm_is_init(self): return _imm_init_getattribute(self, name) else: dd = object.__getattribute__(self, '__dict__') ...
[ "def", "_imm_getattribute", "(", "self", ",", "name", ")", ":", "if", "_imm_is_init", "(", "self", ")", ":", "return", "_imm_init_getattribute", "(", "self", ",", "name", ")", "else", ":", "dd", "=", "object", ".", "__getattribute__", "(", "self", ",", "...
An immutable's getattribute calculates lazy values when not yet cached in the object then adds them as attributes.
[ "An", "immutable", "s", "getattribute", "calculates", "lazy", "values", "when", "not", "yet", "cached", "in", "the", "object", "then", "adds", "them", "as", "attributes", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L119-L149
train
An immutable s getattribute calculates lazy values when not yet cached in the object then adds lazy values when not yet cached in the object then adds lazy values when not yet cached in the object then adds lazy values as attributes.
noahbenson/pimms
pimms/immutable.py
_imm_init_setattr
def _imm_init_setattr(self, name, value): ''' An immutable's initial setattr allows only param's to be set and does not run checks on the new parameters until a full parameter-set has been specified, at which point it runs all checks and switches over to a normal setattr and getattr method. ''' ...
python
def _imm_init_setattr(self, name, value): ''' An immutable's initial setattr allows only param's to be set and does not run checks on the new parameters until a full parameter-set has been specified, at which point it runs all checks and switches over to a normal setattr and getattr method. ''' ...
[ "def", "_imm_init_setattr", "(", "self", ",", "name", ",", "value", ")", ":", "params", "=", "_imm_param_data", "(", "self", ")", "if", "name", "in", "params", ":", "tx_fn", "=", "params", "[", "name", "]", "[", "1", "]", "value", "=", "value", "if",...
An immutable's initial setattr allows only param's to be set and does not run checks on the new parameters until a full parameter-set has been specified, at which point it runs all checks and switches over to a normal setattr and getattr method.
[ "An", "immutable", "s", "initial", "setattr", "allows", "only", "param", "s", "to", "be", "set", "and", "does", "not", "run", "checks", "on", "the", "new", "parameters", "until", "a", "full", "parameter", "-", "set", "has", "been", "specified", "at", "wh...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L150-L165
train
An immutable s initial setattr allows only param s to be set and does not run checks on the new parameters until a full parameter - set has been specified.
noahbenson/pimms
pimms/immutable.py
_imm_trans_setattr
def _imm_trans_setattr(self, name, value): ''' An immutable's transient setattr allows params to be set, and runs checks as they are. ''' params = _imm_param_data(self) dd = object.__getattribute__(self, '__dict__') if name in params: (_, tx_fn, arg_lists, check_fns, deps) = params[name]...
python
def _imm_trans_setattr(self, name, value): ''' An immutable's transient setattr allows params to be set, and runs checks as they are. ''' params = _imm_param_data(self) dd = object.__getattribute__(self, '__dict__') if name in params: (_, tx_fn, arg_lists, check_fns, deps) = params[name]...
[ "def", "_imm_trans_setattr", "(", "self", ",", "name", ",", "value", ")", ":", "params", "=", "_imm_param_data", "(", "self", ")", "dd", "=", "object", ".", "__getattribute__", "(", "self", ",", "'__dict__'", ")", "if", "name", "in", "params", ":", "(", ...
An immutable's transient setattr allows params to be set, and runs checks as they are.
[ "An", "immutable", "s", "transient", "setattr", "allows", "params", "to", "be", "set", "and", "runs", "checks", "as", "they", "are", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L166-L201
train
An immutable s setattr allows params to be set and runs checks as they are.
noahbenson/pimms
pimms/immutable.py
_imm_setattr
def _imm_setattr(self, name, value): ''' A persistent immutable's setattr simply does not allow attributes to be set. ''' if _imm_is_persist(self): raise TypeError('Attempt to change parameter \'%s\' of non-transient immutable' % name) elif _imm_is_trans(self): return _imm_trans_seta...
python
def _imm_setattr(self, name, value): ''' A persistent immutable's setattr simply does not allow attributes to be set. ''' if _imm_is_persist(self): raise TypeError('Attempt to change parameter \'%s\' of non-transient immutable' % name) elif _imm_is_trans(self): return _imm_trans_seta...
[ "def", "_imm_setattr", "(", "self", ",", "name", ",", "value", ")", ":", "if", "_imm_is_persist", "(", "self", ")", ":", "raise", "TypeError", "(", "'Attempt to change parameter \\'%s\\' of non-transient immutable'", "%", "name", ")", "elif", "_imm_is_trans", "(", ...
A persistent immutable's setattr simply does not allow attributes to be set.
[ "A", "persistent", "immutable", "s", "setattr", "simply", "does", "not", "allow", "attributes", "to", "be", "set", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L202-L211
train
A persistent immutable s setattr simply does not allow attributes to be set.
noahbenson/pimms
pimms/immutable.py
_imm_trans_delattr
def _imm_trans_delattr(self, name): ''' A transient immutable's delattr allows the object's value-caches to be invalidated; a var that is deleted returns to its default-value in a transient immutable, otherwise raises an exception. ''' (params, values) = (_imm_param_data(self), _imm_value_data(self)...
python
def _imm_trans_delattr(self, name): ''' A transient immutable's delattr allows the object's value-caches to be invalidated; a var that is deleted returns to its default-value in a transient immutable, otherwise raises an exception. ''' (params, values) = (_imm_param_data(self), _imm_value_data(self)...
[ "def", "_imm_trans_delattr", "(", "self", ",", "name", ")", ":", "(", "params", ",", "values", ")", "=", "(", "_imm_param_data", "(", "self", ")", ",", "_imm_value_data", "(", "self", ")", ")", "if", "name", "in", "params", ":", "dflt", "=", "params", ...
A transient immutable's delattr allows the object's value-caches to be invalidated; a var that is deleted returns to its default-value in a transient immutable, otherwise raises an exception.
[ "A", "transient", "immutable", "s", "delattr", "allows", "the", "object", "s", "value", "-", "caches", "to", "be", "invalidated", ";", "a", "var", "that", "is", "deleted", "returns", "to", "its", "default", "-", "value", "in", "a", "transient", "immutable"...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L212-L230
train
A transient immutable s delattr allows the object s value - caches to be invalidated ; a var that is deleted returns to its default - value in a transient immutable otherwise raises an exception.
noahbenson/pimms
pimms/immutable.py
_imm_delattr
def _imm_delattr(self, name): ''' A persistent immutable's delattr allows the object's value-caches to be invalidated, otherwise raises an exception. ''' if _imm_is_persist(self): values = _imm_value_data(self) if name in values: dd = object.__getattribute__(self, '__dict...
python
def _imm_delattr(self, name): ''' A persistent immutable's delattr allows the object's value-caches to be invalidated, otherwise raises an exception. ''' if _imm_is_persist(self): values = _imm_value_data(self) if name in values: dd = object.__getattribute__(self, '__dict...
[ "def", "_imm_delattr", "(", "self", ",", "name", ")", ":", "if", "_imm_is_persist", "(", "self", ")", ":", "values", "=", "_imm_value_data", "(", "self", ")", "if", "name", "in", "values", ":", "dd", "=", "object", ".", "__getattribute__", "(", "self", ...
A persistent immutable's delattr allows the object's value-caches to be invalidated, otherwise raises an exception.
[ "A", "persistent", "immutable", "s", "delattr", "allows", "the", "object", "s", "value", "-", "caches", "to", "be", "invalidated", "otherwise", "raises", "an", "exception", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L231-L246
train
A persistent immutable s delattr allows the object s value - caches to be invalidated otherwise an exception is raised.
noahbenson/pimms
pimms/immutable.py
_imm_dir
def _imm_dir(self): ''' An immutable object's dir function should list not only its attributes, but also its un-cached lazy values. ''' dir0 = set(dir(self.__class__)) dir0.update(self.__dict__.keys()) dir0.update(six.iterkeys(_imm_value_data(self))) return sorted(list(dir0))
python
def _imm_dir(self): ''' An immutable object's dir function should list not only its attributes, but also its un-cached lazy values. ''' dir0 = set(dir(self.__class__)) dir0.update(self.__dict__.keys()) dir0.update(six.iterkeys(_imm_value_data(self))) return sorted(list(dir0))
[ "def", "_imm_dir", "(", "self", ")", ":", "dir0", "=", "set", "(", "dir", "(", "self", ".", "__class__", ")", ")", "dir0", ".", "update", "(", "self", ".", "__dict__", ".", "keys", "(", ")", ")", "dir0", ".", "update", "(", "six", ".", "iterkeys"...
An immutable object's dir function should list not only its attributes, but also its un-cached lazy values.
[ "An", "immutable", "object", "s", "dir", "function", "should", "list", "not", "only", "its", "attributes", "but", "also", "its", "un", "-", "cached", "lazy", "values", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L247-L255
train
An immutable object s dir function should list only its attributes but also its un - cached lazy values.
noahbenson/pimms
pimms/immutable.py
_imm_repr
def _imm_repr(self): ''' The default representation function for an immutable object. ''' return (type(self).__name__ + ('(' if _imm_is_persist(self) else '*(') + ', '.join([k + '=' + str(v) for (k,v) in six.iteritems(imm_params(self))]) + ')')
python
def _imm_repr(self): ''' The default representation function for an immutable object. ''' return (type(self).__name__ + ('(' if _imm_is_persist(self) else '*(') + ', '.join([k + '=' + str(v) for (k,v) in six.iteritems(imm_params(self))]) + ')')
[ "def", "_imm_repr", "(", "self", ")", ":", "return", "(", "type", "(", "self", ")", ".", "__name__", "+", "(", "'('", "if", "_imm_is_persist", "(", "self", ")", "else", "'*('", ")", "+", "', '", ".", "join", "(", "[", "k", "+", "'='", "+", "str",...
The default representation function for an immutable object.
[ "The", "default", "representation", "function", "for", "an", "immutable", "object", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L256-L263
train
Returns the default representation function for an immutable object.
noahbenson/pimms
pimms/immutable.py
_imm_new
def _imm_new(cls): ''' All immutable new classes use a hack to make sure the post-init cleanup occurs. ''' imm = object.__new__(cls) # Note that right now imm has a normal setattr method; # Give any parameter that has one a default value params = cls._pimms_immutable_data_['params'] for ...
python
def _imm_new(cls): ''' All immutable new classes use a hack to make sure the post-init cleanup occurs. ''' imm = object.__new__(cls) # Note that right now imm has a normal setattr method; # Give any parameter that has one a default value params = cls._pimms_immutable_data_['params'] for ...
[ "def", "_imm_new", "(", "cls", ")", ":", "imm", "=", "object", ".", "__new__", "(", "cls", ")", "# Note that right now imm has a normal setattr method;", "# Give any parameter that has one a default value", "params", "=", "cls", ".", "_pimms_immutable_data_", "[", "'param...
All immutable new classes use a hack to make sure the post-init cleanup occurs.
[ "All", "immutable", "new", "classes", "use", "a", "hack", "to", "make", "sure", "the", "post", "-", "init", "cleanup", "occurs", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L264-L281
train
Create immutable new object.
noahbenson/pimms
pimms/immutable.py
imm_transient
def imm_transient(imm): ''' imm_transient(imm) yields a duplicate of the given immutable imm that is transient. ''' if not is_imm(imm): raise ValueError('Non-immutable given to imm_transient') # make a duplicate immutable that is in the transient state dup = copy.copy(imm) if _imm_is...
python
def imm_transient(imm): ''' imm_transient(imm) yields a duplicate of the given immutable imm that is transient. ''' if not is_imm(imm): raise ValueError('Non-immutable given to imm_transient') # make a duplicate immutable that is in the transient state dup = copy.copy(imm) if _imm_is...
[ "def", "imm_transient", "(", "imm", ")", ":", "if", "not", "is_imm", "(", "imm", ")", ":", "raise", "ValueError", "(", "'Non-immutable given to imm_transient'", ")", "# make a duplicate immutable that is in the transient state", "dup", "=", "copy", ".", "copy", "(", ...
imm_transient(imm) yields a duplicate of the given immutable imm that is transient.
[ "imm_transient", "(", "imm", ")", "yields", "a", "duplicate", "of", "the", "given", "immutable", "imm", "that", "is", "transient", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L327-L342
train
imm_transient yields a duplicate of the given immutable imm that is transient.
noahbenson/pimms
pimms/immutable.py
imm_persist
def imm_persist(imm): ''' imm_persist(imm) turns imm from a transient into a persistent immutable and returns imm. If imm is already persistent, then it is simply returned. ''' if not is_imm(imm): raise ValueError('imm_persist given non-immutable') if not _imm_is_persist(imm): _i...
python
def imm_persist(imm): ''' imm_persist(imm) turns imm from a transient into a persistent immutable and returns imm. If imm is already persistent, then it is simply returned. ''' if not is_imm(imm): raise ValueError('imm_persist given non-immutable') if not _imm_is_persist(imm): _i...
[ "def", "imm_persist", "(", "imm", ")", ":", "if", "not", "is_imm", "(", "imm", ")", ":", "raise", "ValueError", "(", "'imm_persist given non-immutable'", ")", "if", "not", "_imm_is_persist", "(", "imm", ")", ":", "_imm_trans_to_persist", "(", "imm", ")", "re...
imm_persist(imm) turns imm from a transient into a persistent immutable and returns imm. If imm is already persistent, then it is simply returned.
[ "imm_persist", "(", "imm", ")", "turns", "imm", "from", "a", "transient", "into", "a", "persistent", "immutable", "and", "returns", "imm", ".", "If", "imm", "is", "already", "persistent", "then", "it", "is", "simply", "returned", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L343-L352
train
Returns immutable if it is transient and not persistent.
noahbenson/pimms
pimms/immutable.py
imm_copy
def imm_copy(imm, **kwargs): ''' imm_copy(imm, a=b, c=d...) yields a persisent copy of the immutable object imm that differs from imm only in that the parameters a, c, etc. have been changed to have the values b, d, etc. If the object imm is persistent and no changes are made, imm is returned. If imm is...
python
def imm_copy(imm, **kwargs): ''' imm_copy(imm, a=b, c=d...) yields a persisent copy of the immutable object imm that differs from imm only in that the parameters a, c, etc. have been changed to have the values b, d, etc. If the object imm is persistent and no changes are made, imm is returned. If imm is...
[ "def", "imm_copy", "(", "imm", ",", "*", "*", "kwargs", ")", ":", "if", "not", "is_imm", "(", "imm", ")", ":", "raise", "ValueError", "(", "'Non-immutable given to imm_copy'", ")", "if", "imm_is_persistent", "(", "imm", ")", "and", "len", "(", "kwargs", ...
imm_copy(imm, a=b, c=d...) yields a persisent copy of the immutable object imm that differs from imm only in that the parameters a, c, etc. have been changed to have the values b, d, etc. If the object imm is persistent and no changes are made, imm is returned. If imm is transient, a persistent copy of imm ...
[ "imm_copy", "(", "imm", "a", "=", "b", "c", "=", "d", "...", ")", "yields", "a", "persisent", "copy", "of", "the", "immutable", "object", "imm", "that", "differs", "from", "imm", "only", "in", "that", "the", "parameters", "a", "c", "etc", ".", "have"...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L353-L395
train
Returns a persistent copy of the immutable object imm with the same parameters as the given object imm.
noahbenson/pimms
pimms/immutable.py
imm_params
def imm_params(imm): ''' imm_params(imm) yields a dictionary of the parameters of the immutable object imm. ''' return {p: getattr(imm, p) for p in six.iterkeys(_imm_param_data(imm))}
python
def imm_params(imm): ''' imm_params(imm) yields a dictionary of the parameters of the immutable object imm. ''' return {p: getattr(imm, p) for p in six.iterkeys(_imm_param_data(imm))}
[ "def", "imm_params", "(", "imm", ")", ":", "return", "{", "p", ":", "getattr", "(", "imm", ",", "p", ")", "for", "p", "in", "six", ".", "iterkeys", "(", "_imm_param_data", "(", "imm", ")", ")", "}" ]
imm_params(imm) yields a dictionary of the parameters of the immutable object imm.
[ "imm_params", "(", "imm", ")", "yields", "a", "dictionary", "of", "the", "parameters", "of", "the", "immutable", "object", "imm", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L396-L400
train
Returns a dictionary of the parameters of the immutable object imm.
noahbenson/pimms
pimms/immutable.py
imm_values
def imm_values(imm): ''' imm_values(imm) yields a dictionary of the values of the immutable object imm. Note that this forces all of the values to be reified, so only use it if you want to force execution of all lazy values. ''' return {p: getattr(imm, p) for p in six.iterkeys(_imm_value_data(im...
python
def imm_values(imm): ''' imm_values(imm) yields a dictionary of the values of the immutable object imm. Note that this forces all of the values to be reified, so only use it if you want to force execution of all lazy values. ''' return {p: getattr(imm, p) for p in six.iterkeys(_imm_value_data(im...
[ "def", "imm_values", "(", "imm", ")", ":", "return", "{", "p", ":", "getattr", "(", "imm", ",", "p", ")", "for", "p", "in", "six", ".", "iterkeys", "(", "_imm_value_data", "(", "imm", ")", ")", "}" ]
imm_values(imm) yields a dictionary of the values of the immutable object imm. Note that this forces all of the values to be reified, so only use it if you want to force execution of all lazy values.
[ "imm_values", "(", "imm", ")", "yields", "a", "dictionary", "of", "the", "values", "of", "the", "immutable", "object", "imm", ".", "Note", "that", "this", "forces", "all", "of", "the", "values", "to", "be", "reified", "so", "only", "use", "it", "if", "...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L401-L407
train
Returns a dictionary of the values of the immutable object imm.
noahbenson/pimms
pimms/immutable.py
imm_dict
def imm_dict(imm): ''' imm_dict(imm) yields a persistent dictionary of the params and values of the immutable object im. Note that this forces all of the values to be reified, so only use it if you want to force execution of all lazy values. ''' immd = dict(**imm_params(imm)) for (k,v) in si...
python
def imm_dict(imm): ''' imm_dict(imm) yields a persistent dictionary of the params and values of the immutable object im. Note that this forces all of the values to be reified, so only use it if you want to force execution of all lazy values. ''' immd = dict(**imm_params(imm)) for (k,v) in si...
[ "def", "imm_dict", "(", "imm", ")", ":", "immd", "=", "dict", "(", "*", "*", "imm_params", "(", "imm", ")", ")", "for", "(", "k", ",", "v", ")", "in", "six", ".", "iteritems", "(", "imm_values", "(", "imm", ")", ")", ":", "immd", "[", "k", "]...
imm_dict(imm) yields a persistent dictionary of the params and values of the immutable object im. Note that this forces all of the values to be reified, so only use it if you want to force execution of all lazy values.
[ "imm_dict", "(", "imm", ")", "yields", "a", "persistent", "dictionary", "of", "the", "params", "and", "values", "of", "the", "immutable", "object", "im", ".", "Note", "that", "this", "forces", "all", "of", "the", "values", "to", "be", "reified", "so", "o...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L408-L417
train
Returns a persistent dictionary of the params and values of immutable object im.
noahbenson/pimms
pimms/immutable.py
param
def param(f): ''' The @param decorator, usable in an immutable class (see immutable), specifies that the following function is actually a transformation on an input parameter; the parameter is required, and is set to the value returned by the function decorated by the parameter; i.e., if you decorate t...
python
def param(f): ''' The @param decorator, usable in an immutable class (see immutable), specifies that the following function is actually a transformation on an input parameter; the parameter is required, and is set to the value returned by the function decorated by the parameter; i.e., if you decorate t...
[ "def", "param", "(", "f", ")", ":", "(", "args", ",", "varargs", ",", "kwargs", ",", "dflts", ")", "=", "getargspec_py27like", "(", "f", ")", "if", "varargs", "is", "not", "None", "or", "kwargs", "is", "not", "None", "or", "dflts", ":", "raise", "V...
The @param decorator, usable in an immutable class (see immutable), specifies that the following function is actually a transformation on an input parameter; the parameter is required, and is set to the value returned by the function decorated by the parameter; i.e., if you decorate the function abc with @...
[ "The" ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L444-L461
train
Decorator for a function to specify that the parameter is a transformation on an input parameter.
noahbenson/pimms
pimms/immutable.py
option
def option(default_value): ''' The @option(x) decorator, usable in an immutable class (see immutable), is identical to the @param decorator except that the parameter is not required and instead takes on the default value x when the immutable is created. ''' def _option(f): (args, varargs...
python
def option(default_value): ''' The @option(x) decorator, usable in an immutable class (see immutable), is identical to the @param decorator except that the parameter is not required and instead takes on the default value x when the immutable is created. ''' def _option(f): (args, varargs...
[ "def", "option", "(", "default_value", ")", ":", "def", "_option", "(", "f", ")", ":", "(", "args", ",", "varargs", ",", "kwargs", ",", "dflts", ")", "=", "getargspec_py27like", "(", "f", ")", "if", "varargs", "is", "not", "None", "or", "kwargs", "is...
The @option(x) decorator, usable in an immutable class (see immutable), is identical to the @param decorator except that the parameter is not required and instead takes on the default value x when the immutable is created.
[ "The" ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L462-L481
train
Decorator for creating an immutable class option.
noahbenson/pimms
pimms/immutable.py
require
def require(f): ''' The @require decorator, usable in an immutable class (see immutable), specifies that the following function is actually a validation check on the immutable class. These functions will appear as static members of the class and get called automatically when the relevant data change...
python
def require(f): ''' The @require decorator, usable in an immutable class (see immutable), specifies that the following function is actually a validation check on the immutable class. These functions will appear as static members of the class and get called automatically when the relevant data change...
[ "def", "require", "(", "f", ")", ":", "(", "args", ",", "varargs", ",", "kwargs", ",", "dflts", ")", "=", "getargspec_py27like", "(", "f", ")", "if", "varargs", "is", "not", "None", "or", "kwargs", "is", "not", "None", "or", "dflts", ":", "raise", ...
The @require decorator, usable in an immutable class (see immutable), specifies that the following function is actually a validation check on the immutable class. These functions will appear as static members of the class and get called automatically when the relevant data change. Daughter classes can overl...
[ "The" ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L482-L499
train
Decorator for a immutable class that validates the immutable data of a function.
noahbenson/pimms
pimms/immutable.py
_imm_resolve_deps
def _imm_resolve_deps(cls): ''' _imm_resolve_deps(imm_class) resolves the dependencies of the given immutable class imm_class and edits the immutable metadata appropriately. ''' dat = cls._pimms_immutable_data_ params = dat['params'] values = dat['values'] consts = dat['consts'] chec...
python
def _imm_resolve_deps(cls): ''' _imm_resolve_deps(imm_class) resolves the dependencies of the given immutable class imm_class and edits the immutable metadata appropriately. ''' dat = cls._pimms_immutable_data_ params = dat['params'] values = dat['values'] consts = dat['consts'] chec...
[ "def", "_imm_resolve_deps", "(", "cls", ")", ":", "dat", "=", "cls", ".", "_pimms_immutable_data_", "params", "=", "dat", "[", "'params'", "]", "values", "=", "dat", "[", "'values'", "]", "consts", "=", "dat", "[", "'consts'", "]", "checks", "=", "dat", ...
_imm_resolve_deps(imm_class) resolves the dependencies of the given immutable class imm_class and edits the immutable metadata appropriately.
[ "_imm_resolve_deps", "(", "imm_class", ")", "resolves", "the", "dependencies", "of", "the", "given", "immutable", "class", "imm_class", "and", "edits", "the", "immutable", "metadata", "appropriately", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L522-L587
train
_imm_resolve_deps - resolves the dependencies of the given immutable class imm_class and edits the immutable metadata appropriately.
noahbenson/pimms
pimms/immutable.py
_imm_merge_class
def _imm_merge_class(cls, parent): ''' _imm_merge_class(imm_class, parent) updates the given immutable class imm_class to have the appropriate attributes of its given parent class. The parents should be passed through this function in method-resolution order. ''' # If this is not an immutable pa...
python
def _imm_merge_class(cls, parent): ''' _imm_merge_class(imm_class, parent) updates the given immutable class imm_class to have the appropriate attributes of its given parent class. The parents should be passed through this function in method-resolution order. ''' # If this is not an immutable pa...
[ "def", "_imm_merge_class", "(", "cls", ",", "parent", ")", ":", "# If this is not an immutable parent, ignore it", "if", "not", "hasattr", "(", "parent", ",", "'_pimms_immutable_data_'", ")", ":", "return", "cls", "# otherwise, let's look at the data", "cdat", "=", "cls...
_imm_merge_class(imm_class, parent) updates the given immutable class imm_class to have the appropriate attributes of its given parent class. The parents should be passed through this function in method-resolution order.
[ "_imm_merge_class", "(", "imm_class", "parent", ")", "updates", "the", "given", "immutable", "class", "imm_class", "to", "have", "the", "appropriate", "attributes", "of", "its", "given", "parent", "class", ".", "The", "parents", "should", "be", "passed", "throug...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L588-L618
train
Internal method to merge the given immutable class into the given parent class.
noahbenson/pimms
pimms/immutable.py
_annotate_imm
def _annotate_imm(cls): ''' _annotate_imm(cls) crawls the class members and adds the _pimms_immutable_data_ attribute (a dict) with the following items to the class's attributes: * 'params' * 'values' * 'checks' ''' dat = {} cls._pimms_immutable_data_ = dat # First, crawl t...
python
def _annotate_imm(cls): ''' _annotate_imm(cls) crawls the class members and adds the _pimms_immutable_data_ attribute (a dict) with the following items to the class's attributes: * 'params' * 'values' * 'checks' ''' dat = {} cls._pimms_immutable_data_ = dat # First, crawl t...
[ "def", "_annotate_imm", "(", "cls", ")", ":", "dat", "=", "{", "}", "cls", ".", "_pimms_immutable_data_", "=", "dat", "# First, crawl this class's static members to see what has been added...", "mems", "=", "inspect", ".", "getmembers", "(", "cls", ")", "immmems", "...
_annotate_imm(cls) crawls the class members and adds the _pimms_immutable_data_ attribute (a dict) with the following items to the class's attributes: * 'params' * 'values' * 'checks'
[ "_annotate_imm", "(", "cls", ")", "crawls", "the", "class", "members", "and", "adds", "the", "_pimms_immutable_data_", "attribute", "(", "a", "dict", ")", "with", "the", "following", "items", "to", "the", "class", "s", "attributes", ":", "*", "params", "*", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L619-L658
train
_annotate_imm adds the immutable data to the class s _pimms_immutable_data_ attribute
noahbenson/pimms
pimms/immutable.py
immutable
def immutable(cls): ''' The @immutable decorator makes an abstract type out of the decorated class that overloads __new__ to create interesting behavior consistent with immutable data types. The following decorators may be used inside of the decorated class to define immutable behavior: * @value i...
python
def immutable(cls): ''' The @immutable decorator makes an abstract type out of the decorated class that overloads __new__ to create interesting behavior consistent with immutable data types. The following decorators may be used inside of the decorated class to define immutable behavior: * @value i...
[ "def", "immutable", "(", "cls", ")", ":", "# Annotate the class!", "cls", "=", "_annotate_imm", "(", "cls", ")", "# The attributes we want to make sure get set:", "auto_members", "=", "(", "(", "'__getattribute__'", ",", "_imm_getattribute", ")", ",", "(", "'__setattr...
The @immutable decorator makes an abstract type out of the decorated class that overloads __new__ to create interesting behavior consistent with immutable data types. The following decorators may be used inside of the decorated class to define immutable behavior: * @value indicates that the following func...
[ "The" ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/immutable.py#L668-L742
train
Decorator that creates an immutable object of the given class.
tweekmonster/moult
moult/filesystem_scanner.py
_scan_file
def _scan_file(filename, sentinel, source_type='import'): '''Generator that performs the actual scanning of files. Yeilds a tuple containing import type, import path, and an extra file that should be scanned. Extra file scans should be the file or directory that relates to the import name. ''' ...
python
def _scan_file(filename, sentinel, source_type='import'): '''Generator that performs the actual scanning of files. Yeilds a tuple containing import type, import path, and an extra file that should be scanned. Extra file scans should be the file or directory that relates to the import name. ''' ...
[ "def", "_scan_file", "(", "filename", ",", "sentinel", ",", "source_type", "=", "'import'", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "real_filename", "=", "os", ".", "path", ".", "realpath", "(", "filename", ")"...
Generator that performs the actual scanning of files. Yeilds a tuple containing import type, import path, and an extra file that should be scanned. Extra file scans should be the file or directory that relates to the import name.
[ "Generator", "that", "performs", "the", "actual", "scanning", "of", "files", "." ]
38d3a3b9002336219897ebe263ca1d8dcadbecf5
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/filesystem_scanner.py#L20-L48
train
Generator that performs the actual scanning of a file.
tweekmonster/moult
moult/filesystem_scanner.py
_scan_directory
def _scan_directory(directory, sentinel, depth=0): '''Basically os.listdir with some filtering. ''' directory = os.path.abspath(directory) real_directory = os.path.realpath(directory) if depth < max_directory_depth and real_directory not in sentinel \ and os.path.isdir(directory): ...
python
def _scan_directory(directory, sentinel, depth=0): '''Basically os.listdir with some filtering. ''' directory = os.path.abspath(directory) real_directory = os.path.realpath(directory) if depth < max_directory_depth and real_directory not in sentinel \ and os.path.isdir(directory): ...
[ "def", "_scan_directory", "(", "directory", ",", "sentinel", ",", "depth", "=", "0", ")", ":", "directory", "=", "os", ".", "path", ".", "abspath", "(", "directory", ")", "real_directory", "=", "os", ".", "path", ".", "realpath", "(", "directory", ")", ...
Basically os.listdir with some filtering.
[ "Basically", "os", ".", "listdir", "with", "some", "filtering", "." ]
38d3a3b9002336219897ebe263ca1d8dcadbecf5
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/filesystem_scanner.py#L51-L71
train
Basically os. listdir with some filtering.
tweekmonster/moult
moult/filesystem_scanner.py
scan_file
def scan_file(pym, filename, sentinel, installed): '''Entry point scan that creates a PyModule instance if needed. ''' if not utils.is_python_script(filename): return if not pym: # This is for finding a previously created instance, not finding an # installed module with the same...
python
def scan_file(pym, filename, sentinel, installed): '''Entry point scan that creates a PyModule instance if needed. ''' if not utils.is_python_script(filename): return if not pym: # This is for finding a previously created instance, not finding an # installed module with the same...
[ "def", "scan_file", "(", "pym", ",", "filename", ",", "sentinel", ",", "installed", ")", ":", "if", "not", "utils", ".", "is_python_script", "(", "filename", ")", ":", "return", "if", "not", "pym", ":", "# This is for finding a previously created instance, not fin...
Entry point scan that creates a PyModule instance if needed.
[ "Entry", "point", "scan", "that", "creates", "a", "PyModule", "instance", "if", "needed", "." ]
38d3a3b9002336219897ebe263ca1d8dcadbecf5
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/filesystem_scanner.py#L74-L111
train
Entry point scan that creates a PyModule instance if needed.
tweekmonster/moult
moult/filesystem_scanner.py
scan_directory
def scan_directory(pym, directory, sentinel, installed, depth=0): '''Entry point scan that creates a PyModule instance if needed. ''' if not pym: d = os.path.abspath(directory) basename = os.path.basename(d) pym = utils.find_package(basename, installed) if not pym: ...
python
def scan_directory(pym, directory, sentinel, installed, depth=0): '''Entry point scan that creates a PyModule instance if needed. ''' if not pym: d = os.path.abspath(directory) basename = os.path.basename(d) pym = utils.find_package(basename, installed) if not pym: ...
[ "def", "scan_directory", "(", "pym", ",", "directory", ",", "sentinel", ",", "installed", ",", "depth", "=", "0", ")", ":", "if", "not", "pym", ":", "d", "=", "os", ".", "path", ".", "abspath", "(", "directory", ")", "basename", "=", "os", ".", "pa...
Entry point scan that creates a PyModule instance if needed.
[ "Entry", "point", "scan", "that", "creates", "a", "PyModule", "instance", "if", "needed", "." ]
38d3a3b9002336219897ebe263ca1d8dcadbecf5
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/filesystem_scanner.py#L114-L149
train
Entry point scan that creates a PyModule instance if needed.
mkoura/dump2polarion
dump2polarion/configuration.py
_get_project_conf
def _get_project_conf(): """Loads configuration from project config file.""" config_settings = {} project_root = find_vcs_root(".") if project_root is None: return config_settings for conf_dir in PROJECT_CONF_DIRS: conf_dir = conf_dir.lstrip("./") joined_dir = os.path.join(...
python
def _get_project_conf(): """Loads configuration from project config file.""" config_settings = {} project_root = find_vcs_root(".") if project_root is None: return config_settings for conf_dir in PROJECT_CONF_DIRS: conf_dir = conf_dir.lstrip("./") joined_dir = os.path.join(...
[ "def", "_get_project_conf", "(", ")", ":", "config_settings", "=", "{", "}", "project_root", "=", "find_vcs_root", "(", "\".\"", ")", "if", "project_root", "is", "None", ":", "return", "config_settings", "for", "conf_dir", "in", "PROJECT_CONF_DIRS", ":", "conf_d...
Loads configuration from project config file.
[ "Loads", "configuration", "from", "project", "config", "file", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/configuration.py#L131-L160
train
Loads configuration from project config file.
mkoura/dump2polarion
dump2polarion/configuration.py
get_config
def get_config(config_file=None, config_values=None, load_project_conf=True): """Loads config file and returns its content.""" config_values = config_values or {} config_settings = {} default_conf = _get_default_conf() user_conf = _get_user_conf(config_file) if config_file else {} # load projec...
python
def get_config(config_file=None, config_values=None, load_project_conf=True): """Loads config file and returns its content.""" config_values = config_values or {} config_settings = {} default_conf = _get_default_conf() user_conf = _get_user_conf(config_file) if config_file else {} # load projec...
[ "def", "get_config", "(", "config_file", "=", "None", ",", "config_values", "=", "None", ",", "load_project_conf", "=", "True", ")", ":", "config_values", "=", "config_values", "or", "{", "}", "config_settings", "=", "{", "}", "default_conf", "=", "_get_defaul...
Loads config file and returns its content.
[ "Loads", "config", "file", "and", "returns", "its", "content", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/configuration.py#L163-L192
train
Loads config file and returns its content.
ngmarchant/oasis
oasis/input_verification.py
verify_predictions
def verify_predictions(predictions): """Ensures that predictions is stored as a numpy array and checks that all values are either 0 or 1. """ # Check that it contains only zeros and ones predictions = np.array(predictions, copy=False) if not np.array_equal(predictions, predictions.astype(bool)):...
python
def verify_predictions(predictions): """Ensures that predictions is stored as a numpy array and checks that all values are either 0 or 1. """ # Check that it contains only zeros and ones predictions = np.array(predictions, copy=False) if not np.array_equal(predictions, predictions.astype(bool)):...
[ "def", "verify_predictions", "(", "predictions", ")", ":", "# Check that it contains only zeros and ones", "predictions", "=", "np", ".", "array", "(", "predictions", ",", "copy", "=", "False", ")", "if", "not", "np", ".", "array_equal", "(", "predictions", ",", ...
Ensures that predictions is stored as a numpy array and checks that all values are either 0 or 1.
[ "Ensures", "that", "predictions", "is", "stored", "as", "a", "numpy", "array", "and", "checks", "that", "all", "values", "are", "either", "0", "or", "1", "." ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/input_verification.py#L10-L21
train
Ensures that predictions is stored as a numpy array and checks that all values are either 0 or 1.
ngmarchant/oasis
oasis/input_verification.py
verify_scores
def verify_scores(scores): """Ensures that scores is stored as a numpy array and checks that all values are finite. """ scores = np.array(scores, copy=False) if np.any(~np.isfinite(scores)): raise ValueError("scores contains invalid values. " + "Please check that all...
python
def verify_scores(scores): """Ensures that scores is stored as a numpy array and checks that all values are finite. """ scores = np.array(scores, copy=False) if np.any(~np.isfinite(scores)): raise ValueError("scores contains invalid values. " + "Please check that all...
[ "def", "verify_scores", "(", "scores", ")", ":", "scores", "=", "np", ".", "array", "(", "scores", ",", "copy", "=", "False", ")", "if", "np", ".", "any", "(", "~", "np", ".", "isfinite", "(", "scores", ")", ")", ":", "raise", "ValueError", "(", ...
Ensures that scores is stored as a numpy array and checks that all values are finite.
[ "Ensures", "that", "scores", "is", "stored", "as", "a", "numpy", "array", "and", "checks", "that", "all", "values", "are", "finite", "." ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/input_verification.py#L23-L33
train
Ensures that scores is stored as a numpy array and checks that all values are finite.
ngmarchant/oasis
oasis/input_verification.py
verify_consistency
def verify_consistency(predictions, scores, proba, opt_class): """Verifies that all arrays have consistent dimensions. Also verifies that the scores are consistent with proba. Returns ------- proba, opt_class """ if predictions.shape != scores.shape: raise ValueError("predictions an...
python
def verify_consistency(predictions, scores, proba, opt_class): """Verifies that all arrays have consistent dimensions. Also verifies that the scores are consistent with proba. Returns ------- proba, opt_class """ if predictions.shape != scores.shape: raise ValueError("predictions an...
[ "def", "verify_consistency", "(", "predictions", ",", "scores", ",", "proba", ",", "opt_class", ")", ":", "if", "predictions", ".", "shape", "!=", "scores", ".", "shape", ":", "raise", "ValueError", "(", "\"predictions and scores arrays have inconsistent \"", "+", ...
Verifies that all arrays have consistent dimensions. Also verifies that the scores are consistent with proba. Returns ------- proba, opt_class
[ "Verifies", "that", "all", "arrays", "have", "consistent", "dimensions", ".", "Also", "verifies", "that", "the", "scores", "are", "consistent", "with", "proba", "." ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/input_verification.py#L35-L75
train
Verifies that all arrays have consistent dimensions. Also verifies that the scores are consistent with proba. Also verifies that the predictions and scores arrays have consistent dimensions. Also verifies that the proba and opt_class arrays are consistent with proba. Also verifies that the scores are consistent with op...
ngmarchant/oasis
oasis/input_verification.py
verify_identifiers
def verify_identifiers(identifiers, n_items): """Ensure that identifiers has a compatible length and that its elements are unique""" if identifiers is None: return identifiers identifiers = np.array(identifiers, copy=False) # Check length for consistency if len(identifiers) != n_items:...
python
def verify_identifiers(identifiers, n_items): """Ensure that identifiers has a compatible length and that its elements are unique""" if identifiers is None: return identifiers identifiers = np.array(identifiers, copy=False) # Check length for consistency if len(identifiers) != n_items:...
[ "def", "verify_identifiers", "(", "identifiers", ",", "n_items", ")", ":", "if", "identifiers", "is", "None", ":", "return", "identifiers", "identifiers", "=", "np", ".", "array", "(", "identifiers", ",", "copy", "=", "False", ")", "# Check length for consistenc...
Ensure that identifiers has a compatible length and that its elements are unique
[ "Ensure", "that", "identifiers", "has", "a", "compatible", "length", "and", "that", "its", "elements", "are", "unique" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/input_verification.py#L91-L107
train
Ensure that identifiers has a compatible length and that its elements are unique.
ngmarchant/oasis
oasis/input_verification.py
scores_to_probs
def scores_to_probs(scores, proba, eps=0.01): """Transforms scores to probabilities by applying the logistic function""" if np.any(~proba): # Need to convert some of the scores into probabilities probs = copy.deepcopy(scores) n_class = len(proba) for m in range(n_class): ...
python
def scores_to_probs(scores, proba, eps=0.01): """Transforms scores to probabilities by applying the logistic function""" if np.any(~proba): # Need to convert some of the scores into probabilities probs = copy.deepcopy(scores) n_class = len(proba) for m in range(n_class): ...
[ "def", "scores_to_probs", "(", "scores", ",", "proba", ",", "eps", "=", "0.01", ")", ":", "if", "np", ".", "any", "(", "~", "proba", ")", ":", "# Need to convert some of the scores into probabilities", "probs", "=", "copy", ".", "deepcopy", "(", "scores", ")...
Transforms scores to probabilities by applying the logistic function
[ "Transforms", "scores", "to", "probabilities", "by", "applying", "the", "logistic", "function" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/input_verification.py#L117-L133
train
Transforms scores to probabilities by applying the logistic function
praekeltfoundation/seed-message-sender
message_sender/tasks.py
deliver_hook
def deliver_hook(target, payload, instance_id=None, hook_id=None, **kwargs): """ target: the url to receive the payload. payload: a python primitive data structure instance_id: a possibly None "trigger" instance ID hook_id: the ID of defining Hook object """ ...
python
def deliver_hook(target, payload, instance_id=None, hook_id=None, **kwargs): """ target: the url to receive the payload. payload: a python primitive data structure instance_id: a possibly None "trigger" instance ID hook_id: the ID of defining Hook object """ ...
[ "def", "deliver_hook", "(", "target", ",", "payload", ",", "instance_id", "=", "None", ",", "hook_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "r", "=", "requests", ".", "post", "(", "url", "=", "target", ",", "data", "=", "json", ".", "dum...
target: the url to receive the payload. payload: a python primitive data structure instance_id: a possibly None "trigger" instance ID hook_id: the ID of defining Hook object
[ "target", ":", "the", "url", "to", "receive", "the", "payload", ".", "payload", ":", "a", "python", "primitive", "data", "structure", "instance_id", ":", "a", "possibly", "None", "trigger", "instance", "ID", "hook_id", ":", "the", "ID", "of", "defining", "...
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L76-L92
train
deliver a hook to a specific instance
praekeltfoundation/seed-message-sender
message_sender/tasks.py
fire_metric
def fire_metric(metric_name, metric_value): """ Fires a metric using the MetricsApiClient """ metric_value = float(metric_value) metric = {metric_name: metric_value} metric_client.fire_metrics(**metric) return "Fired metric <{}> with value <{}>".format(metric_name, metric_value)
python
def fire_metric(metric_name, metric_value): """ Fires a metric using the MetricsApiClient """ metric_value = float(metric_value) metric = {metric_name: metric_value} metric_client.fire_metrics(**metric) return "Fired metric <{}> with value <{}>".format(metric_name, metric_value)
[ "def", "fire_metric", "(", "metric_name", ",", "metric_value", ")", ":", "metric_value", "=", "float", "(", "metric_value", ")", "metric", "=", "{", "metric_name", ":", "metric_value", "}", "metric_client", ".", "fire_metrics", "(", "*", "*", "metric", ")", ...
Fires a metric using the MetricsApiClient
[ "Fires", "a", "metric", "using", "the", "MetricsApiClient" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L118-L124
train
Fires a metric using the MetricsApiClient
praekeltfoundation/seed-message-sender
message_sender/tasks.py
SendMessage.fire_failed_msisdn_lookup
def fire_failed_msisdn_lookup(self, to_identity): """ Fires a webhook in the event of a None to_addr. """ payload = {"to_identity": to_identity} hooks = Hook.objects.filter(event="identity.no_address") for hook in hooks: hook.deliver_hook( None...
python
def fire_failed_msisdn_lookup(self, to_identity): """ Fires a webhook in the event of a None to_addr. """ payload = {"to_identity": to_identity} hooks = Hook.objects.filter(event="identity.no_address") for hook in hooks: hook.deliver_hook( None...
[ "def", "fire_failed_msisdn_lookup", "(", "self", ",", "to_identity", ")", ":", "payload", "=", "{", "\"to_identity\"", ":", "to_identity", "}", "hooks", "=", "Hook", ".", "objects", ".", "filter", "(", "event", "=", "\"identity.no_address\"", ")", "for", "hook...
Fires a webhook in the event of a None to_addr.
[ "Fires", "a", "webhook", "in", "the", "event", "of", "a", "None", "to_addr", "." ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L214-L223
train
Fires a webhook in the event of a None to_addr.
praekeltfoundation/seed-message-sender
message_sender/tasks.py
SendMessage.run
def run(self, message_id, **kwargs): """ Load and contruct message and send them off """ log = self.get_logger(**kwargs) error_retry_count = kwargs.get("error_retry_count", 0) if error_retry_count >= self.max_error_retries: raise MaxRetriesExceededError( ...
python
def run(self, message_id, **kwargs): """ Load and contruct message and send them off """ log = self.get_logger(**kwargs) error_retry_count = kwargs.get("error_retry_count", 0) if error_retry_count >= self.max_error_retries: raise MaxRetriesExceededError( ...
[ "def", "run", "(", "self", ",", "message_id", ",", "*", "*", "kwargs", ")", ":", "log", "=", "self", ".", "get_logger", "(", "*", "*", "kwargs", ")", "error_retry_count", "=", "kwargs", ".", "get", "(", "\"error_retry_count\"", ",", "0", ")", "if", "...
Load and contruct message and send them off
[ "Load", "and", "contruct", "message", "and", "send", "them", "off" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L225-L383
train
Load and contruct message and send them off
praekeltfoundation/seed-message-sender
message_sender/tasks.py
ArchiveOutboundMessages.dump_data
def dump_data(self, filename, queryset): """ Serializes the queryset into a newline separated JSON format, and places it into a gzipped file """ with gzip.open(filename, "wb") as f: for outbound in queryset.iterator(): data = OutboundArchiveSerializer(...
python
def dump_data(self, filename, queryset): """ Serializes the queryset into a newline separated JSON format, and places it into a gzipped file """ with gzip.open(filename, "wb") as f: for outbound in queryset.iterator(): data = OutboundArchiveSerializer(...
[ "def", "dump_data", "(", "self", ",", "filename", ",", "queryset", ")", ":", "with", "gzip", ".", "open", "(", "filename", ",", "\"wb\"", ")", "as", "f", ":", "for", "outbound", "in", "queryset", ".", "iterator", "(", ")", ":", "data", "=", "Outbound...
Serializes the queryset into a newline separated JSON format, and places it into a gzipped file
[ "Serializes", "the", "queryset", "into", "a", "newline", "separated", "JSON", "format", "and", "places", "it", "into", "a", "gzipped", "file" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L486-L496
train
Dumps the data of the queryset into a gzipped file.
praekeltfoundation/seed-message-sender
message_sender/tasks.py
ArchiveOutboundMessages.create_archived_outbound
def create_archived_outbound(self, date, filename): """ Creates the required ArchivedOutbound entry with the file specified at `filename` """ with open(filename, "rb") as f: f = File(f) ArchivedOutbounds.objects.create(date=date, archive=f)
python
def create_archived_outbound(self, date, filename): """ Creates the required ArchivedOutbound entry with the file specified at `filename` """ with open(filename, "rb") as f: f = File(f) ArchivedOutbounds.objects.create(date=date, archive=f)
[ "def", "create_archived_outbound", "(", "self", ",", "date", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "f", ":", "f", "=", "File", "(", "f", ")", "ArchivedOutbounds", ".", "objects", ".", "create", "(", "date...
Creates the required ArchivedOutbound entry with the file specified at `filename`
[ "Creates", "the", "required", "ArchivedOutbound", "entry", "with", "the", "file", "specified", "at", "filename" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L498-L505
train
Creates the required ArchivedOutbound entry with the file specified at filename.
iLampard/x-utils
xutils/misc.py
valid_dict
def valid_dict(d, keys=None): """ 检查是否字典中含有值为None的键(给定键的名称则检查给定的键,如果没有,则检查全部键) - 如果没有值为None的键,则返回True,反之False - 如果keys中的键不存在于d中,也返回False """ if keys is None: d_ = d else: d_ = itemfilter(lambda item: item[0] in keys, d) if len(d_) != len(keys): return Fal...
python
def valid_dict(d, keys=None): """ 检查是否字典中含有值为None的键(给定键的名称则检查给定的键,如果没有,则检查全部键) - 如果没有值为None的键,则返回True,反之False - 如果keys中的键不存在于d中,也返回False """ if keys is None: d_ = d else: d_ = itemfilter(lambda item: item[0] in keys, d) if len(d_) != len(keys): return Fal...
[ "def", "valid_dict", "(", "d", ",", "keys", "=", "None", ")", ":", "if", "keys", "is", "None", ":", "d_", "=", "d", "else", ":", "d_", "=", "itemfilter", "(", "lambda", "item", ":", "item", "[", "0", "]", "in", "keys", ",", "d", ")", "if", "l...
检查是否字典中含有值为None的键(给定键的名称则检查给定的键,如果没有,则检查全部键) - 如果没有值为None的键,则返回True,反之False - 如果keys中的键不存在于d中,也返回False
[ "检查是否字典中含有值为None的键", "(", "给定键的名称则检查给定的键,如果没有,则检查全部键", ")", "-", "如果没有值为None的键,则返回True,反之False", "-", "如果keys中的键不存在于d中,也返回False" ]
291d92832ee0e0c89bc22e10ecf2f44445e0d300
https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/misc.py#L8-L22
train
Check if a dictionary is valid.
djaodjin/djaodjin-deployutils
deployutils/apps/django/mixins.py
AccessiblesMixin.accessibles
def accessibles(self, roles=None): """ Returns the list of *slugs* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present. """ return [org['slug'] for org in self.get_accessibles(self.request, roles=roles)]
python
def accessibles(self, roles=None): """ Returns the list of *slugs* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present. """ return [org['slug'] for org in self.get_accessibles(self.request, roles=roles)]
[ "def", "accessibles", "(", "self", ",", "roles", "=", "None", ")", ":", "return", "[", "org", "[", "'slug'", "]", "for", "org", "in", "self", ".", "get_accessibles", "(", "self", ".", "request", ",", "roles", "=", "roles", ")", "]" ]
Returns the list of *slugs* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present.
[ "Returns", "the", "list", "of", "*", "slugs", "*", "for", "which", "the", "accounts", "are", "accessibles", "by", "request", ".", "user", "filtered", "by", "roles", "if", "present", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mixins.py#L50-L56
train
Returns the list of all the accessibles for the current user filtered by roles.
djaodjin/djaodjin-deployutils
deployutils/apps/django/mixins.py
AccessiblesMixin.get_accessibles
def get_accessibles(request, roles=None): """ Returns the list of *dictionnaries* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present. """ results = [] for role_name, organizations in six.iteritems(request.session.get( ...
python
def get_accessibles(request, roles=None): """ Returns the list of *dictionnaries* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present. """ results = [] for role_name, organizations in six.iteritems(request.session.get( ...
[ "def", "get_accessibles", "(", "request", ",", "roles", "=", "None", ")", ":", "results", "=", "[", "]", "for", "role_name", ",", "organizations", "in", "six", ".", "iteritems", "(", "request", ".", "session", ".", "get", "(", "'roles'", ",", "{", "}",...
Returns the list of *dictionnaries* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present.
[ "Returns", "the", "list", "of", "*", "dictionnaries", "*", "for", "which", "the", "accounts", "are", "accessibles", "by", "request", ".", "user", "filtered", "by", "roles", "if", "present", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mixins.py#L59-L69
train
Returns the list of accessibles for the user in the current session.
djaodjin/djaodjin-deployutils
deployutils/apps/django/mixins.py
AccessiblesMixin.manages
def manages(self, account): """ Returns ``True`` if the ``request.user`` is a manager for ``account``. ``account`` will be converted to a string and compared to an organization slug. """ account_slug = str(account) for organization in self.request.session.get( ...
python
def manages(self, account): """ Returns ``True`` if the ``request.user`` is a manager for ``account``. ``account`` will be converted to a string and compared to an organization slug. """ account_slug = str(account) for organization in self.request.session.get( ...
[ "def", "manages", "(", "self", ",", "account", ")", ":", "account_slug", "=", "str", "(", "account", ")", "for", "organization", "in", "self", ".", "request", ".", "session", ".", "get", "(", "'roles'", ",", "{", "}", ")", ".", "get", "(", "'manager'...
Returns ``True`` if the ``request.user`` is a manager for ``account``. ``account`` will be converted to a string and compared to an organization slug.
[ "Returns", "True", "if", "the", "request", ".", "user", "is", "a", "manager", "for", "account", ".", "account", "will", "be", "converted", "to", "a", "string", "and", "compared", "to", "an", "organization", "slug", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mixins.py#L99-L110
train
Returns True if the user is a manager for account.
djaodjin/djaodjin-deployutils
deployutils/apps/django/mixins.py
BeforeMixin.get_queryset
def get_queryset(self): """ Implements before date filtering on ``date_field`` """ kwargs = {} if self.ends_at: kwargs.update({'%s__lt' % self.date_field: self.ends_at}) return super(BeforeMixin, self).get_queryset().filter(**kwargs)
python
def get_queryset(self): """ Implements before date filtering on ``date_field`` """ kwargs = {} if self.ends_at: kwargs.update({'%s__lt' % self.date_field: self.ends_at}) return super(BeforeMixin, self).get_queryset().filter(**kwargs)
[ "def", "get_queryset", "(", "self", ")", ":", "kwargs", "=", "{", "}", "if", "self", ".", "ends_at", ":", "kwargs", ".", "update", "(", "{", "'%s__lt'", "%", "self", ".", "date_field", ":", "self", ".", "ends_at", "}", ")", "return", "super", "(", ...
Implements before date filtering on ``date_field``
[ "Implements", "before", "date", "filtering", "on", "date_field" ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mixins.py#L201-L208
train
Implements before date filtering on date_field
djaodjin/djaodjin-deployutils
deployutils/apps/django/mixins.py
DateRangeMixin.get_queryset
def get_queryset(self): """ Implements date range filtering on ``created_at`` """ kwargs = {} if self.start_at: kwargs.update({'%s__gte' % self.date_field: self.start_at}) return super(DateRangeMixin, self).get_queryset().filter(**kwargs)
python
def get_queryset(self): """ Implements date range filtering on ``created_at`` """ kwargs = {} if self.start_at: kwargs.update({'%s__gte' % self.date_field: self.start_at}) return super(DateRangeMixin, self).get_queryset().filter(**kwargs)
[ "def", "get_queryset", "(", "self", ")", ":", "kwargs", "=", "{", "}", "if", "self", ".", "start_at", ":", "kwargs", ".", "update", "(", "{", "'%s__gte'", "%", "self", ".", "date_field", ":", "self", ".", "start_at", "}", ")", "return", "super", "(",...
Implements date range filtering on ``created_at``
[ "Implements", "date", "range", "filtering", "on", "created_at" ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mixins.py#L238-L245
train
Implements date range filtering on created_at
carta/ldap_tools
src/ldap_tools/user.py
API.create
def create(self, fname, lname, group, type, group_api): """Create an LDAP User.""" self.__username(fname, lname) self.client.add( self.__distinguished_name(type, fname=fname, lname=lname), API.__object_class(), self.__ldap_attr(fname, lname, type, group, group...
python
def create(self, fname, lname, group, type, group_api): """Create an LDAP User.""" self.__username(fname, lname) self.client.add( self.__distinguished_name(type, fname=fname, lname=lname), API.__object_class(), self.__ldap_attr(fname, lname, type, group, group...
[ "def", "create", "(", "self", ",", "fname", ",", "lname", ",", "group", ",", "type", ",", "group_api", ")", ":", "self", ".", "__username", "(", "fname", ",", "lname", ")", "self", ".", "client", ".", "add", "(", "self", ".", "__distinguished_name", ...
Create an LDAP User.
[ "Create", "an", "LDAP", "User", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L24-L30
train
Create an LDAP User.
carta/ldap_tools
src/ldap_tools/user.py
API.delete
def delete(self, username, type): """Delete an LDAP user.""" self.client.delete(self.__distinguished_name(type, username=username))
python
def delete(self, username, type): """Delete an LDAP user.""" self.client.delete(self.__distinguished_name(type, username=username))
[ "def", "delete", "(", "self", ",", "username", ",", "type", ")", ":", "self", ".", "client", ".", "delete", "(", "self", ".", "__distinguished_name", "(", "type", ",", "username", "=", "username", ")", ")" ]
Delete an LDAP user.
[ "Delete", "an", "LDAP", "user", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L32-L34
train
Delete an LDAP user.
carta/ldap_tools
src/ldap_tools/user.py
API.show
def show(self, username): """Return a specific user's info in LDIF format.""" filter = ['(objectclass=posixAccount)', "(uid={})".format(username)] return self.client.search(filter)
python
def show(self, username): """Return a specific user's info in LDIF format.""" filter = ['(objectclass=posixAccount)', "(uid={})".format(username)] return self.client.search(filter)
[ "def", "show", "(", "self", ",", "username", ")", ":", "filter", "=", "[", "'(objectclass=posixAccount)'", ",", "\"(uid={})\"", ".", "format", "(", "username", ")", "]", "return", "self", ".", "client", ".", "search", "(", "filter", ")" ]
Return a specific user's info in LDIF format.
[ "Return", "a", "specific", "user", "s", "info", "in", "LDIF", "format", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L41-L44
train
Return a specific user s info in LDIF format.
carta/ldap_tools
src/ldap_tools/user.py
API.find
def find(self, username): """ Find user with given username. Args: username Username of the user to search for Raises: ldap_tools.exceptions.NoUserFound: No users returned by LDAP ldap_tools.exceptions.TooManyResults: Multiple users r...
python
def find(self, username): """ Find user with given username. Args: username Username of the user to search for Raises: ldap_tools.exceptions.NoUserFound: No users returned by LDAP ldap_tools.exceptions.TooManyResults: Multiple users r...
[ "def", "find", "(", "self", ",", "username", ")", ":", "filter", "=", "[", "'(uid={})'", ".", "format", "(", "username", ")", "]", "results", "=", "self", ".", "client", ".", "search", "(", "filter", ")", "if", "len", "(", "results", ")", "<", "1",...
Find user with given username. Args: username Username of the user to search for Raises: ldap_tools.exceptions.NoUserFound: No users returned by LDAP ldap_tools.exceptions.TooManyResults: Multiple users returned by LDAP
[ "Find", "user", "with", "given", "username", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L46-L71
train
Find user with given username.
carta/ldap_tools
src/ldap_tools/user.py
API.__username
def __username(self, fname, lname): # pragma: no cover """Convert first name + last name into first.last style username.""" self.username = '.'.join([i.lower() for i in [fname, lname]])
python
def __username(self, fname, lname): # pragma: no cover """Convert first name + last name into first.last style username.""" self.username = '.'.join([i.lower() for i in [fname, lname]])
[ "def", "__username", "(", "self", ",", "fname", ",", "lname", ")", ":", "# pragma: no cover", "self", ".", "username", "=", "'.'", ".", "join", "(", "[", "i", ".", "lower", "(", ")", "for", "i", "in", "[", "fname", ",", "lname", "]", "]", ")" ]
Convert first name + last name into first.last style username.
[ "Convert", "first", "name", "+", "last", "name", "into", "first", ".", "last", "style", "username", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L73-L75
train
Convert first name + last name into first. last style username.
carta/ldap_tools
src/ldap_tools/user.py
API.__distinguished_name
def __distinguished_name(self, type, fname=None, lname=None, username=None): # pragma: no cover """Assemble the DN of the user.""" if username is None: uid = "uid={}".format(self.username) else: uid = "uid={}".format(username) dn_lis...
python
def __distinguished_name(self, type, fname=None, lname=None, username=None): # pragma: no cover """Assemble the DN of the user.""" if username is None: uid = "uid={}".format(self.username) else: uid = "uid={}".format(username) dn_lis...
[ "def", "__distinguished_name", "(", "self", ",", "type", ",", "fname", "=", "None", ",", "lname", "=", "None", ",", "username", "=", "None", ")", ":", "# pragma: no cover", "if", "username", "is", "None", ":", "uid", "=", "\"uid={}\"", ".", "format", "("...
Assemble the DN of the user.
[ "Assemble", "the", "DN", "of", "the", "user", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L77-L91
train
Assemble the DN of the user.