# Path: css2video/constants.py
# class ValueType(object):
#     """Class to define constants for value types"""
# 
#     number = 'number'
#     length = 'length'
#     percentage = 'percentage'
#     time = 'time'
#     color = 'color'
#     text = 'text'
#     url = 'url'
#     function = 'function'
#     array = 'array'
# 
# Path: css2video/parsers/value.py
# class Color(BaseParser):
#     """Parse a color value. It can be hex, RGB or RGBA"""
# 
#     ParseException = ColorParseException
# 
#     HEX_CHARS = '0123456789ABCDEFabcdef'
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse a color value"""
#         hex3 = (
#             pp.Suppress(pp.Literal('#')) +
#             pp.Word(cls.HEX_CHARS, exact=3).leaveWhitespace()
#         )
#         hex6 = (
#             pp.Suppress(pp.Literal('#')) +
#             pp.Word(cls.HEX_CHARS, exact=6).leaveWhitespace()
#         )
#         rgb = (
#             pp.Suppress(pp.CaselessLiteral('rgb(')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(')'))
#         )
#         rgba = (
#             pp.Suppress(pp.CaselessLiteral('rgba(')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(')'))
#         )
#         return hex6 | hex3 | rgba | rgb
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         alpha = 1
#         if len(tokens) == 1:
#             red, green, blue = cls.hex_to_rgb(tokens[0])
#         elif len(tokens) == 3:
#             red, green, blue = map(float, tokens)
#         elif len(tokens) == 4:
#             red, green, blue, alpha = map(float, tokens)
# 
#         return {
#             'type': ValueType.color,
#             'red': red,
#             'green': green,
#             'blue': blue,
#             'alpha': alpha
#         }
# 
#     @classmethod
#     def hex_to_rgb(cls, hexval):
#         """Convert hex value to RGB value"""
#         if len(hexval) == 3:
#             new_hexval = ''
#             for c in hexval:
#                 new_hexval += c * 2
#             hexval = new_hexval
#         return [int(hexval[i:i + 2], base=16)for i in range(0, 6, 2)]
# 
# class ColorParseException(Exception):
#     """Raised when there is an exception while parsing a color value"""
#     pass


import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Color, ColorParseException



class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Color.parse('#ffF')
        self.assertEqual(
            response,
            dict(type=ValueType.color, red=255, green=255, blue=255, alpha=1)
        )

        response = Color.parse('#FFFFFF')
        self.assertEqual(
            response,

# Path: css2video/constants.py
# class ValueType(object):
#     """Class to define constants for value types"""
# 
#     number = 'number'
#     length = 'length'
#     percentage = 'percentage'
#     time = 'time'
#     color = 'color'
#     text = 'text'
#     url = 'url'
#     function = 'function'
#     array = 'array'
# 
# Path: css2video/parsers/value.py
# class Color(BaseParser):
#     """Parse a color value. It can be hex, RGB or RGBA"""
# 
#     ParseException = ColorParseException
# 
#     HEX_CHARS = '0123456789ABCDEFabcdef'
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse a color value"""
#         hex3 = (
#             pp.Suppress(pp.Literal('#')) +
#             pp.Word(cls.HEX_CHARS, exact=3).leaveWhitespace()
#         )
#         hex6 = (
#             pp.Suppress(pp.Literal('#')) +
#             pp.Word(cls.HEX_CHARS, exact=6).leaveWhitespace()
#         )
#         rgb = (
#             pp.Suppress(pp.CaselessLiteral('rgb(')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(')'))
#         )
#         rgba = (
#             pp.Suppress(pp.CaselessLiteral('rgba(')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(',')) +
#             Number.grammar() +
#             pp.Suppress(pp.Literal(')'))
#         )
#         return hex6 | hex3 | rgba | rgb
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         alpha = 1
#         if len(tokens) == 1:
#             red, green, blue = cls.hex_to_rgb(tokens[0])
#         elif len(tokens) == 3:
#             red, green, blue = map(float, tokens)
#         elif len(tokens) == 4:
#             red, green, blue, alpha = map(float, tokens)
# 
#         return {
#             'type': ValueType.color,
#             'red': red,
#             'green': green,
#             'blue': blue,
#             'alpha': alpha
#         }
# 
#     @classmethod
#     def hex_to_rgb(cls, hexval):
#         """Convert hex value to RGB value"""
#         if len(hexval) == 3:
#             new_hexval = ''
#             for c in hexval:
#                 new_hexval += c * 2
#             hexval = new_hexval
#         return [int(hexval[i:i + 2], base=16)for i in range(0, 6, 2)]
# 
# class ColorParseException(Exception):
#     """Raised when there is an exception while parsing a color value"""
#     pass


# Path: tests/parsers/value/test_color.py
import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Color, ColorParseException




class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Color.parse('#ffF')
        self.assertEqual(
            response,
            dict(type=ValueType.color, red=255, green=255, blue=255, alpha=1)
        )

        response = Color.parse('#FFFFFF')
        self.assertEqual(
            response,

            dict(type=ValueType.color, red=255, green=255, blue=255, alpha=1)