def get_supported_language_list(CodecName=None): if CodecName is None: result = [] for record in parser.get_codec_list_db(): for language in record[2]: if language not in result: result.append(language) result.sort() return result else: for record in parser.get_codec_list_db(): if record[0] == CodecName: return record[2] return []
def get_supported_language_list(CodecName=None): if CodecName is None: result = [] for record in parser.get_codec_list_db(): for language in record[2]: if language not in result: result.append(language) result.sort() return result else: for record in parser.get_codec_list_db(): if record[0] == CodecName: return record[2] return []
def get_supported_codec_list(IncludeAliasesF=False): global _supported_codec_list global _supported_codec_list_plus_aliases assert type(IncludeAliasesF) == bool if len(_supported_codec_list) != 0: if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list file_name = "%s/00-SUPPORTED.txt" % QUEX_CODEC_DB_PATH content = get_file_content_or_die(file_name) _supported_codec_list = content.split() _supported_codec_list_plus_aliases = copy(_supported_codec_list) _supported_codec_list.sort() codec_db_list = parser.get_codec_list_db() for codec_name, aliases_list, dummy in codec_db_list: if codec_name in _supported_codec_list: _supported_codec_list_plus_aliases.extend( filter(lambda x: x != "", aliases_list)) _supported_codec_list_plus_aliases.sort() if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list
def get_codecs_for_language(Language): result = [] for record in parser.get_codec_list_db(): codec = record[0] if codec not in get_supported_codec_list(): continue if Language in record[2]: result.append(record[0]) if len(result) == 0: verify_word_in_list(Language, get_supported_language_list(), "No codec found for language '%s'." % Language) return result
def _get_distinct_codec_name_for_alias(CodecAlias, FH=-1, LineN=None): """Arguments FH and LineN correspond to the arguments of error_msg.""" assert len(CodecAlias) != 0 for record in parser.get_codec_list_db(): if CodecAlias in record[1] or CodecAlias == record[0]: return record[0] verify_word_in_list(CodecAlias, get_supported_codec_list(), "Character encoding '%s' unknown to current version of quex." % CodecAlias, FH, LineN)
def get_codecs_for_language(Language): result = [] for record in parser.get_codec_list_db(): codec = record[0] if codec not in get_supported_codec_list(): continue if Language in record[2]: result.append(record[0]) if len(result) == 0: verify_word_in_list(Language, get_supported_language_list(), "No codec found for language '%s'." % Language) return result
def get_file_name_for_codec_alias(CodecAlias): """Arguments FH and LineN correspond to the arguments of error.log.""" assert CodecAlias for record in parser.get_codec_list_db(): if CodecAlias in record[1] or CodecAlias == record[0]: codec_name = record[0] return codec_name, "%s/%s.dat" % (QUEX_CODEC_DB_PATH, codec_name) error.verify_word_in_list(CodecAlias, get_supported_codec_list(), "Character encoding '%s' unknown to current version of quex." % CodecAlias)
def _get_distinct_codec_name_for_alias(CodecAlias, FH=-1): """Arguments FH and LineN correspond to the arguments of error.log.""" assert len(CodecAlias) != 0 for record in parser.get_codec_list_db(): if CodecAlias in record[1] or CodecAlias == record[0]: return record[0] error.verify_word_in_list( CodecAlias, get_supported_codec_list(), "Character encoding '%s' unknown to current version of quex." % CodecAlias, FH)
def get_supported_codec_list(IncludeAliasesF=False): assert type(IncludeAliasesF) == bool global _supported_codec_list if len(_supported_codec_list) != 0: if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list file_name = QUEX_PATH + "/quex/engine/codec_db/database/00-SUPPORTED.txt" content = get_file_content_or_die(file_name) _supported_codec_list = content.split() _supported_codec_list.sort() codec_db_list = parser.get_codec_list_db() for codec_name, aliases_list, dummy in codec_db_list: if codec_name in _supported_codec_list: _supported_codec_list_plus_aliases.extend(filter(lambda x: x != "", aliases_list)) _supported_codec_list_plus_aliases.sort() if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list
def get_supported_codec_list(IncludeAliasesF=False): assert type(IncludeAliasesF) == bool global _supported_codec_list if len(_supported_codec_list) != 0: if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list file_name = QUEX_PATH + "/quex/engine/codec_db/database/00-SUPPORTED.txt" content = get_file_content_or_die(file_name) _supported_codec_list = content.split() _supported_codec_list.sort() codec_db_list = parser.get_codec_list_db() for codec_name, aliases_list, dummy in codec_db_list: if codec_name in _supported_codec_list: _supported_codec_list_plus_aliases.extend( filter(lambda x: x != "", aliases_list)) _supported_codec_list_plus_aliases.sort() if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list
def get_supported_codec_list(IncludeAliasesF=False): global _supported_codec_list global _supported_codec_list_plus_aliases assert type(IncludeAliasesF) == bool if len(_supported_codec_list) != 0: if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list file_name = "%s/00-SUPPORTED.txt" % QUEX_CODEC_DB_PATH content = get_file_content_or_die(file_name) _supported_codec_list = content.split() _supported_codec_list_plus_aliases = copy(_supported_codec_list) _supported_codec_list.sort() codec_db_list = parser.get_codec_list_db() for codec_name, aliases_list, dummy in codec_db_list: if codec_name in _supported_codec_list: _supported_codec_list_plus_aliases.extend(filter(lambda x: x != "", aliases_list)) _supported_codec_list_plus_aliases.sort() if IncludeAliasesF: return _supported_codec_list_plus_aliases else: return _supported_codec_list
db.append((input_interval, target_interval_begin)) fh = open_file_or_die(QUEX_CODEC_DB_PATH + "/%s.dat" % TargetEncoding, "wb") fh.write("// Describes mapping from Unicode Code pointer to Character code in %s (%s)\n" \ % (TargetEncoding, TargetEncodingName)) fh.write("// [SourceInterval.begin] [SourceInterval.Size] [TargetInterval.begin] (all in hexidecimal)\n") for i, t in db: fh.write("0x%X %i 0x%X\n" % (i.begin, i.end - i.begin, t)) fh.close() return True if __name__ == "__main__": # PURPOSE: Helper script to create database files that describe the mapping from # unicode characters to character codes of a particular encoding. fh = open("00-ALL.txt") fh_supported = open("00-SUPPORTED.txt", "wb") # FIELD SEPARATOR: ';' # RECORD SEPARATOR: '\n' # FIELDS: [Python Coding Name] [Aliases] [Languages] # Aliases and Languages are separated by ',' db_list = get_codec_list_db() for record in db_list: codec = record[0] language_list = record[2] print repr(language_list) + " (", codec, ")", if __create_database_file(codec, language_list): fh_supported.write("%s " % codec) print "[OK]"
"wb") fh.write("// Describes mapping from Unicode Code pointer to Character code in %s (%s)\n" \ % (TargetEncoding, TargetEncodingName)) fh.write( "// [SourceInterval.begin] [SourceInterval.Size] [TargetInterval.begin] (all in hexidecimal)\n" ) for i, t in db: fh.write("0x%X %i 0x%X\n" % (i.begin, i.end - i.begin, t)) fh.close() return True if __name__ == "__main__": # PURPOSE: Helper script to create database files that describe the mapping from # unicode characters to character codes of a particular encoding. fh = open("00-ALL.txt") fh_supported = open("00-SUPPORTED.txt", "wb") # FIELD SEPARATOR: ';' # RECORD SEPARATOR: '\n' # FIELDS: [Python Coding Name] [Aliases] [Languages] # Aliases and Languages are separated by ',' db_list = get_codec_list_db() for record in db_list: codec = record[0] language_list = record[2] print repr(language_list) + " (", codec, ")", if __create_database_file(codec, language_list): fh_supported.write("%s " % codec) print "[OK]"