Example #1
0
 def load_wdhistory(self, workdir=None):
     """Load history from a text file in user home directory"""
     if osp.isfile(self.LOG_PATH):
         wdhistory, _ = encoding.readlines(self.LOG_PATH)
         wdhistory = [name for name in wdhistory if os.path.isdir(name)]
     else:
         if workdir is None:
             workdir = os.getcwdu()
         wdhistory = [ workdir ]
     return wdhistory
Example #2
0
 def load_wdhistory(self, workdir=None):
     """Load history from a text file in user home directory"""
     if osp.isfile(self.LOG_PATH):
         wdhistory, _ = encoding.readlines(self.LOG_PATH)
         wdhistory = [name for name in wdhistory if os.path.isdir(name)]
     else:
         if workdir is None:
             workdir = getcwd()
         wdhistory = [workdir]
     return wdhistory
Example #3
0
    def load_history(self):
        """Load history from a .py file in user home directory"""
        if osp.isfile(self.history_filename):
            rawhistory, _ = encoding.readlines(self.history_filename)
            rawhistory = [line.replace("\n", "") for line in rawhistory]
            if rawhistory[1] != self.INITHISTORY[1]:
                rawhistory = self.INITHISTORY
        else:
            rawhistory = self.INITHISTORY
        history = [line for line in rawhistory if line and not line.startswith("#")]

        # Truncating history to X entries:
        while len(history) >= CONF.get("historylog", "max_entries"):
            del history[0]
            while rawhistory[0].startswith("#"):
                del rawhistory[0]
            del rawhistory[0]
        # Saving truncated history:
        encoding.writelines(rawhistory, self.history_filename)
        return history
Example #4
0
    def load_history(self):
        """Load history from a .py file in user home directory"""
        if osp.isfile(self.history_filename):
            rawhistory, _ = encoding.readlines(self.history_filename)
            rawhistory = [line.replace('\n', '') for line in rawhistory]
            if rawhistory[1] != self.INITHISTORY[1]:
                rawhistory = self.INITHISTORY
        else:
            rawhistory = self.INITHISTORY
        history = [line for line in rawhistory \
                   if line and not line.startswith('#')]

        # Truncating history to X entries:
        while len(history) >= CONF.get('historylog', 'max_entries'):
            del history[0]
            while rawhistory[0].startswith('#'):
                del rawhistory[0]
            del rawhistory[0]
        # Saving truncated history:
        encoding.writelines(rawhistory, self.history_filename)
        return history