2
# Copyright (c) 2008 Canonical
4
# Written by Marc Tardif <marc@interunion.ca>
6
# This file is part of Checkbox.
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.
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.
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/>.
21
from checkbox.lib.cache import cache
22
from checkbox.lib.conversion import string_to_type
24
from checkbox.registries.data import DataRegistry
25
from checkbox.registries.filename import FilenameRegistry
26
from checkbox.registries.link import LinkRegistry
29
class ProcessorRegistry(DataRegistry):
30
"""Registry for processor information.
32
Each item contained in this registry consists of the information
33
for a single processor in the /proc/cpuinfo file.
38
for line in [l.strip() for l in self.split("\n")]:
39
(key, value) = line.split(":", 1)
41
# Sanitize key so that it can be expressed as
44
key = key.replace(" ", "_")
47
# Rename processor entry to name
48
if key == "processor":
51
# Express value as a list if it is flags
56
value = string_to_type(value)
58
items.append((key, value))
60
items.append(("processor", LinkRegistry(None, self)))
65
class CpuinfoRegistry(FilenameRegistry):
66
"""Registry for cpuinfo information.
68
Each item contained in this registry consists of the processor number
69
as key and the corresponding processor registry as value.
75
for data in [d.strip() for d in self.split("\n\n") if d]:
77
value = ProcessorRegistry(None, data)
78
items.append((key, value))
83
factory = CpuinfoRegistry