m = p[<NUM_LIT:1>].parse(None)<EOL>block = self.scope.blocks(m.raw())<EOL>if block:<EOL><INDENT>p[<NUM_LIT:0>] = block.copy_inner(self.scope)<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>] = Deferred(p[<NUM_LIT:1>], None, p.lineno(<NUM_LIT:2>))<EOL><DEDENT>

block_decl               : identifier t_semicolon


try:<EOL><INDENT>p[<NUM_LIT:1>].parse(self.scope)<EOL><DEDENT>except SyntaxError:<EOL><INDENT>pass<EOL><DEDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>self.scope.current = p[<NUM_LIT:1>]<EOL>

block_open                : identifier brace_open


p[<NUM_LIT:0>] = Identifier(p[<NUM_LIT:1>]).parse(self.scope)<EOL>

block_open                : media_query_decl brace_open


p[<NUM_LIT:0>] = Identifier([p[<NUM_LIT:1>], p[<NUM_LIT:2>]]).parse(self.scope)<EOL>

block_open                : css_font_face t_ws brace_open


p[<NUM_LIT:0>] = KeyframeSelector([p[<NUM_LIT:1>]]).parse(self.scope)<EOL>

block_open                 : css_keyframe_selector brace_open
                                      | number brace_open


self.scope.add_mixin(Mixin(list(p)[<NUM_LIT:1>:], p.lineno(<NUM_LIT:3>)).parse(self.scope))<EOL>self.scope.pop()<EOL>p[<NUM_LIT:0>] = None<EOL>

mixin_decl                : open_mixin declaration_list brace_close


p[<NUM_LIT:1>].parse(self.scope)<EOL>self.scope.current = p[<NUM_LIT:1>]<EOL>p[<NUM_LIT:0>] = [p[<NUM_LIT:1>], p[<NUM_LIT:3>]]<EOL>if len(p) > <NUM_LIT:6>:<EOL><INDENT>p[<NUM_LIT:0>].append(p[<NUM_LIT:5>])<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>].append(None)<EOL><DEDENT>

open_mixin                : identifier t_popen mixin_args_list t_pclose brace_open
                                      | identifier t_popen mixin_args_list t_pclose mixin_guard brace_open


p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL>

mixin_guard               : less_when mixin_guard_cond_list


p[<NUM_LIT:1>].append(p[<NUM_LIT:2>])<EOL>p[<NUM_LIT:1>].append(p[<NUM_LIT:3>])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

mixin_guard_cond_list    : mixin_guard_cond_list t_comma mixin_guard_cond
                                     | mixin_guard_cond_list less_and mixin_guard_cond


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>

mixin_guard_cond_list     : mixin_guard_cond


p[<NUM_LIT:0>] = utility.reverse_guard(list(p)[<NUM_LIT:3>:-<NUM_LIT:1>])<EOL>

mixin_guard_cond          : less_not t_popen argument mixin_guard_cmp argument t_pclose
                                      | less_not t_popen argument t_pclose


p[<NUM_LIT:0>] = list(p)[<NUM_LIT:2>:-<NUM_LIT:1>]<EOL>

mixin_guard_cond          : t_popen argument mixin_guard_cmp argument t_pclose
                                      | t_popen argument t_pclose


p[<NUM_LIT:0>] = '<STR_LIT>'.join(list(p)[<NUM_LIT:1>:])<EOL>


p[<NUM_LIT:1>].parse(None)<EOL>p[<NUM_LIT:0>] = Deferred(p[<NUM_LIT:1>], p[<NUM_LIT:3>], p.lineno(<NUM_LIT:4>))<EOL>

call_mixin                : identifier t_popen mixin_args_list t_pclose t_semicolon


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>

mixin_args_list          : less_arguments


p[<NUM_LIT:1>].extend([p[<NUM_LIT:3>]])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

mixin_args_list          : mixin_args_list t_comma mixin_args
                                     | mixin_args_list t_semicolon mixin_args


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>


p[<NUM_LIT:1>].extend(list(p)[<NUM_LIT:2>:])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

mixin_args                : mixin_args argument


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>

mixin_args                : argument
                                      | mixin_kwarg


p[<NUM_LIT:0>] = None<EOL>


p[<NUM_LIT:0>] = Variable(list(p)[<NUM_LIT:1>:], p.lineno(<NUM_LIT:2>))<EOL>

mixin_kwarg                : variable t_colon mixin_kwarg_arg_list


mixin_kwarg_arg_list       : mixin_kwarg_arg_list argument


if len(p) > <NUM_LIT:2>:<EOL><INDENT>p[<NUM_LIT:1>].extend(p[<NUM_LIT:2>])<EOL><DEDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

declaration_list           : declaration_list declaration
                                       | declaration
                                       | empty


p[<NUM_LIT:0>] = p[<NUM_LIT:1>] if isinstance(p[<NUM_LIT:1>], list) else [p[<NUM_LIT:1>]]<EOL>

declaration                : variable_decl
                                       | property_decl
                                       | block_decl
                                       | mixin_decl
                                       | call_mixin
                                       | import_statement


p[<NUM_LIT:0>] = Variable(list(p)[<NUM_LIT:1>:-<NUM_LIT:1>], p.lineno(<NUM_LIT:4>))<EOL>p[<NUM_LIT:0>].parse(self.scope)<EOL>

variable_decl            : variable t_colon style_list t_semicolon


l = len(p)<EOL>p[<NUM_LIT:0>] = Property(list(p)[<NUM_LIT:1>:-<NUM_LIT:1>], p.lineno(l - <NUM_LIT:1>))<EOL>

property_decl           : prop_open style_list t_semicolon
                                    | prop_open style_list css_important t_semicolon
                                    | prop_open empty t_semicolon


p[<NUM_LIT:0>] = Property([p[<NUM_LIT:1>], [p[<NUM_LIT:2>]]], p.lineno(<NUM_LIT:3>))<EOL>

property_decl           : prop_open less_arguments t_semicolon


p[<NUM_LIT:0>] = (p[<NUM_LIT:1>][<NUM_LIT:0>], p[<NUM_LIT:2>][<NUM_LIT:0>])<EOL>


p[<NUM_LIT:0>] = (p[<NUM_LIT:1>][<NUM_LIT:0>], '<STR_LIT>')<EOL>

prop_open               : property t_colon
                                    | vendor_property t_colon
                                    | word t_colon


style_list              : style_list style
                                    | style_list t_comma style
                                    | style_list t_ws style


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

style                   : expression
                                    | string
                                    | word
                                    | property
                                    | vendor_property
                                    | estring


p[<NUM_LIT:0>] = Identifier(p[<NUM_LIT:1>], <NUM_LIT:0>)<EOL>

identifier                : identifier_list
                                      | page
                                      | page filter


p[<NUM_LIT:0>] = Identifier(Call([p[<NUM_LIT:2>], p[<NUM_LIT:3>]]), <NUM_LIT:0>)<EOL>

identifier                : t_popen estring t_pclose


p[<NUM_LIT:1>].extend([p[<NUM_LIT:2>]])<EOL>p[<NUM_LIT:1>].extend(p[<NUM_LIT:3>])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

identifier_list           : identifier_list t_comma identifier_group


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

identifier_list           : identifier_group


p[<NUM_LIT:0>] = list(p)[<NUM_LIT:1>:]<EOL>

identifier_list           : css_keyframes t_ws css_ident
                                      | css_keyframes t_ws css_ident t_ws


identifier_list           : css_viewport
                                      | css_viewport t_ws


p[<NUM_LIT:1>].extend([p[<NUM_LIT:2>]])<EOL>if len(p) > <NUM_LIT:3>:<EOL><INDENT>p[<NUM_LIT:1>].extend(p[<NUM_LIT:3>])<EOL><DEDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

identifier_group          : identifier_group child_selector ident_parts
                                      | identifier_group '+' ident_parts
                                      | identifier_group general_sibling_selector ident_parts
                                      | identifier_group '*'


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>


if isinstance(p[<NUM_LIT:2>], list):<EOL><INDENT>p[<NUM_LIT:1>].extend(p[<NUM_LIT:2>])<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:1>].append(p[<NUM_LIT:2>])<EOL><DEDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

ident_parts               : ident_parts ident_part
                                      | ident_parts filter_group


if not isinstance(p[<NUM_LIT:1>], list):<EOL><INDENT>p[<NUM_LIT:1>] = [p[<NUM_LIT:1>]]<EOL><DEDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

ident_parts               : ident_part
                                      | selector
                                      | filter_group


media_query_decl            : css_media t_ws
                                        | css_media t_ws media_query_list


media_query_list            : media_query_list t_comma media_query


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>

media_query_list            : media_query


media_query                 : media_type
                                        | media_type media_query_expression_list
                                        | not media_type
                                        | not media_type media_query_expression_list
                                        | only media_type
                                        | only media_type media_query_expression_list


media_query                 : media_query_expression media_query_expression_list
                                        | media_query_expression


media_query_expression_list : media_query_expression_list and media_query_expression
                                        | and media_query_expression


media_query_expression      : t_popen css_media_feature t_pclose
                                        | t_popen css_media_feature t_colon media_query_value t_pclose


if utility.is_variable(p[<NUM_LIT:1>]):<EOL><INDENT>var = self.scope.variables('<STR_LIT>'.join(p[<NUM_LIT:1>]))<EOL>if var:<EOL><INDENT>value = var.value[<NUM_LIT:0>]<EOL>if hasattr(value, '<STR_LIT>'):<EOL><INDENT>p[<NUM_LIT:1>] = value.parse(self.scope)<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:1>] = value<EOL><DEDENT><DEDENT><DEDENT>if isinstance(p[<NUM_LIT:1>], Expression):<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>].parse(self.scope)<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL><DEDENT>

media_query_value           : number
                                        | variable
                                        | word
                                        | color
                                        | expression


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

selector                  : '*'
                                      | '+'
                                      | child_selector
                                      | general_sibling_selector


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

ident_part                : iclass
                                      | id
                                      | dom
                                      | combinator
                                      | color


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>], p[<NUM_LIT:2>]]<EOL>

ident_part                : combinator vendor_property


p[<NUM_LIT:1>].extend(p[<NUM_LIT:2>])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

filter_group              : filter_group filter


filter                    : css_filter
                                      | css_filter t_ws
                                      | t_colon word
                                      | t_colon vendor_property
                                      | t_colon vendor_property t_ws
                                      | t_colon css_property
                                      | t_colon css_property t_ws
                                      | t_colon css_filter
                                      | t_colon css_filter t_ws
                                      | t_colon t_colon word
                                      | t_colon t_colon vendor_property


p[<NUM_LIT:0>] = tuple(list(p)[<NUM_LIT:1>:])<EOL>

ms_filter       : css_ms_filter
                            | css_ms_filter t_ws


p[<NUM_LIT:0>] = Call(list(p)[<NUM_LIT:1>:], <NUM_LIT:0>)<EOL>

fcall           : word t_popen argument_list t_pclose
                            | property t_popen argument_list t_pclose
                            | vendor_property t_popen argument_list t_pclose
                            | less_open_format argument_list t_pclose
                            | ms_filter t_popen argument_list t_pclose


p[<NUM_LIT:0>] = '<STR_LIT>'<EOL>


p[<NUM_LIT:1>].extend(list(p)[<NUM_LIT:2>:])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

argument_list       : argument_list argument
                                | argument_list t_comma argument


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

argument        : expression
                            | string
                            | estring
                            | word
                            | id
                            | css_uri
                            | '='
                            | fcall


p[<NUM_LIT:0>] = Expression(list(p)[<NUM_LIT:1>:], <NUM_LIT:0>)<EOL>

expression             : expression '+' expression
                                   | expression '-' expression
                                   | expression '/' expression
                                   | expression '*' expression
                                   | word '/' expression


p[<NUM_LIT:0>] = NegatedExpression([p[<NUM_LIT:3>]], <NUM_LIT:0>)<EOL>

expression             : '-' t_popen expression t_pclose


p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL>

expression             : t_popen expression t_pclose


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

factor                  : color
                                    | number
                                    | variable
                                    | css_dom
                                    | fcall


p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL>

estring                 : t_eopen style_list t_eclose
                                    | t_eopen identifier_list t_eclose


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

string_part             : variable
                                    | css_string


p[<NUM_LIT:1>].extend([p[<NUM_LIT:2>]])<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

string_part_list        : string_part_list string_part


p[<NUM_LIT:0>] = ['<STR_LIT:">', p[<NUM_LIT:2>], '<STR_LIT:">']<EOL>

string                  : t_isopen string_part_list t_isclose


p[<NUM_LIT:0>] = ['<STR_LIT:->', p[<NUM_LIT:2>]]<EOL>


p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL>

variable                : t_popen variable t_pclose


<EOL>p[<NUM_LIT:0>] = tuple(list(p)[<NUM_LIT:1>:])<EOL>

variable                : less_variable
                                    | less_variable t_ws


try:<EOL><INDENT>p[<NUM_LIT:0>] = Color().fmt(p[<NUM_LIT:1>])<EOL>if len(p) > <NUM_LIT:2>:<EOL><INDENT>p[<NUM_LIT:0>] = [p[<NUM_LIT:0>], p[<NUM_LIT:2>]]<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>self.handle_error('<STR_LIT>' % p[<NUM_LIT:1>], p.lineno(<NUM_LIT:1>),<EOL>'<STR_LIT>')<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL><DEDENT>

color                   : css_color
                                    | css_color t_ws


number                    : css_number
                                      | css_number t_ws


dom                       : css_dom
                                      | css_dom t_ws


word                      : css_ident
                                      | css_ident t_ws


class                     : css_class
                                      | css_class t_ws


p[<NUM_LIT:0>] = list(p)[<NUM_LIT:1>:]<EOL>

iclass_part               : less_variable
                                      | less_variable t_ws
                                      | class


iclass_part_list          : iclass_part_list iclass_part


p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL>


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>

iclass                    : iclass_part_list


id                        : css_id
                                      | css_id t_ws


property                  : css_property
                                      | css_property t_ws


page                      : css_page
                                      | css_page t_ws


vendor_property           : css_vendor_property
                                      | css_vendor_property t_ws


media_type                : css_media_type
                                      | css_media_type t_ws


combinator                : '&' t_ws
                                      | '&'


child_selector            : '>' t_ws
                                      | '>'


general_sibling_selector  : t_tilde t_ws
                                      | t_tilde


self.scope.push()<EOL>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>


and                       : t_and t_ws
                                      | t_and


not                       : t_not t_ws
                                      | t_not


