def main(): if len(sys.argv) < 3: print('Usage: {} [input model] [output directory]'.format(sys.argv[0])) exit(0) filename = os.path.abspath(sys.argv[1]) output_folder = sys.argv[2] if os.path.splitext(filename)[1] == '.xcdatamodeld': filename = os.path.join(filename, 'Model.xcdatamodel/contents') model = ModelParser.parse_file(filename) if os.path.isdir(output_folder) is False: os.mkdir(output_folder) for entity in model.entities: name = entity.name interface_filename = filename_for_extension(output_folder, name, 'h') EntityInterfaceWriter(entity).write(interface_filename) implementation_filename = filename_for_extension(output_folder, name, 'm') EntityImplementationWriter(entity).write(implementation_filename)
def test_parser(self): base_path = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) model_fixture = 'fixtures/KFDataFixture/Model.xcdatamodeld/Model.xcdatamodel/contents' filename = os.path.join(base_path, model_fixture) model = ModelParser.parse_file(filename) self.assertEqual(model, self.fixture_model())