예제 #1
0
def testXmlPath(xmlPath):
    if ResMgr.isFile(xmlPath):
        if ResMgr.openSection(xmlPath) is None:
            return XMLSectionStatus.CORRUPTED, xmlPath
        return XMLSectionStatus.NORMAL, xmlPath
    elif ResMgr.isDir(xmlPath):
        return XMLSectionStatus.DIRECTORY, xmlPath
    xmlDirname = EngineUtils.joinResMgrPath(xmlPath, os.pardir)
    if ResMgr.isDir(xmlDirname):
        return XMLSectionStatus.MISSING, xmlPath
    return testXmlPath(xmlDirname)
예제 #2
0
def getResMgrDirectoryContent(path):
    uniques = lambda entries: sorted(set(entries), key=entries.index)
    if ResMgr.isDir(path):
        section = ResMgr.openSection(path)
        if section is not None:
            return uniques(section.keys())
    return None
예제 #3
0
    def getSubSec(subsec, pPath, sPath=""):
        #if sPath == "" and subsec.name != "root":
        #    if subsec.name == "scripts":
        #        return
        #    if subsec.name == "content":
        #        return
        #    if subsec.name == "system":
        #        return
        #    if subsec.name == "packages":
        #        return
        #    if subsec.name == "vehicles":
        #        return
        #    if subsec.name == "maps":
        #        return

        if sPath != "root" and subsec.name != "root":
            if sPath == "":
                sPath = subsec.name
            else:
                sPath += "/" + subsec.name

        isFile = ResMgr.isFile(sPath)
        isDir = ResMgr.isDir(sPath)

        if isFile:
            print "in Section (%s) - File" % (sPath)
            pPath += "\\" + subsec.name
            if os.path.exists(pPath) == False:
                with open(pPath, "ab") as f:
                    if subsec.asBinary:
                        f.write(subsec.asBinary)
                    elif subsec.asWideString:
                        f.write(subsec.asWideString)
                    elif subsec.asString:
                        f.write(subsec.asString)
                f.close()

                print "File (%s) created" % (pPath)
        elif isDir:
            print "in Section (%s) - Directory" % (sPath)
            pPath += "\\" + subsec.name
            if os.path.exists(pPath) == False:
                os.mkdir(pPath)
                print "Directory (%s) created" % (pPath)
        else:
            pass
            #print "in Section (%s) - Content" % (sPath)
            #if subsec.name == "root":
            #    WriteFileContent(subsec, pPath + "\\wot_file")
            #else:
            #    WriteFileContent(subsec, pPath)

        subchilds = subsec.items()
        if len(subchilds) != 0:
            for (keyname, sec) in subchilds:
                getSubSec(sec, pPath, sPath)
        return
예제 #4
0
def list_directory(vfs_directory):
    """
    Returns list of elements in a directory within a wotmod package.

    :param vfs_directory: directory path within a package
    :return: list of elements
    """
    result = []
    folder = ResMgr.openSection(vfs_directory)
    if folder is not None and ResMgr.isDir(vfs_directory):
        for name in folder.keys():
            if name not in result:
                result.append(name)
    return sorted(result)
예제 #5
0
def list_directory(vfs_directory):
    """
    Returns list of elements in a directory within a wotmod package.

    :param vfs_directory: directory path within a package
    :return: list of elements
    """
    result = []
    folder = ResMgr.openSection(vfs_directory)
    if folder is not None and ResMgr.isDir(vfs_directory):
        for name in folder.keys():
            if name not in result:
                result.append(name)
    return sorted(result)
예제 #6
0
def walkResMgrTree(dirpath):
    entries = getResMgrDirectoryContent(dirpath)
    if entries is not None:
        dirnames = filter(
            lambda subpath: ResMgr.isDir(joinResMgrPath(dirpath, subpath)),
            entries)
        filenames = filter(
            lambda subpath: ResMgr.isFile(joinResMgrPath(dirpath, subpath)),
            entries)
        yield dirpath, dirnames, filenames
        for dirname in dirnames:
            for block in walkResMgrTree(joinResMgrPath(dirpath, dirname)):
                yield block
    return
