-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcat-verify
executable file
·658 lines (531 loc) · 23.9 KB
/
cat-verify
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
#!/usr/bin/env python3
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# cat-verify - Generate a Markdown verification manual
#
# USAGE
#
# $ cat-verify -c config.txt -a variable.txt
import re
import sys
import glob
import getopt
import logging
import textwrap
import csv
import os
import collections
BASEDIR = os.path.dirname(os.path.realpath(__file__))
sys.path.append(BASEDIR)
import adlib
try:
import jinja2
except ImportError:
print("ERROR: Please install jinja2 to run this script\n")
print(" $ sudo apt install python3-jinja2\n")
sys.exit(1)
#
# GLOBALS
DEFAULT_VAR = {
"firefox_version": "128.1.0 ESR",
"windows_version": "Windows 10",
"configuration_sheet_name": "configs.xlsx",
"use_meta_installer": "true",
"meta_installer_name": "Fx Meta Installer",
"meta_installer_file_name": "FxMetaInstaller",
"meta_installer_version": "128.1.0",
"install_path_base": "C:\\Program Files (x86)",
"install_path_base_32bit": "C:\\Program Files",
"install_path": "C:\\Program Files (x86)\\Mozilla Firefox",
"install_path_32bit": "C:\\Program Files\\Mozilla Firefox",
"exe_name": "firefox",
"desktop_shortcut": "true",
"desktop_shortcut_path": "C:\\Users\\Public\\Desktop\\Mozilla Firefox.lnk",
"start_menu_shortcut": "true",
"start_menu_shortcut_path": "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Mozilla Firefox.lnk",
"finish_title": "Mozilla Firefox",
"finish_message": "インストールが完了しました",
"restart_title": "Mozilla Firefox",
"restart_message": "今すぐコンピュータを再起動しますか?",
"mcd_local_file": "autoconfig.cfg",
"special_profile_path": "%AppData%\\Mozilla\\Firefox",
"special_profile_name": "Special",
"home_page": "http://example.com/",
"history_expiration_max_pages": "30",
"download_dir": "C:\\",
"proxy_host": "example.local",
"proxy_auth_user": "clearcode",
"pac_url": "http://example.local/proxy.pac",
"pac_url_setup": "data:application/javascript,",
"ntlm_single_signon_hosts": "sso.example.local",
"weak_tls_allowed_hosts": "weak.example.local",
"security_45_exception_hosts": "example.com",
"location_3_hostname_like_term": "example",
"max_connections": "6",
"max_persistent_connections_per_server": "2",
"max_persistent_connections_per_proxy": "2",
"max_pipelining_requests": "32",
"user_agent_name": "Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/128.0",
"navigator_appVersion": "5.0 (Windows)",
"imported_certs": "検証用証明書(example.com), (発行者名1)/(証明署名1), (発行者名1)/(証明署名2), ...",
"flash_download_url": "https://get.adobe.com/jp/flashplayer/",
"ModifySystemTime": "",
"DownloadExeFile": "",
"UpdateFromFirefox60": "",
}
TEMPLATE = """
## {option_id}
『{title}:{option_title}』
{dependency_description}
**検証手順**
{config}
"""
TEMPLATE_PRETEXT = """
## {option_title}
{config}
"""
TEMPLATE_OPTIONS = """
# 設定画面を使用した検証
## 事前準備
- 前項に引き続き検証するか、または以下の状態を整えておく。
- 作成済みの `{{meta_installer_file_name}}*.exe` を検証用ユーザーとして実行し、カスタマイズ済みFirefoxのインストールを完了している。
管理者権限を要求された場合は、`管理者`ユーザーで認証する。
## 検証
- ユーザープロファイルの位置が `%AppData%\Mozilla` 配下にある場合、 `%AppData%\Mozilla` を削除する。そうでない場合、ユーザープロファイルフォルダ自体を削除する。
- Firefoxを起動する。
- パネルメニューから「設定」を開く。
- **確認**
"""
TEMPLATE_ABOUT_CONFIG = """
# about:configを使用した検証
## 事前準備
- 前項に引き続き検証するか、または以下の状態を整えておく。
- 作成済みの `{{meta_installer_file_name}}*.exe` を検証用ユーザーとして実行し、カスタマイズ済みFirefoxのインストールを完了している。
管理者権限を要求された場合は、`管理者`ユーザーで認証する。
## 検証
{%if Security_9_3 %}
- ポリシー設定から `BlockAboutConfig` を削除し、`about:config` を一時的に有効化しておく。
{% endif %}
- ユーザープロファイルの位置が `%AppData%\Mozilla` 配下にある場合、 `%AppData%\Mozilla` を削除する。そうでない場合、ユーザープロファイルフォルダ自体を削除する。
- Firefoxを起動する。
- `about:config`を開く。
- **確認**
"""
TEMPLATE_ABOUT_CONFIG_END = """
{%if Security_9_3 %}
- ポリシー設定から一時的に削除した `BlockAboutConfig` を元に戻す。
{% endif %}
"""
TEMPLATE_ABOUT_POLICIES = """
# about:policiesを使用した検証
## 事前準備
- 前項に引き続き検証するか、または以下の状態を整えておく。
- 作成済みの `{{meta_installer_file_name}}*.exe` を検証用ユーザーとして実行し、カスタマイズ済みFirefoxのインストールを完了している。
管理者権限を要求された場合は、`管理者`ユーザーで認証する。
## 検証
- Firefoxを起動する。
- `about:policies`を開く。
- 「有効」を選択する。
- **確認**
"""
TEMPLATE_SHORTCUT = """
# その他のキーボードショートカットの検証
## 事前準備
- 前項に引き続き検証するか、または以下の状態を整えておく。
- 作成済みの `{{meta_installer_file_name}}*.exe` を検証用ユーザーとして実行し、カスタマイズ済みFirefoxのインストールを完了している。
管理者権限を要求された場合は、`管理者`ユーザーで認証する。
## 検証
- Firefoxを起動する。
- **確認**
"""
TEMPLATE_DEVTOOL_MENU = """
# 開発ツールのメニュー項目の検証
## 事前準備
- 前項に引き続き検証するか、または以下の状態を整えておく。
- 作成済みの `{{meta_installer_file_name}}*.exe` を検証用ユーザーとして実行し、カスタマイズ済みFirefoxのインストールを完了している。
管理者権限を要求された場合は、`管理者`ユーザーで認証する。
## 検証
- Firefoxを起動する。
- 「ツール」メニューの「ウェブ開発」サブメニューを開く。
- **確認**
"""
TEMPLATE_DEVTOOL_PANEL = """
- パネルメニューの「ウェブ開発」サブメニューを開く。
- **確認**
"""
TEMPLATE_DEVTOOL_SKIPPED = """
# 開発ツールの個別の検証
開発ツール非表示のため、「ツール」メニューの「ウェブ開発」およびサブメニューパネルメニューの「ウェブ開発」サブメニュー配下の以下の項目の非表示化は、検証を省略する。
"""
FILES = [
'PRETEXT',
'Install',
'Application',
'Admin',
'Security',
'Privacy',
'Startup',
'Websearch',
'Location',
'Download',
'Tab',
'Network',
'Update',
'Ui',
'Script',
'Plugin',
'External',
'Stability',
'Appearance',
'Performance',
'Addon-IEView',
'Addon-FireIE',
'Addon-Acrobat',
'Addon-Skysea',
'MenuShortcut',
]
SPECIALS = [
'OPTIONS',
'ABOUT_CONFIG',
'ABOUT_POLICIES',
]
#
# Utils
def is_deprecated(string):
return '廃止' in string
def anyof(vars, *args):
return any(vars[k] for k in args)
def should_skip(vars, dependency):
"""Return True if the verification step should be skipped.
>>> vars = {'ModifyTime': 1}
>>> should_skip(vars, 'ModifyTime')
False
>>> should_skip(vars, 'ModifySystem')
False
>>> should_skip(vars, 'not ModifyTime')
True
"""
key = dependency
func = lambda x: x
if key.startswith('not '):
key = key[4:]
func = lambda x: not x
if key not in vars:
return False
return not func(vars[key])
def parse_special(text):
ht = text.split('\n', maxsplit=1)
if ht[0] in SPECIALS:
return (ht[0], ht[1])
return ('', text)
DISABLED_ITEM_KEY_MATCHER = re.compile('(DISABLED_[A-Z_]+):\s+(.+)\Z')
def shift_disabled_item(text):
ht = text.split('\n', maxsplit=1)
match = re.match(DISABLED_ITEM_KEY_MATCHER, ht[0])
if match:
rest = ''
if len(ht) > 1:
rest = ht[1]
return (match.group(1), match.group(2), rest)
return ('', '', text)
PRETEXT_OPTION_MATCHER = re.compile('^[^-]+-0-[0-9]+\Z')
LIST_ITEM_MATCHER = re.compile('^(\s*)(- )?(.*[^\\\\])$', re.MULTILINE)
LIST_LINE_MATCHER = re.compile('^(\s*)(- )?(.+)$', re.MULTILINE)
def create_template(manual, config, vars, options):
items_options = []
items_about_config = []
items_about_policies = []
items_disabled_shortcuts = []
items_disabled_devtool_menu = []
template = vars.get('COVER', '') + '\n'
template += "# 事前準備"
for item in manual['PRETEXT']:
for option in item['options']:
template += TEMPLATE_PRETEXT.format(**option) + '\n'
# prepare internal variables
vars['use_meta_installer'] = vars['use_meta_installer'] == 'true'
vars['desktop_shortcut'] = vars['desktop_shortcut'] == 'true'
vars['start_menu_shortcut'] = vars['start_menu_shortcut'] == 'true'
vars['show_bookmarks_toolbar_on_startup'] = False
for items in manual.values():
for item in items[1:]:
for option in item['options']:
vars[option['option_id'].replace('-', '_')] = option['option_id'] in config
vars['not ' + option['option_id'].replace('-', '_')] = option['option_id'] not in config
vars['DisableDeveloperTools'] = anyof(vars,
'MenuShortcut_10_1', 'MenuShortcut_11_1', 'MenuShortcut_12_1',
'MenuShortcut_13_1', 'MenuShortcut_14_1', 'MenuShortcut_15_1',
'MenuShortcut_16_1', 'MenuShortcut_17_1', 'MenuShortcut_18_1',
'MenuShortcut_21_1', 'MenuShortcut_22_1', 'MenuShortcut_23_1',
'MenuShortcut_24_1', 'MenuShortcut_25_1', 'MenuShortcut_26_1',
'MenuShortcut_28_1', 'MenuShortcut_29_1', 'MenuShortcut_57_1',
'MenuShortcut_64_1', 'MenuShortcut_65_1')
vars['not DisableDeveloperTools'] = not vars['DisableDeveloperTools']
vars['DisableSync'] = anyof(vars, 'Privacy_22_2', 'Privacy_22_3', 'Privacy_24_2', 'Privacy_24_3')
vars['not DisableSync'] = not vars['DisableSync']
vars['DisableFirefoxAccount'] = vars['DisableSync']
vars['not DisableFirefoxAccount'] = not vars['DisableFirefoxAccount']
vars['OfferToSaveLogins'] = not (vars['Privacy_5_3'] or vars['Privacy_5_4'])
vars['not OfferToSaveLogins'] = not vars['OfferToSaveLogins']
vars['UsePACFile'] = vars['Network_2_8']
missing_any_of_privacy_33 = not any([vars['Privacy_33_1'],
vars['Privacy_33_2'],
vars['Privacy_33_4'],
vars['Privacy_33_5']])
vars['UseBlockList'] = (not (vars['Security_5_2'] or vars['Security_6_2'] or vars['Privacy_33_5'])) or \
missing_any_of_privacy_33
vars['InstallAddonsPermission'] = vars['Security_3_3'] or vars['Security_3_6'] or vars['Security_3_7']
vars['DisableSync'] = vars['Privacy_22_2'] or vars['Privacy_22_3']
vars['not DisableSync'] = not vars['DisableSync']
vars['NotificationGloballyDisabled'] = vars['Script_2_3'] or vars['Script_2_6']
vars['not NotificationGloballyDisabled'] = not vars['NotificationGloballyDisabled']
vars['DisabledSponsoredTopSites'] = vars['Tab_5_5'] or vars['Tab_11_6'] or vars['Tab_21_2']
vars['not DisabledSponsoredTopSites'] = not vars['DisabledSponsoredTopSites']
vars['DisabledStatistics'] = vars['Privacy_18_3']
vars['not DisabledStatistics'] = not vars['DisabledStatistics']
vars['PromptForDownloadLocation'] = vars['Download_3_4']
missing_any_of_startup_2 = not any([vars['Startup_2_1'],
vars['Startup_2_4'],
vars['Startup_2_5'],
vars['Startup_2_6']])
vars['show_bookmarks_toolbar_on_startup'] = (vars['Startup_2_1'] or missing_any_of_startup_2) and vars['Appearance_5_2']
vars['show_home_button'] = (vars['Startup_2_4'] or vars['Startup_2_5']) or vars['Appearance_12_1']
if vars['Appearance_12_2']:
vars['show_home_button'] = False
chapters = {}
chapter_options = []
chapter_about_config = []
chapter_about_policies = []
chapter_disabled_shortcut = []
chapter_disabled_devtool = []
first_level_chapter = 2
for items in manual.values():
tmp = ''
if len(items) > 0 and re.match(PRETEXT_OPTION_MATCHER, items[0]['options'][0]['option_id']):
second_level_chapter = 2
else:
second_level_chapter = 1
for item in items[1:]:
for option in item['options']:
if option['option_id'] not in config:
continue
if should_skip(vars, option['dependency']):
continue
config_values = config.get(option['option_id'], '')
option['option_title'] = config_values['option_title']
option['dependency_description'] = ''
if is_deprecated(option['option_title']):
continue
if option['dependency'] in vars:
if not vars[option['dependency']]:
continue
option['dependency'] = ''
sp, text = parse_special(option['config'])
if sp == 'OPTIONS':
items_options.append((option['option_id'], option['dependency'], text))
chapter_options.append(option['option_id'])
continue
elif sp == 'ABOUT_CONFIG':
items_about_config.append((option['option_id'], option['dependency'], text))
chapter_about_config.append(option['option_id'])
continue
elif sp == 'ABOUT_POLICIES':
items_about_policies.append((option['option_id'], option['dependency'], text))
chapter_about_policies.append(option['option_id'])
continue
while True:
key, desc, text = shift_disabled_item(text)
if key == '':
break
elif key == 'DISABLED_SHORTCUT':
items_disabled_shortcuts.append((option['option_id'], desc))
chapter_disabled_shortcut.append(option['option_id'])
elif key == 'DISABLED_DEVTOOL_MENU':
items_disabled_devtool_menu.append((option['option_id'], desc))
chapter_disabled_devtool.append(option['option_id'])
if text == '':
continue
option['config'] = text
if option['dependency'] != '':
option['dependency_description'] = '(' + option['dependency'] + ')'
tmp += TEMPLATE.format(**option, **item) + '\n'
if not re.match(PRETEXT_OPTION_MATCHER, option['option_id']):
capter_id = '%s.%s' % (first_level_chapter, second_level_chapter)
if capter_id in chapters:
option_ids = chapters[capter_id]
else:
option_ids = []
option_ids.append(option['option_id'])
chapters[capter_id] = option_ids
second_level_chapter += 1
if not tmp:
continue # Nothing to verify
template += '\n# %s' % items[0]['title']
for option in items[0]['options']:
template += TEMPLATE_PRETEXT.format(**option) + '\n'
template += tmp
first_level_chapter += 1
if items_options:
template += TEMPLATE_OPTIONS
for option_id, dependency, text in items_options:
if dependency:
suffix = ' (%s %s)' % (option_id, dependency)
else:
suffix = ' (%s)' % (option_id)
template += re.sub(LIST_LINE_MATCHER, '\\1 \\2\\3', re.sub(LIST_ITEM_MATCHER, '\\1\\2\\3 %s' % (suffix), text))
template += '\n'
chapters['%s' % (first_level_chapter)] = chapter_options
first_level_chapter += 1
if items_about_config:
template += TEMPLATE_ABOUT_CONFIG
config_list = []
for option_id, dependency, text in items_about_config:
if dependency:
suffix = ' (%s %s)' % (option_id, dependency)
else:
suffix = ' (%s)' % (option_id)
config_list.append(re.sub(LIST_LINE_MATCHER, '\\1 \\2\\3', re.sub(LIST_ITEM_MATCHER, '\\1\\2\\3 %s' % (suffix), text)))
if options['sort-about-config'] == 'pref':
template += '\n'.join(sort_by_ascii_part(config_list))
elif options['sort-about-config'] == 'option':
# Align by Install, Application, Admin...
for key in chapter_about_config:
for line in config_list:
if re.search('\(%s\s?' % key, line):
template += '\n'.join(sort_by_ascii_part(config_list))
template += TEMPLATE_ABOUT_CONFIG_END
template += '\n'
chapters['%s' % (first_level_chapter)] = chapter_about_config
first_level_chapter += 1
if items_about_policies:
template += TEMPLATE_ABOUT_POLICIES
config_list = []
for option_id, dependency, text in items_about_policies:
if dependency:
suffix = ' (%s %s)' % (option_id, dependency)
else:
suffix = ' (%s)' % (option_id)
config_list.append(re.sub(LIST_LINE_MATCHER, '\\1 \\2\\3', re.sub(LIST_ITEM_MATCHER, '\\1\\2\\3 %s' % (suffix), text)))
template += '\n'.join(sort_by_ascii_part(config_list))
template += '\n'
chapters['%s' % (first_level_chapter)] = chapter_about_policies
first_level_chapter += 1
if items_disabled_shortcuts:
template += TEMPLATE_SHORTCUT
for option_id, text in items_disabled_shortcuts:
template += ' - %s (%s)\n' % (text, option_id)
chapters['%s' % (first_level_chapter)] = chapter_disabled_shortcut
first_level_chapter += 1
if items_disabled_devtool_menu:
if vars['DisableDeveloperTools']:
template += TEMPLATE_DEVTOOL_SKIPPED
for option_id, text in items_disabled_devtool_menu:
template += '- %s (%s)\n' % (text, option_id)
else:
template += TEMPLATE_DEVTOOL_MENU
for option_id, text in items_disabled_devtool_menu:
template += ' - %s (%s)\n' % (text, option_id)
template += TEMPLATE_DEVTOOL_PANEL
for option_id, text in items_disabled_devtool_menu:
template += ' - %s (%s)\n' % (text, option_id)
chapters['%s' % (first_level_chapter)] = chapter_disabled_devtool
first_level_chapter += 1
template += "\n" + vars.get('POSTSCRIPT', '')
urls = extract_urls(template)
vars['urls'] = "\n".join(list(map(lambda url: (' - `' + url + '`'), urls)))
vars['has_urls'] = len(urls) > 0
return (template, chapters)
def sort_by_ascii_part(strings):
return sorted(strings, key=lambda s: re.match(r'^\s*-\s*`?[a-zA-Z0-9\._\-]+', s).group())
def extract_urls(input):
all_extracted_urls = re.findall('(?P<url>https?://[^/(\s」`]+(?:[^(^\s`」][^\s`」]*)?)', input)
wildcard_replaced_urls = list(map(lambda url: re.sub('[~~]$', '*', url), all_extracted_urls))
sorted_urls = sorted(list(set(wildcard_replaced_urls)))
shortened_urls = re.sub("(https?://[^\n]+)(\n\\1[^\n]+)+", "\\1*", "\n".join(sorted_urls)).split("\n")
return shortened_urls
def chapters_to_csv(chapters):
chapters_by_option_id = {}
for chapter_id, option_ids in chapters.items():
for option_id in option_ids:
if option_id in chapters_by_option_id:
chapter_ids = chapters_by_option_id[option_id]
else:
chapter_ids = []
if not chapter_id in chapter_ids:
chapter_ids.append(chapter_id)
chapters_by_option_id[option_id] = chapter_ids
csv_source = []
for option_id, chapter_ids in chapters_by_option_id.items():
csv_source.append((option_id, "\n".join(chapter_ids)))
return csv_source
def chapters_to_checklist(chapters):
rows = []
rows.append(("見出し番号", "検証対象項目", "検証結果(ok/ng)"))
for chapter_id, option_ids in chapters.items():
for option_id in option_ids:
rows.append(("%s" % chapter_id, option_id, ""))
return rows
#
# Main
def usage(err):
print('error: %s' % err, file=sys.stderr)
print('usage: %s INFILE' % sys.argv[0], file=sys.stderr)
sys.exit(1)
def main(args):
config = {}
vars = {}
options = {}
options['sort-about-config'] = 'pref'
only_index_output = False
only_checklist_output = False
opts, args = getopt.getopt(args, 'c:a:il', ["sort-about-config="])
for key, value in opts:
if key == '-c':
config = adlib.load_as_dict(value)
elif key == '-a':
vars = adlib.load_variables(value)
elif key == '-i':
only_index_output = True
elif key == '-l':
only_checklist_output = True
elif key == '--sort-about-config' and value in ['pref', 'option']:
# type of sort: pref or option
options['sort-about-config'] = value
vars = {**DEFAULT_VAR, **vars}
manual = collections.OrderedDict()
for fn in FILES:
manual[fn] = adlib.load('verify/%s' % fn)
# Check whether option id is belonged to pre-defined category
invalid_option_id_count = 0
for option_id in config.keys():
found = False
for category in FILES:
if category in option_id:
found = True
if not found:
invalid_option_id_count += 1
print("%s must be invalid option id, check category of %s: %s" %
(option_id, option_id, config[option_id]['option_title']), file=sys.stderr)
if invalid_option_id_count > 0:
exit(1)
template, chapters = create_template(manual, config, vars, options)
if only_index_output:
# Generate a mapping file of (option_id -> chapter) for
# configuration sheets (see build-xlsx).
csv_writer = csv.writer(sys.stdout)
csv_writer.writerows(chapters_to_csv(chapters))
elif only_checklist_output:
# Generate a checklist for humans.
csv_writer = csv.writer(sys.stdout, quotechar='"', quoting=csv.QUOTE_ALL)
csv_writer.writerows(chapters_to_checklist(chapters))
else:
# Generate a verification manual (default)
logging.basicConfig(format="\033[31m%(message)s\033[0m")
log = logging.getLogger(__name__)
env = jinja2.Environment(undefined=jinja2.make_logging_undefined(log))
print(env.from_string(template).render(vars))
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))