Exemple #1
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        filepath = TESTPATH + 'test_txt.csv'
        self.txtgen = TxtGenerator(self.main_window, filepath)
Exemple #2
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, title="pyspread", S=None)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        # Filenames
        # ---------

        # File with valid signature
        self.filename_valid_sig = TESTPATH + "test1.pys"
        self.grid.actions.sign_file(self.filename_valid_sig)

        # File without signature
        self.filename_no_sig = TESTPATH + "test2.pys"

        # File with invalid signature
        self.filename_invalid_sig = TESTPATH + "test3.pys"

        # File for self.grid size test
        self.filename_gridsize = TESTPATH + "test4.pys"
        self.grid.actions.sign_file(self.filename_gridsize)

        # Empty file
        self.filename_empty = TESTPATH + "test5.pys"

        # File name that cannot be accessed
        self.filename_not_permitted = TESTPATH + "test6.pys"

        # File name without file
        self.filename_wrong = TESTPATH + "test-1.pys"

        # File for testing save
        self.filename_save = TESTPATH + "test_save.pys"
Exemple #3
0
    def OnInit(self):
        """Init class that is automatically run on __init__"""

        # Get command line options and arguments
        cmdp = Commandlineparser()
        options, filename = cmdp.parse()

        kwargs = {"title": "pyspread", "S": self.S}

        # Store command line input in config if no file is provided
        if filename is None:
            kwargs["dimensions"] = options.dimensions

        # Main window creation
        from src.gui._main_window import MainWindow

        self.main_window = MainWindow(None, **kwargs)

        # Initialize file loading via event

        if options.new_gpgkey:
            # Create GPG key if not present

            try:
                from src.lib.gpg import genkey
                self.config["gpg_key_fingerprint"] = repr("")
                genkey()

            except ImportError:
                pass

            except ValueError:
                # python-gnupg is installed but gnupg is not installed
                pass

        # Show application window
        self.SetTopWindow(self.main_window)
        self.main_window.Show()

        # Load filename if provided
        if filename is not None:
            post_command_event(self.main_window,
                               self.GridActionOpenMsg,
                               attr={"filepath": filename})
            self.main_window.filepath = filename

        return True
Exemple #4
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, title="pyspread", S=None)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        self.test_filename = TESTPATH + "test.csv"
        self.test_filename2 = TESTPATH + "test_one_col.csv"
        self.test_filename3 = TESTPATH + "test_write.csv"
Exemple #5
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        self.test_filename = TESTPATH + "test.csv"
        self.test_filename_single_col = TESTPATH + "large.txt"
        self.test_filename_notthere = TESTPATH + "notthere.txt"
        self.test_filename_bin = TESTPATH + "test1.pys"
Exemple #6
0
    def OnInit(self):
        """Init class that is automatically run on __init__"""

        # Get command line options and arguments
        self.get_cmd_args()

        # Initialize the prerequisitions to construct the main window
        wx.InitAllImageHandlers()

        # Main window creation
        from src.gui._main_window import MainWindow

        self.main_window = MainWindow(None, title="pyspread", S=self.S)

        ## Initialize file loading via event

        # Create GPG key if not present

        try:
            from src.lib.gpg import genkey
            genkey()

        except ImportError:
            pass

        except ValueError:
            # python-gnupg is installed but gnupg is not insatlled

            pass

        # Show application window
        self.SetTopWindow(self.main_window)
        self.main_window.Show()

        # Load filename if provided
        if self.filepath is not None:
            post_command_event(self.main_window,
                               self.GridActionOpenMsg,
                               attr={"filepath": self.filepath})
            self.main_window.filepath = self.filepath

        return True
Exemple #7
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        filepath = TESTPATH + 'test1.csv'
        self.dialect, __ = sniff(filepath)
        self.digest_types = [types.UnicodeType]
        has_header = True

        self.interface = CsvInterface(self.main_window, filepath, self.dialect,
                                      self.digest_types, has_header)
Exemple #8
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        # Content for find and replace operations
        grid_data = {
            (0, 0, 0): u"Test",
            (1, 0, 0): u"Test1",
            (2, 0, 0): u"Test2",
        }

        for key in grid_data:
            self.grid.code_array[key] = grid_data[key]
Exemple #9
0
    def setup_method(self, method):

        # Generate a GPG key if not present
        if fingerprint2keyid(config["gpg_key_fingerprint"]) is None and \
           genkey is not None:
            # No GPG key is configured
            self.fingerprint = genkey(key_name="pyspread_test_key")
        else:
            # Use preconfigured key
            self.fingerprint = config["gpg_key_fingerprint"]

        self.main_window = MainWindow(None, title="pyspread", S=None)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        # Sign files in order to get valid signatures for current key
        self.grid.actions.sign_file(self.filename_valid_sig)
        self.grid.actions.sign_file(self.filename_gridsize)
Exemple #10
0
 def setup_method(self, method):
     self.main_window = MainWindow(None, -1)
     self.grid = self.main_window.grid
Exemple #11
0
 def setup_method(self, method):
     self.main_window = MainWindow(None, title="pyspread", S=None)
     self.grid = self.main_window.grid
     self.code_array = self.grid.code_array
Exemple #12
0
class MainApplication(wx.App, GridActionEventMixin):
    """Main application class for pyspread."""

    dimensions = (1, 1, 1)  # Will be overridden anyways
    options = {}
    filename = None

    def __init__(self, *args, **kwargs):

        try:
            self.S = kwargs.pop("S")
        except KeyError:
            self.S = None

        # call parent class initializer
        wx.App.__init__(self, *args, **kwargs)

    def OnInit(self):
        """Init class that is automatically run on __init__"""

        # Get command line options and arguments
        self.get_cmd_args()

        # Initialize the prerequisitions to construct the main window
        wx.InitAllImageHandlers()

        # Main window creation
        from src.gui._main_window import MainWindow

        self.main_window = MainWindow(None, title="pyspread", S=self.S)

        ## Initialize file loading via event

        # Create GPG key if not present

        try:
            from src.lib.gpg import genkey
            genkey()

        except ImportError:
            pass

        except ValueError:
            # python-gnupg is installed but gnupg is not insatlled

            pass

        # Show application window
        self.SetTopWindow(self.main_window)
        self.main_window.Show()

        # Load filename if provided
        if self.filepath is not None:
            post_command_event(self.main_window,
                               self.GridActionOpenMsg,
                               attr={"filepath": self.filepath})
            self.main_window.filepath = self.filepath

        return True

    def get_cmd_args(self):
        """Returns command line arguments

        Created attributes
        ------------------

        options: dict
        \tCommand line options
        dimensions: Three tuple of Int
        \tGrid dimensions, default value (1,1,1).
        filename: String
        \tFile name that is loaded on start

        """

        cmdp = Commandlineparser()
        self.options, self.filepath = cmdp.parse()

        if self.filename is None:
            rows, columns, tables = self.options.dimensions
            cmdp.config["grid_rows"] = str(rows)
            cmdp.config["grid_columns"] = str(columns)
            cmdp.config["grid_tables"] = str(tables)