예제 #7
0
    def buildSubSectionNodes(Section, pPath, sPath = ''):
        ''' if sPath == 'content':
            return
        elif sPath == 'packages':
            return
        elif sPath == 'maps':
            return
        elif sPath == 'system/maps':
            return
        elif sPath == 'vehicles':
            return
        elif sPath == 'objects':
            return '''

        if Section.name != 'root':
            if sPath == '':
                sPath = Section.name
            else:
                sPath += '/%s' % (Section.name)

        isFile = ResMgr.isFile(sPath)
        isDir = ResMgr.isDir(sPath)
        subItems = Section.items()

        print 'in Section (%s)' % (sPath)

        if isFile:
            pPath += '\\%s' % (Section.name)
            if os.path.exists(pPath) == False:
                with open(pPath, 'wb') as f:
                    if len(subItems) == 0:
                        binStr = Section.asBinary
                        if binStr:
                            f.write(binStr)
                    else:
                        f.write('<%s>\n' % (Section.name))
                        buildNodeString(Section, f)
                        f.write('</%s>\n' % (Section.name))
                    print 'File (%s) created' % (pPath)
        elif isDir:
            pPath += '\\%s' % (Section.name)
            if os.path.exists(pPath) == False:
                os.mkdir(pPath)
                print 'Directory (%s) created' % (pPath)

        for (keyName, sec) in subItems:
            buildSubSectionNodes(sec, pPath, sPath)

        ResMgr.purge(sPath)
예제 #8
0
def extendPath(path, name):
    from pkgutil import extend_path
    path = extend_path(path, name)
    if not isinstance(path, list):
        return path
    pname = os.path.join(*name.split('.'))
    init_py = '__init__' + os.extsep + 'py'
    path = path[:]
    for dir in sys.path:
        if not isinstance(dir, basestring) or not ResMgr.isDir(dir):
            continue
        subdir = os.path.join(dir, pname)
        initfile = os.path.join(subdir, init_py)
        if subdir not in path and ResMgr.isFile(initfile):
            path.append(subdir)

    return path
예제 #9
0
def gatherChunks(spaceDir):
    if spaceDir[-1] != "/":
        spaceDir = spaceDir + "/"
    result = []
    entries = ResMgr.openSection(spaceDir)
    if entries:
        for entry in entries.keys():
            if entry[0] == ".":
                continue
            if ResMgr.isDir(spaceDir + entry):
                children = gatherChunks(spaceDir + entry)
                result.extend(children)
            else:
                entry = entry.lower()
                if len(entry) == 15 and entry[-6:] == ".chunk":
                    result.append(spaceDir + entry)

    return result
예제 #10
0
def gatherChunks(spaceDir):
    if spaceDir[-1] != '/':
        spaceDir = spaceDir + '/'
    result = []
    entries = ResMgr.openSection(spaceDir)
    if entries:
        for entry in entries.keys():
            if entry[0] == '.':
                continue
            if ResMgr.isDir(spaceDir + entry):
                children = gatherChunks(spaceDir + entry)
                result.extend(children)
            else:
                entry = entry.lower()
                if len(entry) == 15 and entry[-6:] == '.chunk':
                    result.append(spaceDir + entry)

    return result
예제 #11
0
def extendPath(path, name):
    """Extend path, this method is based on pkgutil.extend_path and will
    allow aid on supporting inheriting resource paths.
    
    Example usage:
    from BWUtil import extendPath
    __path__ = extendPath(__path__, __name__)
    """
    from pkgutil import extend_path
    path = extend_path(path, name)
    if not isinstance(path, list):
        return path
    pname = os.path.join(*name.split('.'))
    init_py = '__init__' + os.extsep + 'py'
    path = path[:]
    for dir in sys.path:
        if not isinstance(dir, basestring) or not ResMgr.isDir(dir):
            continue
        subdir = os.path.join(dir, pname)
        initfile = os.path.join(subdir, init_py)
        if subdir not in path and ResMgr.isFile(initfile):
            path.append(subdir)

    return path
