示例#1
0
def test_rm_fix_parents():

    expected =  procedures.load("expected_parents", 'tests/test_files/rm/parents')

    cleaned_data = software.RM_fix("tests/test_files/rm/parents/rm").reset_index(drop=True)

    if os.path.exists('clean_rm.csv'):
        os.remove('clean_rm.csv')
        os.remove('needs_to_be_merged_rm.csv')

    assert cleaned_data.equals(expected)
示例#2
0
    def __init__(self, filename=None, path=os.getcwd()):
        QtWidgets.QMainWindow.__init__(self)
        self.setupUi(self)

        if filename != None:
            pandaData = procedures.load(filename, path)
            self.createTab(pandaData)
        else:
            self.newEmptyTab()

        # File Menu Actions
        self.actionExit.triggered.connect(self.Exit)
        self.actionLoad.triggered.connect(self.loadData)
        self.actionSave.triggered.connect(self.saveData)
        self.actionOpen.triggered.connect(self.openData)
        self.actionClose_Tab.triggered.connect(self.closeTab)
        self.actionNew_Tab.triggered.connect(self.newEmptyTab)

        # Edit Menu Actions
        self.actionDelete.triggered.connect(self.deleteData)
        self.actionUndo.triggered.connect(self.undo)
        self.actionRedo.triggered.connect(self.redo)
        self.actionAdd_Row.triggered.connect(self.insertBlank)
        self.actionAdd_Column.triggered.connect(self.insertBlank)
        self.actionDuplicate.triggered.connect(self.duplicateSelected)

        # Operations Menu Actions
        self.actionClear_Whitespace.triggered.connect(self.clearWhitespace)
        self.actionRemove_Non_Numberic.triggered.connect(self.removeNonNumeric)
        self.actionCorrect_Date_Format.triggered.connect(
            self.correctDateFormat)
        self.actionDisperse_Ranks_By_Program.triggered.connect(
            self.ranksByProgram)
        self.actionFind_and_Replace.triggered.connect(self.findText)
        self.actionNew_Rows_On_Separator.triggered.connect(
            self.newRowsOnSeparator)

        self.actionKickSite.triggered.connect(self.software_ks)
        self.actionRainmaker.triggered.connect(self.software_rm)

        # View Menu Actions
        self.actionDisplay_Command_Prompt.triggered.connect(
            self.toggleCommandPrompt)

        # Help Menu Actions
        self.actionHelp.triggered.connect(self.help)

        # Run button
        self.runButton.clicked.connect(self.runCommand)
示例#3
0
    def software_rm(self):

        response = Model.RainmakerDialogBox.getResponse(self)

        if response is not [None, None, None]:
            try:
                complete = software.RM_fix(response[0], parents=response[1])
                filepath, filename = os.path.split(response[0])
                original = procedures.load(filename, filepath)
                self.createTab(original, name="Original")
                self.createTab(complete, name="Final")
            except Exception:
                self.notifyUser('Please convert file to .csv or .xlsx')
            except:
                errorMsg = 'Something went wrong. \n' + \
                            'See stack trace: \n\n' + traceback.format_exc()
                self.notifyUser(errorMsg)
示例#4
0
    def openData(self):
        """
        Prompts the user for a file to load into view, instantiates a new PandasTable
        with the user's selection and opens it in a new tab. If an invalid path is given, the user is notified.
        """

        path = QtWidgets.QFileDialog.getOpenFileName(
            self, 'Open File', os.getcwd(), 'CSV, XLSX(*.csv *.xlsx)')

        # If a file was specified, load it up. If not, tell the user to pick a valid file
        if path[0] != '':

            if os.path.exists(path[0]) and os.path.getsize(path[0]):

                filepath, filename = os.path.split(path[0])
                pandaData = procedures.load(filename, filepath)

                self.createTab(pandaData, name=filename)

            else:
                self.notifyUser("Please pick a valid file.")
示例#5
0
    def loadData(self):
        """
        Prompts the user to select a file to load into view. Deletes all other open tabs upon successful load.
        If an invalid path is given, the user is notified.
        """

        path = QtWidgets.QFileDialog.getOpenFileName(
            self, 'Open File', os.getcwd(), 'CSV, XLSX(*.csv *.xlsx)')

        # If a file was specified, load it up. If not, tell the user to pick a valid file
        if path[0] != '':

            if os.path.exists(path[0]) and os.path.getsize(path[0]):

                filepath, filename = os.path.split(path[0])
                pandaData = procedures.load(filename, filepath)

                while self.tabWidget.count() != 0:
                    self.closeTab()
                self.createTab(pandaData)

            else:
                self.notifyUser("Please pick a valid file.")