# Path: tinycsscheme/parser.py
# class StringRule(object):
#     """Any parsed rule with a single STRING head (e.g. @comment).
# 
#     .. attribute:: at_keyword
# 
#         The at-keyword for this rule.
# 
#     .. attribute:: value
# 
#         The value for this rule (a Token).
#     """
#     at_keyword = ''
# 
#     def __init__(self, keyword, value, line, column):
#         self.at_keyword = keyword
#         self.value      = value
#         self.line       = line
#         self.column     = column
# 
#     def __repr__(self):
#         return ('<{0.__class__.__name__} {0.at_keyword} {0.line}:{0.column} '
#                 '{0.value}>'.format(self))
# 
# def strvalue(token):
#     """Get the string value of a token."""
#     if token.type == 'DIMENSION':
#         return token.as_css()
#     else:
#         return str(token.value)


import re
    import plistlib
                import colorsys
from collections import OrderedDict
from .parser import StringRule, strvalue
from .tinycss.parsing import split_on_comma, strip_whitespace
from .tinycss.token_data import Token
            from .css_colors import css_colors
    at_rules = OrderedDict()
    rulesets = []
    asterisk = None
    dummy = DummyToken(0, 0)

    # Save all at-rules and rulesets separately and extract them from the stylesheet
    for r in stylesheet.rules:
        if r.at_keyword:
            at_rules[r.at_keyword.strip('@')] = r
        else:
            if r.selector.as_css() == "*":
                if asterisk:
                    # Actually it is not, but the second will always override the first and it
                    # doesn't make sense anyway
                    raise DumpError(r, "Only one *-rule allowed")
                else:
                    asterisk = r
            else:
                rulesets.append(r)

    # Make sure the name is at the top
    if 'name' in at_rules:
        data['name'] = strvalue(at_rules['name'].value)
        del at_rules['name']

    # Then all remaining at-rules (should be subclasses of StringRule)
    for k, r in at_rules.items():
        assert isinstance(r, StringRule)
        if k == 'settings':
            raise DumpError(r, "Can not override 'settings' key using at-rules.", '@%s' % k)

# Path: tinycsscheme/parser.py
# class StringRule(object):
#     """Any parsed rule with a single STRING head (e.g. @comment).
# 
#     .. attribute:: at_keyword
# 
#         The at-keyword for this rule.
# 
#     .. attribute:: value
# 
#         The value for this rule (a Token).
#     """
#     at_keyword = ''
# 
#     def __init__(self, keyword, value, line, column):
#         self.at_keyword = keyword
#         self.value      = value
#         self.line       = line
#         self.column     = column
# 
#     def __repr__(self):
#         return ('<{0.__class__.__name__} {0.at_keyword} {0.line}:{0.column} '
#                 '{0.value}>'.format(self))
# 
# def strvalue(token):
#     """Get the string value of a token."""
#     if token.type == 'DIMENSION':
#         return token.as_css()
#     else:
#         return str(token.value)


# Path: tinycsscheme/dumper.py
import re
    import plistlib
                import colorsys
from collections import OrderedDict
from .parser import StringRule, strvalue
from .tinycss.parsing import split_on_comma, strip_whitespace
from .tinycss.token_data import Token
            from .css_colors import css_colors

    at_rules = OrderedDict()
    rulesets = []
    asterisk = None
    dummy = DummyToken(0, 0)

    # Save all at-rules and rulesets separately and extract them from the stylesheet
    for r in stylesheet.rules:
        if r.at_keyword:
            at_rules[r.at_keyword.strip('@')] = r
        else:
            if r.selector.as_css() == "*":
                if asterisk:
                    # Actually it is not, but the second will always override the first and it
                    # doesn't make sense anyway
                    raise DumpError(r, "Only one *-rule allowed")
                else:
                    asterisk = r
            else:
                rulesets.append(r)

    # Make sure the name is at the top
    if 'name' in at_rules:
        data['name'] = strvalue(at_rules['name'].value)
        del at_rules['name']

    # Then all remaining at-rules (should be subclasses of StringRule)
    for k, r in at_rules.items():
        assert isinstance(r, StringRule)
        if k == 'settings':
            raise DumpError(r, "Can not override 'settings' key using at-rules.", '@%s' % k)

        data[k] = strvalue(r.value)