3
# This file is part of Checkbox.
5
# Copyright 2012 Canonical Ltd.
7
# Checkbox is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# Checkbox is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
23
from argparse import ArgumentParser
25
from checkbox.lib.template import Template
26
from checkbox.parsers.xinput import (
32
# Command to retrieve xinput information.
33
COMMAND = "xinput --list --long"
36
class XinputResult(IXinputResult):
41
def addXinputDevice(self, device):
42
device["type"] = "device"
43
self.elements.append(device)
45
def addXinputDeviceClass(self, device, device_class):
46
device_class["type"] = "class"
47
device_class.update(device)
48
self.elements.append(device_class)
52
parser = ArgumentParser()
53
parser.add_argument("filename", nargs='?',
54
help="Optional filename containing xinput data")
55
args = parser.parse_args()
58
stream = open(args.filename)
60
stream = os.popen(COMMAND)
62
xinput = XinputParser(stream)
64
result = XinputResult()
68
template.dump_file(result.elements, sys.stdout)
73
if __name__ == "__main__":