1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/env python
# Copyright (C) 2020 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from optparse import OptionParser
from wikidata import *
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-c', '--cache', dest='cache',
action="store_true",
help='Use the local cache only (offline mode)',
metavar='NAME=value')
parser.add_option('-t', '--match-token', dest='match_token',
action='append',
help='Search for information with tokens named NAME that have the value value,',
metavar='NAME=value')
(options, args) = parser.parse_args()
parser_options = options.__dict__
cache = parser_options.get('cache', False)
if parser_options.get('match_token', None):
variants = []
for match_token in options.match_token:
# TODO: check format
(key, value) = match_token.split('=')
if key == 'device':
wikidata = Wikidata(cache)
variants.append(value)
pass
else:
#TODO
pass
if len (variants) > 0:
wikidata.print_compatible_variants(variants)
else:
wikidata = Wikidata(cache)
wikidata.print_compatible_devices()
|