def test_modify(config): modifier = LookMlModifier(config) infile = "test/basic.lkml" outfile = "test/temp.lkml" if os.path.exists(outfile): os.remove(outfile) modifier.modify(infile, outfile) assert os.path.exists(outfile) inlines = open(infile, 'r').readlines() outlines = open(outfile, 'r').readlines() assert len(inlines) == 45 assert len(outlines) == 46 assert inlines[22].strip() == 'description: "this' assert outlines[27].strip() == 'description: "this is a new description" # programmatically added by LookML modifier' assert inlines[10].strip() == "type: string" assert outlines[10].strip() == "description: \"This" assert outlines[11].strip() == "is" assert outlines[12].strip() == "the" assert outlines[13].strip() == "correct" assert outlines[14].strip() == "description\" # programmatically added by LookML modifier" if os.path.exists(outfile): os.remove(outfile) if os.path.exists(config['tmp_file']): os.remove(config['tmp_file'])
def test_modify2(config): config = { "definitions": { "type": "CsvDefinitionsProvider", "filename": "test/definitions_basename.csv", }, "use_basename": True, } modifier = LookMlModifier(config) infile = "test/basic.view.lkml" outfile = "test/temp.lkml" if os.path.exists(outfile): os.remove(outfile) modifier.modify(infile, outfile) assert os.path.exists(outfile) inlines = open(infile, "r").readlines() outlines = open(outfile, "r").readlines() assert len(inlines) == 45 assert len(outlines) == 46 assert inlines[22].strip() == 'description: "this' assert ( outlines[27].strip() == 'description: "this is a new description" # programmatically added by LookML modifier' ) assert inlines[10].strip() == "type: string" assert outlines[10].strip() == 'description: "This' assert outlines[11].strip() == "is" assert outlines[12].strip() == "the" assert outlines[13].strip() == "correct" assert ( outlines[14].strip() == 'description" # programmatically added by LookML modifier' ) if os.path.exists(outfile): os.remove(outfile)
def main(): """ """ logging.basicConfig( format= '%(asctime)s %(levelname)s %(filename)s %(funcName)s: %(message)s', level=logging.INFO) args, _ = parse_arguments() if os.path.exists(args.config): with open(args.config, 'r') as f: config = json.load(f) else: raise Exception('config file at: {} not found'.format(args.config)) modifier = LookMlModifier(config) modifier.modify(args.infile, args.outfile)
def updater(args): modifier = LookMlModifier() modifier.modify(args.infile, args.outfile)