Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

ihgazni2/tytycss

Repository files navigation

tytycss

search css file by selector-string/prelude-string
a wrapped APIs for tinycss2

Install

pip3 install tytycss

Usage

click to see example


1. load from input string

    css = tyty.CSS(input=input) 

        at-rule input string

2. load all css rules from a .css file

    css = tyty.CSS(fn="tst1.css")  

3. display

    css.count
    r = css[2]
    r.atkey
    r.show_css()
    r.prelude
    r.head
    r.show_content()

4. search in loose mode
    default is loose
    find all rules whose selectors-path includes 'ul'

    rs = css.all("ul")

5. search in strict mode
    find all rules whose selectors-path equals ".maincontent"

    rs = css.all(".maincontent",mode="strict")

        compare with loose mode

6. single search

    r = css.first("ul")
    r = css.last("ul")
    r = css.which("ul",8)

7. at_rule search

    r = css.first("ul")
    r = css.last("ul")
    r = css.which("ul",8)

8. beautify rule

    tyty.beautify_selpath("a . test #oo")
    formatted = tyty.beautify_rule(input)

10. beautify file

        before

    tyty.beautify_cssfile("tst1.css","tst1.fmt.css")

        after

11. show as dict

    r.show()

12. level show

    #display at (depth,breadth), 
    r.mshow(0,0)
    # circlely show level by level
    r.more()
    r.more()

13. list show

    r.lshow_prelude()
    r.lshow_content()
    r.lshow_css()

14. internal_dict show

    from xdict.jprint import pobj
    pobj(r.dict)
    pobj(r.dict,fixed_indent=True)

15. internal_description mat show

    pobj(r.mat)

PACKAGE DEPENDANY


tinycss2
xdict
elist
edict
tlist
estring



TODO


1. improve performance
2. deep search


About

search css file via selector-string/prelude-string

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published