/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/controllers/directory_ui.py

  • Committer: Michael Hudson
  • Date: 2008-08-04 01:56:12 UTC
  • mto: (189.3.4 themed-directory-listing)
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: michael.hudson@canonical.com-20080804015612-da5n7y4yvbj1zffi
show last revno

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
#
18
18
 
19
 
from loggerhead.controllers import TemplatedBranchView
20
19
import logging
21
20
import os
22
21
 
 
22
from bzrlib import branch
 
23
from bzrlib import errors
 
24
 
 
25
from loggerhead.controllers import TemplatedBranchView
 
26
 
 
27
class DirEntry(object):
 
28
    def __init__(self, dirname, parity, branch):
 
29
        self.dirname = dirname
 
30
        self.parity = parity
 
31
        self.branch = branch
 
32
 
23
33
class DirectoryUI(TemplatedBranchView):
24
34
    """
25
35
    """
44
54
                   if not d.startswith('.')
45
55
                   and os.path.isdir(os.path.join(self._path, d))]
46
56
        listing.sort(key=lambda x: x.lower())
 
57
        dirs = []
 
58
        parity = 0
 
59
        for d in listing:
 
60
            p = os.path.join(self._path, d)
 
61
            try:
 
62
                b = branch.Branch.open(p)
 
63
            except errors.NotBranchError:
 
64
                b = None
 
65
            dirs.append(DirEntry(d, parity, b))
 
66
            parity = 1 - parity
47
67
        return {
48
 
            'dirs': listing,
49
 
            'path': self._path,
 
68
            'dirs': dirs,
50
69
            'name': self._name,
51
70
            }