Пример #1
0
 def installAssets(self, assets_path):
     assets = QDir(assets_path)
     assets.mkdir("plugins")
     assets.cd("plugins")
     assets.mkdir("animate")
     QFile.copy(":/animate.css",
                assets_path + "/plugins/animate/animate.css")
Пример #2
0
    def __load(self):
        """
        Private slot to load the available scripts into the manager.
        """
        scriptsDir = QDir(self.scriptsDirectory())
        if not scriptsDir.exists():
            scriptsDir.mkpath(self.scriptsDirectory())

        if not scriptsDir.exists("requires"):
            scriptsDir.mkdir("requires")

        self.__disabledScripts = Preferences.getWebBrowser(
            "GreaseMonkeyDisabledScripts")

        from .GreaseMonkeyScript import GreaseMonkeyScript
        for fileName in scriptsDir.entryList(["*.js"], QDir.Files):
            absolutePath = scriptsDir.absoluteFilePath(fileName)
            script = GreaseMonkeyScript(self, absolutePath)

            if not script.isValid():
                del script
                continue

            self.__scripts.append(script)

            if script.fullName() in self.__disabledScripts:
                script.setEnabled(False)
            else:
                collection = WebBrowserWindow.webProfile().scripts()
                collection.insert(script.webScript())

        self.__jsObject.setSettingsFile(
            os.path.join(Utilities.getConfigDir(), "web_browser",
                         "greasemonkey_values.ini"))
        ExternalJsObject.registerExtraObject("GreaseMonkey", self.__jsObject)
Пример #3
0
 def initUndoRedo(self):
     self.undoStack = QUndoStack()
     temp = QDir(os.path.join(QDir.tempPath(), "FlatSiteBuilder"))
     if temp.exists():
         temp.removeRecursively()
     temp.setPath(QDir.tempPath())
     temp.mkdir("FlatSiteBuilder")
Пример #4
0
    def import_color_schema_from_file(self, filepath: str) -> None:
        """Imports color schema from a file"""
        # Parse schema
        try:
            schema = toml.load(filepath)
        except Exception as e:
            print(
                f"Failed to parse color schema at path: {filepath} Error: {str(e)}"
            )
            return

        # Assume file is not Manuwrite color schema if it doesn't have this key-value pair
        try:
            if not schema["Data type"] == "Manuwrite color schema":
                raise ValueError
        except ValueError:
            return

        schema_name = schema["Schema name"]
        new_path = self.get_appdata_path(
        ) + "/color_schemas/" + schema_name + "/schema.toml"

        try:
            # Create schema dir
            directory = QDir(self.get_appdata_path() + "/color_schemas")
            directory.mkdir(schema_name)

            # Copy schema to its dir and add to SettingsManager
            schemas = self.get_setting_value("Colors/Color_schemas")
            schemas[schema_name] = {"name": schema_name, "path": new_path}
            self.set_setting_value("Colors/Color_schemas", schemas)

            QFile.copy(filepath, new_path)
        except Exception:
            print(f"Failed to copy color schema files to path: {new_path}")
Пример #5
0
    def __load(self):
        """
        Private slot to load the available scripts into the manager.
        """
        scriptsDir = QDir(self.scriptsDirectory())
        if not scriptsDir.exists():
            scriptsDir.mkpath(self.scriptsDirectory())

        if not scriptsDir.exists("requires"):
            scriptsDir.mkdir("requires")

        self.__disabledScripts = \
            Preferences.getHelp("GreaseMonkeyDisabledScripts")

        from .GreaseMonkeyScript import GreaseMonkeyScript
        for fileName in scriptsDir.entryList(["*.js"], QDir.Files):
            absolutePath = scriptsDir.absoluteFilePath(fileName)
            script = GreaseMonkeyScript(self, absolutePath)

            if script.fullName() in self.__disabledScripts:
                script.setEnabled(False)

            if script.startAt() == GreaseMonkeyScript.DocumentStart:
                self.__startScripts.append(script)
            else:
                self.__endScripts.append(script)
