~ubuntu-branches/ubuntu/precise/checkbox/precise

« back to all changes in this revision

Viewing changes to registries/pvs.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Tardif
  • Date: 2009-01-20 16:46:15 UTC
  • Revision ID: james.westby@ubuntu.com-20090120164615-7iz6nmlef41h4vx2
Tags: 0.4
* Setup bzr-builddeb in native mode.
* Removed LGPL notice from the copyright file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright (c) 2008 Canonical
 
3
#
 
4
# Written by Marc Tardif <marc@interunion.ca>
 
5
#
 
6
# This file is part of Checkbox.
 
7
#
 
8
# Checkbox is free software: you can redistribute it and/or modify
 
9
# it under the terms of the GNU General Public License as published by
 
10
# the Free Software Foundation, either version 3 of the License, or
 
11
# (at your option) any later version.
 
12
#
 
13
# Checkbox is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
import re
 
22
 
 
23
from checkbox.lib.cache import cache
 
24
from checkbox.lib.conversion import string_to_type
 
25
 
 
26
from checkbox.registries.command import CommandRegistry
 
27
from checkbox.registries.map import MapRegistry
 
28
 
 
29
 
 
30
class PvsRegistry(CommandRegistry):
 
31
    """Registry for pvs information.
 
32
 
 
33
    Each item contained in this registry consists information about
 
34
    the mount point.
 
35
    """
 
36
 
 
37
    @cache
 
38
    def items(self):
 
39
        items = []
 
40
        lines = [l.strip() for l in self.split("\n") if l]
 
41
        if lines:
 
42
            keys_line = lines.pop(0)
 
43
            keys = [k.lower() for k in re.split(r"\s+", keys_line)]
 
44
 
 
45
            for line in lines:
 
46
                values = [string_to_type(v) for v in re.split(r"\s+", line)]
 
47
                map = dict(zip(keys, values))
 
48
                value = MapRegistry(None, map)
 
49
                items.append((map["pv"], value))
 
50
 
 
51
        return items
 
52
 
 
53
 
 
54
factory = PvsRegistry