def serialize_TOC(self, output_idx, output_data): """Dump the TOC data to the file """ if self.tocReady: dumper = Dumper(output_idx) dumper.dump(self.TOC) dumper.close() dumper = Dumper(output_data) dumper.dumpForEach(self.TOCEntries) dumper.close()
def serialize_glyf(self, output_idx, output_data): """Dump the Glyf data to the file """ if self.glyfReady: dumper = Dumper(output_idx) dumper.dump(self.GlyphTable) dumper.dump_for_each(self.glyphs_info) dumper.close() dumper = Dumper(output_data) dumper.dump_for_each(self.glyphs_data) dumper.close()
def serialize_cff(self, output_idx, output_data): """Dump the Glyf data to the file """ if self.cffReady: dumper = Dumper(output_idx) dumper.dump(self.CffTable) dumper.dump_for_each(self.glyphs_info) dumper.close() dumper = Dumper(output_data) dumper.dump_for_each(self.glyphs_data) dumper.close()
def serialize_TOC(self, output_idx, output_data): """Dump the TOC data to the file """ # TODO(bstell) remove this is not used anywhere if self.tocReady: dumper = Dumper(output_idx) dumper.dump(self.TOC) dumper.close() dumper = Dumper(output_data) dumper.dumpForEach(self.TOCEntries) dumper.close()
def test_dumping(self): dump_handler = Dumper(config.backups_path, db.get_connection()) dumps = dump_handler.dump() self.assertEqual(True, len(dumps) > 0, 'Dumps paths list is empty') self.assertEqual( True, len(os.listdir(config.backups_path)) > 0, '%s dir must be contains backups' % config.backups_path ) dump_handler.clear()
def sha1_fingerprint(self): dumper = Dumper(self.folder + '/sha1_fingerprint') fingerprint = FontInfo.getInformation(self.fontfile, ['SHA1'])['SHA1'] dumper.dump(fingerprint) dumper.close()
def main(): global vaultFactory mydir = os.path.dirname(os.path.realpath(__file__)) parser = argparse.ArgumentParser() parser.add_argument('--src', required=True) parser.add_argument('--mark', choices=["none", "both", "start", "end"]) parser.add_argument('--dump', action='store_true') parser.add_argument('--dumpPasswords', action='store_true') parser.add_argument('--out') # Generate a file to set some variable param = parser.parse_args() loggingConfFile = os.path.join(mydir, "./logging.yml") logging.config.dictConfig( yaml.load(open(loggingConfFile), Loader=yaml.SafeLoader)) sourceFile = os.path.normpath(os.path.abspath(param.src)) if not os.path.isfile(sourceFile): ERROR("File '{}' does not exists".format(sourceFile)) logger.info("Will handle '{}'".format(sourceFile)) sourceFileDir = os.path.dirname(sourceFile) cluster = yaml.load(open(sourceFile), Loader=yaml.SafeLoader) targetFolder = misc.appendPath( sourceFileDir, cluster["build_folder"] if "build_folder" in cluster else "build") misc.ensureFolder(targetFolder) logger.info("Build folder: '{}'".format(targetFolder)) if "config_file" in cluster: baseConfigFile = cluster["config_file"] else: baseConfigFile = "ezconfig.yml" config, configFile = buildConfig(sourceFileDir, baseConfigFile) plugins = [] plugins.append(Plugin("core", misc.appendPath(mydir, "../plugins/core"))) logger.debug("Plugins path:'{}'".format(config[PLUGINS_PATH])) appendPlugins(plugins, cluster, config[PLUGINS_PATH]) schema = buildSchema(mydir, plugins) configSchema, safeConfigSchema = buildConfigSchema(mydir, config[PLUGINS_PATH]) if param.dump: dumper = Dumper(targetFolder, param.dumpPasswords) dumper.dump("schema.json", schema) dumper.dump("config-schema.json", configSchema) dumper.dump("safe-config-schema.json", safeConfigSchema) else: dumper = None k = kwalify(source_data=cluster, schema_data=schema) k.validate(raise_exception=False) if len(k.errors) != 0: ERROR("Problem {0}: {1}".format(sourceFile, k.errors)) k = kwalify(source_data=config, schema_data=configSchema) k.validate(raise_exception=False) if len(k.errors) != 0: ERROR("Configuration problem {0}: {1}".format(configFile, k.errors)) data = {} data['sourceFileDir'] = sourceFileDir data["targetFolder"] = targetFolder data['ezclusterHome'] = misc.appendPath(mydir, "..") data["rolePaths"] = set() data["configFile"] = configFile model = {} model['cluster'] = cluster model["config"] = config model['data'] = data initVault(model) if SAFE_CONFIG in model and safeConfigSchema != None: k = kwalify(source_data=model[SAFE_CONFIG], schema_data=safeConfigSchema) k.validate(raise_exception=False) if len(k.errors) != 0: ERROR("Configuration problem {0}: {1}".format( model["data"][_SAFE_CONFIG_FILE_], k.errors)) for plugin in plugins: plugin.groom(model) for plugin in plugins: plugin.groom2(model) targetFileByName = buildTargetFileByName(plugins) if param.dump: dumper.dump("cluster.json", model['cluster']) dumper.dump("data.json", model['data']) dumper.dump("targetFileByName.json", targetFileByName) dumper.dump("config.json", config) if SAFE_CONFIG in model and dumper.unsafe: dumper.dump("safeConfig.json", model[SAFE_CONFIG]) for plugin in plugins: plugin.dump(model, dumper) generate(targetFileByName, targetFolder, model, param.mark, dumper) if "out" in param: f = open(param.out, "w+") f.write("# Generated by ezcluster:\n") if "buildScript" in model["data"]: f.write('BUILD_SCRIPT="{}"\n'.format(model["data"]["buildScript"])) f.close()