def _upgrade_041_to_042(self, config_parser): import config try: config_parser = confparser.config() config_parser.read(config.sword_paths_file) if not config_parser.has_section("Install"): config_parser.add_section("Install") config_parser.set("Install", "LocalePath", "locales\\dummy") config_parser.write(open(config.sword_paths_file, "w")) except EnvironmentError, e: dprint(WARNING, "Error on upgrading - is sword.conf writable?", e)
def FindXULRunnerVersion(self): """Find the XULRunner version from the XULRunner platform.ini config file. This should be provided by XULRunner (and then wxWebConnect) through the nsIXULAppInfo API, but it seems this is only possible when xulrunner has been run from the command line and has an application.ini and XRE_Main() has been called. Since XRE_Main() is just looking up the value in the INI file, I figure it can't hurt too much to do the same here. """ xulrunner_ini_file = os.path.join(xulrunner_path, "platform.ini") config_parser = confparser.config() config_parser.read(xulrunner_ini_file) if config_parser.has_option("Build", "Milestone"): config.xulrunner_version = config_parser.get("Build", "Milestone")[0] dprint(MESSAGE,"XULRunner version is %s." % config.xulrunner_version)
def FindXULRunnerVersion(self): """Find the XULRunner version from the XULRunner platform.ini config file. This should be provided by XULRunner (and then wxWebConnect) through the nsIXULAppInfo API, but it seems this is only possible when xulrunner has been run from the command line and has an application.ini and XRE_Main() has been called. Since XRE_Main() is just looking up the value in the INI file, I figure it can't hurt too much to do the same here. """ xulrunner_ini_file = os.path.join(xulrunner_path, "platform.ini") config_parser = confparser.config() config_parser.read(xulrunner_ini_file) if config_parser.has_option("Build", "Milestone"): config.xulrunner_version = config_parser.get("Build", "Milestone")[0] dprint(MESSAGE, "XULRunner version is %s." % config.xulrunner_version)
def write_paths(self, paths, filename=config.sword_paths_file): paths = paths[::-1] config_parser = confparser.config() config_parser.read(filename) if not config_parser.has_section("Install"): config_parser.add_section("Install") config_parser.set("Install", "DataPath", paths[0]) config_parser.set("Install", "AugmentPath", []) # We set the locale path to a dummy directory to give us greater # control of the locale setup process. config_parser.set("Install", "LocalePath", "locales\\dummy") augment_paths = config_parser.get("Install", "AugmentPath") del augment_paths[0] augment_paths.extend(paths[1:]) config_parser.write(open(filename, "w"))
def read_config(self, conf_file): config_parser = confparser.config() file_obj = StringIO(self.zip_file.read(conf_file)) config_parser._read(file_obj, conf_file) sections = config_parser.sections() if not sections: raise BadMetadata(_("Cannot read book metadata in file %s") % self.zip_file) if len(sections) > 1: dprint(WARNING, "More than one section in module. Taking the first one:", sections[0]) section_name = sections[0] config_section = MultiMap() for item in config_parser.options(section_name): config_section[item] = config_parser.get(section_name, item) return config_section, section_name
def load_paths(self, filename=config.sword_paths_file): config_parser = confparser.config() try: f = open(filename) config_parser._read(f, filename) except EnvironmentError: return ["resources"] data_path = "resources" if config_parser.has_option("Install", "DataPath"): data_path = config_parser.get("Install", "DataPath")[0] if config_parser.has_option("Install", "AugmentPath"): paths = config_parser.get("Install", "AugmentPath")[::-1] if data_path and data_path not in paths: paths.append(data_path) else: paths = [data_path] if "resources" not in paths: paths.append("resources") return paths
def read_config(self, conf_file): config_parser = confparser.config() file_obj = StringIO(self.zip_file.read(conf_file)) config_parser._read(file_obj, conf_file) sections = config_parser.sections() if not sections: raise BadMetadata( _("Cannot read book metadata in file %s") % self.zip_file) if len(sections) > 1: dprint(WARNING, "More than one section in module. Taking the first one:", sections[0]) section_name = sections[0] config_section = MultiMap() for item in config_parser.options(section_name): config_section[item] = config_parser.get(section_name, item) return config_section, section_name