whitespace cleanup
This commit is contained in:
parent
0e35c9d40f
commit
8dc6137373
5 changed files with 2696 additions and 2694 deletions
5328
scour/scour.py
5328
scour/scour.py
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
||||||
# This software is OSI Certified Open Source Software.
|
# This software is OSI Certified Open Source Software.
|
||||||
# OSI Certified is a certification mark of the Open Source Initiative.
|
# OSI Certified is a certification mark of the Open Source Initiative.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006, Enthought, Inc.
|
# Copyright (c) 2006, Enthought, Inc.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,8 @@ class SVGTransformationParser(object):
|
||||||
commands = []
|
commands = []
|
||||||
token = next()
|
token = next()
|
||||||
while token[0] is not EOF:
|
while token[0] is not EOF:
|
||||||
command, token = self.rule_svg_transform(next, token)
|
command, token = self.rule_svg_transform(next, token)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def rule_svg_transform(self, next, token):
|
def rule_svg_transform(self, next, token):
|
||||||
|
|
@ -177,7 +177,7 @@ class SVGTransformationParser(object):
|
||||||
number, token = self.rule_optional_number(next, token)
|
number, token = self.rule_optional_number(next, token)
|
||||||
if number is not None:
|
if number is not None:
|
||||||
numbers.append(number)
|
numbers.append(number)
|
||||||
|
|
||||||
return numbers, token
|
return numbers, token
|
||||||
|
|
||||||
def rule_1number(self, next, token):
|
def rule_1number(self, next, token):
|
||||||
|
|
@ -199,10 +199,10 @@ class SVGTransformationParser(object):
|
||||||
# but, if the 2nd number is provided, the 3rd is mandatory.
|
# but, if the 2nd number is provided, the 3rd is mandatory.
|
||||||
# we can't have just 2.
|
# we can't have just 2.
|
||||||
numbers.append(number)
|
numbers.append(number)
|
||||||
|
|
||||||
number, token = self.rule_number(next, token)
|
number, token = self.rule_number(next, token)
|
||||||
numbers.append(number)
|
numbers.append(number)
|
||||||
|
|
||||||
return numbers, token
|
return numbers, token
|
||||||
|
|
||||||
def rule_6numbers(self, next, token):
|
def rule_6numbers(self, next, token):
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
# scour needed a bare-minimum CSS parser in order to determine if some elements
|
# scour needed a bare-minimum CSS parser in order to determine if some elements
|
||||||
# were still referenced by CSS properties.
|
# were still referenced by CSS properties.
|
||||||
|
|
||||||
# I looked at css-py (a CSS parser built in Python), but that library
|
# I looked at css-py (a CSS parser built in Python), but that library
|
||||||
# is about 35k of Python and requires ply to be installed. I just need
|
# is about 35k of Python and requires ply to be installed. I just need
|
||||||
# something very basic to suit scour's needs.
|
# something very basic to suit scour's needs.
|
||||||
|
|
||||||
# yocto-css takes a string of CSS and tries to spit out a list of rules
|
# yocto-css takes a string of CSS and tries to spit out a list of rules
|
||||||
|
|
@ -45,28 +45,28 @@
|
||||||
# value : [ any | block | ATKEYWORD S* ]+;
|
# value : [ any | block | ATKEYWORD S* ]+;
|
||||||
# any : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
|
# any : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
|
||||||
# | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
|
# | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
|
||||||
# | DASHMATCH | FUNCTION S* any* ')'
|
# | DASHMATCH | FUNCTION S* any* ')'
|
||||||
# | '(' S* any* ')' | '[' S* any* ']' ] S*;
|
# | '(' S* any* ')' | '[' S* any* ']' ] S*;
|
||||||
|
|
||||||
def parseCssString(str):
|
def parseCssString(str):
|
||||||
rules = []
|
rules = []
|
||||||
# first, split on } to get the rule chunks
|
# first, split on } to get the rule chunks
|
||||||
chunks = str.split('}')
|
chunks = str.split('}')
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
# second, split on { to get the selector and the list of properties
|
# second, split on { to get the selector and the list of properties
|
||||||
bits = chunk.split('{')
|
bits = chunk.split('{')
|
||||||
if len(bits) != 2: continue
|
if len(bits) != 2: continue
|
||||||
rule = {}
|
rule = {}
|
||||||
rule['selector'] = bits[0].strip()
|
rule['selector'] = bits[0].strip()
|
||||||
# third, split on ; to get the property declarations
|
# third, split on ; to get the property declarations
|
||||||
bites = bits[1].strip().split(';')
|
bites = bits[1].strip().split(';')
|
||||||
if len(bites) < 1: continue
|
if len(bites) < 1: continue
|
||||||
props = {}
|
props = {}
|
||||||
for bite in bites:
|
for bite in bites:
|
||||||
# fourth, split on : to get the property name and value
|
# fourth, split on : to get the property name and value
|
||||||
nibbles = bite.strip().split(':')
|
nibbles = bite.strip().split(':')
|
||||||
if len(nibbles) != 2: continue
|
if len(nibbles) != 2: continue
|
||||||
props[nibbles[0].strip()] = nibbles[1].strip()
|
props[nibbles[0].strip()] = nibbles[1].strip()
|
||||||
rule['properties'] = props
|
rule['properties'] = props
|
||||||
rules.append(rule)
|
rules.append(rule)
|
||||||
return rules
|
return rules
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -20,7 +20,7 @@ from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup (
|
setup (
|
||||||
name = 'scour',
|
name = 'scour',
|
||||||
version = '0.26',
|
version = '0.27',
|
||||||
description = 'Scour SVG Optimizer',
|
description = 'Scour SVG Optimizer',
|
||||||
long_description = open("README.md").read(),
|
long_description = open("README.md").read(),
|
||||||
license = 'Apache License 2.0',
|
license = 'Apache License 2.0',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue