コード例 #1
0
ファイル: Tutorial.py プロジェクト: brainysmurf/pydir
class TutorialDir(Pydir):

    def __init__(self):
        Pydir.__init__(self, menu_class=TutorialMenu)
        self.set_current_directory(os.path.expanduser('~'))
        self.tutor_info = TutorInfo()
        self.user_command = TutorialShell(self)
        self.menu.basic()
        self.output = TutorialOutput(self.list_current_directory())
        self.list_current_directory().do_indexing()

    def start(self, path):
        """
        Same as dir but without set_current_directory because I want to always start at same place every time
        ->path is therefore ignored.
        """
        self.update_tutor([]) # tells it to take the first thing available
        return Dir.start(self, path)

    def set_message(self, m):
        self.message = m
        self.output.set_message(m)

    def update_tutor(self, check):
        result = self.tutor_info.update_tutor(check)
        if result:
            self.set_message(result)
        
    def list_items(self, header=None):
        Dir.list_items(self, header=header)
        for line in self.output.tutor_wrapped_message:
            print(red(line))

    def list_current_page(self, header=None):
        Dir.list_current_page(self, header=header)
        for line in self.output.tutor_wrapped_message:
            print(red(line))

    def parse_input(self, user_input):
        self.update_tutor(user_input.split(' ')[0])
        result = Dir.parse_input(self, user_input)
        self.update_tutor(self.current_directory)
        return result

    def select_wrapper(self, _list, using, *args, header=None, **kwargs):
        return Dir.select_wrapper(self, _list, using, self.tutor_info, self.output,
                                  *args, header=header, klass=TutorialSelect, **kwargs)

    def tutorial(self, on):
        if on:
            raise BadArguments("Already on!")
        else:
            self.stop()

    def _done_default(self):
        self.message = "Any file that has the return symbol instead of number\ncan be opened just by hitting return.\nIf it's a file, it'll open, if it's a directory, it'll navigate there.\n\nGet to the parent directory back by typing '..'"

    def stop(self):
        #TODO: remove tutor dir, go back to default
        Dir.stop(self)
コード例 #2
0
ファイル: Tutorial.py プロジェクト: brainysmurf/pydir
 def __init__(self):
     Pydir.__init__(self, menu_class=TutorialMenu)
     self.set_current_directory(os.path.expanduser('~'))
     self.tutor_info = TutorInfo()
     self.user_command = TutorialShell(self)
     self.menu.basic()
     self.output = TutorialOutput(self.list_current_directory())
     self.list_current_directory().do_indexing()