Example #1
0
 def do_quit(self, line):
     arg = str(line).lower()
     if not arg == "-f" and not len(self._std.new_data) == 0:
         View.warning("The new data hasn't been saved. "
                      "Enter \"quit -f\" to quit without saving.")
     else:
         View.display("Thanks for using. Bye!")
         return True
Example #2
0
    def do_show(self, line):
        """
        Show command
        :param line: (String) [-t|-p|-b] [object]
        :return: None
        :Author: Zhiming Liu
        """
        # Get all instructions
        args = list(arg.lower() for arg in str(line).split())

        # Those commands are required single arguments
        # single_commands = ["-a"]
        # Those commands are required two arguments
        plot_commands = ["-p", "-b"]

        # Show data table
        if args[0] == "-t":
            if len(self._std.data) == 0 and len(self._std.new_data) == 0:
                View.info("No data to display.")
            if not len(self._std.data) == 0:
                View.display("ORIGINAL DATA:")
                View.display_data(self._std.data, ind=True)
            if not len(self._std.new_data) == 0:
                View.display("\nNEW DATA:")
                View.display_data(self._std.new_data, ind=True)
                View.display("\n(Input command \"save\" to save the new data)")

        elif args[0] in plot_commands:
            try:
                if len(args) == 1:
                    raise IndexError("Incomplete command line.")

                if args[0] == "-p":
                    self.show_pie(args[1])
                if args[0] == "-b":
                    self.show_bar(args[1])

            except IndexError as e:
                View.error(str(e) + "\n")
                View.help_show()
        else:
            View.info("Invalid command line.\n")
            View.help_show()
Example #3
0
 def help_export():
     View.display("Export data to a local file "
                  "that is specified in the command line.\n")
     View.help_export()
Example #4
0
 def help_import():
     View.display("Import data from a file "
                  "that is specified in the command line.\n")
     View.help_import()
Example #5
0
 def help_quit():
     View.display("This command is used for "
                  "quitting the command line mode\n")
     View.help_quit()
Example #6
0
 def help_select():
     View.display("Select a source of data for reading "
                  "and saving staff information.\n")
     View.help_select()
Example #7
0
 def help_save():
     View.display("This command is used for saving all newly added data "
                  "to the selected data source.\n")
     View.help_save()
Example #8
0
 def help_add():
     View.display("This command adds a new staff data to the system.\n")
     View.help_add()
Example #9
0
 def help_show():
     View.display("This command is used for displaying all data that "
                  "is existed in the system.\n")
     View.help_show()