Commits

Juan BC committed 9a152bb

added support for import yyf

Comments (0)

Files changed (5)

     - hap_id: hap0
       a: 1
       b: 2
-      c: 3
+      c: "3"
     - hap_id: hap1
-      b: "hola"
+      b: 56
       c: "chau"
 
 facts:
     - weight: 30
       haps_id:
           - hap0
-          - hap 1
+          - hap1

yatel/gui/connection_setup.py

         """
         filename = None
         if self._action == self.CREATE:
-            filename = QtGui.QFileDialog.getSaveFileName(
-                self, self.tr("Save Database"),
-                yatel.HOME_PATH,
-                self.tr("sqlite (*.db)")
-            )
+            filename = QtGui.QFileDialog.getSaveFileName(self,
+                                                         self.tr("Save Database"),
+                                                         yatel.HOME_PATH,
+                                                         self.tr("sqlite (*.db)"))
         elif self._action == self.OPEN:
-            filename = QtGui.QFileDialog.getOpenFileName(
-                self, self.tr("Open Database File"),
-                yatel.HOME_PATH,
-                self.tr("sqlite (*.db)")
-            )
+            filename = QtGui.QFileDialog.getOpenFileName(self,
+                                                         self.tr("Open Database File"),
+                                                         yatel.HOME_PATH,
+                                                         self.tr("sqlite (*.db)"))
         if filename:
             self.nameLineEdit.setText(filename)
 

yatel/gui/main_window.py

 
 import yatel
 from yatel import db
+from yatel.conversors import yyf2yatel
 
 from yatel.gui import uis
 from yatel.gui import csv_wizard
             del self.dialog
 
     @QtCore.pyqtSlot()
+    def on_actionImportYYF_triggered(self):
+        """Slot executed when ``actionImportYYF`` is triggered.
+
+        Show a file dialog for select a "Yatel Yaml Format" to be imported
+
+        """
+        if not self.close_explorer():
+            return
+        self.dialog = connection_setup.ConnectionSetupDialog(self, "create")
+        try:
+            title = self.tr("Open Yatel Yaml Format")
+            filetypes = self.tr("Yatel Yaml Format (*.yyf *.yaml *.yml)")
+            filename = QtGui.QFileDialog.getOpenFileName(self, title,
+                                                         yatel.HOME_PATH,
+                                                         filetypes)
+            if filename:
+                with open(filename) as fp:
+                    haps, facts, edges = yyf2yatel.load(fp)
+            if not self.dialog.exec_():
+                return
+            conn = db.YatelConnection(**self.dialog.params())
+            conn.init_with_values(haps, facts, edges)
+        except Exception as err:
+            error_dialog.critical(self.tr("Error"), err)
+        else:
+            self.open_explorer(conn, saved=False)
+        finally:
+            self.dialog.setParent(None)
+            self.dialog.destroy()
+            del self.dialog
+
+    @QtCore.pyqtSlot()
     def on_actionImportCSV_triggered(self):
         """Slot executed when ``actionImportCSV`` is triggered.
 

yatel/gui/network.py

         self.haplotype = hap
         self.x, self.y = x, y
         self.aprender(habilidades.Arrastrable)
-        self.aprender(habilidades.AumentarConRueda)
         self._texto.aprender(habilidades.Imitar, self)
-        self._texto.aprender(habilidades.AumentarConRueda)
         self._selected.aprender(habilidades.Imitar, self)
-        self._selected.aprender(habilidades.AumentarConRueda)
         # connect events
         eventos.click_de_mouse.conectar(self._on_mouse_clicked,
                                         id=hex(id(self)))

yatel/gui/uis/MainWindow.ui

       <string>&amp;Import</string>
      </property>
      <addaction name="actionImportCSV"/>
+     <addaction name="actionImportYYF"/>
     </widget>
     <addaction name="actionOpenYatelDB"/>
     <addaction name="menu_Import"/>
     <string>CSV</string>
    </property>
   </action>
+  <action name="actionImportYYF">
+   <property name="text">
+    <string>YYF</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>