def __init__(self, file, version): self.filename = file self.version = convert.to_version(version, version) # Meta data information self.config = OrderedDict() # The actual config values self.values = {} self.check_version() self.load_default() self.parse(self.filename)
def check_version(self): """ Determines if config needs to be deleted. """ if not os.path.exists(self.filename): with io.open(self.filename, mode='wb') as fp: fp.write("version: {0}".format( convert.from_version(self.version))) return None version = None try: with io.open(self.filename, mode='rb') as fp: m = self._RE_VERSION.match(fp.readline()) version = convert.to_version(m.group(1)) except (AttributeError, TypeError): pass if not self.version or version[:-1] != self.version[:-1]: os.rename(self.filename, "{0}.old".format(self.filename)) with io.open(self.filename, mode='wb') as fp: fp.write("version: {0}".format(convert.from_version(self.version)))
configdir = os.path.join(DATADIR, 'pyLoad' if os.name == 'nt' else '.pyload') return os.path.abspath(os.path.join(configdir, profile)) def _gen_info(): """ Load info dict from `setup.py`. """ fp, filename, desc = imp.find_module('setup', PACKDIR) module = imp.load_module('_setup', fp, filename, desc) return module.info _info = _gen_info() _version = convert.to_version(_info['version']) class Restart(Exception): __slots__ = [] def __str__(self): return """<RestartSignal {0}>""".format(self.message) class Shutdown(Exception): __slots__ = [] def __str__(self): return """<ShutdownSignal {0}>""".format(self.message)
from pyload.utils.misc import install_translation from pyload.utils.path import availspace, makedirs, pyclean, remove from pyload.utils.struct.info import Info def _get_setup_map(): """ Load info dict from `setup.py`. """ fp, filename, desc = imp.find_module('setup', PACKDIR) module = imp.load_module('_setup', fp, filename, desc) return module.SETUP_MAP __setup_map = _get_setup_map() __core_version = convert.to_version(__setup_map['version']) def _gen_profiledir(profile=None, configdir=None): if not profile: profile = 'default' if configdir: configdir = os.path.expanduser(configdir) else: configdir = os.path.join(DATADIR, 'pyLoad' if os.name == 'nt' else '.pyload') profiledir = os.path.abspath(os.path.join(configdir, profile)) makedirs(profiledir) return profiledir
from pyload.utils.check import ismodule from pyload.utils.misc import install_translation from pyload.utils.path import availspace, makedirs, pyclean, remove from pyload.utils.struct.info import Info def _get_setup_map(): """ Load info dict from `setup.py`. """ fp, filename, desc = imp.find_module('setup', PACKDIR) module = imp.load_module('_setup', fp, filename, desc) return module.SETUP_MAP __setup_map = _get_setup_map() __core_version = convert.to_version(__setup_map['version']) def _gen_profiledir(profile=None, configdir=None): if not profile: profile = 'default' if configdir: configdir = os.path.expanduser(configdir) else: configdir = os.path.join( DATADIR, 'pyLoad' if os.name == 'nt' else '.pyload') profiledir = os.path.abspath(os.path.join(configdir, profile)) makedirs(profiledir) return profiledir