only                      : t_only t_ws
                                      | t_only


pass<EOL>


if t:<EOL><INDENT>error_msg = "<STR_LIT>" %(self.target, t.lineno, t.type, t.value)<EOL>self.register.register(error_msg)<EOL><DEDENT>while True:<EOL><INDENT>t = self.lex.token()<EOL>if not t or t.value == '<STR_LIT:}>':<EOL><INDENT>if len(self.scope) > <NUM_LIT:1>:<EOL><INDENT>self.scope.pop()<EOL><DEDENT>break<EOL><DEDENT><DEDENT>self.parser.restart()<EOL>return t<EOL>

Internal error handler
        args:
            t (Lex token): Error token


def handle_error(self, e, line, t='<STR_LIT:E>'):

self.register.register("<STR_LIT>" % (t, line, e))<EOL>

Custom error handler
        args:
            e (Mixed): Exception or str
            line (int): line number
            t(str): Error type


return t<EOL>


t.lexer.in_property_decl = False<EOL>return t<EOL>


<EOL>t.lexer.pop_state()<EOL>return t<EOL>


<EOL>return t<EOL>


<EOL>t.lexer.pop_state()<EOL>t.value = '<STR_LIT:U+0020>'<EOL>return t<EOL>


t.lexer.pop_state()<EOL>return t<EOL>


<EOL>t.lexer.pop_state()  <EOL>t.lexer.pop_state()  <EOL>return t<EOL>


v = t.value.lower()<EOL>if v in reserved.tokens:<EOL><INDENT>t.type = reserved.tokens[v]<EOL>if t.type == "<STR_LIT>":<EOL><INDENT>t.lexer.push_state("<STR_LIT>")<EOL><DEDENT>elif t.type == "<STR_LIT>":<EOL><INDENT>t.lexer.push_state("<STR_LIT>")<EOL><DEDENT><DEDENT>return t<EOL>


t.lexer.lineno += t.value.count('<STR_LIT:\n>')<EOL>


t.lexer.lineno += t.value.count('<STR_LIT:\n>')<EOL>pass<EOL>


t.value = '<STR_LIT>'<EOL>return t<EOL>


t.value = '<STR_LIT:U+0020>'<EOL>return t<EOL>


t.lexer.push_state('<STR_LIT>')<EOL>return t<EOL>


