def cssjanus::CalculateNewBackgroundPosition | ( | m | ) |
Fixes horizontal background-position percentages. This function should be used as an argument to re.sub since it needs to perform replacement specific calculations. Args: m: A match object. Returns: A string with the horizontal background position percentage fixed. BG_HORIZONTAL_PERCENTAGE_RE.sub(FixBackgroundPosition, 'background-position: 75% 50%') will return 'background-position: 25% 50%'.
Definition at line 400 of file cssjanus.py.
def cssjanus::CalculateNewBackgroundPositionX | ( | m | ) |
Fixes percent based background-position-x. This function should be used as an argument to re.sub since it needs to perform replacement specific calculations. Args: m: A match object. Returns: A string with the background-position-x percentage fixed. BG_HORIZONTAL_PERCENTAGE_X_RE.sub(CalculateNewBackgroundPosition, 'background-position-x: 75%') will return 'background-position-x: 25%'.
Definition at line 429 of file cssjanus.py.
def cssjanus::ChangeLeftToRightToLeft | ( | lines, | ||
swap_ltr_rtl_in_url = None , |
||||
swap_left_right_in_url = None | ||||
) |
Turns lines into a stream and runs the fixing functions against it. Args: lines: An list of CSS lines. swap_ltr_rtl_in_url: Overrides this flag if param is set. swap_left_right_in_url: Overrides this flag if param is set. Returns: The same lines, but with left and right fixes.
Definition at line 451 of file cssjanus.py.
def cssjanus::FixBackgroundPosition | ( | line | ) |
Fixes horizontal background percentage values in line. Args: line: A string to fix horizontal background position values in. Returns: line reformatted with the 4 part notations swapped.
Definition at line 384 of file cssjanus.py.
def cssjanus::FixBodyDirectionLtrAndRtl | ( | line | ) |
Replaces ltr with rtl and vice versa ONLY in the body direction. Args: line: A string to replace instances of ltr with rtl. Returns: line with direction: ltr and direction: rtl swapped only in body selector. line = FixBodyDirectionLtrAndRtl('body { direction:ltr }') line will now be 'body { direction:rtl }'.
Definition at line 273 of file cssjanus.py.
def cssjanus::FixCursorProperties | ( | line | ) |
Fixes directional CSS cursor properties. Args: line: A string to fix CSS cursor properties in. Returns: line reformatted with the cursor properties substituted. For example: line = FixCursorProperties('cursor: ne-resize') line will now be 'cursor: nw-resize'.
Definition at line 348 of file cssjanus.py.
def cssjanus::FixFourPartNotation | ( | line | ) |
Fixes the second and fourth positions in 4 part CSS notation. Args: line: A string to fix 4 part CSS notation in. Returns: line reformatted with the 4 part notations swapped. For example: line = FixFourPartNotation('padding: 1px 2px 3px 4px') line will now be 'padding: 1px 4px 3px 2px'.
Definition at line 367 of file cssjanus.py.
def cssjanus::FixLeftAndRight | ( | line | ) |
Replaces left with right and vice versa in line. Args: line: A string in which to perform the replacement. Returns: line with left and right swapped. For example: line = FixLeftAndRight('padding-left: 2px; margin-right: 1px;') line will now be 'padding-right: 2px; margin-left: 1px;'.
Definition at line 291 of file cssjanus.py.
def cssjanus::FixLeftAndRightInUrl | ( | line | ) |
Replaces left with right and vice versa ONLY within background urls. Args: line: A string in which to replace left with right and vice versa. Returns: line with left and right swapped in the url string. For example: line = FixLeftAndRightInUrl('background:url(right.png)') line will now be 'background:url(left.png)'.
Definition at line 310 of file cssjanus.py.
def cssjanus::FixLtrAndRtlInUrl | ( | line | ) |
Replaces ltr with rtl and vice versa ONLY within background urls. Args: line: A string in which to replace ltr with rtl and vice versa. Returns: line with left and right swapped. For example: line = FixLtrAndRtlInUrl('background:url(rtl.png)') line will now be 'background:url(ltr.png)'.
Definition at line 329 of file cssjanus.py.
def cssjanus::main | ( | argv | ) |
Sends stdin lines to ChangeLeftToRightToLeft and writes to stdout.
Definition at line 554 of file cssjanus.py.
def cssjanus::setflags | ( | opts | ) |
Parse the passed in command line arguments and set the FLAGS global. Args: opts: getopt iterable intercepted from argv.
Definition at line 531 of file cssjanus.py.
def cssjanus::usage | ( | ) |
string cssjanus::__author__ = 'elsigh@google.com (Lindsey Simon)' |
Definition at line 17 of file cssjanus.py.
string cssjanus::__version__ = '0.1' |
Definition at line 18 of file cssjanus.py.
Initial value:
re.compile(r'background(-position)?(%s:%s)' '([^%%]*?)(%s)%%' '(%s(?:%s|%s))' % (csslex.WHITESPACE, csslex.WHITESPACE, csslex.NUM, csslex.WHITESPACE, csslex.QUANTITY, csslex.IDENT))
Definition at line 107 of file cssjanus.py.
Initial value:
re.compile(r'background-position-x(%s:%s)' '(%s)%%' % (csslex.WHITESPACE, csslex.WHITESPACE, csslex.NUM))
Definition at line 116 of file cssjanus.py.
Initial value:
re.compile(r'(%s)(%s)(%s)(ltr)' %
(BODY_SELECTOR, CHARS_WITHIN_SELECTOR,
DIRECTION_RE),
re.I)
Definition at line 132 of file cssjanus.py.
Initial value:
re.compile(r'(%s)(%s)(%s)(rtl)' %
(BODY_SELECTOR, CHARS_WITHIN_SELECTOR,
DIRECTION_RE),
re.I)
Definition at line 136 of file cssjanus.py.
string cssjanus::BODY_SELECTOR = r'body%s{%s' |
Definition at line 122 of file cssjanus.py.
string cssjanus::CHARS_WITHIN_SELECTOR = r'[^\}]*?' |
Definition at line 125 of file cssjanus.py.
string cssjanus::COLOR = r'(%s|%s)' |
Definition at line 87 of file cssjanus.py.
string cssjanus::COLOR_SPACE = r'%s%s' |
Definition at line 88 of file cssjanus.py.
tuple cssjanus::COMMENT_RE = re.compile('(%s)' % csslex.COMMENT, re.I) |
Definition at line 179 of file cssjanus.py.
tuple cssjanus::CURSOR_EAST_RE = re.compile(LOOKBEHIND_NOT_LETTER + '([ns]?)e-resize') |
Definition at line 99 of file cssjanus.py.
tuple cssjanus::CURSOR_WEST_RE = re.compile(LOOKBEHIND_NOT_LETTER + '([ns]?)w-resize') |
Definition at line 100 of file cssjanus.py.
tuple cssjanus::DIRECTION_LTR_RE = re.compile(r'%s(ltr)' % DIRECTION_RE) |
Definition at line 144 of file cssjanus.py.
string cssjanus::DIRECTION_RE = r'direction%s:%s' |
Definition at line 128 of file cssjanus.py.
tuple cssjanus::DIRECTION_RTL_RE = re.compile(r'%s(rtl)' % DIRECTION_RE) |
Definition at line 145 of file cssjanus.py.
dictionary cssjanus::FLAGS |
Initial value:
{'swap_ltr_rtl_in_url': SWAP_LTR_RTL_IN_URL_DEFAULT, 'swap_left_right_in_url': SWAP_LEFT_RIGHT_IN_URL_DEFAULT}
Definition at line 33 of file cssjanus.py.
Initial value:
re.compile(r'(-color%s:%s)%s%s%s(%s)' %
(csslex.WHITESPACE,
csslex.WHITESPACE,
COLOR_SPACE,
COLOR_SPACE,
COLOR_SPACE,
COLOR),
re.I)
Definition at line 89 of file cssjanus.py.
Initial value:
re.compile(r'%s%s%s%s' %
(POSSIBLY_NEGATIVE_QUANTITY_SPACE,
POSSIBLY_NEGATIVE_QUANTITY_SPACE,
POSSIBLY_NEGATIVE_QUANTITY_SPACE,
POSSIBLY_NEGATIVE_QUANTITY),
re.I)
Definition at line 81 of file cssjanus.py.
string cssjanus::LEFT = 'left' |
Definition at line 48 of file cssjanus.py.
tuple cssjanus::LEFT_IN_URL_RE |
Initial value:
re.compile('%s(%s)%s' % (LOOKBEHIND_NOT_LETTER,
LEFT,
LOOKAHEAD_FOR_CLOSING_PAREN),
re.I)
Definition at line 162 of file cssjanus.py.
tuple cssjanus::LEFT_RE |
Initial value:
re.compile('%s(%s)%s%s' % (LOOKBEHIND_NOT_LETTER,
LEFT,
LOOKAHEAD_NOT_CLOSING_PAREN,
LOOKAHEAD_NOT_OPEN_BRACE),
re.I)
Definition at line 152 of file cssjanus.py.
string cssjanus::LOOKAHEAD_FOR_CLOSING_PAREN = r'(?=%s?%s\))' |
Definition at line 71 of file cssjanus.py.
string cssjanus::LOOKAHEAD_NOT_CLOSING_PAREN = r'(?!%s?%s\))' |
Definition at line 69 of file cssjanus.py.
Initial value:
(r'(?!(?:%s|%s|%s|#|\:|\.|\,|\+|>)*?{)' %
(csslex.NMCHAR, TOKEN_LINES, csslex.SPACE))
Definition at line 61 of file cssjanus.py.
string cssjanus::LOOKBEHIND_NOT_LETTER = r'(?<![a-zA-Z])' |
Definition at line 54 of file cssjanus.py.
string cssjanus::LTR = 'ltr' |
Definition at line 46 of file cssjanus.py.
tuple cssjanus::LTR_IN_URL_RE |
Initial value:
re.compile('%s(%s)%s' % (LOOKBEHIND_NOT_LETTER,
LTR,
LOOKAHEAD_FOR_CLOSING_PAREN),
re.I)
Definition at line 170 of file cssjanus.py.
string cssjanus::NOFLIP_ANNOTATION = r'/\*%s%s%s\*/' |
Definition at line 185 of file cssjanus.py.
Initial value:
re.compile(r'(%s%s})' % (NOFLIP_ANNOTATION,
CHARS_WITHIN_SELECTOR),
re.I)
Definition at line 200 of file cssjanus.py.
Initial value:
re.compile(r'(%s%s[^;}]+;?)' % (NOFLIP_ANNOTATION,
LOOKAHEAD_NOT_OPEN_BRACE),
re.I)
Definition at line 193 of file cssjanus.py.
string cssjanus::NOFLIP_TOKEN = r'\@noflip' |
Definition at line 181 of file cssjanus.py.
string cssjanus::POSSIBLY_NEGATIVE_QUANTITY = r'((?:-?%s)|(?:inherit|auto))' |
Definition at line 77 of file cssjanus.py.
string cssjanus::POSSIBLY_NEGATIVE_QUANTITY_SPACE = r'%s%s%s' |
Definition at line 78 of file cssjanus.py.
string cssjanus::RIGHT = 'right' |
Definition at line 49 of file cssjanus.py.
Initial value:
re.compile('%s(%s)%s' % (LOOKBEHIND_NOT_LETTER,
RIGHT,
LOOKAHEAD_FOR_CLOSING_PAREN),
re.I)
Definition at line 166 of file cssjanus.py.
tuple cssjanus::RIGHT_RE |
Initial value:
re.compile('%s(%s)%s%s' % (LOOKBEHIND_NOT_LETTER,
RIGHT,
LOOKAHEAD_NOT_CLOSING_PAREN,
LOOKAHEAD_NOT_OPEN_BRACE),
re.I)
Definition at line 157 of file cssjanus.py.
string cssjanus::RTL = 'rtl' |
Definition at line 47 of file cssjanus.py.
tuple cssjanus::RTL_IN_URL_RE |
Initial value:
re.compile('%s(%s)%s' % (LOOKBEHIND_NOT_LETTER,
RTL,
LOOKAHEAD_FOR_CLOSING_PAREN),
re.I)
Definition at line 174 of file cssjanus.py.
Definition at line 32 of file cssjanus.py.
Definition at line 31 of file cssjanus.py.
string cssjanus::TMP_TOKEN = '%sTMP%s' |
Definition at line 40 of file cssjanus.py.
string cssjanus::TOKEN_DELIMITER = '~' |
Definition at line 37 of file cssjanus.py.
string cssjanus::TOKEN_LINES = '%sJ%s' |
Definition at line 43 of file cssjanus.py.
string cssjanus::VALID_AFTER_URI_CHARS = r'[\'\"]?%s' |
Definition at line 68 of file cssjanus.py.