Files
react-native-devtools-frontend/scripts/build/generate_aria.py
T
Liviu Rau 3da5d4a22e Run build scripts with vpython3
Bug: 1292013
Change-Id: Idf2e5de0b6ca3a296e5efd7952911783d6005e30
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3484196
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Liviu Rau <liviurau@chromium.org>
2022-02-25 10:12:14 +00:00

36 lines
1.3 KiB
Python

#!/usr/bin/env vpython3
#
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import datetime
import json
import os
import sys
from os import path
PYJSON5_DIR = os.path.join(os.path.dirname(__file__), '..', '..', 'third_party', 'pyjson5', 'src')
sys.path.append(PYJSON5_DIR)
import json5 # pylint: disable=import-error
ROOT_DIRECTORY = path.join(path.dirname(__file__), '..', '..')
GENERATED_LOCATION = path.join(ROOT_DIRECTORY, 'front_end', 'generated', 'ARIAProperties.js')
READ_LOCATION = path.join(ROOT_DIRECTORY, 'third_party', 'blink', 'renderer', 'core', 'html', 'aria_properties.json5')
def properties_from_file(file_name):
with open(os.path.abspath(file_name)) as json5_file:
properties = json5.loads(json5_file.read())
return properties
ARIA_PROPERTIES = properties_from_file(READ_LOCATION)
now = datetime.datetime.now()
with open(GENERATED_LOCATION, "w+") as f:
f.write('// Copyright %d The Chromium Authors. All rights reserved.\n' % now.year)
f.write('// Use of this source code is governed by a BSD-style license that can be\n')
f.write('// found in the LICENSE file.\n')
f.write('\n')
f.write("export const config = %s;\n" % json.dumps(ARIA_PROPERTIES))