Skip to main content

A module to convert CSS code into a Python dictionary

Project description

CSS2dict is a Python module to parse CSS and make it a dictionary
Features:
- It is **callable**, that means you can do directly CSS2dict(code) instead of doing CSS2dict.parse(code)
- It returns a dictionary of this structure:


{
'selector':
{
'selection': <Style object>
}
'other selector:
{
'selection': <Style object>
'other selection': <Style object>
}
}
- Style objects are objects containing all the properties of the selection, like selection.color, selection.font-size, etc.
- Style objects have a \_\_str\_\_ method wich makes them look as dictionaries, but they aren't
- If you want Style objects to be dictionaries, you can pass True as the second argument

>> import CSS2py
>> x = CSS2py(".marquee { color: red}")
>> x['.']['marquee'].color
red
>> type(x['.']['marquee'])
Style
>> x
{'.':{'marquee':{'color':'red'}}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CSS2dict-0.1.2.tar.gz (4.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page