Esempio n. 1
0
def extract_theme_properties(addon, channel):
    version = addon.find_latest_version(channel)
    if not version or not version.all_files:
        return {}
    try:
        parsed_data = parse_xpi(
            version.all_files[0].file_path, addon=addon, user=core.get_user())
    except ValidationError:
        # If we can't parse the existing manifest safely return.
        return {}
    theme_props = parsed_data.get('theme', {})
    # pre-process colors to convert chrome style colors and strip spaces
    theme_props['colors'] = dict(
        process_color_value(prop, color)
        for prop, color in theme_props.get('colors', {}).items())
    # replace headerURL with path to existing background
    if 'images' in theme_props:
        if 'theme_frame' in theme_props['images']:
            header_url = theme_props['images'].pop('theme_frame')
        if 'headerURL' in theme_props['images']:
            header_url = theme_props['images'].pop('headerURL')
        if header_url:
            theme_props['images']['headerURL'] = '/'.join((
                user_media_url('addons'), text_type(addon.id),
                text_type(version.id), header_url))
    return theme_props
Esempio n. 2
0
def extract_theme_properties(addon, channel):
    version = addon.find_latest_version(channel)
    if not version or not version.all_files:
        return {}
    try:
        parsed_data = parse_xpi(
            version.all_files[0].file_path, addon=addon, user=core.get_user())
    except ValidationError:
        # If we can't parse the existing manifest safely return.
        return {}
    theme_props = parsed_data.get('theme', {})
    # pre-process colors to convert chrome style colors and strip spaces
    theme_props['colors'] = dict(
        process_color_value(prop, color)
        for prop, color in theme_props.get('colors', {}).items())
    return theme_props
Esempio n. 3
0
def extract_theme_properties(addon, channel):
    version = addon.find_latest_version(channel)
    if not version or not version.all_files:
        return {}
    try:
        parsed_data = parse_xpi(
            version.all_files[0].file_path, addon=addon, user=core.get_user())
    except ValidationError:
        # If we can't parse the existing manifest safely return.
        return {}
    theme_props = parsed_data.get('theme', {})
    # pre-process colors to convert chrome style colors and strip spaces
    theme_props['colors'] = dict(
        process_color_value(prop, color)
        for prop, color in theme_props.get('colors', {}).items())
    return theme_props
Esempio n. 4
0
def extract_theme_properties(addon, channel):
    version = addon.find_latest_version(channel)
    if not version or not version.all_files:
        return {}
    try:
        parsed_data = parse_xpi(
            version.all_files[0].file_path, addon=addon, user=core.get_user())
    except ValidationError:
        # If we can't parse the existing manifest safely return.
        return {}
    theme_props = parsed_data.get('theme', {})
    # pre-process colors to deprecated colors; strip spaces.
    theme_props['colors'] = dict(
        process_color_value(prop, color)
        for prop, color in theme_props.get('colors', {}).items())
    # upgrade manifest from deprecated headerURL to theme_frame
    if 'headerURL' in theme_props.get('images', {}):
        url = theme_props['images'].pop('headerURL')
        theme_props['images']['theme_frame'] = url
    return theme_props
Esempio n. 5
0
def test_process_color_value(chrome_prop, chrome_color, firefox_prop,
                             css_color):
    assert (firefox_prop, css_color) == (
        process_color_value(chrome_prop, chrome_color))
Esempio n. 6
0
def test_process_color_value(manifest_property, manifest_color, firefox_prop,
                             css_color):
    assert (firefox_prop,
            css_color) == (process_color_value(manifest_property,
                                               manifest_color))
Esempio n. 7
0
def test_process_color_value(manifest_property, manifest_color, firefox_prop,
                             css_color):
    assert (firefox_prop, css_color) == (
        process_color_value(manifest_property, manifest_color))
Esempio n. 8
0
def test_process_color_value(chrome_prop, chrome_color, firefox_prop,
                             css_color):
    assert (firefox_prop,
            css_color) == (process_color_value(chrome_prop, chrome_color))