Exemplo n.º 1
0
def main():
    # ----------------------------- ARGPARSE ----------------------------

    parser = argparse.ArgumentParser()
    parser.add_argument("--path", type=str, help="enter path to file")
    parser.add_argument("--format", type=str, help="enter format to convert")
    args = parser.parse_args()
    file_path = getattr(args, 'path')
    new_format_type = getattr(args, 'format')

    print(file_path)
    print(new_format_type)

    # --------------------------- UTILITY WORK ------------------------------

    str_parts = file_path.split(".")
    initial_format_type = str_parts[1]
    serializer = Factory.create_serializer(initial_format_type)
    py_obj = serializer.deserialize("", file_path)

    serializer = Factory.create_serializer(new_format_type)

    new_file_name = str_parts[0] + "." + new_format_type
    serializer.serialize(py_obj, new_file_name)
Exemplo n.º 2
0
Arquivo: task.py Projeto: dmkrch/Labs
 def load(self):
     s = Factory.create_serializer("json")
     self.objects_set = s.deserialize("", "save_set.json")
Exemplo n.º 3
0
Arquivo: task.py Projeto: dmkrch/Labs
 def save(self):
     s = Factory.create_serializer("json")
     s.serialize(self.objects_set, "save_set.json")