예제 #12
0
def extendPath(path, name):
    """Extend path, this method is based on pkgutil.extend_path and will
    allow aid on supporting inheriting resource paths.
    
    Example usage:
    from BWUtil import extendPath
    __path__ = extendPath(__path__, __name__)
    """
    from pkgutil import extend_path
    path = extend_path(path, name)
    if not isinstance(path, list):
        return path
    pname = os.path.join(*name.split('.'))
    init_py = '__init__' + os.extsep + 'py'
    path = path[:]
    for dir in sys.path:
        if not isinstance(dir, basestring) or not ResMgr.isDir(dir):
            continue
        subdir = os.path.join(dir, pname)
        initfile = os.path.join(subdir, init_py)
        if subdir not in path and ResMgr.isFile(initfile):
            path.append(subdir)

    return path
예제 #13
0
    def readCamouflages(self, doShopCheck):
        self.configFolders.clear()
        self.camouflages = {'modded': {}}
        self.camouflagesCache = PYmodsCore.loadJson(self.ID, 'camouflagesCache', self.camouflagesCache, self.configPath)
        try:
            camoDirPath = '../' + self.configPath + 'camouflages'
            camoDirSect = ResMgr.openSection(camoDirPath)
            camoNames = set(
                (x for x in camoDirSect.keys() if ResMgr.isDir(camoDirPath + '/' + x)) if camoDirSect is not None else [])
            for camoName in camoNames:
                self.configFolders[camoName] = confFolder = set()
                settings = PYmodsCore.loadJson(self.ID, 'settings', {}, self.configPath + 'camouflages/' + camoName + '/')
                for key in settings:
                    confFolder.add(key)
                self.camouflages['modded'].update(settings)
        except StandardError:
            traceback.print_exc()

        self.interCamo = [x['name'] for x in items.vehicles.g_cache.customization(0)['camouflages'].itervalues()]
        for nationID in xrange(1, len(nations.NAMES)):
            camoNames = [x['name'] for x in items.vehicles.g_cache.customization(nationID)['camouflages'].itervalues()]
            self.interCamo = [x for x in self.interCamo if x in camoNames]
        self.origInterCamo = [x for x in self.interCamo if x not in self.camouflages['modded']]
        settings = PYmodsCore.loadJson(self.ID, 'settings', {}, self.configPath)
        if 'disable' in settings:
            if not settings['disable']:
                del settings['disable']
            else:
                self.disable = settings['disable']
        for nation in settings.keys():
            if nation not in nations.NAMES:
                if nation != 'international':
                    del settings[nation]
                    continue
                nationID = 0
            else:
                nationID = nations.INDICES[nation]
            camouflages = items.vehicles.g_cache.customization(nationID)['camouflages']
            nationConf = settings[nation]
            camoNames = [camouflage['name'] for camouflage in camouflages.values()]
            for camoName in nationConf:
                if camoName not in camoNames:
                    del nationConf[camoName]
            for camoID, camouflage in camouflages.items():
                camoName = camouflage['name']
                if camoName not in nationConf:
                    continue
                camoInShop = not doShopCheck or g_customizationController.dataAggregator._elementIsInShop(
                    camoID, 0, nationID)
                if nationConf[camoName].get('random_mode') == 2 or nationConf[camoName].get(
                        'random_mode') == 1 and camoName not in self.interCamo:
                    del nationConf[camoName]['random_mode']
                kinds = nationConf[camoName].get('kinds')
                if kinds is not None:
                    kindNames = filter(None, kinds.split(','))
                    if len(kindNames) == 1 and kindNames[0] == CAMOUFLAGE_KIND_INDICES[
                            camouflage['kind']] or camoInShop and doShopCheck:
                        del nationConf[camoName]['kinds']
                        if camoInShop:
                            print '%s: in-shop camouflage kind changing is disabled (name: %s)' % (self.ID, camoName)
                for team in ('Ally', 'Enemy'):
                    if nationConf[camoName].get('useFor%s' % team):
                        del nationConf[camoName]['useFor%s' % team]
                if not nationConf[camoName]:
                    del nationConf[camoName]
            if not nationConf:
                del settings[nation]
            else:
                self.camouflages[nation] = nationConf
        newSettings = {}
        if self.disable:
            newSettings['disable'] = self.disable
        for nation in settings:
            newSettings[nation] = settings[nation]
        PYmodsCore.loadJson(self.ID, 'settings', newSettings, self.configPath, True)