Пример #6
0
def getConfigDir():
    """

    Module function to get the name of the directory storing the config data.

    

    @return directory name of the config dir (string)

    """

    if configDir is not None and os.path.exists(configDir):

        hp = configDir

    else:

        if isWindowsPlatform():

            cdn = "_eric4"

        else:

            cdn = ".eric4"

        hp = QDir.homePath()

        dn = QDir(hp)

        dn.mkdir(cdn)

        hp.append("/").append(cdn)

    return str(toNativeSeparators(hp))
Пример #7
0
 def __load(self):
     """
     Private slot to load the available scripts into the manager.
     """
     scriptsDir = QDir(self.scriptsDirectory())
     if not scriptsDir.exists():
         scriptsDir.mkpath(self.scriptsDirectory())
     
     if not scriptsDir.exists("requires"):
         scriptsDir.mkdir("requires")
     
     self.__disabledScripts = \
         Preferences.getHelp("GreaseMonkeyDisabledScripts")
     
     from .GreaseMonkeyScript import GreaseMonkeyScript
     for fileName in scriptsDir.entryList(["*.js"], QDir.Files):
         absolutePath = scriptsDir.absoluteFilePath(fileName)
         script = GreaseMonkeyScript(self, absolutePath)
         
         if script.fullName() in self.__disabledScripts:
             script.setEnabled(False)
         
         if script.startAt() == GreaseMonkeyScript.DocumentStart:
             self.__startScripts.append(script)
         else:
             self.__endScripts.append(script)
Пример #8
0
 def initUndoRedo(self):
     self.undoStack = QUndoStack()
     temp = QDir(QDir.tempPath() + "/AppBuilder")
     if temp.exists():
         temp.removeRecursively()
     temp.setPath(QDir.tempPath())
     temp.mkdir("AppBuilder")
Пример #9
0
def create_project_structure(base_dir):
    base_qdir = QDir(base_dir)
    base_qdir.mkpath('normalizado/heStain')
    base_qdir.mkpath('train/print')
    base_qdir.mkpath('train/mitosis')
    base_qdir.mkpath('train/candidates')
    base_qdir.mkpath('test/mitosis')
    base_qdir.mkdir('anotations')
Пример #10
0
 def setUp(self) -> None:
     self.newItemDefaultName = "NewEntry.md"
     self.itemProvider = EntryProviderFile(self.newItemDefaultName)
     dir = QDir('/tmp')
     dir.mkdir('retext_itemprovider_tests')
     dir.cd('retext_itemprovider_tests')
     self.testDir = dir
     self.itemProvider.setDirectory("/tmp/retext_itemprovider_tests")
Пример #11
0
 def installAssets(self, assets_path):
     assets = QDir(assets_path)
     assets.mkdir("plugins")
     assets.cd("plugins")
     assets.mkdir("animate")
     dst = os.path.join(assets_path, "plugins", "animate", "animate.css")
     QFile.copy(":/animate.css", dst)
     os.chmod(
         dst, stat.S_IWRITE | stat.S_IREAD | stat.S_IWGRP | stat.S_IRGRP
         | stat.S_IROTH)
Пример #12
0
 def loadProject(self, filename):
     if self.reloadProject(filename):
         # create temp dir for undo redo
         tempPath = self.site.source_path[self.site.source_path.rfind("/") +
                                          1:]
         temp = QDir(QDir.tempPath() + "/FlatSiteBuilder")
         temp.mkdir(tempPath)
         temp.cd(tempPath)
         temp.mkdir("pages")
         temp.mkdir("posts")
         return True
     else:
         return False
