def _construct_production_name(glyph_name, data=None):
<EOL>base_name, dot, suffix = glyph_name.partition("<STR_LIT:.>")<EOL>glyphinfo = _lookup_attributes(base_name, data)<EOL>if glyphinfo and glyphinfo.get("<STR_LIT>"):<EOL><INDENT>return glyphinfo["<STR_LIT>"] + dot + suffix<EOL><DEDENT>if glyph_name in fontTools.agl.AGL2UV or base_name in fontTools.agl.AGL2UV:<EOL><INDENT>return glyph_name<EOL><DEDENT>if "<STR_LIT:_>" not in base_name:<EOL><INDENT>return _agl_compliant_name(glyph_name)<EOL><DEDENT>base_name_parts = base_name.split("<STR_LIT:_>")<EOL>if all(part in fontTools.agl.AGL2UV for part in base_name_parts):<EOL><INDENT>return _agl_compliant_name(glyph_name)<EOL><DEDENT>_character_outside_BMP = False<EOL>production_names = []<EOL>for part in base_name_parts:<EOL><INDENT>if part in fontTools.agl.AGL2UV:<EOL><INDENT>production_names.append(part)<EOL><DEDENT>else:<EOL><INDENT>part_entry = data.names.get(part) or {}<EOL>part_production_name = part_entry.get("<STR_LIT>")<EOL>if part_production_name:<EOL><INDENT>production_names.append(part_production_name)<EOL>if len(part_production_name) > <NUM_LIT:5> and _is_unicode_u_value(<EOL>part_production_name<EOL>):<EOL><INDENT>_character_outside_BMP = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return _agl_compliant_name(glyph_name)<EOL><DEDENT><DEDENT><DEDENT>if any("<STR_LIT:.>" in part for part in production_names[:-<NUM_LIT:1>]):<EOL><INDENT>return _agl_compliant_name(glyph_name)<EOL><DEDENT>if not _character_outside_BMP and any(<EOL>part.startswith("<STR_LIT>") for part in production_names<EOL>):<EOL><INDENT>uni_names = []<EOL>for part in production_names:<EOL><INDENT>if part.startswith("<STR_LIT>"):<EOL><INDENT>uni_names.append(part[<NUM_LIT:3>:])<EOL><DEDENT>elif len(part) == <NUM_LIT:5> and _is_unicode_u_value(part):<EOL><INDENT>uni_names.append(part[<NUM_LIT:1>:])<EOL><DEDENT>elif part in fontTools.agl.AGL2UV:<EOL><INDENT>uni_names.append("<STR_LIT>".format(fontTools.agl.AGL2UV[part]))<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>final_production_name = "<STR_LIT>" + "<STR_LIT>".join(uni_names) + dot + suffix<EOL><DEDENT>else:<EOL><INDENT>final_production_name = "<STR_LIT:_>".join(production_names) + dot + suffix<EOL><DEDENT>return _agl_compliant_name(final_production_name)<EOL>
Return the production name for a glyph name from the GlyphData.xml
    database according to the AGL specification.

    This should be run only if there is no official entry with a production
    name in it.

    Handles single glyphs (e.g. "brevecomb") and ligatures (e.g.
    "brevecomb_acutecomb"). Returns None when a valid and semantically
    meaningful production name can't be constructed or when the AGL
    specification would be violated, get_glyph() will use the bare glyph
    name then.

    Note:
    - Glyph name is the full name, e.g. "brevecomb_acutecomb.case".
    - Base name is the base part, e.g. "brevecomb_acutecomb"
    - Suffix is e.g. "case".