예제 #14
0
파일: config.py 프로젝트: GodzillaUA/PYmods
    def readCurrentSettings(self, quiet=True):
        super(ConfigInterface, self).readCurrentSettings()
        self.settings = PYmodsCore.loadJson(self.ID, 'settings', self.settings, self.configPath)
        self.skinsCache.update(PYmodsCore.loadJson(self.ID, 'skinsCache', self.skinsCache, self.configPath))
        configsPath = self.configPath + 'remods/*.json'
        self.OM.enabled = bool(glob.glob(configsPath))
        if self.OM.enabled:
            self.OM.selected = PYmodsCore.loadJson(self.ID, 'remodsCache', self.OM.selected, self.configPath)
            snameList = set()
            for configPath in glob.iglob(configsPath):
                sname = os.path.basename(configPath).split('.')[0]
                confDict = PYmodsCore.loadJson(self.ID, sname, {}, os.path.dirname(configPath) + '/', encrypted=True)
                if not confDict:
                    print '%s: error while reading %s.' % (self.ID, os.path.basename(configPath))
                    continue
                settingsDict = self.settings['remods'].setdefault(sname, {})
                snameList.add(sname)
                if not settingsDict.setdefault('enabled', self.defaultRemodConfig['enabled']):
                    print '%s: %s disabled, moving on' % (self.ID, sname)
                    if sname in self.OM.models:
                        del self.OM.models[sname]
                    continue
                self.OM.models[sname] = pRecord = OMDescriptor()
                pRecord.name = sname
                pRecord.authorMessage = confDict.get('authorMessage', '')
                for tankType in OM.tankGroups:
                    selected = self.OM.selected[tankType]
                    swapKey = 'swap%s' % tankType
                    WLKey = '%sWhitelist' % tankType.lower()
                    whiteStr = settingsDict.setdefault(WLKey, confDict.get(WLKey, ''))
                    templist = [x.strip() for x in whiteStr.split(',') if x]
                    whitelist = pRecord.whitelists[tankType]
                    whitelist.update(templist)
                    if not whitelist:
                        if self.data['isDebug']:
                            print '%s: empty whitelist for %s. Not applied to %s tanks.' % (
                                self.ID, sname, tankType.lower())
                    else:
                        if self.data['isDebug']:
                            print '%s: whitelist for %s: %s' % (self.ID, tankType.lower(), list(whitelist))
                        for xmlName in selected:
                            if sname == selected[xmlName] and xmlName not in whitelist:
                                selected[xmlName] = None
                    if not settingsDict.setdefault(swapKey, confDict.get(swapKey, self.defaultRemodConfig[swapKey])):
                        if self.data['isDebug']:
                            print '%s: %s swapping in %s disabled.' % (self.ID, tankType.lower(), sname)
                        whitelist.clear()
                        for xmlName in selected:
                            if sname == selected[xmlName]:
                                selected[xmlName] = None
                for key, data in pRecord.data.iteritems():
                    if key == 'common':
                        confSubDict = confDict
                    else:
                        confSubDict = confDict.get(key)
                    if not confSubDict:
                        continue
                    if 'undamaged' in data:
                        data['undamaged'] = confSubDict['undamaged']
                    if 'AODecals' in data and 'AODecals' in confSubDict and 'hullPosition' in confSubDict:
                        data['AODecals'] = readAODecals(confSubDict['AODecals'])
                        data['hullPosition'] = Math.Vector3(tuple(confSubDict['hullPosition']))
                    if 'camouflage' in data and 'exclusionMask' in confSubDict.get('camouflage', {}):
                        data['camouflage']['exclusionMask'] = confSubDict['camouflage']['exclusionMask']
                        if 'tiling' in confSubDict['camouflage']:
                            data['camouflage']['tiling'] = tuple(confDict['camouflage']['tiling'])
                    elif key == 'common' and self.data['isDebug']:
                        print '%s: default camomask not found for %s' % (self.ID, sname)
                    if 'emblemSlots' in data:
                        data['emblemSlots'] = readEmblemSlots(confSubDict.get('emblemSlots', []))
                    if 'exhaust' in data:
                        if 'nodes' in confSubDict.get('exhaust', {}):
                            data['exhaust']['nodes'] = confSubDict['exhaust']['nodes'].split()
                        if 'pixie' in confSubDict.get('exhaust', {}):
                            data['exhaust']['pixie'] = confSubDict['exhaust']['pixie']
                    if key == 'chassis':
                        for k in ('traces', 'tracks', 'wheels', 'groundNodes', 'trackNodes', 'splineDesc', 'trackParams'):
                            data[k] = confSubDict[k]
                    for subKey in ('effects', 'reloadEffect', 'wwsoundPC', 'wwsoundNPC'):
                        if subKey in data and subKey in confSubDict:
                            data[subKey] = confSubDict[subKey]
                if self.data['isDebug']:
                    print '%s: config for %s loaded.' % (self.ID, sname)

            for sname in self.OM.models.keys():
                if sname not in snameList:
                    del self.OM.models[sname]

            for sname in self.settings['remods'].keys():
                if sname not in snameList:
                    del self.settings['remods'][sname]

            if not self.OM.models:
                if not quiet:
                    print '%s: no configs found, model module standing down.' % self.ID
                self.OM.enabled = False
                PYmodsCore.loadJson(self.ID, 'remodsCache', self.OM.selected, self.configPath, True, quiet=quiet)
            else:
                remodTanks = {key: set() for key in self.OM.selected}
                for OMDesc in self.OM.models.values():
                    for tankType, whitelist in OMDesc.whitelists.iteritems():
                        for xmlName in whitelist:
                            remodTanks[tankType].add(xmlName)
                            if xmlName not in self.OM.selected[tankType]:
                                self.OM.selected[tankType][xmlName] = None
                for tankType in OM.tankGroups:
                    for xmlName in self.OM.selected[tankType].keys():
                        if (self.OM.selected[tankType][xmlName] and self.OM.selected[tankType][
                                xmlName] not in self.OM.models):
                            self.OM.selected[tankType][xmlName] = None
                        if xmlName not in remodTanks[tankType]:
                            del self.OM.selected[tankType][xmlName]
                if self.OM.selected['Remod'] and self.OM.selected['Remod'] not in self.OM.models:
                    self.OM.selected['Remod'] = ''
                PYmodsCore.loadJson(self.ID, 'remodsCache', self.OM.selected, self.configPath, True, quiet=quiet)
        else:
            if not quiet:
                print '%s: no remods found, model module standing down.' % self.ID
            self.OM.enabled = False
            PYmodsCore.loadJson(self.ID, 'remodsCache', self.OM.selected, self.configPath, True, quiet=quiet)
        self.OS.enabled = ResMgr.openSection('vehicles/skins/') is not None and ResMgr.isDir('vehicles/skins/')
        if self.OS.enabled:
            self.OS.priorities = PYmodsCore.loadJson(self.ID, 'skinsPriority', self.OS.priorities, self.configPath)
            skinDir = 'vehicles/skins/textures/'
            for skinTypeSuff in ('', '_dynamic'):
                skinType = 'static' if not skinTypeSuff else skinTypeSuff[1:]
                skinsSettings = self.settings['skins%s' % skinTypeSuff]
                disabledSkins = []
                if self.data['isDebug']:
                    print '%s: loading configs for %s skins' % (self.ID, skinType)
                skinDirSect = ResMgr.openSection(skinDir)
                for sname in [] if skinDirSect is None else PYmodsCore.remDups(skinDirSect.keys()):
                    confDict = skinsSettings.setdefault(sname, self.defaultSkinConfig[skinType])
                    if not confDict.get('enabled', True):
                        print '%s: %s disabled, moving on' % (self.ID, sname)
                        disabledSkins.append(sname)
                        continue
                    self.OS.models[skinType][sname] = pRecord = OSDescriptor()
                    pRecord.name = sname
                    priorities = self.OS.priorities[skinType]
                    for tankType in priorities:
                        key = 'swap%s' % tankType
                        if not confDict.setdefault(key, self.defaultSkinConfig[skinType][key]):
                            if self.data['isDebug']:
                                print '%s: %s swapping in %s disabled.' % (self.ID, tankType, sname)
                            if sname in priorities[tankType]:
                                priorities[tankType].remove(sname)
                            continue
                        if sname not in priorities[tankType]:
                            priorities[tankType].append(sname)
                    pRecord.whitelist.clear()
                    vehiclesDirPath = skinDir + sname + '/vehicles/'
                    vehiclesDirSect = ResMgr.openSection(vehiclesDirPath)
                    for curNation in [] if vehiclesDirSect is None else PYmodsCore.remDups(vehiclesDirSect.keys()):
                        nationDirPath = vehiclesDirPath + curNation + '/'
                        nationDirSect = ResMgr.openSection(nationDirPath)
                        for vehicleName in [] if nationDirSect is None else PYmodsCore.remDups(nationDirSect.keys()):
                            vehDirPath = nationDirPath + vehicleName + '/'
                            vehDirSect = ResMgr.openSection(vehDirPath)
                            tracksDirPath = vehDirPath + 'tracks/'
                            tracksDirSect = ResMgr.openSection(tracksDirPath)
                            if not [texName for texName in
                                    ([] if vehDirSect is None else PYmodsCore.remDups(vehDirSect.keys())) if
                                    texName.endswith('.dds')] and not [texName for texName in (
                                    [] if tracksDirSect is None else PYmodsCore.remDups(tracksDirSect.keys())) if
                                                                       texName.endswith('.dds')]:
                                if self.data['isDebug']:
                                    print '%s: %s folder from %s pack is empty' % (
                                        self.ID, vehicleName, sname)
                            else:
                                pRecord.whitelist.add(vehicleName)

                    if self.data['isDebug']:
                        print '%s: config for %s loaded.' % (self.ID, sname)
                snameList = self.OS.models[skinType].keys() + disabledSkins
                for sname in skinsSettings.keys():
                    if sname not in snameList:
                        del skinsSettings[sname]
            if not any(self.OS.models.values()):
                if not quiet:
                    print '%s: no skins configs found, skins module standing down.' % self.ID
                self.OS.enabled = False
                for skinType in self.OS.priorities:
                    for key in self.OS.priorities[skinType]:
                        self.OS.priorities[skinType][key] = []
            else:
                for skinType in self.OS.priorities:
                    for key in self.OS.priorities[skinType]:
                        for sname in list(self.OS.priorities[skinType][key]):
                            if sname not in self.OS.models[skinType]:
                                self.OS.priorities[skinType][key].remove(sname)
        else:
            if not quiet:
                print '%s: no skins found, skins module standing down.' % self.ID
            for skinType in self.OS.priorities:
                for key in self.OS.priorities[skinType]:
                    self.OS.priorities[skinType][key] = []
        PYmodsCore.loadJson(self.ID, 'skinsPriority', self.OS.priorities, self.configPath, True, quiet=quiet)
        PYmodsCore.loadJson(self.ID, 'settings', self.settings, self.configPath, True, quiet=quiet)