Пример #13
0
 def getpath(self):
     self.tableWidget.setRowCount(0)
     path = self.lineEdit.text()
     if path != "":
         dir = QDir()
         if not dir.exists(path):
             dir.mkdir(path)
         dir = QDir(path)
         flag = 0
         for d in dir.entryList(QDir.Dirs | QDir.NoDotAndDotDot):
             self.tableWidget.insertRow(flag)
             self.tableWidget.setItem(flag, 0, QtWidgets.QTableWidgetItem(os.path.join(path, d)))
             flag += 1
 def installAssets(self, assets_path):
     assets = QDir(assets_path)
     assets.mkdir("plugins")
     assets.cd("plugins")
     assets.mkdir("revolution-slider")
     assets.cd("revolution-slider")
     assets.mkdir("css")
     assets.mkdir("js")
     assets.mkdir("assets")
     QFile.copy(":/css", assets_path + "/plugins/revolution-slider/css")
     QFile.copy(":/js", assets_path + "/js")
     QFile.copy(":/js/plugins",
                assets_path + "/plugins/revolution-slider/js")
     QFile.copy(":/assets",
                assets_path + "/plugins/revolution-slider/assets")
Пример #15
0
def add_block():
    try:
        if not (block_ui.comboBox.currentText() == "" and block_ui.lineEdit.text() == ""):
            logging.debug("create dir {}".format(block_ui.lineEdit.text()))
            path = "{}/{}".format(address[block_ui.comboBox.currentText()], block_ui.lineEdit.text())
            dir = QDir()
            dir.mkdir(path)
            try:
                logging.warning("add block")
                book[block_ui.comboBox.currentText()][block_ui.lineEdit.text()] = []
                save()
                ui.statusbar.showMessage("分区{}创建".format(book_ui.lineEdit.text()))
            except OSError:
                logging.warning("failed to add")
    except OSError:
        logging.warning("failed to create")
    def createMacsplitFileToStartup(self, splitFileName, execFileTarget):
        launchAgentsPath = os.path.join(QDir.homePath(),
                                        "/Library/LaunchAgents/")
        if not QDir(launchAgentsPath).exists():
            if not QDir.mkdir(launchAgentsPath): return False

        # https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
        macOSSplitFile = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>{name}</string>
        <key>ProgramArguments</key>
        <array>
            <string>{target}</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>"""
        macOSSplitFile = macOSSplitFile.format(name=splitFileName,
                                               target=execFileTarget)
        splitFileName = "{}.split".format(splitFileName)
        if not self.createStartupFile(launchAgentsPath, splitFileName,
                                      macOSSplitFile):
            return False
        return True
Пример #17
0
    def uploadFile(self):
        global fileName, path
        fileName, _ = QFileDialog.getOpenFileName(
            None, "QFileDialog.getOpenFileName()", "", "All Files (*);;Python Files (*.py)", QDir.homePath())
        self.lineEdit.setText(fileName)
        if fileName != '':
            self.myVideo.mediaPlayer.setMedia(
                QMediaContent(QUrl.fromLocalFile(fileName)))
            self.myVideo.playButton.setEnabled(True)

        # create project folder
        dic = QDir()
        path = QDir(fileName).dirName()
        path = path.replace(".", "-")
        # path = './output/'
        dic.mkdir(path)
        dic.setCurrent(path)
Пример #18
0
def getConfigDir():
    """
    Global function to get the name of the directory storing the config data.
    
    @return directory name of the config dir (string)
    """
    if sys.platform.startswith("win"):
        cdn = "_eric6"
    else:
        cdn = ".eric6"
        
    hp = QDir.homePath()
    dn = QDir(hp)
    dn.mkdir(cdn)
    hp += "/" + cdn
    try:
        return QDir.toNativeSeparators(hp)
    except AttributeError:
        return QDir.toNativeSeparators(hp)
Пример #19
0
def getConfigDir():
    """
    Module function to get the name of the directory storing the config data.
    
    @return directory name of the config dir (string)
    """
    if configDir is not None and os.path.exists(configDir):
        hp = configDir
    else:
        if isWindowsPlatform():
            cdn = "_pymakr"
        else:
            cdn = ".pymakr"

        hp = QDir.homePath()
        dn = QDir(hp)
        dn.mkdir(cdn)
        hp += "/" + cdn
    return QDir.toNativeSeparators(hp)
Пример #20
0
def getConfigDir():
    """
    Module function to get the name of the directory storing the config data.
    
    @return directory name of the config dir (string)
    """
    if configDir is not None and os.path.exists(configDir):
        hp = configDir
    else:
        if isWindowsPlatform():
            cdn = "_eric6"
        else:
            cdn = ".eric6"

        hp = QDir.homePath()
        dn = QDir(hp)
        dn.mkdir(cdn)
        hp += "/" + cdn
    return QDir.toNativeSeparators(hp)
Пример #21
0
def getConfigDir():
    """
    Global function to get the name of the directory storing the config data.
    
    @return directory name of the config dir (string)
    """
    if sys.platform.startswith("win"):
        cdn = "_eric6"
    else:
        cdn = ".eric6"

    hp = QDir.homePath()
    dn = QDir(hp)
    dn.mkdir(cdn)
    hp += "/" + cdn
    try:
        return QDir.toNativeSeparators(hp)
    except AttributeError:
        return QDir.toNativeSeparators(hp)
Пример #22
0
    def import_color_schema_from_dict(self, schema_name: str,
                                      color_schema: dict) -> None:
        """Imports color schema from a dictionary"""
        # Set schema name
        color_schema["Schema name"] = schema_name

        # Create directory for new schema file
        directory = QDir(self.get_appdata_path() + "/color_schemas")
        directory.mkdir(schema_name)

        # Add information about schema to settings manager
        schemas = self.get_setting_value("Colors/Color_schemas")
        filepath = self.get_appdata_path(
        ) + "/color_schemas/" + schema_name + "/schema.toml"
        schema_info = {"name": schema_name, "path": filepath}

        schemas[schema_name] = schema_info

        # Save schema
        self.set_setting_value("Colors/Color_schemas", schemas)
        self.save_color_schema(color_schema)
Пример #23
0
    def loadProject(self, filename):
        self.default_path = filename[0:-9]  # - /Site.qml
        if self.reloadProject(filename):
            # create temp dir for undo redo
            tempPath = self.site.source_path[self.site.source_path.rfind("/") +
                                             1:]
            temp = QDir(os.path.join(QDir.tempPath(), "FlatSiteBuilder"))
            temp.mkdir(tempPath)
            temp.cd(tempPath)
            temp.mkdir("pages")
            temp.mkdir("posts")

            # in case these subfolders were empty and not published to github
            dir = QDir(self.site.source_path)
            dir.mkdir("pages")
            dir.mkdir("posts")
            dir.mkdir("assets")
            dir.cd("assets")
            dir.mkdir("images")
            return True
        else:
            return False
Пример #24
0
    def on_btnDir_mkdir_clicked(self):
        self.__showBtnInfo(self.sender())
        sous = self.ui.editDir.text().strip()
        if sous == "":
            self.ui.textEdit.appendPlainText("请先选择一个目录")
            return

        subDir = "subdir1"
        dirObj = QDir(sous)
        if dirObj.mkdir(subDir):
            self.ui.textEdit.appendPlainText("新建一个子目录: " + subDir + "\n")
        else:
            self.ui.textEdit.appendPlainText("创建目录失败\n")
Пример #25
0
 def createBackupFolder(self, profileName: str):
     """ Create a backup folder in the profile. The profile must exist """
     profileDir = QDir(self.profilePath(profileName))
     if not profileDir.exists():
         raise ValueError(
             "Attempted to create backup folder in non-existant profile: {}"
             .format(profileName))
     if profileDir.exists(self.PROFILE_DIR):
         return True
     if not profileDir.mkdir(self.PROFILE_DIR):
         moWarn("Failed to create backup directory in profile: {}".format(
             profileName))
         return False
     return True
Пример #26
0
    def Successful_Tmp(self):# CheckTmpDir, StateTmpDir
        failed = lambda: not self.tdir or not self.tdir.isValid()
        if failed():# not successfully
            self.tdir = QTemporaryDir()
            if failed():
                QMessageBox.critical(self, "Unexpected Failurer", "The application has detected a problem trying to\nCreate or Access a Temporary File!.")
                return None
            else:
                self.tdir.setAutoRemove(True)

        d = QDir(self.tdir.path())
        if not d.exists("ninja-ide"):
            if not d.mkdir("ninja-ide"):
                self.tdir = None
        d.cd("ninja-ide")
        return d
Пример #27
0
    def createProfile(self, name):
        if self.profileExists(name):
            return True

        # TODO: need to fix up the name before creating the directory
        # Refer to https://github.com/ModOrganizer2/modorganizer-uibase/blob/13963ed37276ede1fb052b838f8b7828d0f8d2f5/src/utility.cpp#L612
        # Refer to https://github.com/ModOrganizer2/modorganizer/blob/9945beabf160c68852a8bdac07de255f04fd6886/src/profile.cpp#L80

        profilesDir = QDir(self.profilesFolder())
        if not profilesDir.mkdir(name):
            moWarn(
                self.tr("Failed to create profile folder: {}").format(
                    profilesDir.absoluteFilesPath(name)))
            return False
        self.profileCreated.emit(name)

        # copy all files (one level) from current profile to new profile
        return self.copyFiles(self.profilePath(), self.profilePath(name))
Пример #28
0
    def Successful_Tmp(self):  # CheckTmpDir, StateTmpDir
        failed = lambda: not self.tdir or not self.tdir.isValid()
        if failed():  # not successfully
            self.tdir = QTemporaryDir()
            if failed():
                QMessageBox.critical(
                    self, "Unexpected Failurer",
                    "The application has detected a problem trying to\nCreate or Access a Temporary File!."
                )
                return None
            else:
                self.tdir.setAutoRemove(True)

        d = QDir(self.tdir.path())
        if not d.exists("ninja-ide"):
            if not d.mkdir("ninja-ide"):
                self.tdir = None
        d.cd("ninja-ide")
        return d
Пример #29
0
    def on_saveImageButton_pressed(self):
        extension = "PNG"
        filename = "image-{:%Y-%m-%d_%H-%M-%S}.{}".format(
            datetime.datetime.now(), extension)

        location = Paths.join(self.workspace.working_directory,
                              Paths.camera_images)

        location_directory = QDir(location)

        if not location_directory.exists():
            if not location_directory.mkdir(location):
                raise Exception(
                    "Could not create path {} to save image.".format(location))

        full_path = Paths.join(location, filename)

        if not self.cameraFrameDisplay.image.save(full_path, extension):
            raise Exception("Could not save file to {}".format(full_path))

        self.statusLabel.setText("Image snapped {}".format(full_path))
Пример #30
0
    def create_project(directory_path: str) -> None:
        """Creates a new project at given path"""

        try:
            directory = QDir(directory_path)

            directory.mkdir(".manuwrite")
            directory.mkdir("images")
            directory.mkdir("notes")
            directory.mkdir("data")

            directory.mkpath(".manuwrite/render")
            file = QFile()
            file.setFileName(directory_path + "/.manuwrite/project.toml")
            file.open(QFile.ReadWrite)

            project_settings = copy.deepcopy(defaults.project_settings)
            project_settings["Absolute path"] = {"type": "str", "value": directory_path}

            file.write(toml.dumps(project_settings).encode())
            file.close()
        except OSError:
            raise ProjectError("Error creating project files")
Пример #31
0
# -*- coding: utf-8 -*-
Пример #32
0
 def create_folder(self, path: str) -> None:
     """Creates an empty directory at given path"""
     directory = QDir(self.root_path)
     directory.mkdir(path)
Пример #33
0
class Exportdialog(rcspy_Exportdialog.Ui_Dialog, QtWidgets.QDialog):
    def __init__(self, parent):
        super(Exportdialog, self).__init__(parent)
        self.setupUi(self)
        self.File_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.channel_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.connectevent()
        self.expath = ""
        self.radioMSEED.setChecked(True)
        self.radioSEED.setEnabled(False)

    def getFiles(self, Files):
        self.Files = Files
        for file in self.Files.files:
            listitem = QListWidgetItem(file)
            listitem.setText(file.name)
            self.File_list.addItem(listitem)

    def connectevent(self):
        self.btnOK.clicked.connect(self.Onbtnok)
        self.btn_Cancel.clicked.connect(self.Onbtncancel)
        self.File_list.itemSelectionChanged.connect(
            self.OnFilelist_selectionchange)
        self.channel_list.itemSelectionChanged.connect(
            self.Onchannellist_selectionchange)
        self.allchannel_checkbox.stateChanged.connect(self.Onallchannel_change)
        self.btn_set_folder.clicked.connect(self.set_exfolder)

    def set_exfolder(self):
        foldername = QFileDialog.getExistingDirectory(self, 'save folder')
        if foldername != "":
            self.expath = foldername
            self.Exfolder_edit.setText(foldername)

    def Onallchannel_change(self):
        if self.allchannel_checkbox.isChecked() == True:
            self.channel_list.selectAll()
        else:
            self.channel_list.clearSelection()
            self.single_channel_checkbox.setEnabled(True)

    def OnFilelist_selectionchange(self):
        self.channel_list.clear()
        if len(self.File_list.selectedItems()) == 1:
            self.channel_list.setEnabled(True)
            self.allchannel_checkbox.setEnabled(True)
            file = self.File_list.selectedItems()[0].parent
            for station in file.stations:
                listitem = QListWidgetItem(station)
                listitem.setText(station.name)
                self.channel_list.addItem(listitem)
        if len(self.File_list.selectedItems()) > 1:
            for item in self.File_list.selectedItems():
                file = item.parent
                for station in file.stations:
                    listitem = QListWidgetItem(station)
                    listitem.setText(station.name)
                    self.channel_list.addItem(listitem)
            self.channel_list.setEnabled(False)
            self.allchannel_checkbox.setChecked(True)
            self.allchannel_checkbox.setEnabled(False)
            self.radioMSEED.setChecked(True)

    def Onchannellist_selectionchange(self):
        count = self.channel_list.count()
        if len(self.channel_list.selectedItems()) == count:
            self.allchannel_checkbox.setChecked(True)
        else:
            self.allchannel_checkbox.setChecked(False)

    def Onbtncancel(self):
        self.close()

    def Onbtnok(self):
        if self.expath == "":
            QMessageBox.about(self, "tips", "please set export folder")

        elif len(self.File_list.selectedItems()) == 0:
            QMessageBox.about(self, "tips", "please set export files")
        else:
            self.dir = QDir()
            self.dir.cd(self.expath)
            self.pgb = QProgressBar(self)
            self.pgb.setWindowTitle("Exporting")
            self.pgb.setGeometry(140, 380, 260, 25)
            self.pgb.show()
            if self.radioMSEED.isChecked():
                self.Export2mseed()
            if self.radioASCII.isChecked():
                self.Export2Ascii()
            if self.radioSAC.isChecked():
                self.Export2sac()
            self.pgb.close()
            QMessageBox.about(self, "tips", "finished")

    def Export2mseed(self):
        self.allnum = len(self.File_list.selectedItems())
        self.currnum = 0
        if self.allnum == 1:
            self.allnum = len(self.channel_list.selectedItems()) * 3
            exstream = obspy.core.Stream()
            append = exstream.append
            for item in self.channel_list.selectedItems():
                for channel in item.parent.channels:
                    append(channel.tr)
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))
                    self.currnum = self.currnum + 1
            file = self.File_list.selectedItems()[0].parent
            filesave = self.expath + "/" + str(file.ename) + ".mseed"
            '''
            single channel
            '''
            if self.single_channel_checkbox.isChecked() == True:
                self.currnum = 0
                if self.dir.exists(file.ename) == False:
                    self.dir.mkdir(file.ename)
                filesave = self.expath + "/" + file.ename + "/"
                for tr in exstream:
                    tr.write(filesave + str(tr.id) + ".mseed", format='MSEED')
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))
                    self.currnum = self.currnum + 1
            else:
                exstream.write(filesave, format='MSEED')
        else:
            '''
            single channel
            '''
            if self.single_channel_checkbox.isChecked() == True:
                for item in self.File_list.selectedItems():
                    self.allnum = self.allnum + len(item.parent.stations) * 3
                for item in self.File_list.selectedItems():
                    file = item.parent
                    if self.dir.exists(file.ename) == False:
                        self.dir.mkdir(file.ename)
                    filesave = self.expath + "/" + str(file.ename) + "/"
                    for tr in file.stream:
                        tr.write(filesave + str(tr.id) + ".mseed",
                                 format='MSEED')
                        self.currnum = self.currnum + 1
                        step = self.currnum * 100 / self.allnum
                        self.pgb.setValue(int(step))
            else:
                for item in self.File_list.selectedItems():
                    file = item.parent
                    filesave = self.expath + "/" + str(file.ename) + ".mseed"
                    file.stream.write(filesave, format='MSEED')
                    self.currnum = self.currnum + 1
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))

    def Export2Ascii(self):
        self.allnum = len(self.File_list.selectedItems())
        self.currnum = 0
        if self.allnum == 1:
            self.allnum = len(self.channel_list.selectedItems()) * 3
            exstream = obspy.core.Stream()
            append = exstream.append
            for item in self.channel_list.selectedItems():
                for channel in item.parent.channels:
                    append(channel.tr)
                    self.currnum = self.currnum + 1
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))
            file = self.File_list.selectedItems()[0].parent
            filesave = self.expath + "/" + str(file.ename) + ".ascii"
            '''
            single channel
            '''
            if self.single_channel_checkbox.isChecked() == True:
                if self.dir.exists(file.ename) == False:
                    self.dir.mkdir(file.ename)
                filesave = self.expath + "/" + file.ename + "/"
                for tr in exstream:
                    tr.write(filesave + str(tr.id) + ".ascii", format='SLIST')
            else:
                exstream.write(filesave, format='SLIST')
        else:
            '''
            single channel
            '''
            if self.single_channel_checkbox.isChecked() == True:
                for item in self.File_list.selectedItems():
                    self.allnum = self.allnum + len(item.parent.stations) * 3
                for item in self.File_list.selectedItems():
                    file = item.parent
                    if self.dir.exists(file.ename) == False:
                        self.dir.mkdir(file.ename)
                    filesave = self.expath + "/" + str(file.ename) + "/"
                    for tr in file.stream:
                        tr.write(filesave + str(tr.id) + ".ascii",
                                 format='SLIST')
                        self.currnum = self.currnum + 1
                        step = self.currnum * 100 / self.allnum
                        self.pgb.setValue(int(step))
            else:
                for item in self.File_list.selectedItems():
                    file = item.parent
                    filesave = self.expath + "/" + str(file.ename) + ".ascii"
                    file.stream.write(filesave, format='SLIST')
                    self.currnum = self.currnum + 1
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))

    def Export2sac(self):
        self.allnum = len(self.File_list.selectedItems())
        self.currnum = 0
        if self.allnum == 1:
            self.allnum = len(self.channel_list.selectedItems()) * 3
            exstream = obspy.core.Stream()
            append = exstream.append
            for item in self.channel_list.selectedItems():
                for channel in item.parent.channels:
                    append(channel.tr)
                    self.currnum = self.currnum + 1
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))
            file = self.File_list.selectedItems()[0].parent
            if self.dir.exists(file.ename) == False:
                self.dir.mkdir(file.ename)
            for tr in exstream:
                filesave = self.expath + "/" + file.ename + "/" + str(
                    tr.id) + ".SAC"
                tr.write(filesave, format='SAC')
        else:
            self.allnum = 0
            for item in self.File_list.selectedItems():
                self.allnum = self.allnum + len(item.parent.stations) * 3
            for item in self.File_list.selectedItems():
                if self.dir.exists(item.parent.ename) == False:
                    self.dir.mkdir(item.parent.ename)
                filedir = self.expath + "/" + item.parent.ename + "/"
                for tr in item.parent.stream:
                    filesave = filedir + tr.id + ".SAC"
                    tr.write(filesave, format='SAC')
                    self.currnum = self.currnum + 1
                    step = self.currnum * 100 / self.allnum
                    self.pgb.setValue(int(step))