Beispiel #1
0
    def set_up(self):

        self.setMinimumWidth(600)
        self.setModal(True)
        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)

        self.form_layout = QtWidgets.QFormLayout()
        self.form = QtWidgets.QWidget()
        self.form.setLayout(self.form_layout)
        self.layout.addWidget(self.form)

        self.temp_store = Store()
        self.db = self.temp_store.datasources.DB()
        self.dbrel = self.temp_store.datasources.DBRel()
        self.ds = None

        connstrings = []
        for row in self.view.menu.get_recent(
        ):  # [[url], [identifier, connstr], ...]
            if len(row) == 2:
                connstrings.append(row[1])

        self.connstr = QtWidgets.QComboBox()
        if connstrings:
            self.connstr.addItems(connstrings)
        self.connstr.setEditable(True)
        self.connstr.currentTextChanged.connect(self.on_connstr_changed)

        self.identifier = QtWidgets.QListWidget()

        self.form_layout.addRow("Connect string:", self.connstr)
        self.form_layout.addRow("Identifier:", self.identifier)

        if connstrings:
            self.on_connstr_changed(connstrings[0])
Beispiel #2
0
    def __init__(self, model, view, parent):

        self.model = model
        self.view = view
        self.parent = parent

        self._connstr_prev = None
        self._schemas = defaultdict(lambda: defaultdict(
            list))  # {server: {db_name: [schema, ...], ...}, ...}
        self._identifiers = []

        DModule.__init__(self)
        QtWidgets.QFrame.__init__(self, parent)

        self.form = QtWidgets.QWidget()
        self.form.setLayout(QtWidgets.QFormLayout())

        self.setLayout(QtWidgets.QVBoxLayout())
        self.layout().setContentsMargins(10, 10, 10, 10)

        self.server_combo = QtWidgets.QComboBox()
        self.server_combo.setEditable(True)
        self.db_name_combo = QtWidgets.QComboBox()
        self.db_name_combo.setEditable(True)
        self.schema_name_combo = QtWidgets.QComboBox()
        self.schema_name_combo.setEditable(True)
        self.schema_name_combo.setCurrentText("public")
        self.user_edit = QtWidgets.QLineEdit("")
        self.user_edit.textChanged.connect(self.update)
        self.pass_edit = QtWidgets.QLineEdit("")
        self.pass_edit.setEchoMode(QtWidgets.QLineEdit.Password)
        self.pass_edit.textChanged.connect(self.update)
        self.identifier_combo = QtWidgets.QComboBox()
        self.identifier_combo.setEditable(True)
        self.local_folder_edit = QtWidgets.QLineEdit("")
        self.local_folder_edit.textChanged.connect(self.on_local_folder_edit)
        self.local_folder_edit._edited = False
        self.lf_browse_button = QtWidgets.QPushButton("Browse...")
        self.lf_browse_button.clicked.connect(self.on_lf_browse)

        lf_container = QtWidgets.QWidget()
        lf_container.setLayout(QtWidgets.QHBoxLayout())
        lf_container.layout().setContentsMargins(0, 0, 0, 0)
        lf_container.layout().addWidget(self.local_folder_edit)
        lf_container.layout().addWidget(self.lf_browse_button)

        self.temp_store = Store()
        self.db = self.temp_store.datasources.DB()
        servers = []
        logins = []
        names = {}  # {server: [name, ...], ...}
        for row in self.view.menu.get_recent(
        ):  # [[url], [identifier, connstr], ...]
            if len(row) == 2:
                server, name = row[1].split("/")[-2:]
                schema = "public"
                if "?" in name:
                    name, schema = name.split("?")
                    schema = schema.split("%3D")[-1]
                user, server = server.split("@")
                user, password = user.split(":")
                if server not in names:
                    names[server] = []
                if name not in names[server]:
                    names[server].append(name)
                if schema not in self._schemas[server][name]:
                    self._schemas[server][name].append(schema)
                if server not in servers:
                    servers.append(server)
                    logins.append([user, password])
        self.server_combo.addItem("")
        for i in range(len(servers)):
            self.server_combo.addItem(servers[i], [servers[i]] + logins[i] +
                                      [names[servers[i]]])

        self.server_combo.editTextChanged.connect(self.on_server_changed)
        self.db_name_combo.editTextChanged.connect(self.update)
        self.schema_name_combo.editTextChanged.connect(self.update)
        self.identifier_combo.editTextChanged.connect(
            self.on_identifier_changed)

        self.connect_button = QtWidgets.QPushButton(
            self.parent.connect_caption())
        self.connect_button.clicked.connect(self.on_connect)

        self.form.layout().addRow("Server[:port]:", self.server_combo)
        self.form.layout().addRow("Database:", self.db_name_combo)
        self.form.layout().addRow("Schema:", self.schema_name_combo)
        self.form.layout().addRow("Username:"******"Password:"******"Identifier:", self.identifier_combo)
        self.form.layout().addRow("Local Folder:", lf_container)

        self.layout().addWidget(self.form)
        self.layout().addWidget(self.connect_button,
                                alignment=QtCore.Qt.AlignCenter)
        self.layout().addStretch()

        self.update()
Beispiel #3
0
from deposit.store.Store import Store
from lib.fnc_matching import *

store = Store()
store.load("d:\\documents_synced\\CeraMatch\\DEP_kap_typology\\kap_typology.json")

cmax = len(store.classes["Sample"].objects)
cnt = 1
for id in store.classes["Sample"].objects:
	print("\r%d/%d               " % (cnt, cmax), end = "")
	cnt += 1
	obj = store.objects[id]
	profile = np.array(obj.descriptors["Profile"].label.coords[0])
	axis, thickness = profile_axis(profile, rasterize_factor = 10)
	axis_length = np.sqrt((np.diff(axis, axis = 0) ** 2).sum(axis = 1)).sum()
	obj.add_descriptor("Axis_Length", axis_length)
	obj.add_descriptor("Norm_Length", axis_length / thickness)
	
store.save()