Example #1
0
    def test_import_model_small(self):
        model_path = get_resource_path('model/mysqlwb-small.mwb')
        data = mysqlwb.import_model(model_path, 'name', 'version')
        with open(get_resource_path('model/mysqlwb-small.json')) as fin:
            expected_data = json.load(fin)

        self.assertDictEqual(expected_data, data)
Example #2
0
    def test_import_model_small(self):
        model_path = get_resource_path('model/mysqlwb-small.mwb')
        data = mysqlwb.import_model(model_path, 'name', 'version')
        with open(get_resource_path('model/mysqlwb-small.json')) as fin:
            expected_data = json.load(fin)

        self.assertDictEqual(expected_data, data)
Example #3
0
            "id":
            element.get('id').strip('{}'),
            "foreignKeyId":
            element.find('.link[@key="foreignKey"]').text.strip('{}'),
            "element": {
                "draw": draw
            }
        }
    except AttributeError as e:
        print(
            "Could not parse element with id %s, could not find foreignKey link"
            % element.get('id'))


def convert_workbench_size(value):
    segments = value.split("e+")
    return int(float(segments[0]) * (10**int(segments[1])))


def read_model_from_zip(path):
    zip_file = ZipFile(path)
    return zip_file.read("document.mwb.xml")


if __name__ == '__main__':
    import json

    model_path = get_resource_path('model/mysqlwb.mwb')
    data = import_model(model_path, 'name', 'version')
    print(json.dumps(data, separators=(',', ':')))
Example #4
0
    else:
        draw = "hidden"
    try:
        return {
            "id": element.get('id').strip('{}'),
            "foreignKeyId": element.find('.link[@key="foreignKey"]').text.strip('{}'),
            "element": {
                "draw": draw
            }
        }
    except AttributeError as e:
        print("Could not parse element with id %s, could not find foreignKey link" % element.get('id'))


def convert_workbench_size(value):
    segments = value.split("e+")
    return int(float(segments[0]) * (10 ** int(segments[1])))


def read_model_from_zip(path):
    zip_file = ZipFile(path)
    return zip_file.read("document.mwb.xml")


if __name__ == '__main__':
    import json

    model_path = get_resource_path('model/mysqlwb.mwb')
    data = import_model(model_path, 'name', 'version')
    print(json.dumps(data, separators=(',', ':')))