File: selectors_tolower.py

package info (click to toggle)
cssutils 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,312 kB
  • sloc: python: 23,625; javascript: 803; sh: 62; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import cssutils

EXPOUT = '''--- ORIGINAL ---\n@charset "ascii";\n        @namespace PREfix "uri";\n        SOME > WeIrD + selector ~ used here {color: green}\n        PREfix|name {color: green}\n    \n\n--- SELECTORS TO LOWER CASE (does not simply work for PREfix|name!) ---\n--- CHANGE PREFIX (prefix is not really part of selectorText, URI is! ---\n\n@charset "ascii";\n@namespace lower-case_prefix "uri";\nsome > weird + selector ~ used here {\n    color: green\n    }\nlower-case_prefix|name {\n    color: green\n    }\n'''
EXPERR = 'Property: Found valid "CSS Level 2.1" value: green [3:46: color]\nProperty: Found valid "CSS Level 2.1" value: green [4:22: color]\n'


def main():
    examplecss = """@charset "ascii";
        @namespace PREfix "uri";
        SOME > WeIrD + selector ~ used here {color: green}
        PREfix|name {color: green}
    """

    import logging

    sheet = cssutils.CSSParser(loglevel=logging.DEBUG).parseString(examplecss)

    print("--- ORIGINAL ---")
    print(examplecss)
    print()

    print("--- SELECTORS TO LOWER CASE (does not simply work for PREfix|name!) ---")
    sheet.cssRules[2].selectorText = sheet.cssRules[2].selectorText.lower()

    print("--- CHANGE PREFIX (prefix is not really part of selectorText, URI is! ---")
    sheet.cssRules[1].prefix = 'lower-case_prefix'

    print()
    print(sheet.cssText)


if __name__ == '__main__':
    main()