예제 #15
0
 def readCurrentSettings(self, quiet=True):
     super(ConfigInterface, self).readCurrentSettings(quiet)
     self.configFolders.clear()
     self.camouflages = {'remap': {}, 'custom': {}}
     self.outfitCache = loadJson(self.ID, 'outfitCache', self.outfitCache,
                                 self.configPath)
     if os.path.isfile(self.configPath + 'camouflagesCache.json'):
         camouflagesCache = loadJson(self.ID, 'camouflagesCache', {},
                                     self.configPath)
         for nat in camouflagesCache:
             for vehName in camouflagesCache[nat]:
                 for season in camouflagesCache[nat][vehName]:
                     self.outfitCache.setdefault(nat, {}).setdefault(vehName, {}).setdefault(season, {})['camo'] = \
                         camouflagesCache[nat][vehName][season]
         os.remove(self.configPath + 'camouflagesCache.json')
         loadJson(self.ID, 'outfitCache', self.outfitCache, self.configPath,
                  True)
     try:
         camoDirPath = '../' + self.configPath + 'camouflages'
         camoDirSect = ResMgr.openSection(camoDirPath)
         for camoName in remDups((
                 x for x in camoDirSect.keys()
                 if ResMgr.isDir(camoDirPath + '/' +
                                 x)) if camoDirSect is not None else []):
             self.configFolders[camoName] = confFolder = set()
             fileName = self.configPath + 'camouflages/' + camoName + '/'
             settings = loadJson(self.ID, 'settings', {}, fileName)
             for key in settings:
                 conf = settings[key]
                 if 'kinds' in conf:
                     conf['season'] = conf['kinds']
                     del conf['kinds']
                 if 'season' in conf:
                     seasonNames = [
                         x for x in conf['season'].split(',') if x
                     ]
                     seasonType = SeasonType.UNDEFINED
                     for season in seasonNames:
                         if season in SEASONS_CONSTANTS.SEASONS:
                             seasonType |= getattr(SeasonType,
                                                   season.upper())
                         else:
                             print self.ID + ': unknown season name for camouflage', key + ':', season
                             conf['season'] = conf['season'].replace(
                                 season, '')
                     while ',,' in conf['season']:
                         conf['season'] = conf['season'].replace(',,', ',')
                 else:
                     conf['season'] = ','.join(SEASONS_CONSTANTS.SEASONS)
                 confFolder.add(key)
             self.camouflages['custom'].update(settings)
             loadJson(self.ID, 'settings', settings, fileName, True)
     except StandardError:
         traceback.print_exc()
     camouflages = items.vehicles.g_cache.customization20().camouflages
     camoNames = {
         id: getCamoTextureName(x)
         for id, x in camouflages.iteritems()
         if 'custom' not in x.priceGroupTags
     }
     camoIndices = {}
     for camoID, camoName in camoNames.iteritems():
         camoIndices.setdefault(camoName, []).append(camoID)
     self.interCamo = []
     for camoName, indices in camoIndices.iteritems():
         nationsList = []
         for ID in indices:
             for filterNode in camouflages[ID].filter.include:
                 if filterNode.nations:
                     nationsList += filterNode.nations
         if set(nationsList) >= set(
                 idx for idx, name in enumerate(nations.NAMES)
                 if name != 'italy'):
             self.interCamo.append(camoName)
     settings = loadJson(self.ID, 'settings', {}, self.configPath)
     if 'disable' in settings:
         if not settings['disable']:
             del settings['disable']
         else:
             self.disable = settings['disable']
     if 'remap' in settings:
         conf = settings['remap']
         for camoName in conf.keys():
             try:
                 camoName = int(camoName)
             except ValueError:
                 if camoName not in camoIndices:
                     print self.ID + ': unknown camouflage for remapping:', camoName
                 else:
                     for camoID in camoIndices[camoName]:
                         conf[camoID] = conf[camoName].copy()
                 del conf[camoName]
                 continue
             if camoName not in camoNames:
                 print self.ID + ': unknown camouflage for remapping:', camoName
                 del conf[str(camoName)]
             else:
                 conf[camoName] = conf.pop(str(camoName))
         for camoID, camouflage in camouflages.items():
             if camoID not in conf:
                 continue
             camoConf = conf[camoID]
             if camoConf.get('random_mode') == RandMode.RANDOM:
                 del camoConf['random_mode']
             if 'kinds' in camoConf:
                 camoConf['season'] = camoConf['kinds']
                 del camoConf['kinds']
             if 'season' in camoConf:
                 seasonNames = [
                     x for x in camoConf['season'].split(',') if x
                 ]
                 seasonType = SeasonType.UNDEFINED
                 for season in seasonNames:
                     if season in SEASONS_CONSTANTS.SEASONS:
                         seasonType |= getattr(SeasonType, season.upper())
                     else:
                         print self.ID + ': unknown season name for camouflage', camoID + ':', season
                         camoConf['season'] = camoConf['season'].replace(
                             season, '')
                 while ',,' in camoConf['season']:
                     camoConf['season'] = camoConf['season'].replace(
                         ',,', ',')
                 if seasonType == camouflage.season:
                     del camoConf['season']
             for team in ('Ally', 'Enemy'):
                 if camoConf.get('useFor' + team):
                     del camoConf['useFor' + team]
             if not camoConf:
                 del conf[camoID]
         self.camouflages['remap'] = conf
     newSettings = {}
     if self.disable:
         newSettings['disable'] = self.disable
     newSettings['remap'] = settings.get('remap', {})
     loadJson(self.ID, 'settings', newSettings, self.configPath, True)