~ubuntu-dev/ubuntu/lucid/coherence/lucid-201002101853

« back to all changes in this revision

Viewing changes to coherence/backend.py

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Quette
  • Date: 2008-03-05 13:43:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080305134301-pg572ehbze3h7cii
Tags: 0.5.2-1
* New upstream release
* debian/control: depend on python-pkg-resources instead of
  python-setuptools for the runtime dependency (Closes: #468724)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Licensed under the MIT license
 
4
# http://opensource.org/licenses/mit-license.php
 
5
 
 
6
# Copyright 2007, Frank Scholz <coherence@beebits.net>
 
7
 
 
8
from coherence.extern.simple_plugin import Plugin
 
9
 
 
10
from coherence import log
 
11
 
 
12
 
 
13
class BackendItem(log.Loggable):
 
14
 
 
15
    """ the base class for all backend store items
 
16
    """
 
17
 
 
18
    logCategory = 'backend_item'
 
19
 
 
20
 
 
21
class BackendStore(log.Loggable,Plugin):
 
22
 
 
23
    """ the base class for all backend store items
 
24
    """
 
25
 
 
26
    logCategory = 'backend_store'
 
27
    wmc_mapping = {'4':'4', '5':'5', '6':'6','7':'7','14':'14','F':'F',
 
28
                   '11':'11','16':'16','B':'B','C':'C','D':'D',
 
29
                   '13':'13', '17':'17',
 
30
                   '8':'8', '9':'9', '10':'10', '15':'15', 'A':'A', 'E':'E'}
 
31
 
 
32
    def __init__(self):
 
33
        self.wmc_mapping.update({'4':lambda: self._get_all_items(0),
 
34
                                 '8':lambda: self._get_all_items(0),
 
35
                                 'B':lambda: self._get_all_items(0),
 
36
                                })
 
37
 
 
38
    def _get_all_items(self,id):
 
39
        items = []
 
40
        item = self.get_by_id(id)
 
41
        if item is not None:
 
42
            containers = [item]
 
43
            while len(containers)>0:
 
44
                container = containers.pop()
 
45
                if container.mimetype not in ['root', 'directory']:
 
46
                    continue
 
47
                for child in container.get_children(0,0):
 
48
                    if child.mimetype in ['root', 'directory']:
 
49
                        containers.append(child)
 
50
                    else:
 
51
                        items.append(child)
 
52
        return items
 
 
b'\\ No newline at end of file'