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'}}}
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.2.tar.gz
(4.5 kB
view hashes)