Exemple #1
0
    def get_items(self):
        iterators = []
        ui = datatools.UniqueIterator(S.toplevel_source()
                                      for S in self.sources)
        for S in ui:
            it = S.get_leaves()
            iterators.append(it)

        return itertools.chain(*iterators)
Exemple #2
0
def get_vim_files(filepath):
    """
	Read ~/.viminfo from @filepath

	Look for a line like this:
	*encoding=<encoding>

	Return an iterator of unicode string file paths
	"""
    encoding = "UTF-8"
    recents = []
    with open(filepath, "r") as f:
        for line in f:
            if line.startswith("*encoding="):
                _, enc = line.split("=")
                encoding = enc.strip()
            us_line = line.decode(encoding, "replace")
            ## Now find the jumplist
            if us_line.startswith("-'  "):
                parts = us_line.split(None, 3)
                recentfile = os.path.expanduser(parts[-1].strip())
                if recentfile:
                    recents.append(recentfile)
    return datatools.UniqueIterator(recents)
Exemple #3
0
 def as_set_iter(seq):
     key = operator.attrgetter("object")
     return datatools.UniqueIterator(seq, key=key)
Exemple #4
0
 def __init__(self, obj, name=_("Multiple Objects")):
     # modifying the list of objects is strictly forbidden
     robj = list(datatools.UniqueIterator(obj))
     Leaf.__init__(self, robj, name)