Exemple #1
0
class AbstractDir():
    quit_request = 'q'
    xattr_signature = "com_mistermorris_pydir"
    
    def __init__(self, menu_class=Menu):
        """
        Init app
        """
        self.ask_pound()
        self._user_saved = None
        self.errors = Error_Handler(error_dict)
        self.command = Shell(avoid_recursion="pydir", errors=self.errors)
        self.user_command = PydirShell(self)
        colorama_init()
        self.input_list = []
        self.reset_pages()
        self.user_filter = None
        self.user_sorter = 'name'
        self.menu = menu_class(self)
        self.last_mod_time = None
        self._project_saved_searches = {}
        self.output = Output()
        
    def set_current_directory(self, path):
        try:
            os.chdir(path)
        except OSError:
            self.errors.handle_error('permission denied', path)

    def __getattribute__(self, name):
        """ Sets up aliases """
        if name == "current_directory":
             return os.getcwd() + os.sep
        elif name == "parent_directory":
            return os.path.split(self.current_directory)[0]
        elif name == "join":
            return os.path.join
        elif name == "split":
            return shlex.split
        elif name == "split_extension":
            return os.path.splitext
        elif name == "last_modified":
            return os.path.getmtime
        else:
            return object.__getattribute__(self, name)
Exemple #2
0
 def __init__(self, menu_class=Menu):
     """
     Init app
     """
     self.ask_pound()
     self._user_saved = None
     self.errors = Error_Handler(error_dict)
     self.command = Shell(avoid_recursion="pydir", errors=self.errors)
     self.user_command = PydirShell(self)
     colorama_init()
     self.input_list = []
     self.reset_pages()
     self.user_filter = None
     self.user_sorter = 'name'
     self.menu = menu_class(self)
     self.last_mod_time = None
     self._project_saved_searches = {}
     self.output = Output()