# Path: Lib/glyphsLib/builder/constants.py
# GLYPHS_PREFIX = "com.schriftgestaltung."


from collections import deque
from .constants import GLYPHS_PREFIX
def _get_linked_style(style_name, is_bold, is_italic):
    # strip last occurrence of 'Regular', 'Bold', 'Italic' from style_name
    # depending on the values of is_bold and is_italic
    linked_style = deque()
    is_regular = not (is_bold or is_italic)
    for part in reversed(style_name.split()):
        if part == "Regular" and is_regular:
            is_regular = False
        elif part == "Bold" and is_bold:
            is_bold = False
        elif part == "Italic" and is_italic:
            is_italic = False
        else:
            linked_style.appendleft(part)
    return " ".join(linked_style)


def to_glyphs_family_names(self, ufo, merge=False):
    if not merge:
        # First UFO
        self.font.familyName = ufo.info.familyName
    else:
        # Subsequent UFOs
        if self.font.familyName != ufo.info.familyName:
            raise RuntimeError("All UFOs should have the same family name.")


def to_glyphs_master_names(self, ufo, master):
    name = ufo.info.styleName
    weight = ufo.lib.get(GLYPHS_PREFIX + "weight")

# Path: Lib/glyphsLib/builder/constants.py
# GLYPHS_PREFIX = "com.schriftgestaltung."


# Path: Lib/glyphsLib/builder/names.py
from collections import deque
from .constants import GLYPHS_PREFIX

def _get_linked_style(style_name, is_bold, is_italic):
    # strip last occurrence of 'Regular', 'Bold', 'Italic' from style_name
    # depending on the values of is_bold and is_italic
    linked_style = deque()
    is_regular = not (is_bold or is_italic)
    for part in reversed(style_name.split()):
        if part == "Regular" and is_regular:
            is_regular = False
        elif part == "Bold" and is_bold:
            is_bold = False
        elif part == "Italic" and is_italic:
            is_italic = False
        else:
            linked_style.appendleft(part)
    return " ".join(linked_style)


def to_glyphs_family_names(self, ufo, merge=False):
    if not merge:
        # First UFO
        self.font.familyName = ufo.info.familyName
    else:
        # Subsequent UFOs
        if self.font.familyName != ufo.info.familyName:
            raise RuntimeError("All UFOs should have the same family name.")


def to_glyphs_master_names(self, ufo, master):
    name = ufo.info.styleName
    weight = ufo.lib.get(GLYPHS_PREFIX + "weight")

    width = ufo.lib.get(GLYPHS_PREFIX + "width")