#!/bin/env python # Copyright (C) 2020 Denis 'GNUtoo' Carikli # # 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 . 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()