Пример #1
0
def ImportFromPNG(win: QW.QWidget,
                  gallery_seed_log: ClientImportGallerySeeds.GallerySeedLog,
                  can_generate_more_pages: bool):

    with QP.FileDialog(win,
                       'select the png with the urls',
                       wildcard='PNG (*.png)') as dlg:

        if dlg.exec() == QW.QDialog.Accepted:

            path = dlg.GetPath()

            try:

                payload_string = ClientSerialisable.LoadStringFromPNG(path)

                urls = GetURLsFromURLsString(payload_string)

                ImportURLs(win, gallery_seed_log, urls,
                           can_generate_more_pages)

            except:

                QW.QMessageBox.critical(win, 'Error', 'Could not import!')

                raise
Пример #2
0
    def _ExportToJSON(self):

        export_object = self._GetExportObject()

        if export_object is not None:

            json = export_object.DumpToString()

            with QP.FileDialog(self,
                               'select where to save the json file',
                               default_filename='export.json',
                               wildcard='JSON (*.json)',
                               acceptMode=QW.QFileDialog.AcceptSave,
                               fileMode=QW.QFileDialog.AnyFile) as f_dlg:

                if f_dlg.exec() == QW.QDialog.Accepted:

                    path = f_dlg.GetPath()

                    if os.path.exists(path):

                        from hydrus.client.gui import ClientGUIDialogsQuick

                        message = 'The path "{}" already exists! Ok to overwrite?'.format(
                            path)

                        result = ClientGUIDialogsQuick.GetYesNo(self, message)

                        if result != QW.QDialog.Accepted:

                            return

                    with open(path, 'w', encoding='utf-8') as f:

                        f.write(json)
Пример #3
0
 def _ImportFromPng( self ):
     
     with QP.FileDialog( self, 'select the png or pngs with the encoded data', acceptMode = QW.QFileDialog.AcceptOpen, fileMode = QW.QFileDialog.ExistingFiles, wildcard = 'PNG (*.png)|*.png' ) as dlg:
         
         if dlg.exec() == QW.QDialog.Accepted:
             
             paths = dlg.GetPaths()
             
             self._ImportPngs( paths )
             
         
     
     self._listctrl.Sort()
Пример #4
0
 def EventSaveToFile( self ):
     
     filename = 'keys.txt'
     
     with QP.FileDialog( self, acceptMode = QW.QFileDialog.AcceptSave, defaultFile = filename ) as dlg:
         
         if dlg.exec() == QW.QDialog.Accepted:
             
             path = dlg.GetPath()
             
             with open( path, 'w', encoding = 'utf-8' ) as f:
                 
                 f.write( self._text )
Пример #5
0
    def _ImportFromJSON(self):

        with QP.FileDialog(self,
                           'select the json or jsons with the serialised data',
                           acceptMode=QW.QFileDialog.AcceptOpen,
                           fileMode=QW.QFileDialog.ExistingFiles,
                           wildcard='JSON (*.json)|*.json') as dlg:

            if dlg.exec() == QW.QDialog.Accepted:

                paths = dlg.GetPaths()

                self._ImportJSONs(paths)

        self._listctrl.Sort()
Пример #6
0
 def _ImportFromPng( self ):
     
     with QP.FileDialog( self, 'select the png with the urls', wildcard = 'PNG (*.png)' ) as dlg:
         
         if dlg.exec() == QW.QDialog.Accepted:
             
             path = dlg.GetPath()
             
             payload = ClientSerialisable.LoadFromPng( path )
             
             try:
                 
                 urls = self._GetURLsFromURLsString( payload )
                 
                 self._ImportURLs( urls )
                 
             except:
                 
                 QW.QMessageBox.critical( self, 'Error', 'Could not import!' )
                 
                 raise
Пример #7
0
    def _ImportFromPNG(self):

        with QP.FileDialog(self,
                           'select the png with the sources',
                           wildcard='PNG (*.png)') as dlg:

            if dlg.exec() == QW.QDialog.Accepted:

                path = dlg.GetPath()

                try:

                    payload_string = ClientSerialisable.LoadStringFromPNG(path)

                    sources = self._GetSourcesFromSourcesString(payload_string)

                    self._ImportSources(sources)

                except:

                    QW.QMessageBox.critical(self, 'Error', 'Could not import!')

                    raise
Пример #8
0
def ImportFromPNG(win: QW.QWidget,
                  file_seed_cache: ClientImportFileSeeds.FileSeedCache):

    with QP.FileDialog(win,
                       'select the png with the sources',
                       wildcard='PNG (*.png)') as dlg:

        if dlg.exec() == QW.QDialog.Accepted:

            path = dlg.GetPath()

            try:

                payload_string = ClientSerialisable.LoadStringFromPNG(path)

                sources = GetSourcesFromSourcesString(payload_string)

                ImportSources(file_seed_cache, sources)

            except:

                QW.QMessageBox.critical(win, 'Error', 'Could not import!')

                raise