示例#1
0
文件: Unused.py 项目: Zenwolf/jasy
def cleanup(node):
    """
    """
    
    if not hasattr(node, "variables"):
        ScopeScanner.scan(node)

    # Re cleanup until nothing to remove is found
    iteration = 0
    cleaned = False
    
    Console.info("Removing unused variables...")
    Console.indent()

    while True:
        iteration += 1

        modified = __cleanup(node)
        if modified > 0:
            Console.info("Removed %s unused variables", modified)
            ScopeScanner.scan(node)
            cleaned = True
        else:
            break
        
    Console.outdent()

    return cleaned
示例#2
0
def cleanup(node):
    """"""

    if not hasattr(node, "variables"):
        ScopeScanner.scan(node)

    # Re cleanup until nothing to remove is found
    iteration = 0
    cleaned = False

    Console.debug("Removing unused variables...")
    Console.indent()

    while True:
        iteration += 1

        modified = __cleanup(node)
        if modified > 0:
            Console.debug("Removed %s unused variables", modified)
            ScopeScanner.scan(node)
            cleaned = True
        else:
            break

    Console.outdent()

    return cleaned
示例#3
0
文件: Engine.py 项目: Zenwolf/jasy
def permutateTree(tree, permutation=None):
    """
    Returns an optimized tree with permutations applied
    """

    if permutation:

        # Work on a copy
        tree = copy.deepcopy(tree)

        Resolver.process(tree, permutation)
        ScopeScanner.scan(tree)

        return tree

    else:

        return tree
示例#4
0
def reduceTree(tree, profile=None):
    """Applies all relevant modifications to the tree to allow compression to CSS."""

    Console.info("Reducing tree: %s...", tree.fileId)
    Console.indent()

    # PHASE 2
    # Trivial cleanups
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 3
    # Resolve all mixins
    Mixins.processMixins(tree)
    Mixins.processSelectors(tree)
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 4
    # Assign selectors to mixins (support for extend)
    Mixins.processExtends(tree)

    # PHASE 5
    # Post mixin cleanups
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 6
    # Execute variable resolution and method calls
    Executer.process(tree, profile)

    # PHASE 7
    # Flattening selectors
    Flatter.process(tree)

    # PHASE 8
    # Post scan to remove (hopefully) all variable/mixin access
    ScopeScanner.scan(tree)

    Console.outdent()

    return tree
示例#5
0
def reduceTree(tree, profile=None):
    """Applies all relevant modifications to the tree to allow compression to CSS."""

    Console.info("Reducing tree: %s...", tree.fileId)
    Console.indent()

    # PHASE 2
    # Trivial cleanups
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 3
    # Resolve all mixins
    Mixins.processMixins(tree)
    Mixins.processSelectors(tree)
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 4
    # Assign selectors to mixins (support for extend)
    Mixins.processExtends(tree)

    # PHASE 5
    # Post mixin cleanups
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 6
    # Execute variable resolution and method calls
    Executer.process(tree, profile)

    # PHASE 7
    # Flattening selectors
    Flatter.process(tree)

    # PHASE 8
    # Post scan to remove (hopefully) all variable/mixin access
    ScopeScanner.scan(tree)

    Console.outdent()

    return tree
示例#6
0
文件: Style.py 项目: Zenwolf/jasy
    def getCompressed(
        self, session, permutation=None, translation=None, optimization=None, formatting=None, context="compressed"
    ):

        tree = self.getMergedTree(permutation, session)

        # PHASE 1
        # Resolving conditionals
        self.__resolveConditionals(tree)

        # PHASE 2
        # Trivial cleanups
        ScopeScanner.scan(tree)
        Unused.cleanup(tree)

        # PHASE 3
        # Resolve all mixins
        Mixins.processExtends(tree)
        Mixins.processMixins(tree)
        Mixins.processSelectors(tree)

        # PHASE 4
        # Post mixin cleanups
        ScopeScanner.scan(tree)
        Unused.cleanup(tree)

        # PHASE 5
        # Compute variables
        Variables.compute(tree)

        # PHASE 6
        # Flattening selectors
        Flatter.process(tree)

        # PHASE 7
        # Post scan to remove (hopefully) all variable/mixin access
        ScopeScanner.scan(tree)

        # DONE
        return Compressor(formatting).compress(tree)
示例#7
0
文件: Engine.py 项目: Zenwolf/jasy
def processTree(tree):
    """
    Applies all relevant modifications to the tree to allow compression to CSS
    """

    # PHASE 2
    # Trivial cleanups
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 3
    # Resolve all mixins
    Mixins.processMixins(tree)
    Mixins.processSelectors(tree)

    # PHASE 4
    # Assign selectors to mixins (support for extend)
    Mixins.processExtends(tree)

    # PHASE 5
    # Post mixin cleanups
    ScopeScanner.scan(tree)
    Unused.cleanup(tree)

    # PHASE 6
    # Compute variables
    Variables.compute(tree)

    # PHASE 7
    # Flattening selectors
    Flatter.process(tree)

    # PHASE 8
    # Post scan to remove (hopefully) all variable/mixin access
    ScopeScanner.scan(tree)

    return tree