if t.value[<NUM_LIT:1>] == '<STR_LIT:">':<EOL><INDENT>t.lexer.push_state('<STR_LIT>')<EOL><DEDENT>elif t.value[<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>t.lexer.push_state('<STR_LIT>')<EOL><DEDENT>return t<EOL>


t.lexer.lineno += t.value.count('<STR_LIT:\n>')<EOL>return t<EOL>


if t.value[<NUM_LIT:0>] == '<STR_LIT:">':<EOL><INDENT>t.lexer.push_state('<STR_LIT>')<EOL><DEDENT>elif t.value[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>t.lexer.push_state('<STR_LIT>')<EOL><DEDENT>return t<EOL>


with open(filename) as f:<EOL><INDENT>self.lexer.input(f.read())<EOL><DEDENT>return self<EOL>


if isinstance(file, string_types):<EOL><INDENT>with open(file) as f:<EOL><INDENT>self.lexer.input(f.read())<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.lexer.input(file.read())<EOL><DEDENT>

Load lexer with content from `file` which can be a path or a file
like object.


if self.next_:<EOL><INDENT>t = self.next_<EOL>self.next_ = None<EOL>return t<EOL><DEDENT>while True:<EOL><INDENT>t = self.lexer.token()<EOL>if not t:<EOL><INDENT>return t<EOL><DEDENT>if t.type == '<STR_LIT>' and (<EOL>self.pretok or<EOL>(self.last and self.last.type not in self.significant_ws)):<EOL><INDENT>continue<EOL><DEDENT>self.pretok = False<EOL>if t.type == '<STR_LIT>' and self.last and self.last.type not in ['<STR_LIT>', '<STR_LIT>'] and self.last.type != '<STR_LIT>'and not (hasattr(t, '<STR_LIT>') and (t.lexer.lexstate == '<STR_LIT>' or t.lexer.lexstate == '<STR_LIT>')):<EOL><INDENT>self.next_ = t<EOL>tok = lex.LexToken()<EOL>tok.type = '<STR_LIT>'<EOL>tok.value = '<STR_LIT:;>'<EOL>tok.lineno = t.lineno<EOL>tok.lexpos = t.lexpos<EOL>self.last = tok<EOL>self.lexer.in_property_decl = False<EOL>return tok<EOL><DEDENT>self.last = t<EOL>break<EOL><DEDENT>return t<EOL>

Token function. Contains 2 hacks:
    1.  Injects ';' into blocks where the last property
        leaves out the ;
    2.  Strips out whitespace from nonsignificant locations
        to ease parsing.


for elm in lst:<EOL><INDENT>if isinstance(elm, collections.Iterable) and not isinstance(<EOL>elm, string_types):<EOL><INDENT>for sub in flatten(elm):<EOL><INDENT>yield sub<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield elm<EOL><DEDENT><DEDENT>

Flatten list.
    Args:
        lst (list): List to flatten
    Returns:
        generator


if not lst:<EOL><INDENT>return<EOL><DEDENT>length = len(lst)<EOL>for i in range(length - <NUM_LIT:1>):<EOL><INDENT>yield lst[i], lst[i + <NUM_LIT:1>]<EOL><DEDENT>yield lst[-<NUM_LIT:1>], None<EOL>

yield item i and item i+1 in lst. e.g.
        (lst[0], lst[1]), (lst[1], lst[2]), ..., (lst[-1], None)
    Args:
        lst (list): List to process
    Returns:
        list


for p in blocks:<EOL><INDENT>if isinstance(p, stype):<EOL><INDENT>p.tokens[<NUM_LIT:0>].parse(scope)<EOL>if p.tokens[<NUM_LIT:1>]:<EOL><INDENT>scope.push()<EOL>scope.current = p.tokens[<NUM_LIT:0>]<EOL>rename(p.tokens[<NUM_LIT:1>], scope, stype)<EOL>scope.pop()<EOL><DEDENT><DEDENT><DEDENT>

Rename all sub-blocks moved under another
        block. (mixins)
    Args:
        lst (list): block list
        scope (object): Scope object


if hasattr(block, '<STR_LIT>'):<EOL><INDENT>for b in block.tokens[<NUM_LIT:1>]:<EOL><INDENT>b = (b if hasattr(b, '<STR_LIT>') and b.raw() == name else blocksearch(<EOL>b, name))<EOL>if b:<EOL><INDENT>return b<EOL><DEDENT><DEDENT><DEDENT>return False<EOL>

Recursive search for name in block (inner blocks)
    Args:
        name (str): search term
    Returns:
        Block OR False


rev = {'<STR_LIT:<>': '<STR_LIT>', '<STR_LIT:>>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT:<>', '<STR_LIT>': '<STR_LIT:>>'}<EOL>return [rev[l] if l in rev else l for l in lst]<EOL>

Reverse guard expression. not
        (@a > 5) ->  (@a =< 5)
    Args:
        lst (list): Expression
    returns:
        list


pad = '<STR_LIT>'.join(['<STR_LIT>'] * lvl)<EOL>t = type(lst)<EOL>if t is list:<EOL><INDENT>for p in lst:<EOL><INDENT>debug_print(p, lvl)<EOL><DEDENT><DEDENT>elif hasattr(lst, '<STR_LIT>'):<EOL><INDENT>print(pad, t)<EOL>debug_print(list(flatten(lst.tokens)), lvl + <NUM_LIT:1>)<EOL><DEDENT>

Print scope tree
    args:
        lst (list): parse result
        lvl (int): current nesting level


return value.strip('<STR_LIT>')<EOL>

Strip quotes from string
    args:
        value (str)
    returns:
        str


n, u = split_unit(var)<EOL>if not isinstance(var, string_types):<EOL><INDENT>return (var, u)<EOL><DEDENT>if is_color(var):<EOL><INDENT>return (var, '<STR_LIT>')<EOL><DEDENT>if is_int(n):<EOL><INDENT>n = int(n)<EOL><DEDENT>elif is_float(n):<EOL><INDENT>n = float(n)<EOL><DEDENT>else:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % (err, var))<EOL><DEDENT>return (n, u)<EOL>

Analyse number for type and split from unit
        1px -> (q, 'px')
    args:
        var (str): number string
    kwargs:
        err (str): Error message
    raises:
        SyntaxError
    returns:
        tuple


if isinstance(number, tuple):<EOL><INDENT>number, unit = number<EOL><DEDENT>if number == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT:0>'<EOL><DEDENT>if unit:<EOL><INDENT>number = str(number)<EOL>if number.startswith('<STR_LIT:.>'):<EOL><INDENT>number = '<STR_LIT:0>' + number<EOL><DEDENT>return "<STR_LIT>" % (number, unit)<EOL><DEDENT>return number if isinstance(number, string_types) else str(number)<EOL>

Return number with unit
    args:
        number (mixed): Number
        unit (str): Unit
    returns:
        str


if not value or not isinstance(value, string_types):<EOL><INDENT>return False<EOL><DEDENT>if value[<NUM_LIT:0>] == '<STR_LIT:#>' and len(value) in [<NUM_LIT:4>, <NUM_LIT:5>, <NUM_LIT:7>, <NUM_LIT:9>]:<EOL><INDENT>try:<EOL><INDENT>int(value[<NUM_LIT:1>:], <NUM_LIT:16>)<EOL>return True<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return False<EOL>

Is string CSS color
    args:
        value (str): string
    returns:
        bool


if isinstance(value, string_types):<EOL><INDENT>return (value.startswith('<STR_LIT:@>') or value.startswith('<STR_LIT>'))<EOL><DEDENT>elif isinstance(value, tuple):<EOL><INDENT>value = '<STR_LIT>'.join(value)<EOL>return (value.startswith('<STR_LIT:@>') or value.startswith('<STR_LIT>'))<EOL><DEDENT>return False<EOL>

Check if string is LESS variable
    args:
        value (str): string
    returns:
        bool


try:<EOL><INDENT>int(str(value))<EOL>return True<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>pass<EOL><DEDENT>return False<EOL>

Is value integer
    args:
        value (str): string
    returns:
        bool


if not is_int(value):<EOL><INDENT>try:<EOL><INDENT>float(str(value))<EOL>return True<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return False<EOL>

Is value float
    args:
        value (str): string
    returns:
        bool


r = re.search('<STR_LIT>', str(value))<EOL>return r.groups() if r else ('<STR_LIT>', '<STR_LIT>')<EOL>

Split a number from its unit
        1px -> (q, 'px')
    Args:
        value (str): input
    returns:
        tuple


if sys.version_info[<NUM_LIT:0>] >= <NUM_LIT:3>:<EOL><INDENT>p = <NUM_LIT:10>**ndigits<EOL>return float(math.floor((value * p) + math.copysign(<NUM_LIT:0.5>, value))) / p<EOL><DEDENT>else:<EOL><INDENT>return round(value, ndigits)<EOL><DEDENT>

Round half-way away from zero.

    Python2's round() method.


if sys.version_info[<NUM_LIT:0>] < <NUM_LIT:3>:<EOL><INDENT>if value < <NUM_LIT:0.0>:<EOL><INDENT>return -convergent_round(-value)<EOL><DEDENT>epsilon = <NUM_LIT><EOL>integral_part, _ = divmod(value, <NUM_LIT:1>)<EOL>if abs(value - (integral_part + <NUM_LIT:0.5>)) < epsilon:<EOL><INDENT>if integral_part % <NUM_LIT> < epsilon:<EOL><INDENT>return integral_part<EOL><DEDENT>else:<EOL><INDENT>nearest_even = integral_part + <NUM_LIT:0.5><EOL>return math.ceil(nearest_even)<EOL><DEDENT><DEDENT><DEDENT>return round(value, ndigits)<EOL>

Convergent rounding.

    Round to neareas even, similar to Python3's round() method.


if isinstance(s, string_types) and '<STR_LIT:%>' in s:<EOL><INDENT>return float(s.strip('<STR_LIT:%>')) / <NUM_LIT><EOL><DEDENT>return float(s)<EOL>

Utility function to process strings that contain either percentiles or floats
    args:
        str: s
    returns:
       float


pool = tuple(iterable)<EOL>n = len(pool)<EOL>r = n if r is None else r<EOL>for indices in itertools.product(range(n), repeat=r):<EOL><INDENT>yield list(pool[i] for i in indices)<EOL><DEDENT>

Return successive r length permutations of elements in the iterable.

    Similar to itertools.permutation but withouth repeated values filtering.


super(Scope, self).__init__()<EOL>self._mixins = {}<EOL>if init:<EOL><INDENT>self.push()<EOL><DEDENT>self.deferred = False<EOL>self.real = []<EOL>

Scope
        Args:
            init (bool): Initiate scope


self.append({<EOL>'<STR_LIT>': {},<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': None<EOL>})<EOL>


return [r['<STR_LIT>'] for r in self if r['<STR_LIT>']]<EOL>

Current scope name as list
        Returns:
            list


self[-<NUM_LIT:1>]['<STR_LIT>'].append(block)<EOL>self[-<NUM_LIT:1>]['<STR_LIT>'].append(block.raw())<EOL>

Add block element to scope
        Args:
            block (Block): Block object


def remove_block(self, block, index="<STR_LIT>"):

self[index]["<STR_LIT>"].remove(block)<EOL>self[index]["<STR_LIT>"].remove(block.raw())<EOL>

Remove block element from scope
        Args:
            block (Block): Block object


raw = mixin.tokens[<NUM_LIT:0>][<NUM_LIT:0>].raw()<EOL>if raw in self._mixins:<EOL><INDENT>self._mixins[raw].append(mixin)<EOL><DEDENT>else:<EOL><INDENT>self._mixins[raw] = [mixin]<EOL><DEDENT>

Add mixin to scope
        Args:
            mixin (Mixin): Mixin object


self[-<NUM_LIT:1>]['<STR_LIT>'][variable.name] = variable<EOL>

Add variable to scope
        Args:
            variable (Variable): Variable object


if isinstance(name, tuple):<EOL><INDENT>name = name[<NUM_LIT:0>]<EOL><DEDENT>if name.startswith('<STR_LIT>'):<EOL><INDENT>name = '<STR_LIT:@>' + name[<NUM_LIT:2>:-<NUM_LIT:1>]<EOL><DEDENT>i = len(self)<EOL>while i >= <NUM_LIT:0>:<EOL><INDENT>i -= <NUM_LIT:1><EOL>if name in self[i]['<STR_LIT>']:<EOL><INDENT>return self[i]['<STR_LIT>'][name]<EOL><DEDENT><DEDENT>return False<EOL>

Search for variable by name. Searches scope top down
        Args:
            name (string): Search term
        Returns:
            Variable object OR False


m = self._smixins(name)<EOL>if m:<EOL><INDENT>return m<EOL><DEDENT>return self._smixins(name.replace('<STR_LIT>', '<STR_LIT:U+0020>'))<EOL>

Search mixins for name.
        Allow '>' to be ignored. '.a .b()' == '.a > .b()'
        Args:
            name (string): Search term
        Returns:
            Mixin object list OR False


return (self._mixins[name] if name in self._mixins else False)<EOL>

Inner wrapper to search for mixins by name.


b = self._blocks(name)<EOL>if b:<EOL><INDENT>return b<EOL><DEDENT>return self._blocks(name.replace('<STR_LIT>', '<STR_LIT:U+0020>'))<EOL>

Search for defined blocks recursively.
Allow '>' to be ignored. '.a .b' == '.a > .b'
Args:
    name (string): Search term
Returns:
    Block object OR False


i = len(self)<EOL>while i >= <NUM_LIT:0>:<EOL><INDENT>i -= <NUM_LIT:1><EOL>if name in self[i]['<STR_LIT>']:<EOL><INDENT>for b in self[i]['<STR_LIT>']:<EOL><INDENT>r = b.raw()<EOL>if r and r == name:<EOL><INDENT>return b<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for b in self[i]['<STR_LIT>']:<EOL><INDENT>r = b.raw()<EOL>if r and name.startswith(r):<EOL><INDENT>b = utility.blocksearch(b, name)<EOL>if b:<EOL><INDENT>return b<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return False<EOL>

Inner wrapper to search for blocks by name.


def update(self, scope, at=<NUM_LIT:0>):

if hasattr(scope, '<STR_LIT>') and not at:<EOL><INDENT>self._mixins.update(scope._mixins)<EOL><DEDENT>self[at]['<STR_LIT>'].update(scope[at]['<STR_LIT>'])<EOL>self[at]['<STR_LIT>'].extend(scope[at]['<STR_LIT>'])<EOL>self[at]['<STR_LIT>'].extend(scope[at]['<STR_LIT>'])<EOL>

Update scope. Add another scope to this one.
        Args:
            scope (Scope): Scope object
        Kwargs:
            at (int): Level to update


if name.startswith('<STR_LIT>'):<EOL><INDENT>var = self.variables(name[<NUM_LIT:1>:])<EOL>if var is False:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % name)<EOL><DEDENT>name = '<STR_LIT:@>' + utility.destring(var.value[<NUM_LIT:0>])<EOL>var = self.variables(name)<EOL>if var is False:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % name)<EOL><DEDENT><DEDENT>elif name.startswith('<STR_LIT>'):<EOL><INDENT>var = self.variables('<STR_LIT:@>' + name[<NUM_LIT:2>:-<NUM_LIT:1>])<EOL>if var is False:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % name)<EOL><DEDENT>if isinstance(var.value[<NUM_LIT:0>], string_types):<EOL><INDENT>var.value[<NUM_LIT:0>] = utility.destring(var.value[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>var = self.variables(name)<EOL>if var is False:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % name)<EOL><DEDENT><DEDENT>return var.value<EOL>

Swap variable name for variable value
        Args:
            name (str): Variable name
        Returns:
            Variable value (Mixed)


a, o, b = expression<EOL>c1 = self._hextorgb(a)<EOL>c2 = self._hextorgb(b)<EOL>r = ['<STR_LIT:#>']<EOL>for i in range(<NUM_LIT:3>):<EOL><INDENT>v = self.operate(c1[i], c2[i], o)<EOL>if v > <NUM_LIT>:<EOL><INDENT>v = <NUM_LIT><EOL><DEDENT>if v < <NUM_LIT:0>:<EOL><INDENT>v = <NUM_LIT:0><EOL><DEDENT>r.append("<STR_LIT>" % int(v))<EOL><DEDENT>return '<STR_LIT>'.join(r)<EOL>

Process color expression
        args:
            expression (tuple): color expression
        returns:
            str


def operate(self, left, right, operation):

operation = {<EOL>'<STR_LIT:+>': operator.add,<EOL>'<STR_LIT:->': operator.sub,<EOL>'<STR_LIT:*>': operator.mul,<EOL>'<STR_LIT:/>': operator.truediv<EOL>}.get(operation)<EOL>return operation(left, right)<EOL>

Do operation on colors
        args:
            left (str): left side
            right (str): right side
            operation (str): Operation
        returns:
            str


if len(args) == <NUM_LIT:4>:<EOL><INDENT>args = args[:<NUM_LIT:3>]<EOL><DEDENT>if len(args) == <NUM_LIT:3>:<EOL><INDENT>try:<EOL><INDENT>return self._rgbatohex(list(map(int, args)))<EOL><DEDENT>except ValueError:<EOL><INDENT>if all((a for a in args<EOL>if a[-<NUM_LIT:1>] == '<STR_LIT:%>' and <NUM_LIT:100> >= int(a[:-<NUM_LIT:1>]) >= <NUM_LIT:0>)):<EOL><INDENT>return self._rgbatohex(<EOL>[int(a[:-<NUM_LIT:1>]) * <NUM_LIT:255> / <NUM_LIT> for a in args])<EOL><DEDENT><DEDENT><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Translate rgb(...) to color string
        raises:
            ValueError
        returns:
            str


if len(args) == <NUM_LIT:4>:<EOL><INDENT>try:<EOL><INDENT>falpha = float(list(args)[<NUM_LIT:3>])<EOL>if falpha > <NUM_LIT:1>:<EOL><INDENT>args = args[:<NUM_LIT:3>]<EOL><DEDENT>if falpha == <NUM_LIT:0>:<EOL><INDENT>values = self._rgbatohex_raw(list(map(int, args)))<EOL>return "<STR_LIT>" % '<STR_LIT:U+002C>'.join([str(a) for a in values])<EOL><DEDENT>return self._rgbatohex(list(map(int, args)))<EOL><DEDENT>except ValueError:<EOL><INDENT>if all((a for a in args<EOL>if a[-<NUM_LIT:1>] == '<STR_LIT:%>' and <NUM_LIT:100> >= int(a[:-<NUM_LIT:1>]) >= <NUM_LIT:0>)):<EOL><INDENT>alpha = list(args)[<NUM_LIT:3>]<EOL>if alpha[-<NUM_LIT:1>] == '<STR_LIT:%>' and float(alpha[:-<NUM_LIT:1>]) == <NUM_LIT:0>:<EOL><INDENT>values = self._rgbatohex_raw(<EOL>[int(a[:-<NUM_LIT:1>]) * <NUM_LIT:255> / <NUM_LIT> for a in args])<EOL>return "<STR_LIT>" % '<STR_LIT:U+002C>'.join([str(a) for a in values])<EOL><DEDENT>return self._rgbatohex(<EOL>[int(a[:-<NUM_LIT:1>]) * <NUM_LIT:255> / <NUM_LIT> for a in args])<EOL><DEDENT><DEDENT><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Translate rgba(...) to color string
        raises:
            ValueError
        returns:
            str


if len(args) == <NUM_LIT:1> and type(args[<NUM_LIT:0>]) is str:<EOL><INDENT>match = re.match(r'<STR_LIT>', args[<NUM_LIT:0>])<EOL>if match:<EOL><INDENT>rgb = re.sub(r'<STR_LIT>', '<STR_LIT>', match.group(<NUM_LIT:1>)).split('<STR_LIT:U+002C>')<EOL><DEDENT>else:<EOL><INDENT>rgb = list(self._hextorgb(args[<NUM_LIT:0>]))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>rgb = list(args)<EOL><DEDENT>if len(rgb) == <NUM_LIT:3>:<EOL><INDENT>return self._rgbatohex([<NUM_LIT:255>] + list(map(int, rgb)))<EOL><DEDENT>elif len(rgb) == <NUM_LIT:4>:<EOL><INDENT>rgb = [rgb.pop()] + rgb  <EOL>try:<EOL><INDENT>fval = float(list(rgb)[<NUM_LIT:0>])<EOL>if fval > <NUM_LIT:1>:<EOL><INDENT>rgb = [<NUM_LIT:255>] + rgb[<NUM_LIT:1>:]  <EOL><DEDENT>elif <NUM_LIT:1> >= fval >= <NUM_LIT:0>:<EOL><INDENT>rgb = [<EOL>fval * <NUM_LIT><EOL>] + rgb[<NUM_LIT:1>:]  <EOL><DEDENT>else:<EOL><INDENT>rgb = [<NUM_LIT:0>] + rgb[<NUM_LIT:1>:]  <EOL><DEDENT>return self._rgbatohex(list(map(int, rgb)))<EOL><DEDENT>except ValueError:<EOL><INDENT>if all((a for a in rgb<EOL>if a[-<NUM_LIT:1>] == '<STR_LIT:%>' and <NUM_LIT:100> >= int(a[:-<NUM_LIT:1>]) >= <NUM_LIT:0>)):<EOL><INDENT>return self._rgbatohex(<EOL>[int(a[:-<NUM_LIT:1>]) * <NUM_LIT:255> / <NUM_LIT> for a in rgb])<EOL><DEDENT><DEDENT><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Translate argb(...) to color string

        Creates a hex representation of a color in #AARRGGBB format (NOT
        #RRGGBBAA!). This format is used in Internet Explorer, and .NET
        and Android development.

        raises:
            ValueError
        returns:
            str


if len(args) == <NUM_LIT:4>:<EOL><INDENT>return self.hsla(*args)<EOL><DEDENT>elif len(args) == <NUM_LIT:3>:<EOL><INDENT>h, s, l = args<EOL>rgb = colorsys.hls_to_rgb(<EOL>int(h) / <NUM_LIT>, utility.pc_or_float(l), utility.pc_or_float(s))<EOL>color = (utility.convergent_round(c * <NUM_LIT:255>) for c in rgb)<EOL>return self._rgbatohex(color)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Translate hsl(...) to color string
        raises:
            ValueError
        returns:
            str


if len(args) == <NUM_LIT:4>:<EOL><INDENT>h, s, l, a = args<EOL>rgb = colorsys.hls_to_rgb(<EOL>int(h) / <NUM_LIT>, utility.pc_or_float(l), utility.pc_or_float(s))<EOL>color = [float(utility.convergent_round(c * <NUM_LIT:255>)) for c in rgb]<EOL>color.append(utility.pc_or_float(a))<EOL>return "<STR_LIT>" % tuple(color)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Translate hsla(...) to color string
        raises:
            ValueError
        returns:
            str


if color:<EOL><INDENT>h, l, s = self._hextohls(color)<EOL>return utility.convergent_round(h * <NUM_LIT>, <NUM_LIT:3>)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Return the hue value of a color
        args:
            color (str): color
        raises:
            ValueError
        returns:
            float


if color:<EOL><INDENT>h, l, s = self._hextohls(color)<EOL>return s * <NUM_LIT><EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Return the saturation value of a color
        args:
            color (str): color
        raises:
            ValueError
        returns:
            float


if color:<EOL><INDENT>h, l, s = self._hextohls(color)<EOL>return l * <NUM_LIT><EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Return the lightness value of a color
        args:
            color (str): color
        raises:
            ValueError
        returns:
            float


if color and diff:<EOL><INDENT>return self._ophsl(color, diff, <NUM_LIT:1>, operator.add)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Lighten a color
        args:
            color (str): color
            diff (str): percentage
        returns:
            str


if color and diff:<EOL><INDENT>return self._ophsl(color, diff, <NUM_LIT:1>, operator.sub)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Darken a color
        args:
            color (str): color
            diff (str): percentage
        returns:
            str


if color and diff:<EOL><INDENT>return self._ophsl(color, diff, <NUM_LIT:2>, operator.add)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Saturate a color
        args:
            color (str): color
            diff (str): percentage
        returns:
            str


def desaturate(self, color, diff, *args):

if color and diff:<EOL><INDENT>return self._ophsl(color, diff, <NUM_LIT:2>, operator.sub)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Desaturate a color
        args:
            color (str): color
            diff (str): percentage
        returns:
            str


if color:<EOL><INDENT>return self.desaturate(color, <NUM_LIT>)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Simply 100% desaturate.
        args:
            color (str): color
        returns:
            str


return self.greyscale(color, *args)<EOL>


if color and degree:<EOL><INDENT>if isinstance(degree, string_types):<EOL><INDENT>degree = float(degree.strip('<STR_LIT:%>'))<EOL><DEDENT>h, l, s = self._hextohls(color)<EOL>h = ((h * <NUM_LIT>) + degree) % <NUM_LIT><EOL>h = <NUM_LIT> + h if h < <NUM_LIT:0> else h<EOL>rgb = colorsys.hls_to_rgb(h / <NUM_LIT>, l, s)<EOL>color = (utility.convergent_round(c * <NUM_LIT:255>) for c in rgb)<EOL>return self._rgbatohex(color)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Spin color by degree. (Increase / decrease hue)
        args:
            color (str): color
            degree (str): percentage
        raises:
            ValueError
        returns:
            str


def mix(self, color1, color2, weight=<NUM_LIT:50>, *args):

if color1 and color2:<EOL><INDENT>if isinstance(weight, string_types):<EOL><INDENT>weight = float(weight.strip('<STR_LIT:%>'))<EOL><DEDENT>weight = ((weight / <NUM_LIT>) * <NUM_LIT:2>) - <NUM_LIT:1><EOL>rgb1 = self._hextorgb(color1)<EOL>rgb2 = self._hextorgb(color2)<EOL>alpha = <NUM_LIT:0><EOL>w1 = (((weight if weight * alpha == -<NUM_LIT:1> else weight + alpha) /<EOL>(<NUM_LIT:1> + weight * alpha)) + <NUM_LIT:1>)<EOL>w1 = w1 / <NUM_LIT><EOL>w2 = <NUM_LIT:1> - w1<EOL>rgb = [<EOL>rgb1[<NUM_LIT:0>] * w1 + rgb2[<NUM_LIT:0>] * w2,<EOL>rgb1[<NUM_LIT:1>] * w1 + rgb2[<NUM_LIT:1>] * w2,<EOL>rgb1[<NUM_LIT:2>] * w1 + rgb2[<NUM_LIT:2>] * w2,<EOL>]<EOL>return self._rgbatohex(rgb)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

This algorithm factors in both the user-provided weight
        and the difference between the alpha values of the two colors
        to decide how to perform the weighted average of the two RGB values.

        It works by first normalizing both parameters to be within [-1, 1],
        where 1 indicates "only use color1", -1 indicates "only use color 0",
        and all values in between indicated a proportionately weighted average.

        Once we have the normalized variables w and a,
        we apply the formula (w + a)/(1 + w*a)
        to get the combined weight (in [-1, 1]) of color1.
        This formula has two especially nice properties:

         * When either w or a are -1 or 1, the combined weight is also that number
           (cases where w * a == -1 are undefined, and handled as a special case).

         * When a is 0, the combined weight is w, and vice versa

        Finally, the weight of color1 is renormalized to be within [0, 1]
        and the weight of color2 is given by 1 minus the weight of color1.

        Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
        http://sass-lang.com
        args:
            color1 (str): first color
            color2 (str): second color
            weight (int/str): weight
        raises:
            ValueError
        returns:
            str


if utility.is_color(color):<EOL><INDENT>color = color.lower().strip('<STR_LIT:#>')<EOL>if len(color) in [<NUM_LIT:3>, <NUM_LIT:4>]:<EOL><INDENT>color = '<STR_LIT>'.join([c * <NUM_LIT:2> for c in color])<EOL><DEDENT>return '<STR_LIT>' % color<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>

Format CSS Hex color code.
        uppercase becomes lowercase, 3 digit codes expand to 6 digit.
        args:
            color (str): color
        raises:
            ValueError
        returns:
            str


self.keyframe, = [<EOL>e[<NUM_LIT:0>] if isinstance(e, tuple) else e for e in self.tokens<EOL>if str(e).strip()<EOL>]<EOL>self.subparse = False<EOL>return self<EOL>

Parse node.
        args:
            scope (Scope): Current scope
        raises:
            SyntaxError
        returns:
            self


return KeyframeSelector(self.tokens, <NUM_LIT:0>)<EOL>

Return copy of self
        Returns:
            KeyframeSelector object


return self.keyframe<EOL>

Format identifier
        args:
            fills (dict): replacements
        returns:
            str (CSS)


self.name, args, self.guards = self.tokens[<NUM_LIT:0>]<EOL>self.args = [a for a in utility.flatten(args) if a]<EOL>self.body = Block([None, self.tokens[<NUM_LIT:1>]], <NUM_LIT:0>)<EOL>self.vars = list(<EOL>utility.flatten([<EOL>list(v.values()) for v in [s['<STR_LIT>'] for s in scope]<EOL>]))<EOL>return self<EOL>

Parse node
        args:
            scope (Scope): current scope
        raises:
            SyntaxError
        returns:
            self


return self.name.raw()<EOL>

Raw mixin name
        returns:
            str


arguments = list(zip(args,<EOL>['<STR_LIT:U+0020>'] * len(args))) if args and args[<NUM_LIT:0>] else None<EOL>zl = itertools.zip_longest if sys.version_info[<EOL><NUM_LIT:0>] == <NUM_LIT:3> else itertools.izip_longest<EOL>if self.args:<EOL><INDENT>parsed = [<EOL>v if hasattr(v, '<STR_LIT>') else v for v in copy.copy(self.args)<EOL>]<EOL>args = args if isinstance(args, list) else [args]<EOL>vars = [<EOL>self._parse_arg(var, arg, scope)<EOL>for arg, var in zl([a for a in args], parsed)<EOL>]<EOL>for var in vars:<EOL><INDENT>if var:<EOL><INDENT>var.parse(scope)<EOL><DEDENT><DEDENT>if not arguments:<EOL><INDENT>arguments = [v.value for v in vars if v]<EOL><DEDENT><DEDENT>if not arguments:<EOL><INDENT>arguments = '<STR_LIT>'<EOL><DEDENT>Variable(['<STR_LIT>', None, arguments]).parse(scope)<EOL>

Parse arguments to mixin. Add them to scope
        as variables. Sets upp special variable @arguments
        as well.
        args:
            args (list): arguments
            scope (Scope): current scope
        raises:
            SyntaxError


if isinstance(var, Variable):<EOL><INDENT>if arg:<EOL><INDENT>if utility.is_variable(arg[<NUM_LIT:0>]):<EOL><INDENT>tmp = scope.variables(arg[<NUM_LIT:0>])<EOL>if not tmp:<EOL><INDENT>return None<EOL><DEDENT>val = tmp.value<EOL><DEDENT>else:<EOL><INDENT>val = arg<EOL><DEDENT>var = Variable(var.tokens[:-<NUM_LIT:1>] + [val])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if utility.is_variable(var):<EOL><INDENT>if arg is None:<EOL><INDENT>raise SyntaxError('<STR_LIT>')<EOL><DEDENT>elif utility.is_variable(arg[<NUM_LIT:0>]):<EOL><INDENT>tmp = scope.variables(arg[<NUM_LIT:0>])<EOL>if not tmp:<EOL><INDENT>return None<EOL><DEDENT>val = tmp.value<EOL><DEDENT>else:<EOL><INDENT>val = arg<EOL><DEDENT>var = Variable([var, None, val])<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>return var<EOL>

Parse a single argument to mixin.
        args:
            var (Variable object): variable
            arg (mixed): argument
            scope (Scope object): current scope
        returns:
            Variable object or None


if self.guards:<EOL><INDENT>cor = True if '<STR_LIT:U+002C>' in self.guards else False<EOL>for g in self.guards:<EOL><INDENT>if isinstance(g, list):<EOL><INDENT>res = (g[<NUM_LIT:0>].parse(scope)<EOL>if len(g) == <NUM_LIT:1> else Expression(g).parse(scope))<EOL>if cor:<EOL><INDENT>if res:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif not res:<EOL><INDENT>return False<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return True<EOL>

Parse guards on mixin.
        args:
            scope (Scope): current scope
        raises:
            SyntaxError
        returns:
            bool (passes guards)


ret = False<EOL>if args:<EOL><INDENT>args = [[<EOL>a.parse(scope) if isinstance(a, Expression) else a for a in arg<EOL>] if arg else arg for arg in args]<EOL><DEDENT>try:<EOL><INDENT>self.parse_args(args, scope)<EOL><DEDENT>except SyntaxError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if self.parse_guards(scope):<EOL><INDENT>body = self.body.copy()<EOL>ret = body.tokens[<NUM_LIT:1>]<EOL>if ret:<EOL><INDENT>utility.rename(ret, scope, Block)<EOL><DEDENT><DEDENT><DEDENT>return ret<EOL>

Call mixin. Parses a copy of the mixins body
        in the current scope and returns it.
        args:
            scope (Scope): current scope
            args (list): arguments
        raises:
            SyntaxError
        returns:
            list or False


self.parsed = list(utility.flatten(self.tokens))<EOL>if self.parsed[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>if len(self.parsed) > <NUM_LIT:4>:<EOL><INDENT>self.parsed.insert(<NUM_LIT:3>, '<STR_LIT:U+0020>')<EOL><DEDENT><DEDENT>return self<EOL>


return '<STR_LIT>'.join(self.parsed) + fills['<STR_LIT>']<EOL>

Format node
        args:
            fills (dict): replacements
        returns:
            str


assert (len(self.tokens) == <NUM_LIT:3>)<EOL>expr = self.process(self.tokens, scope)<EOL>A, O, B = [<EOL>e[<NUM_LIT:0>] if isinstance(e, tuple) else e for e in expr<EOL>if str(e).strip()<EOL>]<EOL>try:<EOL><INDENT>a, ua = utility.analyze_number(A, '<STR_LIT>')<EOL>b, ub = utility.analyze_number(B, '<STR_LIT>')<EOL><DEDENT>except SyntaxError:<EOL><INDENT>return '<STR_LIT:U+0020>'.join([str(A), str(O), str(B)])<EOL><DEDENT>if (a is False or b is False):<EOL><INDENT>return '<STR_LIT:U+0020>'.join([str(A), str(O), str(B)])<EOL><DEDENT>if ua == '<STR_LIT>' or ub == '<STR_LIT>':<EOL><INDENT>return color.Color().process((A, O, B))<EOL><DEDENT>if a == <NUM_LIT:0> and O == '<STR_LIT:/>':<EOL><INDENT>return '<STR_LIT>'.join([str(A), str(O), str(B), '<STR_LIT:U+0020>'])<EOL><DEDENT>out = self.operate(a, b, O)<EOL>if isinstance(out, bool):<EOL><INDENT>return out<EOL><DEDENT>return self.with_units(out, ua, ub)<EOL>

Parse Node
        args:
            scope (Scope): Scope object
        raises:
            SyntaxError
        returns:
            str


if not val:<EOL><INDENT>return str(val)<EOL><DEDENT>if ua or ub:<EOL><INDENT>if ua and ub:<EOL><INDENT>if ua == ub:<EOL><INDENT>return str(val) + ua<EOL><DEDENT>else:<EOL><INDENT>return str(val) + ua<EOL><DEDENT><DEDENT>elif ua:<EOL><INDENT>return str(val) + ua<EOL><DEDENT>elif ub:<EOL><INDENT>return str(val) + ub<EOL><DEDENT><DEDENT>return repr(val)<EOL>

Return value with unit.
        args:
            val (mixed): result
            ua (str): 1st unit
            ub (str): 2nd unit
        raises:
            SyntaxError
        returns:
            str


operation = {<EOL>'<STR_LIT:+>': operator.add,<EOL>'<STR_LIT:->': operator.sub,<EOL>'<STR_LIT:*>': operator.mul,<EOL>'<STR_LIT:/>': operator.truediv,<EOL>'<STR_LIT:=>': operator.eq,<EOL>'<STR_LIT:>>': operator.gt,<EOL>'<STR_LIT:<>': operator.lt,<EOL>'<STR_LIT>': operator.ge,<EOL>'<STR_LIT>': operator.le,<EOL>}.get(oper)<EOL>if operation is None:<EOL><INDENT>raise SyntaxError("<STR_LIT>" % oper)<EOL><DEDENT>ret = operation(vala, valb)<EOL>if oper in '<STR_LIT>' and int(ret) == ret:<EOL><INDENT>ret = int(ret)<EOL><DEDENT>return ret<EOL>

Perform operation
        args:
            vala (mixed): 1st value
            valb (mixed): 2nd value
            oper (str): operation
        returns:
            mixed


return utility.flatten(self.tokens)<EOL>

Return str representation of expression
        returns:
            str


if not self.parsed:<EOL><INDENT>if len(self.tokens) > <NUM_LIT:2>:<EOL><INDENT>property, style, _ = self.tokens<EOL>self.important = True<EOL><DEDENT>else:<EOL><INDENT>property, style = self.tokens<EOL>self.important = False<EOL><DEDENT>self.property = '<STR_LIT>'.join(property)<EOL>self.parsed = []<EOL>if style:<EOL><INDENT>style = self.preprocess(style)<EOL>self.parsed = self.process(style, scope)<EOL><DEDENT><DEDENT>return self<EOL>


if self.property == '<STR_LIT>':<EOL><INDENT>style = [<EOL>'<STR_LIT>'.join(u.expression()) if hasattr(u, '<STR_LIT>') else u<EOL>for u in style<EOL>]<EOL><DEDENT>else:<EOL><INDENT>style = [(u, '<STR_LIT:U+0020>') if hasattr(u, '<STR_LIT>') else u<EOL>for u in style]<EOL><DEDENT>return style<EOL>

Hackish preprocessing from font shorthand tags.
        Skips expression parse on certain tags.
        args:
            style (list): .
        returns:
            list


f = "<STR_LIT>"<EOL>imp = '<STR_LIT>' if self.important else '<STR_LIT>'<EOL>if fills['<STR_LIT>']:<EOL><INDENT>self.parsed = [<EOL>'<STR_LIT>' % fills['<STR_LIT>'] if p == '<STR_LIT:U+002C>' else p for p in self.parsed<EOL>]<EOL><DEDENT>style = '<STR_LIT>'.join([<EOL>p.fmt(fills) if hasattr(p, '<STR_LIT>') else str(p) for p in self.parsed<EOL>])<EOL>style = re.sub("<STR_LIT>", "<STR_LIT>", style)<EOL>fills.update({<EOL>'<STR_LIT>': self.property,<EOL>'<STR_LIT>': style.strip(),<EOL>'<STR_LIT>': imp<EOL>})<EOL>return f % fills<EOL>


return Property([t for t in self.tokens], <NUM_LIT:0>)<EOL>

Return a full copy of self
        Returns:
            Property object


def __init__(self, mixin, args, lineno=<NUM_LIT:0>):

self.tokens = [mixin, args]<EOL>self.lineno = lineno<EOL>

This node represents mixin calls. The calls
        to these mixins are deferred until the second
        parse cycle. lessc.js allows calls to mixins not
        yet defined or known.
        args:
            mixin (Mixin): Mixin object
            args (list): Call arguments


def parse(self, scope, error=False, depth=<NUM_LIT:0>):

res = False<EOL>ident, args = self.tokens<EOL>ident.parse(scope)<EOL>mixins = scope.mixins(ident.raw())<EOL>if not mixins:<EOL><INDENT>ident.parse(None)<EOL>mixins = scope.mixins(ident.raw())<EOL><DEDENT>if depth > <NUM_LIT:64>:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % ident.raw(True))<EOL><DEDENT>if not mixins:<EOL><INDENT>if scope.deferred:<EOL><INDENT>store = [t for t in scope.deferred.parsed[-<NUM_LIT:1>]]<EOL>i = <NUM_LIT:0><EOL>while scope.deferred.parsed[-<NUM_LIT:1>]:<EOL><INDENT>scope.current = scope.deferred<EOL>ident.parse(scope)<EOL>mixins = scope.mixins(ident.raw())<EOL>scope.current = None<EOL>if mixins or i > <NUM_LIT:64>:<EOL><INDENT>break<EOL><DEDENT>scope.deferred.parsed[-<NUM_LIT:1>].pop()<EOL>i += <NUM_LIT:1><EOL><DEDENT>scope.deferred.parsed[-<NUM_LIT:1>] = store<EOL><DEDENT><DEDENT>if not mixins:<EOL><INDENT>block = scope.blocks(ident.raw())<EOL>if not block:<EOL><INDENT>ident.parse(None)<EOL>block = scope.blocks(ident.raw())<EOL><DEDENT>if block:<EOL><INDENT>scope.current = scope.real[-<NUM_LIT:1>] if scope.real else None<EOL>res = block.copy_inner(scope)<EOL>scope.current = None<EOL><DEDENT><DEDENT>if mixins:<EOL><INDENT>for mixin in mixins:<EOL><INDENT>scope.current = scope.real[-<NUM_LIT:1>] if scope.real else None<EOL>res = mixin.call(scope, args)<EOL>if res:<EOL><INDENT>[scope.add_variable(v) for v in mixin.vars]<EOL>scope.deferred = ident<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if res:<EOL><INDENT>store = [t for t in scope.deferred.parsed[-<NUM_LIT:1>]<EOL>] if scope.deferred else False<EOL>tmp_res = []<EOL>for p in res:<EOL><INDENT>if p:<EOL><INDENT>if isinstance(p, Deferred):<EOL><INDENT>tmp_res.append(p.parse(scope, depth=depth + <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>tmp_res.append(p.parse(scope))<EOL><DEDENT><DEDENT><DEDENT>res = tmp_res<EOL>while (any(t for t in res if isinstance(t, Deferred))):<EOL><INDENT>res = [p.parse(scope) for p in res if p]<EOL><DEDENT>if store:<EOL><INDENT>scope.deferred.parsed[-<NUM_LIT:1>] = store<EOL><DEDENT><DEDENT>if error and not res:<EOL><INDENT>raise SyntaxError('<STR_LIT>' % ident.raw(True))<EOL><DEDENT>return res<EOL>

Parse function. We search for mixins
        first within current scope then fallback
        to global scope. The special scope.deferred
        is used when local scope mixins are called
        within parent mixins.
        If nothing is found we fallback to block-mixin
        as lessc.js allows calls to blocks and mixins to
        be inter-changable.
        clx: This method is a HACK that stems from
        poor design elsewhere. I will fix it
        when I have more time.
        args:
            scope (Scope): Current scope
        returns:
            mixed


return self<EOL>

Returns self (used when Block objects are copy'd)
        returns:
            self


if not self.parsed:<EOL><INDENT>self.parsed = '<STR_LIT>'.join(self.process(self.tokens, scope))<EOL><DEDENT>return self.parsed<EOL>

Parse node
        args:
            scope (Scope): current scope
        raises:
            SyntaxError
        returns:
            parsed


return Import([t for t in self.tokens], <NUM_LIT:0>)<EOL>

Return a full copy of self
        Returns:
            Import object


self.name, _, self.value = self.tokens<EOL>if isinstance(self.name, tuple):<EOL><INDENT>if len(self.name) > <NUM_LIT:1>:<EOL><INDENT>self.name, pad = self.name<EOL>self.value.append(pad)<EOL><DEDENT>else:<EOL><INDENT>self.name = self.name[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>scope.add_variable(self)<EOL>return self<EOL>

Parse function
        args:
            scope (Scope): Scope object
        returns:
            self


return Variable([t for t in self.tokens])<EOL>

Return a copy of self
        Returns:
            Variable object


names = []<EOL>name = []<EOL>self._subp = ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>')<EOL>if self.tokens and hasattr(self.tokens, '<STR_LIT>'):<EOL><INDENT>self.tokens = list(<EOL>utility.flatten([<EOL>id.split() + ['<STR_LIT:U+002C>']<EOL>for id in self.tokens.parse(scope).split('<STR_LIT:U+002C>')<EOL>]))<EOL>self.tokens.pop()<EOL><DEDENT>if self.tokens and any(hasattr(t, '<STR_LIT>') for t in self.tokens):<EOL><INDENT>tmp_tokens = []<EOL>for t in self.tokens:<EOL><INDENT>if hasattr(t, '<STR_LIT>'):<EOL><INDENT>tmp_tokens.append(t.parse(scope))<EOL><DEDENT>else:<EOL><INDENT>tmp_tokens.append(t)<EOL><DEDENT><DEDENT>self.tokens = list(utility.flatten(tmp_tokens))<EOL><DEDENT>if self.tokens and self.tokens[<NUM_LIT:0>] in self._subp:<EOL><INDENT>name = list(utility.flatten(self.tokens))<EOL>self.subparse = True<EOL><DEDENT>else:<EOL><INDENT>self.subparse = False<EOL>for n in utility.flatten(self.tokens):<EOL><INDENT>if n == '<STR_LIT:*>':<EOL><INDENT>name.append('<STR_LIT>')<EOL><DEDENT>elif n in '<STR_LIT>':<EOL><INDENT>if name and name[-<NUM_LIT:1>] == '<STR_LIT:U+0020>':<EOL><INDENT>name.pop()<EOL><DEDENT>name.append('<STR_LIT>' % n)<EOL><DEDENT>elif n == '<STR_LIT:U+002C>':<EOL><INDENT>names.append(name)<EOL>name = []<EOL><DEDENT>else:<EOL><INDENT>name.append(n)<EOL><DEDENT><DEDENT><DEDENT>names.append(name)<EOL>parsed = self.root(scope, names) if scope else names<EOL>def replace_variables(tokens, scope):<EOL><INDENT>return [<EOL>scope.swap(t)<EOL>if (utility.is_variable(t) and not t in reserved.tokens) else t<EOL>for t in tokens<EOL>]<EOL><DEDENT>parsed = [<EOL>list(utility.flatten(replace_variables(part, scope)))<EOL>for part in parsed<EOL>]<EOL>self.parsed = [[<EOL>i for i, j in utility.pairwise(part)<EOL>if i != '<STR_LIT:U+0020>' or (j and '<STR_LIT:?>' not in j)<EOL>] for part in parsed]<EOL>return self<EOL>

Parse node. Block identifiers are stored as
        strings with spaces replaced with ?
        args:
            scope (Scope): Current scope
        raises:
            SyntaxError
        returns:
            self


parent = scope.scopename<EOL>if parent:<EOL><INDENT>parent = parent[-<NUM_LIT:1>]<EOL>if parent.parsed:<EOL><INDENT>parsed_names = []<EOL>for name in names:<EOL><INDENT>ampersand_count = name.count('<STR_LIT:&>')<EOL>if ampersand_count:<EOL><INDENT>filtered_parts = []<EOL>for part in parent.parsed:<EOL><INDENT>if part and part[<NUM_LIT:0>] not in self._subp:<EOL><INDENT>filtered_parts.append(part)<EOL><DEDENT><DEDENT>permutations = list(<EOL>utility.permutations_with_replacement(<EOL>filtered_parts, ampersand_count))<EOL>for permutation in permutations:<EOL><INDENT>parsed = []<EOL>for name_part in name:<EOL><INDENT>if name_part == "<STR_LIT:&>":<EOL><INDENT>parent_part = permutation.pop(<NUM_LIT:0>)<EOL>if parsed and parsed[-<NUM_LIT:1>].endswith('<STR_LIT:]>'):<EOL><INDENT>parsed.extend('<STR_LIT:U+0020>')<EOL><DEDENT>if parent_part[-<NUM_LIT:1>] == '<STR_LIT:U+0020>':<EOL><INDENT>parent_part.pop()<EOL><DEDENT>parsed.extend(parent_part)<EOL><DEDENT>else:<EOL><INDENT>parsed.append(name_part)<EOL><DEDENT><DEDENT>parsed_names.append(parsed)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for part in parent.parsed:<EOL><INDENT>if part and part[<NUM_LIT:0>] not in self._subp:<EOL><INDENT>parsed = []<EOL>if name[<NUM_LIT:0>] == "<STR_LIT>":<EOL><INDENT>parsed.extend(name)<EOL><DEDENT>else:<EOL><INDENT>parsed.extend(part)<EOL>if part[-<NUM_LIT:1>] != '<STR_LIT:U+0020>':<EOL><INDENT>parsed.append('<STR_LIT:U+0020>')<EOL><DEDENT>parsed.extend(name)<EOL><DEDENT>parsed_names.append(parsed)<EOL><DEDENT>else:<EOL><INDENT>parsed_names.append(name)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return parsed_names<EOL><DEDENT><DEDENT>return names<EOL>

Find root of identifier, from scope
        args:
            scope (Scope): current scope
            names (list): identifier name list (, separated identifiers)
        returns:
            list


if clean:<EOL><INDENT>return '<STR_LIT>'.join('<STR_LIT>'.join(p) for p in self.parsed).replace('<STR_LIT:?>', '<STR_LIT:U+0020>')<EOL><DEDENT>return '<STR_LIT:%>'.join('<STR_LIT:%>'.join(p) for p in self.parsed).strip().strip('<STR_LIT:%>')<EOL>

Raw identifier.
        args:
            clean (bool): clean name
        returns:
            str


tokens = ([t for t in self.tokens]<EOL>if isinstance(self.tokens, list) else self.tokens)<EOL>return Identifier(tokens, <NUM_LIT:0>)<EOL>

Return copy of self
        Returns:
            Identifier object


name = '<STR_LIT>'.join('<STR_LIT>'.join(p).strip() for p in self.parsed)<EOL>name = re.sub('<STR_LIT>', '<STR_LIT>', name) % fills<EOL>return name.replace('<STR_LIT>', fills['<STR_LIT>']).replace('<STR_LIT:U+0020>', '<STR_LIT:U+0020>')<EOL>

Format identifier
        args:
            fills (dict): replacements
        returns:
            str (CSS)


if not self.parsed:<EOL><INDENT>scope.push()<EOL>self.name, inner = self.tokens<EOL>scope.current = self.name<EOL>scope.real.append(self.name)<EOL>if not self.name.parsed:<EOL><INDENT>self.name.parse(scope)<EOL><DEDENT>if not inner:<EOL><INDENT>inner = []<EOL><DEDENT>inner = list(utility.flatten([p.parse(scope) for p in inner if p]))<EOL>self.parsed = []<EOL>self.inner = []<EOL>if not hasattr(self, "<STR_LIT>"):<EOL><INDENT>self.inner_media_queries = []<EOL><DEDENT>for p in inner:<EOL><INDENT>if p is not None:<EOL><INDENT>if isinstance(p, Block):<EOL><INDENT>if (len(scope) == <NUM_LIT:2> and p.tokens[<NUM_LIT:1>] is not None):<EOL><INDENT>p_is_mediaquery = p.name.tokens[<NUM_LIT:0>] == '<STR_LIT>'<EOL>append_list = []<EOL>reparse_p = False<EOL>for child in p.tokens[<NUM_LIT:1>]:<EOL><INDENT>if isinstance(child, Block) and child.name.raw(<EOL>).startswith("<STR_LIT>"):<EOL><INDENT>p.tokens[<NUM_LIT:1>].remove(child)<EOL>if p_is_mediaquery:  <EOL><INDENT>reparse_p = True<EOL>part_a = p.name.tokens[<NUM_LIT:2>:][<NUM_LIT:0>][<NUM_LIT:0>][<NUM_LIT:0>]<EOL>part_b = child.name.tokens[<NUM_LIT:2>:][<NUM_LIT:0>][<NUM_LIT:0>]<EOL>new_ident_tokens = [<EOL>'<STR_LIT>', '<STR_LIT:U+0020>', [<EOL>part_a, ('<STR_LIT:U+0020>', '<STR_LIT>', '<STR_LIT:U+0020>'),<EOL>part_b<EOL>]<EOL>]<EOL>child.tokens[<NUM_LIT:0>] = Identifier(<EOL>new_ident_tokens)<EOL>child.parsed = None<EOL>child = child.parse(scope)<EOL><DEDENT>else:<EOL><INDENT>child.block_name = p.name<EOL><DEDENT>append_list.append(child)<EOL><DEDENT>if reparse_p:<EOL><INDENT>p.parsed = None<EOL>p = p.parse(scope)<EOL><DEDENT><DEDENT>if not p_is_mediaquery and not append_list:<EOL><INDENT>self.inner.append(p)<EOL><DEDENT>else:<EOL><INDENT>append_list.insert(<EOL><NUM_LIT:0>, p<EOL>)  <EOL>for media_query in append_list:<EOL><INDENT>self.inner_media_queries.append(<EOL>media_query)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self.inner.append(p)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.parsed.append(p)<EOL><DEDENT><DEDENT><DEDENT>if self.inner_media_queries:<EOL><INDENT>scope.remove_block(self, index=-<NUM_LIT:2>)<EOL>for mb in self.inner_media_queries:<EOL><INDENT>if hasattr(mb, '<STR_LIT>'):<EOL><INDENT>cb_name = mb.block_name<EOL><DEDENT>else:<EOL><INDENT>cb_name = self.tokens[<NUM_LIT:0>]<EOL><DEDENT>cb = Block([cb_name, mb.tokens[<NUM_LIT:1>]]).parse(scope)<EOL>new_mb = Block([mb.tokens[<NUM_LIT:0>], [cb]]).parse(scope)<EOL>self.inner.append(new_mb)<EOL>scope.add_block(new_mb)<EOL><DEDENT><DEDENT>scope.real.pop()<EOL>scope.pop()<EOL><DEDENT>return self<EOL>

Parse block node.
        args:
            scope (Scope): Current scope
        raises:
            SyntaxError
        returns:
            self


try:<EOL><INDENT>return self.tokens[<NUM_LIT:0>].raw(clean)<EOL><DEDENT>except (AttributeError, TypeError):<EOL><INDENT>pass<EOL><DEDENT>

Raw block name
        args:
            clean (bool): clean name
        returns:
            str


f = "<STR_LIT>"<EOL>out = []<EOL>name = self.name.fmt(fills)<EOL>if self.parsed and any(<EOL>p for p in self.parsed<EOL>if str(type(p)) != "<STR_LIT>"):<EOL><INDENT>fills.update({<EOL>'<STR_LIT>':<EOL>name,<EOL>'<STR_LIT>':<EOL>'<STR_LIT>'.join([p.fmt(fills) for p in self.parsed if p]),<EOL>})<EOL>out.append(f % fills)<EOL><DEDENT>if hasattr(self, '<STR_LIT>'):<EOL><INDENT>if self.name.subparse and len(self.inner) > <NUM_LIT:0>:  <EOL><INDENT>inner = '<STR_LIT>'.join([p.fmt(fills) for p in self.inner])<EOL>inner = inner.replace(fills['<STR_LIT>'],<EOL>fills['<STR_LIT>'] + fills['<STR_LIT>']).rstrip(<EOL>fills['<STR_LIT>'])<EOL>if not fills['<STR_LIT>']:<EOL><INDENT>inner = inner.strip()<EOL><DEDENT>fills.update({<EOL>'<STR_LIT>': name,<EOL>'<STR_LIT>': fills['<STR_LIT>'] + inner<EOL>})<EOL>out.append(f % fills)<EOL><DEDENT>else:<EOL><INDENT>out.append('<STR_LIT>'.join([p.fmt(fills) for p in self.inner]))<EOL><DEDENT><DEDENT>return '<STR_LIT>'.join(out)<EOL>

Format block (CSS)
        args:
            fills (dict): Fill elements
        returns:
            str (CSS)


name, inner = self.tokens<EOL>if inner:<EOL><INDENT>inner = [u.copy() if u else u for u in inner]<EOL><DEDENT>if name:<EOL><INDENT>name = name.copy()<EOL><DEDENT>return Block([name, inner], <NUM_LIT:0>)<EOL>

Return a full copy of self
        returns: Block object


if self.tokens[<NUM_LIT:1>]:<EOL><INDENT>tokens = [u.copy() if u else u for u in self.tokens[<NUM_LIT:1>]]<EOL>out = [p for p in tokens if p]<EOL>utility.rename(out, scope, Block)<EOL>return out<EOL><DEDENT>return None<EOL>

Copy block contents (properties, inner blocks).
        Renames inner block from current scope.
        Used for mixins.
        args:
            scope (Scope): Current scope
        returns:
            list (block contents)


def __init__(self, tokens, lineno=<NUM_LIT:0>):

self.tokens = tokens<EOL>self.lineno = lineno<EOL>self.parsed = False<EOL>

Base Node
        args:
            tokens (list): tokenlist
            lineno (int): Line number of node


return self<EOL>

Base parse function
        args:
            scope (Scope): Current scope
        returns:
            self


while True:<EOL><INDENT>tokens = list(utility.flatten(tokens))<EOL>done = True<EOL>if any(t for t in tokens if hasattr(t, '<STR_LIT>')):<EOL><INDENT>tokens = [<EOL>t.parse(scope) if hasattr(t, '<STR_LIT>') else t<EOL>for t in tokens<EOL>]<EOL>done = False<EOL><DEDENT>if any(<EOL>t for t in tokens<EOL>if (utility.is_variable(t)) or str(type(t)) ==<EOL>"<STR_LIT>"):<EOL><INDENT>tokens = self.replace_variables(tokens, scope)<EOL>done = False<EOL><DEDENT>if done:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return tokens<EOL>

Process tokenslist, flattening and parsing it
        args:
            tokens (list): tokenlist
            scope (Scope): Current scope
        returns:
            list


def replace_variables(self, tokens, scope):

list = []<EOL>for t in tokens:<EOL><INDENT>if utility.is_variable(t):<EOL><INDENT>list.append(scope.swap(t))<EOL><DEDENT>elif str(type(t)) == "<STR_LIT>":<EOL><INDENT>list.append(scope.swap(t.name))<EOL><DEDENT>else:<EOL><INDENT>list.append(t)<EOL><DEDENT><DEDENT>return list<EOL>

Replace variables in tokenlist
        args:
            tokens (list): tokenlist
            scope (Scope): Current scope
        returns:
            list


raise ValueError('<STR_LIT>')<EOL>

Format node
        args:
            fills (dict): replacements
        returns:
            str


name = '<STR_LIT>'.join(self.tokens[<NUM_LIT:0>])<EOL>parsed = self.process(self.tokens[<NUM_LIT:1>:], scope)<EOL>if name == '<STR_LIT>':<EOL><INDENT>name = '<STR_LIT>'<EOL><DEDENT>elif name in ('<STR_LIT>', '<STR_LIT:e>'):<EOL><INDENT>name = '<STR_LIT>'<EOL><DEDENT>color = Color.Color()<EOL>args = [<EOL>t for t in parsed<EOL>if not isinstance(t, string_types) or t not in '<STR_LIT>'<EOL>]<EOL>if hasattr(self, name):<EOL><INDENT>try:<EOL><INDENT>return getattr(self, name)(*args)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if hasattr(color, name):<EOL><INDENT>try:<EOL><INDENT>result = getattr(color, name)(*args)<EOL>try:<EOL><INDENT>return result + '<STR_LIT:U+0020>'<EOL><DEDENT>except TypeError:<EOL><INDENT>return result<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return name + '<STR_LIT>'.join([p for p in parsed])<EOL>

Parse Node within scope.
        the functions ~( and e( map to self.escape
        and %( maps to self.sformat
        args:
            scope (Scope): Current scope


return utility.destring(string.strip('<STR_LIT>'))<EOL>

Less Escape.
        args:
            string (str): string to escape
        returns:
            str


format = string<EOL>items = []<EOL>m = re.findall('<STR_LIT>', format)<EOL>if m and not args:<EOL><INDENT>raise SyntaxError('<STR_LIT>')<EOL><DEDENT>i = <NUM_LIT:0><EOL>for n in m:<EOL><INDENT>v = {<EOL>'<STR_LIT>': urlquote,<EOL>'<STR_LIT:%s>': utility.destring,<EOL>}.get(n, str)(args[i])<EOL>items.append(v)<EOL>i += <NUM_LIT:1><EOL><DEDENT>format = format.replace('<STR_LIT>', '<STR_LIT:%s>')<EOL>format = format.replace('<STR_LIT>', '<STR_LIT:%s>')<EOL>return format % tuple(items)<EOL>

String format.
        args:
            string (str): string to format
            args (list): format options
        returns:
            str


try:<EOL><INDENT>n, u = utility.analyze_number(string)<EOL><DEDENT>except SyntaxError:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>

Is number
        args:
            string (str): match
        returns:
            bool


return (string in lessColors)<EOL>

Is color
        args:
            string (str): match
        returns:
            bool


arg = utility.destring(string)<EOL>regex = re.compile(<EOL>r'<STR_LIT>'  <EOL>r'<STR_LIT>'<EOL>r'<STR_LIT>'  <EOL>r'<STR_LIT>'<EOL>r'<STR_LIT>'  <EOL>r'<STR_LIT>'<EOL>r'<STR_LIT>',<EOL>re.IGNORECASE)<EOL>return regex.match(arg)<EOL>

Is url
        args:
            string (str): match
        returns:
            bool


regex = re.compile(r'<STR_LIT>')<EOL>return regex.match(string)<EOL>

Is string
        args:
            string (str): match
        returns:
            bool


return (string in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL>

Is less keyword
        args:
            string (str): match
        returns:
            bool


n, u = utility.analyze_number(value)<EOL>return utility.with_unit(n + <NUM_LIT:1>, u)<EOL>

Increment function
        args:
            value (str): target
        returns:
            str


n, u = utility.analyze_number(value)<EOL>return utility.with_unit(n - <NUM_LIT:1>, u)<EOL>

Decrement function
        args:
            value (str): target
        returns:
            str


if (len(args) <= <NUM_LIT:1>):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>return sum([int(v) for v in args])<EOL>

Add integers
        args:
            args (list): target
        returns:
            str


n, u = utility.analyze_number(value)<EOL>return utility.with_unit(<EOL>int(utility.away_from_zero_round(float(n))), u)<EOL>

Round number
        args:
            value (str): target
        returns:
            str


n, u = utility.analyze_number(value)<EOL>return utility.with_unit(int(math.ceil(n)), u)<EOL>

Ceil number
        args:
            value (str): target
        returns:
            str


n, u = utility.analyze_number(value)<EOL>return utility.with_unit(int(math.floor(n)), u)<EOL>

Floor number
        args:
            value (str): target
        returns:
            str


n, u = utility.analyze_number(value)<EOL>n = int(n * <NUM_LIT>)<EOL>u = '<STR_LIT:%>'<EOL>return utility.with_unit(n, u)<EOL>

Return percentage value
        args:
            value (str): target
        returns:
            str


def ldirectory(inpath, outpath, args, scope):

yacctab = '<STR_LIT>' if args.debug else None<EOL>if not outpath:<EOL><INDENT>sys.exit("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>if not os.path.isdir(outpath):<EOL><INDENT>if args.verbose:<EOL><INDENT>print("<STR_LIT>" % outpath, file=sys.stderr)<EOL><DEDENT>if not args.dry_run:<EOL><INDENT>os.mkdir(outpath)<EOL><DEDENT><DEDENT><DEDENT>less = glob.glob(os.path.join(inpath, '<STR_LIT>'))<EOL>f = formatter.Formatter(args)<EOL>for lf in less:<EOL><INDENT>outf = os.path.splitext(os.path.basename(lf))<EOL>minx = '<STR_LIT>' if args.min_ending else '<STR_LIT>'<EOL>outf = "<STR_LIT>" % (outpath, outf[<NUM_LIT:0>], minx)<EOL>if not args.force and os.path.exists(outf):<EOL><INDENT>recompile = os.path.getmtime(outf) < os.path.getmtime(lf)<EOL><DEDENT>else:<EOL><INDENT>recompile = True<EOL><DEDENT>if recompile:<EOL><INDENT>print('<STR_LIT>' % (lf, outf))<EOL>p = parser.LessParser(<EOL>yacc_debug=(args.debug),<EOL>lex_optimize=True,<EOL>yacc_optimize=(not args.debug),<EOL>scope=scope,<EOL>tabfile=yacctab,<EOL>verbose=args.verbose)<EOL>p.parse(filename=lf, debuglevel=<NUM_LIT:0>)<EOL>css = f.format(p)<EOL>if not args.dry_run:<EOL><INDENT>with open(outf, '<STR_LIT:w>') as outfile:<EOL><INDENT>outfile.write(css)<EOL><DEDENT><DEDENT><DEDENT>elif args.verbose:<EOL><INDENT>print('<STR_LIT>' % lf, file=sys.stderr)<EOL><DEDENT>sys.stdout.flush()<EOL><DEDENT>if args.recurse:<EOL><INDENT>[<EOL>ldirectory(<EOL>os.path.join(inpath, name), os.path.join(outpath, name), args,<EOL>scope) for name in os.listdir(inpath)<EOL>if os.path.isdir(os.path.join(inpath, name))<EOL>and not name.startswith('<STR_LIT:.>') and not name == outpath<EOL>]<EOL><DEDENT>

Compile all *.less files in directory
    Args:
        inpath (str): Path to compile
        outpath (str): Output directory
        args (object): Argparse Object
        scope (Scope): Scope object or None


return '<STR_LIT:.>'.join(str(i) for i in VERSION[:<NUM_LIT:3>])<EOL>


ip = get_real_ip(request)<EOL>if ip is None:<EOL><INDENT>ip = get_ip(request)<EOL>if ip is None:<EOL><INDENT>ip = '<STR_LIT:127.0.0.1>'<EOL><DEDENT><DEDENT>return ip<EOL>

Return user ip

    :param request: Django request object
    :return: user ip


api_key = kwargs.get('<STR_LIT>', None)<EOL>api_host = kwargs.get('<STR_LIT>', None)<EOL>api_timeout = kwargs.get('<STR_LIT>', None)<EOL>use_cache = kwargs.get('<STR_LIT>', None)<EOL>cache_backend = kwargs.get('<STR_LIT>', None)<EOL>cache_timeout = kwargs.get('<STR_LIT>', None)<EOL>no_api_key = True<EOL>if hasattr(settings, '<STR_LIT>'):<EOL><INDENT>self._api_key = api_key if api_key else settings.CACHED_HTTPBL_API_KEY<EOL>if self._api_key is not None:<EOL><INDENT>no_api_key = False<EOL><DEDENT><DEDENT>if no_api_key:<EOL><INDENT>raise ImproperlyConfigured(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>self._last_result = None<EOL>self._api_host = api_host if api_host else settings.CACHED_HTTPBL_API_HOST<EOL>self._api_timeout = api_timeout if api_timeout else settings.CACHED_HTTPBL_API_TIMEOUT<EOL>self._use_cache = use_cache if use_cache else settings.CACHED_HTTPBL_USE_CACHE<EOL>self._cache_backend = cache_backend if cache_backend else settings.CACHED_HTTPBL_CACHE_BACKEND<EOL>self._cache_timeout = cache_timeout if cache_timeout else settings.CACHED_HTTPBL_CACHE_TIMEOUT<EOL>self._cache_version = <NUM_LIT:1><EOL>if self._use_cache and self._cache_backend is None:<EOL><INDENT>self._cache_backend = '<STR_LIT:default>'<EOL><DEDENT>if self._use_cache:<EOL><INDENT>try:<EOL><INDENT>self._cache = cache.caches[self._cache_backend]<EOL>try:<EOL><INDENT>self._cache_version = int(self._cache.get('<STR_LIT>'.format(self._api_key)))<EOL><DEDENT>except TypeError:<EOL><INDENT>self._cache.set('<STR_LIT>'.format(self._api_key), str(<NUM_LIT:1>))<EOL><DEDENT><DEDENT>except cache.InvalidCacheBackendError:<EOL><INDENT>raise ImproperlyConfigured('<STR_LIT>')<EOL><DEDENT><DEDENT>

Instantiate the CachedHTTPBL object.

:param kwargs: optional parameters
:return:


self._last_result = None<EOL>if is_valid_ipv4(ip):<EOL><INDENT>key = None<EOL>if self._use_cache:<EOL><INDENT>key = self._make_cache_key(ip)<EOL>self._last_result = self._cache.get(key, version=self._cache_version)<EOL><DEDENT>if self._last_result is None:<EOL><INDENT>error, age, threat, type = self._request_httpbl(ip)<EOL>if error == <NUM_LIT> or error == <NUM_LIT:0>:<EOL><INDENT>self._last_result = {<EOL>'<STR_LIT:error>': error,<EOL>'<STR_LIT>': age,<EOL>'<STR_LIT>': threat,<EOL>'<STR_LIT:type>': type<EOL>}<EOL>if self._use_cache:<EOL><INDENT>self._cache.set(key, self._last_result, timeout=self._api_timeout, version=self._cache_version)<EOL><DEDENT><DEDENT><DEDENT>if self._last_result is not None and settings.CACHED_HTTPBL_USE_LOGGING:<EOL><INDENT>logger.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(ip,<EOL>self._last_result['<STR_LIT:error>'],<EOL>self._last_result['<STR_LIT>'],<EOL>self._last_result['<STR_LIT>'],<EOL>self._last_result['<STR_LIT:type>']<EOL>)<EOL>)<EOL><DEDENT><DEDENT>return self._last_result<EOL>

Check IP trough the httpBL API

:param ip: ipv4 ip address
:return: httpBL results or None if any error is occurred


def is_threat(self, result=None, harmless_age=None, threat_score=None, threat_type=None):

harmless_age = harmless_age if harmless_age is not None else settings.CACHED_HTTPBL_HARMLESS_AGE<EOL>threat_score = threat_score if threat_score is not None else settings.CACHED_HTTPBL_THREAT_SCORE<EOL>threat_type = threat_type if threat_type is not None else -<NUM_LIT:1><EOL>result = result if result is not None else self._last_result<EOL>threat = False<EOL>if result is not None:<EOL><INDENT>if result['<STR_LIT>'] < harmless_age and result['<STR_LIT>'] > threat_score:<EOL><INDENT>threat = True<EOL><DEDENT>if threat_type > -<NUM_LIT:1>:<EOL><INDENT>if result['<STR_LIT:type>'] & threat_type:<EOL><INDENT>threat = True<EOL><DEDENT>else:<EOL><INDENT>threat = False<EOL><DEDENT><DEDENT><DEDENT>return threat<EOL>

Check if IP is a threat

:param result: httpBL results; if None, then results from last check_ip() used (optional)
:param harmless_age: harmless age for check if httpBL age is older (optional)
:param threat_score: threat score for check if httpBL threat is lower (optional)
:param threat_type:  threat type, if not equal httpBL score type, then return False (optional)
:return: True or False


result = result if result is not None else self._last_result<EOL>suspicious = False<EOL>if result is not None:<EOL><INDENT>suspicious = True if result['<STR_LIT:type>'] > <NUM_LIT:0> else False<EOL><DEDENT>return suspicious<EOL>

Check if IP is suspicious

:param result: httpBL results; if None, then results from last check_ip() used (optional)
:return: True or False


if self._use_cache:<EOL><INDENT>key = self._make_cache_key(ip)<EOL>self._cache.delete(key, version=self._cache_version)<EOL><DEDENT>

Invalidate httpBL cache for IP address

:param ip: ipv4 IP address


if self._use_cache:<EOL><INDENT>self._cache_version += <NUM_LIT:1><EOL>self._cache.increment('<STR_LIT>'.format(self._api_key))<EOL><DEDENT>


<EOL>def wrapped_view(*args, **kwargs):<EOL><INDENT>return view_func(*args, **kwargs)<EOL><DEDENT>wrapped_view.cached_httpbl_exempt = True<EOL>return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)<EOL>

Marks a view function as being exempt from the cached httpbl view protection.


def __init__(self, oauth_version, consumer_key, consumer_secret, **kwargs):

self.oauth_version = oauth_version<EOL>data = {}<EOL>if kwargs.get('<STR_LIT>'):<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>self.from_file = kwargs.get('<STR_LIT>')<EOL>data = get_data(self.from_file)<EOL>vars(self).update(data)<EOL><DEDENT>else:<EOL><INDENT>self.consumer_key = consumer_key<EOL>self.consumer_secret = consumer_secret<EOL><DEDENT>vars(self).update(kwargs)<EOL>self.oauth_version = oauth_version<EOL>self.callback_uri = vars(self).get('<STR_LIT>',CALLBACK_URI)<EOL>if self.oauth_version == '<STR_LIT>':<EOL><INDENT>service_params = {<EOL>'<STR_LIT>': self.consumer_key,<EOL>'<STR_LIT>' : self.consumer_secret,<EOL>'<STR_LIT>': services[self.oauth_version]['<STR_LIT>']<EOL>}<EOL><DEDENT>else:<EOL><INDENT>service_params = {<EOL>'<STR_LIT>': self.consumer_key,<EOL>'<STR_LIT>': self.consumer_secret<EOL>}<EOL><DEDENT>service_params.update({<EOL>'<STR_LIT:name>' : '<STR_LIT>',<EOL>'<STR_LIT>' : services[self.oauth_version]['<STR_LIT>'],<EOL>'<STR_LIT>' : services[self.oauth_version]['<STR_LIT>'],<EOL>'<STR_LIT>': vars(self).get('<STR_LIT>',None)<EOL>})<EOL>self.oauth = services[oauth_version]['<STR_LIT>'](**service_params)<EOL>if vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>'):<EOL><INDENT>if not self.token_is_valid():<EOL><INDENT>data.update(self.refresh_access_token())<EOL><DEDENT><DEDENT>elif vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>'):<EOL><INDENT>if not self.token_is_valid():<EOL><INDENT>data.update(self.refresh_access_token())<EOL><DEDENT><DEDENT>else:<EOL><INDENT>data.update(self.handler()) <EOL><DEDENT>if self.oauth_version == '<STR_LIT>':<EOL><INDENT>self.session = self.oauth.get_session((self.access_token, self.access_token_secret))<EOL><DEDENT>else:<EOL><INDENT>self.session = self.oauth.get_session(token=self.access_token)<EOL><DEDENT>write_data(data, vars(self).get('<STR_LIT>','<STR_LIT>'))<EOL>

consumer_key : client key
consumer_secret : client secret
access_token : access token
access_token_secret : access token secret
from_file : file containing the credentials
base_url : Base url


if self.oauth_version == '<STR_LIT>':<EOL><INDENT>request_token, request_token_secret = self.oauth.get_request_token(params={'<STR_LIT>': self.callback_uri})<EOL>logger.debug("<STR_LIT>".format(request_token, request_token_secret))<EOL>authorize_url = self.oauth.get_authorize_url(request_token)<EOL><DEDENT>else:<EOL><INDENT>authorize_url = self.oauth.get_authorize_url(client_secret=self.consumer_secret, redirect_uri=self.callback_uri, response_type='<STR_LIT:code>')<EOL><DEDENT>logger.debug("<STR_LIT>".format(authorize_url))<EOL>webbrowser.open(authorize_url)<EOL>self.verifier = input("<STR_LIT>")<EOL>self.token_time = time.time()<EOL>credentials = {'<STR_LIT>': self.token_time}<EOL>if self.oauth_version == '<STR_LIT>':<EOL><INDENT>raw_access = self.oauth.get_raw_access_token(request_token, request_token_secret, params={"<STR_LIT>": self.verifier})<EOL>parsed_access = parse_utf8_qsl(raw_access.content)<EOL>self.access_token = parsed_access['<STR_LIT>']<EOL>self.access_token_secret = parsed_access['<STR_LIT>']<EOL>self.session_handle = parsed_access['<STR_LIT>']<EOL>self.guid = parsed_access['<STR_LIT>']<EOL>credentials.update({<EOL>'<STR_LIT>': self.access_token,<EOL>'<STR_LIT>': self.access_token_secret,<EOL>'<STR_LIT>': self.session_handle,<EOL>'<STR_LIT>': self.guid<EOL>})<EOL><DEDENT>else:<EOL><INDENT>headers = self.generate_oauth2_headers()<EOL>raw_access = self.oauth.get_raw_access_token(data={"<STR_LIT:code>": self.verifier, '<STR_LIT>': self.callback_uri,'<STR_LIT>':'<STR_LIT>'}, headers=headers)<EOL>credentials.update(self.oauth2_access_parser(raw_access))<EOL><DEDENT>return credentials<EOL>

* get request token if OAuth1
            * Get user authorization
            * Get access token


parsed_access = json.loads(raw_access.content.decode('<STR_LIT:utf-8>'))<EOL>self.access_token = parsed_access['<STR_LIT>']<EOL>self.token_type = parsed_access['<STR_LIT>']<EOL>self.refresh_token = parsed_access['<STR_LIT>']<EOL>self.guid = parsed_access['<STR_LIT>']<EOL>credentials = {<EOL>'<STR_LIT>': self.access_token,<EOL>'<STR_LIT>': self.token_type,<EOL>'<STR_LIT>': self.refresh_token,<EOL>'<STR_LIT>': self.guid<EOL>}<EOL>return credentials<EOL>


logger.debug("<STR_LIT>")<EOL>self.token_time = time.time()<EOL>credentials = {<EOL>'<STR_LIT>': self.token_time<EOL>}<EOL>if self.oauth_version == '<STR_LIT>':<EOL><INDENT>self.access_token, self.access_token_secret = self.oauth.get_access_token(self.access_token, self.access_token_secret, params={"<STR_LIT>": self.session_handle})<EOL>credentials.update({<EOL>'<STR_LIT>': self.access_token,<EOL>'<STR_LIT>': self.access_token_secret,<EOL>'<STR_LIT>': self.session_handle,<EOL>'<STR_LIT>': self.token_time<EOL>})<EOL><DEDENT>else:<EOL><INDENT>headers = self.generate_oauth2_headers()<EOL>raw_access = self.oauth.get_raw_access_token(data={"<STR_LIT>": self.refresh_token, '<STR_LIT>': self.callback_uri,'<STR_LIT>':'<STR_LIT>'}, headers=headers)<EOL>credentials.update(self.oauth2_access_parser(raw_access))            <EOL><DEDENT>return credentials<EOL>


elapsed_time = time.time() - self.token_time<EOL>logger.debug("<STR_LIT>".format(elapsed_time))<EOL>if elapsed_time > <NUM_LIT>: <EOL><INDENT>logger.debug("<STR_LIT>")<EOL>return False<EOL><DEDENT>logger.debug("<STR_LIT>")<EOL>return True<EOL>


name, ext = get_file_extension(filename)<EOL>func = json_get_data if ext == '<STR_LIT>' else yaml_get_data<EOL>return func(filename)<EOL>

Calls right function according to file extension


name, ext = get_file_extension(filename)<EOL>func = json_write_data if ext == '<STR_LIT>' else yaml_write_data<EOL>return func(data, filename)<EOL>

Call right func to save data according to file extension


with open(filename, '<STR_LIT:w>') as fp:<EOL><INDENT>json.dump(json_data, fp, indent=<NUM_LIT:4>, sort_keys=True, ensure_ascii=False)<EOL>return True<EOL><DEDENT>return False<EOL>


with open(filename) as fp:<EOL><INDENT>json_data = json.load(fp)<EOL>return json_data<EOL><DEDENT>return False<EOL>


with open(filename, '<STR_LIT:rb>') as fd:<EOL><INDENT>yaml_data = yaml.load(fd)<EOL>return yaml_data<EOL><DEDENT>return False<EOL>


with open(filename, '<STR_LIT:w>') as fd:<EOL><INDENT>yaml.dump(yaml_data, fd, default_flow_style=False)<EOL>return True<EOL><DEDENT>return False<EOL>


def __init__(self, name, level=logging.DEBUG):

super(YahooLogger, self).__init__(name)<EOL>self.name = name<EOL>self.level = level<EOL>self.setLevel(self.level)<EOL>formatter = logging.Formatter("<STR_LIT>")<EOL>stream_handler = logging.StreamHandler()<EOL>stream_handler.setFormatter(formatter)<EOL>self.addHandler(stream_handler)<EOL>

- name : logger name
- filename : file containing logs


assert isinstance(callsign, str)<EOL>callsign = callsign.split('<STR_LIT:->')[<NUM_LIT:0>].upper()<EOL>code = <NUM_LIT><EOL>for i, char in enumerate(callsign):<EOL><INDENT>code ^= ord(char) << (<NUM_LIT:8> if not i % <NUM_LIT:2> else <NUM_LIT:0>)<EOL><DEDENT>return code & <NUM_LIT><EOL>


try:<EOL><INDENT>(fromcall, path) = head.split('<STR_LIT:>>', <NUM_LIT:1>)<EOL><DEDENT>except:<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT>if (not <NUM_LIT:1> <= len(fromcall) <= <NUM_LIT:9> or<EOL>not re.findall(r"<STR_LIT>", fromcall, re.I)):<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT>path = path.split('<STR_LIT:U+002C>')<EOL>if len(path[<NUM_LIT:0>]) == <NUM_LIT:0>:<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT>tocall = path[<NUM_LIT:0>]<EOL>path = path[<NUM_LIT:1>:]<EOL>validate_callsign(tocall, "<STR_LIT>")<EOL>for digi in path:<EOL><INDENT>if not re.findall(r"<STR_LIT>", digi, re.I):<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT><DEDENT>parsed = {<EOL>'<STR_LIT>': fromcall,<EOL>'<STR_LIT:to>': tocall,<EOL>'<STR_LIT:path>': path,<EOL>}<EOL>viacall = "<STR_LIT>"<EOL>if len(path) >= <NUM_LIT:2> and re.match(r"<STR_LIT>", path[-<NUM_LIT:2>]):<EOL><INDENT>viacall = path[-<NUM_LIT:1>]<EOL><DEDENT>parsed.update({'<STR_LIT>': viacall})<EOL>return parsed<EOL>

Parses the header part of packet
Returns a dict


if not isinstance(packet, string_type_parse):<EOL><INDENT>raise TypeError("<STR_LIT>", type(packet))<EOL><DEDENT>if len(packet) == <NUM_LIT:0>:<EOL><INDENT>raise ParseError("<STR_LIT>", packet)<EOL><DEDENT>if isinstance(packet, bytes):<EOL><INDENT>packet = _unicode_packet(packet)<EOL><DEDENT>packet = packet.rstrip("<STR_LIT:\r\n>")<EOL>logger.debug("<STR_LIT>", packet)<EOL>try:<EOL><INDENT>(head, body) = packet.split('<STR_LIT::>', <NUM_LIT:1>)<EOL><DEDENT>except:<EOL><INDENT>raise ParseError("<STR_LIT>", packet)<EOL><DEDENT>if len(body) == <NUM_LIT:0>:<EOL><INDENT>raise ParseError("<STR_LIT>", packet)<EOL><DEDENT>parsed = {<EOL>'<STR_LIT>': packet,<EOL>}<EOL>try:<EOL><INDENT>parsed.update(parse_header(head))<EOL><DEDENT>except ParseError as msg:<EOL><INDENT>raise ParseError(str(msg), packet)<EOL><DEDENT>packet_type = body[<NUM_LIT:0>]<EOL>body = body[<NUM_LIT:1>:]<EOL>if len(body) == <NUM_LIT:0> and packet_type != '<STR_LIT:>>':<EOL><INDENT>raise ParseError("<STR_LIT>", packet)<EOL><DEDENT>try:<EOL><INDENT>_try_toparse_body(packet_type, body, parsed)<EOL><DEDENT>except (UnknownFormat, ParseError) as exp:<EOL><INDENT>exp.packet = packet<EOL>raise<EOL><DEDENT>if '<STR_LIT>' not in parsed:<EOL><INDENT>if not re.match(r"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", parsed['<STR_LIT:to>']):<EOL><INDENT>raise UnknownFormat("<STR_LIT>", packet)<EOL><DEDENT>parsed.update({<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:text>': packet_type + body,<EOL>})<EOL><DEDENT>logger.debug("<STR_LIT>")<EOL>return parsed<EOL>

Parses an APRS packet and returns a dict with decoded data

- All attributes are in metric units


parsed = {}<EOL>match = re.findall(r"<STR_LIT>", text)<EOL>if match and len(match[<NUM_LIT:0>][<NUM_LIT:1>]) % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>text, telemetry, post = match[<NUM_LIT:0>]<EOL>text += post<EOL>temp = [<NUM_LIT:0>] * <NUM_LIT:7><EOL>for i in range(<NUM_LIT:7>):<EOL><INDENT>temp[i] = base91.to_decimal(telemetry[i*<NUM_LIT:2>:i*<NUM_LIT:2>+<NUM_LIT:2>])<EOL><DEDENT>parsed.update({<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': temp[<NUM_LIT:0>],<EOL>'<STR_LIT>': temp[<NUM_LIT:1>:<NUM_LIT:6>]<EOL>}<EOL>})<EOL>if temp[<NUM_LIT:6>] != '<STR_LIT>':<EOL><INDENT>parsed['<STR_LIT>'].update({<EOL>'<STR_LIT>': "<STR_LIT>".format(temp[<NUM_LIT:6>] & <NUM_LIT>)[::-<NUM_LIT:1>]<EOL>})<EOL><DEDENT><DEDENT>return (text, parsed)<EOL>

Looks for base91 telemetry found in comment field
Returns [remaining_text, telemetry]


def __init__(self, callsign, passwd="<STR_LIT>", host="<STR_LIT>", port=<NUM_LIT>, skip_login=False):

self.logger = logging.getLogger("<STR_LIT>" % (__name__, self.__class__.__name__))<EOL>self._parse = parse<EOL>self.set_server(host, port)<EOL>self.set_login(callsign, passwd, skip_login)<EOL>self.sock = None<EOL>self.filter = "<STR_LIT>"  <EOL>self._connected = False<EOL>self.buf = b'<STR_LIT>'<EOL>

callsign        - used when login in
passwd          - for verification, or "-1" if only listening
Host & port     - aprs-is server


self.filter = filter_text<EOL>self.logger.info("<STR_LIT>", self.filter)<EOL>if self._connected:<EOL><INDENT>self._sendall("<STR_LIT>" % self.filter)<EOL><DEDENT>

Set a specified aprs-is filter for this connection


def set_login(self, callsign, passwd="<STR_LIT>", skip_login=False):


self.server = (host, port)<EOL>


def connect(self, blocking=False, retry=<NUM_LIT:30>):

if self._connected:<EOL><INDENT>return<EOL><DEDENT>while True:<EOL><INDENT>try:<EOL><INDENT>self._connect()<EOL>if not self.skip_login:<EOL><INDENT>self._send_login()<EOL><DEDENT>break<EOL><DEDENT>except (LoginError, ConnectionError):<EOL><INDENT>if not blocking:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>self.logger.info("<STR_LIT>" % retry)<EOL>time.sleep(retry)<EOL><DEDENT>

Initiate connection to APRS server and attempt to login

blocking = False     - Should we block until connected and logged-in
retry = 30           - Retry interval in seconds


self._connected = False<EOL>self.buf = b'<STR_LIT>'<EOL>if self.sock is not None:<EOL><INDENT>self.sock.close()<EOL><DEDENT>

Closes the socket
Called internally when Exceptions are raised


if isinstance(line, APRSPacket):<EOL><INDENT>line = str(line)<EOL><DEDENT>elif not isinstance(line, string_type):<EOL><INDENT>raise TypeError("<STR_LIT>", type(line))<EOL><DEDENT>if not self._connected:<EOL><INDENT>raise ConnectionError("<STR_LIT>")<EOL><DEDENT>if line == "<STR_LIT>":<EOL><INDENT>return<EOL><DEDENT>line = line.rstrip("<STR_LIT:\r\n>") + "<STR_LIT:\r\n>"<EOL>try:<EOL><INDENT>self.sock.setblocking(<NUM_LIT:1>)<EOL>self.sock.settimeout(<NUM_LIT:5>)<EOL>self._sendall(line)<EOL><DEDENT>except socket.error as exp:<EOL><INDENT>self.close()<EOL>raise ConnectionError(str(exp))<EOL><DEDENT>

Send a line, or multiple lines sperapted by '\\r\\n'


def consumer(self, callback, blocking=True, immortal=False, raw=False):

if not self._connected:<EOL><INDENT>raise ConnectionError("<STR_LIT>")<EOL><DEDENT>line = b'<STR_LIT>'<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>for line in self._socket_readlines(blocking):<EOL><INDENT>if line[<NUM_LIT:0>:<NUM_LIT:1>] != b'<STR_LIT:#>':<EOL><INDENT>if raw:<EOL><INDENT>callback(line)<EOL><DEDENT>else:<EOL><INDENT>callback(self._parse(line))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.logger.debug("<STR_LIT>", line.decode('<STR_LIT:utf8>'))<EOL><DEDENT><DEDENT><DEDENT>except ParseError as exp:<EOL><INDENT>self.logger.log(<NUM_LIT:11>, "<STR_LIT>", exp.message, exp.packet)<EOL><DEDENT>except UnknownFormat as exp:<EOL><INDENT>self.logger.log(<NUM_LIT:9>, "<STR_LIT>", exp.message, exp.packet)<EOL><DEDENT>except LoginError as exp:<EOL><INDENT>self.logger.error("<STR_LIT>", exp.__class__.__name__, exp.message)<EOL><DEDENT>except (KeyboardInterrupt, SystemExit):<EOL><INDENT>raise<EOL><DEDENT>except (ConnectionDrop, ConnectionError):<EOL><INDENT>self.close()<EOL>if not immortal:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>self.connect(blocking=blocking)<EOL>continue<EOL><DEDENT><DEDENT>except GenericError:<EOL><INDENT>pass<EOL><DEDENT>except StopIteration:<EOL><INDENT>break<EOL><DEDENT>except:<EOL><INDENT>self.logger.error("<STR_LIT>", line)<EOL>raise<EOL><DEDENT>if not blocking:<EOL><INDENT>break<EOL><DEDENT><DEDENT>

When a position sentence is received, it will be passed to the callback function

blocking: if true (default), runs forever, otherwise will return after one sentence
          You can still exit the loop, by raising StopIteration in the callback function

immortal: When true, consumer will try to reconnect and stop propagation of Parse exceptions
          if false (default), consumer will return

raw: when true, raw packet is passed to callback, otherwise the result from aprs.parse()


self.sock = socket.create_connection(self.server, <NUM_LIT:15>)<EOL>


self.logger.info("<STR_LIT>", self.server[<NUM_LIT:0>], self.server[<NUM_LIT:1>])<EOL>try:<EOL><INDENT>self._open_socket()<EOL>peer = self.sock.getpeername()<EOL>self.logger.info("<STR_LIT>", str(peer))<EOL>self.sock.setblocking(<NUM_LIT:1>)<EOL>self.sock.settimeout(<NUM_LIT:5>)<EOL>self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, <NUM_LIT:1>)<EOL>banner = self.sock.recv(<NUM_LIT>)<EOL>if is_py3:<EOL><INDENT>banner = banner.decode('<STR_LIT>')<EOL><DEDENT>if banner[<NUM_LIT:0>] == "<STR_LIT:#>":<EOL><INDENT>self.logger.debug("<STR_LIT>", banner.rstrip())<EOL><DEDENT>else:<EOL><INDENT>raise ConnectionError("<STR_LIT>")<EOL><DEDENT><DEDENT>except ConnectionError as e:<EOL><INDENT>self.logger.error(str(e))<EOL>self.close()<EOL>raise<EOL><DEDENT>except (socket.error, socket.timeout) as e:<EOL><INDENT>self.close()<EOL>self.logger.error("<STR_LIT>" % str(e))<EOL>if str(e) == "<STR_LIT>":<EOL><INDENT>raise ConnectionError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>raise ConnectionError(e)<EOL><DEDENT><DEDENT>self._connected = True<EOL>


login_str = "<STR_LIT>"<EOL>login_str = login_str.format(<EOL>self.callsign,<EOL>self.passwd,<EOL>("<STR_LIT>" + self.filter) if self.filter != "<STR_LIT>" else "<STR_LIT>",<EOL>__version__<EOL>)<EOL>self.logger.info("<STR_LIT>")<EOL>try:<EOL><INDENT>self._sendall(login_str)<EOL>self.sock.settimeout(<NUM_LIT:5>)<EOL>test = self.sock.recv(len(login_str) + <NUM_LIT:100>)<EOL>if is_py3:<EOL><INDENT>test = test.decode('<STR_LIT>')<EOL><DEDENT>test = test.rstrip()<EOL>self.logger.debug("<STR_LIT>", test)<EOL>_, _, callsign, status, _ = test.split('<STR_LIT:U+0020>', <NUM_LIT:4>)<EOL>if callsign == "<STR_LIT>":<EOL><INDENT>raise LoginError("<STR_LIT>")<EOL><DEDENT>if callsign != self.callsign:<EOL><INDENT>raise LoginError("<STR_LIT>" % test)<EOL><DEDENT>if status != "<STR_LIT>" and self.passwd != "<STR_LIT>":<EOL><INDENT>raise LoginError("<STR_LIT>")<EOL><DEDENT>if self.passwd == "<STR_LIT>":<EOL><INDENT>self.logger.info("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self.logger.info("<STR_LIT>")<EOL><DEDENT><DEDENT>except LoginError as e:<EOL><INDENT>self.logger.error(str(e))<EOL>self.close()<EOL>raise<EOL><DEDENT>except:<EOL><INDENT>self.close()<EOL>self.logger.error("<STR_LIT>")<EOL>raise LoginError("<STR_LIT>")<EOL><DEDENT>


try:<EOL><INDENT>self.sock.setblocking(<NUM_LIT:0>)<EOL><DEDENT>except socket.error as e:<EOL><INDENT>self.logger.error("<STR_LIT>" % str(e))<EOL>raise ConnectionDrop("<STR_LIT>")<EOL><DEDENT>while True:<EOL><INDENT>short_buf = b'<STR_LIT>'<EOL>newline = b'<STR_LIT:\r\n>'<EOL>select.select([self.sock], [], [], None if blocking else <NUM_LIT:0>)<EOL>try:<EOL><INDENT>short_buf = self.sock.recv(<NUM_LIT>)<EOL>if not short_buf:<EOL><INDENT>self.logger.error("<STR_LIT>")<EOL>raise ConnectionDrop("<STR_LIT>")<EOL><DEDENT><DEDENT>except socket.error as e:<EOL><INDENT>self.logger.error("<STR_LIT>" % str(e))<EOL>if "<STR_LIT>" in str(e):<EOL><INDENT>if not blocking:<EOL><INDENT>if len(self.buf) == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>self.buf += short_buf<EOL>while newline in self.buf:<EOL><INDENT>line, self.buf = self.buf.split(newline, <NUM_LIT:1>)<EOL>yield line<EOL><DEDENT><DEDENT>

Generator for complete lines, received from the server


if not isinstance(text, string_type):<EOL><INDENT>raise TypeError("<STR_LIT>" % type(text))<EOL><DEDENT>if findall(r"<STR_LIT>", text):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>text = text.lstrip('<STR_LIT:!>')<EOL>decimal = <NUM_LIT:0><EOL>length = len(text) - <NUM_LIT:1><EOL>for i, char in enumerate(text):<EOL><INDENT>decimal += (ord(char) - <NUM_LIT>) * (<NUM_LIT> ** (length - i))<EOL><DEDENT>return decimal if text != '<STR_LIT>' else <NUM_LIT:0><EOL>

Takes a base91 char string and returns decimal


text = []<EOL>if not isinstance(number, int_type):<EOL><INDENT>raise TypeError("<STR_LIT>", type(number))<EOL><DEDENT>elif not isinstance(width, int_type):<EOL><INDENT>raise TypeError("<STR_LIT>", type(number))<EOL><DEDENT>elif number < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>elif number > <NUM_LIT:0>:<EOL><INDENT>max_n = ceil(log(number) / log(<NUM_LIT>))<EOL>for n in _range(int(max_n), -<NUM_LIT:1>, -<NUM_LIT:1>):<EOL><INDENT>quotient, number = divmod(number, <NUM_LIT>**n)<EOL>text.append(chr(<NUM_LIT> + quotient))<EOL><DEDENT><DEDENT>return "<STR_LIT>".join(text).lstrip('<STR_LIT:!>').rjust(max(<NUM_LIT:1>, width), '<STR_LIT:!>')<EOL>

Takes a decimal and returns base91 char string.
With optional parameter for fix with output


for frm in self.search_date_formats:<EOL><INDENT>try:<EOL><INDENT>return datetime.datetime.strptime(word, frm).date()<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

Tries to convert word to date(datetime) using search_date_formats
Return None if word fits no one format


return self.search_use_q and self.request.GET.get('<STR_LIT:q>', '<STR_LIT>').strip()<EOL>

Get query from request.GET 'q' parameter when search_use_q is set to True
Override this method to provide your own query to search


def get_params_for_field(self, field_name, sort_type=None):

if not sort_type:<EOL><INDENT>if self.initial_sort == field_name:<EOL><INDENT>sort_type = '<STR_LIT>' if self.initial_sort_type == '<STR_LIT>' else '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>sort_type = '<STR_LIT>'<EOL><DEDENT><DEDENT>self.initial_params[self.sort_param_name] = self.sort_fields[field_name]<EOL>self.initial_params[self.sort_type_param_name] = sort_type<EOL>return '<STR_LIT>' % self.initial_params.urlencode()<EOL>

If sort_type is None - inverse current sort for field, if no sorted - use asc


result = generic_inlineformset_factory(self.inline_model, **self.get_factory_kwargs())<EOL>return result<EOL>

Returns the final formset class from generic_inlineformset_factory.


formset_class = self.get_formset()<EOL>if hasattr(self, '<STR_LIT>'):<EOL><INDENT>klass = type(self).__name__<EOL>raise DeprecationWarning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(klass),<EOL>)<EOL><DEDENT>return formset_class(**self.get_formset_kwargs())<EOL>


return self.initial[:]<EOL>

Returns a copy of the initial data to use for formsets on this view.


return self.prefix<EOL>

Returns the prefix used for formsets on this view.


return self.formset_class<EOL>

Returns the formset class to use in the formset factory


return self.form_class<EOL>

Returns the form class to use with the formset in this view


return formset_factory(self.get_form_class(), **self.get_factory_kwargs())<EOL>

Returns the formset class from the formset factory