'Create master file of strings and their distribution in modules'

@classmethod
def create_master_file(cls):

    try:
        import cPickle as pickle
    except:
        import pickle
    api = TranslateAPI()
    modules = api.get_modules()
    modules.append('core')
    all_strings = []
    addstring = all_strings.append
    indices = {}
    string_indices = {}
    index = 0
    get_strings_by_module = api.get_strings_by_module
    for module in modules:
        module_indices = []
        addindex = module_indices.append
        strings = get_strings_by_module(module)
        for (origin, string) in strings:
            if (((string[0] == '"') and (string[(-1)] == '"')) or ((string[0] == "'") and (string[(-1)] == "'"))):
                string = string[1:(-1)]
            string_index = string_indices.get(string)
            if (string_index is None):
                string_indices[string] = index
                addstring(string)
                addindex(index)
                index += 1
            else:
                addindex(string_index)
        indices[module] = module_indices
    data_file = os.path.join(current.request.folder, 'uploads', 'temp.pkl')
    f = open(data_file, 'wb')
    pickle.dump(all_strings, f)
    pickle.dump(indices, f)
    f.close()
    ptable = current.s3db.translate_percentage
    current.db((ptable.id > 0)).update(dirty=True)
