QtBase  v6.3.1
qedidvendortable.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
29 
30 import urllib.request
31 
32 # The original source for this data used to be
33 # 'https://git.fedorahosted.org/cgit/hwdata.git/plain/pnp.ids'
34 # which is discontinued. For now there seems to be a fork at:
35 url = 'https://github.com/vcrhonek/hwdata/raw/master/pnp.ids'
36 
37 copyright = """/****************************************************************************
38 **
39 ** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
40 ** Contact: https://www.qt.io/licensing/
41 **
42 ** This file is part of the QtGui module of the Qt Toolkit.
43 **
44 ** $QT_BEGIN_LICENSE:LGPL$
45 ** Commercial License Usage
46 ** Licensees holding valid commercial Qt licenses may use this file in
47 ** accordance with the commercial license agreement provided with the
48 ** Software or, alternatively, in accordance with the terms contained in
49 ** a written agreement between you and The Qt Company. For licensing terms
50 ** and conditions see https://www.qt.io/terms-conditions. For further
51 ** information use the contact form at https://www.qt.io/contact-us.
52 **
53 ** GNU Lesser General Public License Usage
54 ** Alternatively, this file may be used under the terms of the GNU Lesser
55 ** General Public License version 3 as published by the Free Software
56 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
57 ** packaging of this file. Please review the following information to
58 ** ensure the GNU Lesser General Public License version 3 requirements
59 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
60 **
61 ** GNU General Public License Usage
62 ** Alternatively, this file may be used under the terms of the GNU
63 ** General Public License version 2.0 or (at your option) the GNU General
64 ** Public license version 3 or any later version approved by the KDE Free
65 ** Qt Foundation. The licenses are as published by the Free Software
66 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
67 ** included in the packaging of this file. Please review the following
68 ** information to ensure the GNU General Public License requirements will
69 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
70 ** https://www.gnu.org/licenses/gpl-3.0.html.
71 **
72 ** $QT_END_LICENSE$
73 **
74 ****************************************************************************/
75 """
76 
77 notice = """/*
78  * This lookup table was generated from {}
79  *
80  * Do not change this file directly, instead edit the
81  * qtbase/util/edid/qedidvendortable.py script and regenerate this file.
82  */""".format(url)
83 
84 header = """
85 #ifndef QEDIDVENDORTABLE_P_H
86 #define QEDIDVENDORTABLE_P_H
87 
88 //
89 // W A R N I N G
90 // -------------
91 //
92 // This file is not part of the Qt API. It exists purely as an
93 // implementation detail. This header file may change from version to
94 // version without notice, or even be removed.
95 //
96 // We mean it.
97 //
98 
99 QT_BEGIN_NAMESPACE
100 
101 struct VendorTable {
102  const char id[4];
103  const char name[%d];
104 };
105 
106 static const VendorTable q_edidVendorTable[] = {"""
107 
108 footer = """};
109 
110 QT_END_NAMESPACE
111 
112 #endif // QEDIDVENDORTABLE_P_H"""
113 
114 vendors = {}
115 
116 max_vendor_length = 0
117 
118 response = urllib.request.urlopen(url)
119 data = response.read().decode('utf-8')
120 for line in data.split('\n'):
121  l = line.split()
122  if line.startswith('#'):
123  continue
124  elif len(l) == 0:
125  continue
126  else:
127  pnp_id = l[0].upper()
128  vendors[pnp_id] = ' '.join(l[1:])
129  if len(vendors[pnp_id]) > max_vendor_length:
130  max_vendor_length = len(vendors[pnp_id])
131 
132 print(copyright)
133 print(notice)
134 print(header % (max_vendor_length + 1))
135 for pnp_id in sorted(vendors.keys()):
136  print(' { "%s", "%s" },' % (pnp_id, vendors[pnp_id]))
137 print(footer)
#define decode(x)
Definition: qurlquery.cpp:242
C sorted(C c)