def _init_settings_files(fsName_): """Construct a dict mapping directory paths to setting files. Keys are tuples of absolute paths to directories, paired with the relative paths in the backup file. Values are sets of setting files in those paths, or empty, meaning we have to list those paths and backup everything.""" if not initialization.bash_dirs_initialized: raise BoltError(u'_init_settings_files: Bash dirs are not initialized') settings_info = { (dirs['mopy'], jo(fsName_, u'Mopy')): { u'bash.ini', }, (dirs['mods'].join(u'Bash'), jo(fsName_, u'Data', u'Bash')): { u'Table.dat', }, (dirs['mods'].join(u'Docs'), jo(fsName_, u'Data', u'Docs')): { u'Bash Readme Template.txt', u'Bash Readme Template.html', u'My Readme Template.txt', u'My Readme Template.html', u'wtxt_sand_small.css', u'wtxt_teal.css', }, (dirs['modsBash'], jo(fsName_ + u' Mods', u'Bash Mod Data')): { u'Table.dat', }, (dirs['modsBash'].join(u'INI Data'), jo(fsName_ + u' Mods', u'Bash Mod Data', u'INI Data')): { u'Table.dat', }, (dirs['bainData'], jo(fsName_ + u' Mods', u'Bash Installers', u'Bash')): { u'Converters.dat', u'Installers.dat', }, (dirs['saveBase'], jo(u'My Games', fsName_)): { u'BashProfiles.dat', u'BashSettings.dat', u'BashLoadOrders.dat', u'People.dat', }, # backup all files in Mopy\bash\l10n, Data\Bash Patches\ and # Data\INI Tweaks\ (dirs['l10n'], jo(fsName_, u'Mopy', u'bash', u'l10n')): {}, (dirs['mods'].join(u'Bash Patches'), jo(fsName_, u'Data', u'Bash Patches')): {}, (dirs['mods'].join(u'INI Tweaks'), jo(fsName_, u'Data', u'INI Tweaks')): {}, } for setting_files in settings_info.itervalues(): for settings_file in set(setting_files): if settings_file.endswith(u'.dat'): # add corresponding bak file setting_files.add(settings_file + u'.bak') return settings_info
def gl(s): return [ f for g in [ glob(jo(p, '**', s), recursive=True) for p in self._paths.values() ] for f in g ]
def __init__(self, config='data.cfg'): self.conf = ConfigParser() self.conf.read(config) self._data = {} base = self.conf['base']['path'] self._paths = {k: jo(base, v) for k, v in self.conf['paths'].items()} self.open('_sta', 'stations.h5')
def backup_ini_path(self): """Get the path to the backup bash.ini if it exists - must be run before restore_settings is called, as we need the Bash ini to initialize bass.dirs.""" if self._extract_dir is self.__unset: raise BoltError( u'backup_ini_path: you must extract the settings file first') for r, d, fs in bolt.walkdir(u'%s' % self._extract_dir): for f in fs: if f == u'bash.ini': self._bash_ini_path = jo(r, f) break else: self.bash_ini_path = None return self._bash_ini_path