id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
157,303 | import atexit
import collections
import enum
import os
import re
import shutil
import signal
import stat
import subprocess
import sys
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import dictionary_manager
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers import options
from clusterfuzz._internal.bot.fuzzers import strategy_selection
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
from clusterfuzz._internal.fuzzing import strategy
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import profiler
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
from clusterfuzz._internal.system import shell
The provided code snippet includes necessary dependencies for implementing the `list_full_file_paths` function. Write a Python function `def list_full_file_paths(directory)` to solve the following problem:
List the absolute paths of files in |directory|.
Here is the function:
def list_full_file_paths(directory):
"""List the absolute paths of files in |directory|."""
directory_absolute_path = os.path.abspath(directory)
paths = []
for relative_path in os.listdir(directory):
absolute_path = os.path.join(directory_absolute_path, relative_path)
if os.path.isfile(absolute_path): # Only return paths to files.
paths.append(absolute_path)
return paths | List the absolute paths of files in |directory|. |
157,304 | import atexit
import collections
import enum
import os
import re
import shutil
import signal
import stat
import subprocess
import sys
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import dictionary_manager
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers import options
from clusterfuzz._internal.bot.fuzzers import strategy_selection
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
from clusterfuzz._internal.fuzzing import strategy
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import profiler
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
from clusterfuzz._internal.system import shell
The provided code snippet includes necessary dependencies for implementing the `get_first_stacktrace` function. Write a Python function `def get_first_stacktrace(stderr_data)` to solve the following problem:
If |stderr_data| contains stack traces, only returns the first one. Otherwise returns the entire string.
Here is the function:
def get_first_stacktrace(stderr_data):
"""If |stderr_data| contains stack traces, only returns the first one.
Otherwise returns the entire string."""
# Use question mark after .+ for non-greedy, otherwise it will match more
# than one stack trace.
sanitizer_stacktrace_regex = (
r'ERROR: [A-Za-z]+Sanitizer: .*\n(.|\n)+?ABORTING')
match = re.search(sanitizer_stacktrace_regex, stderr_data)
# If we can't find the first stacktrace, return the whole thing.
if match is None:
return stderr_data
return stderr_data[:match.end()] | If |stderr_data| contains stack traces, only returns the first one. Otherwise returns the entire string. |
157,305 | import atexit
import collections
import enum
import os
import re
import shutil
import signal
import stat
import subprocess
import sys
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import dictionary_manager
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers import options
from clusterfuzz._internal.bot.fuzzers import strategy_selection
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
from clusterfuzz._internal.fuzzing import strategy
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import profiler
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
from clusterfuzz._internal.system import shell
DEFAULT_MERGE_TIMEOUT = 30 * 60
POSTPROCESSING_TIMEOUT = 30
The provided code snippet includes necessary dependencies for implementing the `get_fuzz_timeout` function. Write a Python function `def get_fuzz_timeout(is_mutations_run, full_timeout=None)` to solve the following problem:
Get the maximum amount of time that should be spent fuzzing.
Here is the function:
def get_fuzz_timeout(is_mutations_run, full_timeout=None):
"""Get the maximum amount of time that should be spent fuzzing."""
fuzz_timeout = full_timeout
# TODO(mbarbella): Delete this check once non-engine support is removed. The
# engine pipeline always specifies a timeout.
if fuzz_timeout is None:
fuzz_timeout = engine_common.get_hard_timeout() - POSTPROCESSING_TIMEOUT
# Subtract mutations timeout from the total timeout.
if is_mutations_run:
fuzz_timeout -= engine_common.get_new_testcase_mutations_timeout()
# Subtract the merge timeout from the fuzz timeout in the non-engine case.
if not full_timeout:
fuzz_timeout -= engine_common.get_merge_timeout(DEFAULT_MERGE_TIMEOUT)
assert fuzz_timeout > 0
return fuzz_timeout | Get the maximum amount of time that should be spent fuzzing. |
157,306 | import atexit
import collections
import enum
import os
import re
import shutil
import signal
import stat
import subprocess
import sys
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import dictionary_manager
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers import options
from clusterfuzz._internal.bot.fuzzers import strategy_selection
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
from clusterfuzz._internal.fuzzing import strategy
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import profiler
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
from clusterfuzz._internal.system import shell
class AflRunner(AflRunnerCommon, new_process.UnicodeProcessRunner):
"""Afl runner."""
def __init__(self,
target_path,
config,
testcase_file_path,
input_directory,
timeout=None,
afl_tools_path=None,
strategy_dict=None):
super().__init__(target_path, config, testcase_file_path, input_directory,
timeout, afl_tools_path, strategy_dict)
new_process.ProcessRunner.__init__(self, self.afl_fuzz_path)
class AflAndroidRunner(AflRunnerCommon, new_process.UnicodeProcessRunner):
"""Afl Android runner."""
# Time that we need to remove from timeout command to ensure a clean exit
# while fuzzing on device
# NOTE: if run_and_wait times out before afl on device process it will return
# an error, and clusterfuzz will think there was an error with the fuzzing
DEVICE_FUZZING_CLEAN_EXIT_TIME = 10.0
def __init__(self,
target_path,
config,
testcase_file_path,
input_directory,
timeout=None,
afl_tools_path=None,
strategy_dict=None):
super().__init__(target_path, config, testcase_file_path, input_directory,
timeout, afl_tools_path, strategy_dict)
new_process.ProcessRunner.__init__(
self, executable_path=android.adb.get_adb_path())
self.showmap_output_path = os.path.join(
android.constants.DEVICE_FUZZING_DIR, self.SHOWMAP_FILENAME)
self._showmap_results_dir = os.path.join(environment.get_root_directory(),
"tmp/showmap_results")
def _copy_local_directories_to_device(self, local_directories):
"""Copies local directories to device."""
for local_directory in sorted(set(local_directories)):
self._copy_local_directory_to_device(local_directory)
def _copy_local_directory_to_device(self, local_directory):
"""Copies single local directory to device."""
device_directory = android.util.get_device_path(local_directory)
android.adb.remove_directory(device_directory, recreate=True)
android.adb.copy_local_directory_to_remote(local_directory,
device_directory)
def _copy_directories_from_device(self, local_directories):
"""Copies directories from device to local."""
for local_directory in sorted(set(local_directories)):
device_directory = android.util.get_device_path(local_directory)
shell.remove_directory(local_directory, recreate=True)
android.adb.copy_remote_directory_to_local(device_directory,
local_directory)
def afl_setup(self):
android.adb.remove_file(android.util.get_device_path(self.stderr_file_path))
super().afl_setup()
def run_single_testcase(self, testcase_path):
"""Runs a single testcase.
Args:
testcase_path: Path to testcase to be run.
Returns:
A new_process.ProcessResult.
"""
assert not testcase_path.isdigit(), ('We don\'t want to specify number of'
' executions by accident.')
self.afl_setup()
self._executable_path = android.adb.get_adb_path()
self._default_args = (['shell'] + self.get_afl_environment_variables() +
[android.util.get_device_path(self.target_path)])
device_target_path = android.util.get_device_path(testcase_path)
android.adb.copy_local_file_to_remote(testcase_path, device_target_path)
result = self.run_and_wait(additional_args=[device_target_path])
# Copy error to local.
android.adb.copy_remote_file_to_local(
android.util.get_device_path(self.stderr_file_path),
self.stderr_file_path)
self.check_return_code(result, [134])
return result
def get_file_features(self, input_file_path, showmap_args):
"""Get the features (edge hit counts) of |input_file_path| using
afl-showmap."""
# TODO(metzman): Figure out if we should worry about CPU affinity errors
# here.
filename = os.path.basename(input_file_path)
intput_file_showmap_results_file = os.path.join(self._showmap_results_dir,
filename)
if not os.path.exists(intput_file_showmap_results_file):
logs.log_error('Cannot merge corpus. Most likely reason is AFL_MAP_SIZE'
'required is very large for fuzzing target.')
return None, False
showmap_output = engine_common.read_data_from_file(
intput_file_showmap_results_file)
return self.get_feature_tuple(showmap_output), False
def fuzz(self):
self._executable_path = android.adb.get_adb_path()
self._default_args = ['shell']
self.initial_max_total_time = (
get_fuzz_timeout(
self.strategies.is_mutations_run, full_timeout=self.timeout) -
self.AFL_CLEAN_EXIT_TIME - self.SIGTERM_WAIT_TIME)
on_device_fuzzing_timeout = self.timeout - int(
self.AFL_CLEAN_EXIT_TIME + self.SIGTERM_WAIT_TIME +
self.DEVICE_FUZZING_CLEAN_EXIT_TIME)
self._copy_local_directories_to_device([
self.afl_input.input_directory,
os.path.dirname(os.path.realpath(self.target_path))
])
device_output_dir = android.util.get_device_path(
self.afl_output.output_directory)
android.adb.create_directory_if_needed(device_output_dir)
self._fuzz_args = self.generate_afl_args(
afl_input=android.util.get_device_path(self.afl_input.input_directory),
afl_output=device_output_dir,
additional_args=[
constants.FUZZING_TIMEOUT_FLAG + str(on_device_fuzzing_timeout)
],
target_path=android.util.get_device_path(self.target_path))
fuzz_result = self.run_afl_fuzz(self._fuzz_args)
# Generate file features from fuzzing results.
device_script_path = os.path.join(android.constants.DEVICE_FUZZING_DIR,
"run.sh")
local_script_path = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'create_file_features_showmap.sh')
android.adb.copy_local_file_to_remote(local_script_path, device_script_path)
android.adb.run_shell_command(f'chmod 0777 {device_script_path}', root=True)
android.adb.run_shell_command(
device_script_path + ' --showmap_path ' + android.util.get_device_path(
self.afl_showmap_path) + ' --fuzzer_path ' +
android.util.get_device_path(self.target_path) + ' --corpus_path ' +
android.util.get_device_path(self.afl_output.queue) + ' --output_path '
+ android.util.get_device_path(self._showmap_results_dir) +
' --seed_path ' + android.util.get_device_path(
self.afl_input.input_directory),
root=True,
log_output=True)
# Copy all results from device to local.
self._copy_directories_from_device(
[self.afl_output.output_directory, self._showmap_results_dir])
android.adb.copy_remote_file_to_local(
android.util.get_device_path(self.stderr_file_path),
self.stderr_file_path)
return fuzz_result
class UnshareAflRunner(new_process.ModifierProcessRunnerMixin, AflRunner):
"""AFL runner which unshares."""
def set_additional_sanitizer_options_for_afl_fuzz():
"""Set *SAN_OPTIONS to afl's liking.
If ASAN_OPTIONS or MSAN_OPTION is set, they must contain certain options or
afl-fuzz will refuse to fuzz. See check_asan_opts() in afl-fuzz.c in afl for
more details.
"""
# We need to check if ASAN_OPTIONS and/or MSAN_OPTIONS contain symbolize=0
# because ClusterFuzz sets all sanitizers options equal to an empty string
# before adding symbolize=0 to *either* ASAN_OPTIONS or MSAN_OPTIONS. Because
# they will both be set but one will be empty, afl will think the empty one is
# incorrect and quit if we don't do this.
required_sanitizer_options = {
'ASAN_OPTIONS': {
'symbolize': 0,
'abort_on_error': 1
},
'MSAN_OPTIONS': {
'symbolize': 0,
'exit_code': 86
},
}
for options_env_var, option_values in required_sanitizer_options.items():
# If os.environ[options_env_var] is an empty string, afl will refuse to run,
# because we haven't set the right options. Thus only continue if it does
# not exist.
if options_env_var not in os.environ:
continue
options_env_value = environment.get_memory_tool_options(options_env_var)
options_env_value.update(option_values)
environment.set_memory_tool_options(options_env_var, options_env_value)
The provided code snippet includes necessary dependencies for implementing the `prepare_runner` function. Write a Python function `def prepare_runner(fuzzer_path, config, testcase_file_path, input_directory, timeout=None, strategy_dict=None)` to solve the following problem:
Common initialization code shared by the new pipeline and main.
Here is the function:
def prepare_runner(fuzzer_path,
config,
testcase_file_path,
input_directory,
timeout=None,
strategy_dict=None):
"""Common initialization code shared by the new pipeline and main."""
# Set up temp dir.
engine_common.recreate_directory(fuzzer_utils.get_temp_dir())
if environment.get_value('USE_UNSHARE'):
runner_class = UnshareAflRunner
elif environment.is_android():
runner_class = AflAndroidRunner
else:
runner_class = AflRunner
runner = runner_class(
fuzzer_path,
config,
testcase_file_path,
input_directory,
timeout=timeout,
strategy_dict=strategy_dict)
# Make sure afl won't exit because of bad sanitizer options.
set_additional_sanitizer_options_for_afl_fuzz()
# Add *SAN_OPTIONS overrides from .options file.
engine_common.process_sanitizer_options_overrides(fuzzer_path)
return runner | Common initialization code shared by the new pipeline and main. |
157,307 | import atexit
import collections
import enum
import os
import re
import shutil
import signal
import stat
import subprocess
import sys
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import dictionary_manager
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers import options
from clusterfuzz._internal.bot.fuzzers import strategy_selection
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
from clusterfuzz._internal.fuzzing import strategy
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import profiler
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
from clusterfuzz._internal.system import shell
The provided code snippet includes necessary dependencies for implementing the `rand_schedule` function. Write a Python function `def rand_schedule(scheduler_probs)` to solve the following problem:
Returns a random queue scheduler.
Here is the function:
def rand_schedule(scheduler_probs):
"""Returns a random queue scheduler."""
schedule = 'fast'
rnd = engine_common.get_probability()
for schedule_opt, prob in scheduler_probs:
if rnd > prob:
rnd -= prob
else:
schedule = schedule_opt
break
return schedule | Returns a random queue scheduler. |
157,308 | import atexit
import collections
import enum
import os
import re
import shutil
import signal
import stat
import subprocess
import sys
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import dictionary_manager
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers import options
from clusterfuzz._internal.bot.fuzzers import strategy_selection
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
from clusterfuzz._internal.fuzzing import strategy
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import profiler
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
from clusterfuzz._internal.system import shell
The provided code snippet includes necessary dependencies for implementing the `rand_cmplog_level` function. Write a Python function `def rand_cmplog_level(strategies)` to solve the following problem:
Returns a random CMPLOG intensity level.
Here is the function:
def rand_cmplog_level(strategies):
"""Returns a random CMPLOG intensity level."""
cmplog_level = '2'
rnd = engine_common.get_probability()
for cmplog_level_opt, prob in strategies.CMPLOG_LEVEL_PROBS:
if rnd > prob:
rnd -= prob
else:
cmplog_level = cmplog_level_opt
break
if engine_common.decide_with_probability(strategies.CMPLOG_ARITH_PROB):
cmplog_level += constants.CMPLOG_ARITH
if engine_common.decide_with_probability(strategies.CMPLOG_TRANS_PROB):
cmplog_level += constants.CMPLOG_TRANS
if engine_common.decide_with_probability(strategies.CMPLOG_XTREME_PROB):
cmplog_level += constants.CMPLOG_XTREME
if engine_common.decide_with_probability(strategies.CMPLOG_RAND_PROB):
cmplog_level += constants.CMPLOG_RAND
return cmplog_level | Returns a random CMPLOG intensity level. |
157,309 | import os
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import builtin
from clusterfuzz._internal.system import environment
AFL_DUMMY_INPUT = 'in1'
The provided code snippet includes necessary dependencies for implementing the `write_dummy_file` function. Write a Python function `def write_dummy_file(input_dir)` to solve the following problem:
Afl will refuse to run if the corpus directory is empty or contains empty files. So write the bare minimum to get afl to run if there is no corpus yet.
Here is the function:
def write_dummy_file(input_dir):
"""Afl will refuse to run if the corpus directory is empty or contains empty
files. So write the bare minimum to get afl to run if there is no corpus
yet."""
dummy_input_path = os.path.join(input_dir, AFL_DUMMY_INPUT)
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
file_host.write_data_to_worker(b' ', dummy_input_path)
else:
utils.write_data_to_file(' ', dummy_input_path) | Afl will refuse to run if the corpus directory is empty or contains empty files. So write the bare minimum to get afl to run if there is no corpus yet. |
157,310 | import os
import stat
from clusterfuzz._internal.bot.fuzzers import engine_common
from clusterfuzz._internal.bot.fuzzers.afl import launcher
from clusterfuzz._internal.bot.fuzzers.afl import stats
from clusterfuzz._internal.metrics import logs
from clusterfuzz.fuzz import engine
The provided code snippet includes necessary dependencies for implementing the `_run_single_testcase` function. Write a Python function `def _run_single_testcase(fuzzer_runner, testcase_file_path)` to solve the following problem:
Loads a crash testcase if it exists.
Here is the function:
def _run_single_testcase(fuzzer_runner, testcase_file_path):
"""Loads a crash testcase if it exists."""
# To ensure that we can run the fuzzer.
os.chmod(fuzzer_runner.executable_path, stat.S_IRWXU | stat.S_IRGRP
| stat.S_IXGRP)
return fuzzer_runner.run_single_testcase(testcase_file_path) | Loads a crash testcase if it exists. |
157,311 | from io import StringIO
import sys
from antlr4 import *
def serializedATN():
with StringIO() as buf:
buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2")
buf.write(u"\31\u017b\b\1\b\1\b\1\b\1\b\1\4\2\t\2\4\3\t\3\4\4\t\4")
buf.write(u"\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13")
buf.write(u"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4")
buf.write(u"\21\t\21\4\22\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26")
buf.write(u"\t\26\4\27\t\27\4\30\t\30\4\31\t\31\4\32\t\32\4\33\t")
buf.write(u"\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!")
buf.write(u"\t!\4\"\t\"\3\2\3\2\3\2\3\2\3\2\3\2\7\2P\n\2\f\2\16\2")
buf.write(u"S\13\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\7\3^\n\3\f")
buf.write(u"\3\16\3a\13\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4")
buf.write(u"\7\4m\n\4\f\4\16\4p\13\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5")
buf.write(u"\3\5\3\5\3\5\3\5\3\5\3\5\7\5\177\n\5\f\5\16\5\u0082\13")
buf.write(u"\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\7\6\u008c\n\6\f\6")
buf.write(u"\16\6\u008f\13\6\3\6\3\6\3\7\3\7\3\7\3\7\7\7\u0097\n")
buf.write(u"\7\f\7\16\7\u009a\13\7\3\7\3\7\3\7\3\7\3\7\3\7\7\7\u00a2")
buf.write(u"\n\7\f\7\16\7\u00a5\13\7\3\7\3\7\5\7\u00a9\n\7\3\b\3")
buf.write(u"\b\5\b\u00ad\n\b\3\b\6\b\u00b0\n\b\r\b\16\b\u00b1\3\t")
buf.write(u"\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\7\t\u00bd\n\t\f\t\16")
buf.write(u"\t\u00c0\13\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n")
buf.write(u"\3\n\3\n\7\n\u00ce\n\n\f\n\16\n\u00d1\13\n\3\n\3\n\3")
buf.write(u"\n\3\n\3\13\3\13\3\13\3\13\3\f\6\f\u00dc\n\f\r\f\16\f")
buf.write(u"\u00dd\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\17")
buf.write(u"\3\17\3\20\3\20\3\20\3\20\3\21\3\21\7\21\u00f1\n\21\f")
buf.write(u"\21\16\21\u00f4\13\21\3\22\3\22\3\23\3\23\3\24\3\24\3")
buf.write(u"\25\3\25\3\25\3\25\5\25\u0100\n\25\3\26\5\26\u0103\n")
buf.write(u"\26\3\27\7\27\u0106\n\27\f\27\16\27\u0109\13\27\3\27")
buf.write(u"\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3")
buf.write(u"\27\3\30\7\30\u0118\n\30\f\30\16\30\u011b\13\30\3\30")
buf.write(u"\3\30\3\30\3\30\3\30\3\30\3\31\7\31\u0124\n\31\f\31\16")
buf.write(u"\31\u0127\13\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3")
buf.write(u"\31\3\31\3\31\3\31\3\32\7\32\u0135\n\32\f\32\16\32\u0138")
buf.write(u"\13\32\3\32\3\32\3\32\3\32\3\32\3\32\3\33\7\33\u0141")
buf.write(u"\n\33\f\33\16\33\u0144\13\33\3\33\3\33\3\33\3\33\3\34")
buf.write(u"\3\34\3\34\3\34\3\34\5\34\u014f\n\34\3\35\5\35\u0152")
buf.write(u"\n\35\3\36\6\36\u0155\n\36\r\36\16\36\u0156\3\36\5\36")
buf.write(u"\u015a\n\36\3\37\3\37\6\37\u015e\n\37\r\37\16\37\u015f")
buf.write(u"\3 \6 \u0163\n \r \16 \u0164\3 \5 \u0168\n \3!\3!\7!")
buf.write(u"\u016c\n!\f!\16!\u016f\13!\3!\3!\3\"\3\"\7\"\u0175\n")
buf.write(u"\"\f\"\16\"\u0178\13\"\3\"\3\"\17Q_n\u0080\u008d\u0098")
buf.write(u"\u00a3\u00be\u00cf\u0107\u0119\u0125\u0136\2#\7\3\t\4")
buf.write(u"\13\5\r\6\17\7\21\b\23\t\25\n\27\13\31\f\33\r\35\16\37")
buf.write(u"\17!\20#\21%\22\'\23)\2+\2-\2/\2\61\24\63\25\65\26\67")
buf.write(u"\279\30;\31=\2?\2A\2C\2E\2G\2\7\2\3\4\5\6\16\4\2\13\13")
buf.write(u"\"\"\3\2>>\5\2\13\f\17\17\"\"\5\2\62;CHch\3\2\62;\4\2")
buf.write(u"/\60aa\5\2\u00b9\u00b9\u0302\u0371\u2041\u2042\n\2<<")
buf.write(u"C\\c|\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1")
buf.write(u"\ufdf2\uffff\3\2\"\"\t\2%%-=??AAC\\aac|\4\2$$>>\4\2)")
buf.write(u")>>\2\u018e\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r")
buf.write(u"\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25")
buf.write(u"\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\3\35")
buf.write(u"\3\2\2\2\3\37\3\2\2\2\3!\3\2\2\2\3#\3\2\2\2\3%\3\2\2")
buf.write(u"\2\3\'\3\2\2\2\4\61\3\2\2\2\4\63\3\2\2\2\5\65\3\2\2\2")
buf.write(u"\5\67\3\2\2\2\69\3\2\2\2\6;\3\2\2\2\7I\3\2\2\2\tX\3\2")
buf.write(u"\2\2\13e\3\2\2\2\rs\3\2\2\2\17\u0087\3\2\2\2\21\u00a8")
buf.write(u"\3\2\2\2\23\u00af\3\2\2\2\25\u00b3\3\2\2\2\27\u00c5\3")
buf.write(u"\2\2\2\31\u00d6\3\2\2\2\33\u00db\3\2\2\2\35\u00df\3\2")
buf.write(u"\2\2\37\u00e3\3\2\2\2!\u00e8\3\2\2\2#\u00ea\3\2\2\2%")
buf.write(u"\u00ee\3\2\2\2\'\u00f5\3\2\2\2)\u00f7\3\2\2\2+\u00f9")
buf.write(u"\3\2\2\2-\u00ff\3\2\2\2/\u0102\3\2\2\2\61\u0107\3\2\2")
buf.write(u"\2\63\u0119\3\2\2\2\65\u0125\3\2\2\2\67\u0136\3\2\2\2")
buf.write(u"9\u0142\3\2\2\2;\u014e\3\2\2\2=\u0151\3\2\2\2?\u0154")
buf.write(u"\3\2\2\2A\u015b\3\2\2\2C\u0162\3\2\2\2E\u0169\3\2\2\2")
buf.write(u"G\u0172\3\2\2\2IJ\7>\2\2JK\7#\2\2KL\7/\2\2LM\7/\2\2M")
buf.write(u"Q\3\2\2\2NP\13\2\2\2ON\3\2\2\2PS\3\2\2\2QR\3\2\2\2QO")
buf.write(u"\3\2\2\2RT\3\2\2\2SQ\3\2\2\2TU\7/\2\2UV\7/\2\2VW\7@\2")
buf.write(u"\2W\b\3\2\2\2XY\7>\2\2YZ\7#\2\2Z[\7]\2\2[_\3\2\2\2\\")
buf.write(u"^\13\2\2\2]\\\3\2\2\2^a\3\2\2\2_`\3\2\2\2_]\3\2\2\2`")
buf.write(u"b\3\2\2\2a_\3\2\2\2bc\7_\2\2cd\7@\2\2d\n\3\2\2\2ef\7")
buf.write(u">\2\2fg\7A\2\2gh\7z\2\2hi\7o\2\2ij\7n\2\2jn\3\2\2\2k")
buf.write(u"m\13\2\2\2lk\3\2\2\2mp\3\2\2\2no\3\2\2\2nl\3\2\2\2oq")
buf.write(u"\3\2\2\2pn\3\2\2\2qr\7@\2\2r\f\3\2\2\2st\7>\2\2tu\7#")
buf.write(u"\2\2uv\7]\2\2vw\7E\2\2wx\7F\2\2xy\7C\2\2yz\7V\2\2z{\7")
buf.write(u"C\2\2{|\7]\2\2|\u0080\3\2\2\2}\177\13\2\2\2~}\3\2\2\2")
buf.write(u"\177\u0082\3\2\2\2\u0080\u0081\3\2\2\2\u0080~\3\2\2\2")
buf.write(u"\u0081\u0083\3\2\2\2\u0082\u0080\3\2\2\2\u0083\u0084")
buf.write(u"\7_\2\2\u0084\u0085\7_\2\2\u0085\u0086\7@\2\2\u0086\16")
buf.write(u"\3\2\2\2\u0087\u0088\7>\2\2\u0088\u0089\7#\2\2\u0089")
buf.write(u"\u008d\3\2\2\2\u008a\u008c\13\2\2\2\u008b\u008a\3\2\2")
buf.write(u"\2\u008c\u008f\3\2\2\2\u008d\u008e\3\2\2\2\u008d\u008b")
buf.write(u"\3\2\2\2\u008e\u0090\3\2\2\2\u008f\u008d\3\2\2\2\u0090")
buf.write(u"\u0091\7@\2\2\u0091\20\3\2\2\2\u0092\u0093\7>\2\2\u0093")
buf.write(u"\u0094\7A\2\2\u0094\u0098\3\2\2\2\u0095\u0097\13\2\2")
buf.write(u"\2\u0096\u0095\3\2\2\2\u0097\u009a\3\2\2\2\u0098\u0099")
buf.write(u"\3\2\2\2\u0098\u0096\3\2\2\2\u0099\u009b\3\2\2\2\u009a")
buf.write(u"\u0098\3\2\2\2\u009b\u009c\7A\2\2\u009c\u00a9\7@\2\2")
buf.write(u"\u009d\u009e\7>\2\2\u009e\u009f\7\'\2\2\u009f\u00a3\3")
buf.write(u"\2\2\2\u00a0\u00a2\13\2\2\2\u00a1\u00a0\3\2\2\2\u00a2")
buf.write(u"\u00a5\3\2\2\2\u00a3\u00a4\3\2\2\2\u00a3\u00a1\3\2\2")
buf.write(u"\2\u00a4\u00a6\3\2\2\2\u00a5\u00a3\3\2\2\2\u00a6\u00a7")
buf.write(u"\7\'\2\2\u00a7\u00a9\7@\2\2\u00a8\u0092\3\2\2\2\u00a8")
buf.write(u"\u009d\3\2\2\2\u00a9\22\3\2\2\2\u00aa\u00b0\t\2\2\2\u00ab")
buf.write(u"\u00ad\7\17\2\2\u00ac\u00ab\3\2\2\2\u00ac\u00ad\3\2\2")
buf.write(u"\2\u00ad\u00ae\3\2\2\2\u00ae\u00b0\7\f\2\2\u00af\u00aa")
buf.write(u"\3\2\2\2\u00af\u00ac\3\2\2\2\u00b0\u00b1\3\2\2\2\u00b1")
buf.write(u"\u00af\3\2\2\2\u00b1\u00b2\3\2\2\2\u00b2\24\3\2\2\2\u00b3")
buf.write(u"\u00b4\7>\2\2\u00b4\u00b5\7u\2\2\u00b5\u00b6\7e\2\2\u00b6")
buf.write(u"\u00b7\7t\2\2\u00b7\u00b8\7k\2\2\u00b8\u00b9\7r\2\2\u00b9")
buf.write(u"\u00ba\7v\2\2\u00ba\u00be\3\2\2\2\u00bb\u00bd\13\2\2")
buf.write(u"\2\u00bc\u00bb\3\2\2\2\u00bd\u00c0\3\2\2\2\u00be\u00bf")
buf.write(u"\3\2\2\2\u00be\u00bc\3\2\2\2\u00bf\u00c1\3\2\2\2\u00c0")
buf.write(u"\u00be\3\2\2\2\u00c1\u00c2\7@\2\2\u00c2\u00c3\3\2\2\2")
buf.write(u"\u00c3\u00c4\b\t\2\2\u00c4\26\3\2\2\2\u00c5\u00c6\7>")
buf.write(u"\2\2\u00c6\u00c7\7u\2\2\u00c7\u00c8\7v\2\2\u00c8\u00c9")
buf.write(u"\7{\2\2\u00c9\u00ca\7n\2\2\u00ca\u00cb\7g\2\2\u00cb\u00cf")
buf.write(u"\3\2\2\2\u00cc\u00ce\13\2\2\2\u00cd\u00cc\3\2\2\2\u00ce")
buf.write(u"\u00d1\3\2\2\2\u00cf\u00d0\3\2\2\2\u00cf\u00cd\3\2\2")
buf.write(u"\2\u00d0\u00d2\3\2\2\2\u00d1\u00cf\3\2\2\2\u00d2\u00d3")
buf.write(u"\7@\2\2\u00d3\u00d4\3\2\2\2\u00d4\u00d5\b\n\3\2\u00d5")
buf.write(u"\30\3\2\2\2\u00d6\u00d7\7>\2\2\u00d7\u00d8\3\2\2\2\u00d8")
buf.write(u"\u00d9\b\13\4\2\u00d9\32\3\2\2\2\u00da\u00dc\n\3\2\2")
buf.write(u"\u00db\u00da\3\2\2\2\u00dc\u00dd\3\2\2\2\u00dd\u00db")
buf.write(u"\3\2\2\2\u00dd\u00de\3\2\2\2\u00de\34\3\2\2\2\u00df\u00e0")
buf.write(u"\7@\2\2\u00e0\u00e1\3\2\2\2\u00e1\u00e2\b\r\5\2\u00e2")
buf.write(u"\36\3\2\2\2\u00e3\u00e4\7\61\2\2\u00e4\u00e5\7@\2\2\u00e5")
buf.write(u"\u00e6\3\2\2\2\u00e6\u00e7\b\16\5\2\u00e7 \3\2\2\2\u00e8")
buf.write(u"\u00e9\7\61\2\2\u00e9\"\3\2\2\2\u00ea\u00eb\7?\2\2\u00eb")
buf.write(u"\u00ec\3\2\2\2\u00ec\u00ed\b\20\6\2\u00ed$\3\2\2\2\u00ee")
buf.write(u"\u00f2\5/\26\2\u00ef\u00f1\5-\25\2\u00f0\u00ef\3\2\2")
buf.write(u"\2\u00f1\u00f4\3\2\2\2\u00f2\u00f0\3\2\2\2\u00f2\u00f3")
buf.write(u"\3\2\2\2\u00f3&\3\2\2\2\u00f4\u00f2\3\2\2\2\u00f5\u00f6")
buf.write(u"\t\4\2\2\u00f6(\3\2\2\2\u00f7\u00f8\t\5\2\2\u00f8*\3")
buf.write(u"\2\2\2\u00f9\u00fa\t\6\2\2\u00fa,\3\2\2\2\u00fb\u0100")
buf.write(u"\5/\26\2\u00fc\u0100\t\7\2\2\u00fd\u0100\5+\24\2\u00fe")
buf.write(u"\u0100\t\b\2\2\u00ff\u00fb\3\2\2\2\u00ff\u00fc\3\2\2")
buf.write(u"\2\u00ff\u00fd\3\2\2\2\u00ff\u00fe\3\2\2\2\u0100.\3\2")
buf.write(u"\2\2\u0101\u0103\t\t\2\2\u0102\u0101\3\2\2\2\u0103\60")
buf.write(u"\3\2\2\2\u0104\u0106\13\2\2\2\u0105\u0104\3\2\2\2\u0106")
buf.write(u"\u0109\3\2\2\2\u0107\u0108\3\2\2\2\u0107\u0105\3\2\2")
buf.write(u"\2\u0108\u010a\3\2\2\2\u0109\u0107\3\2\2\2\u010a\u010b")
buf.write(u"\7>\2\2\u010b\u010c\7\61\2\2\u010c\u010d\7u\2\2\u010d")
buf.write(u"\u010e\7e\2\2\u010e\u010f\7t\2\2\u010f\u0110\7k\2\2\u0110")
buf.write(u"\u0111\7r\2\2\u0111\u0112\7v\2\2\u0112\u0113\7@\2\2\u0113")
buf.write(u"\u0114\3\2\2\2\u0114\u0115\b\27\5\2\u0115\62\3\2\2\2")
buf.write(u"\u0116\u0118\13\2\2\2\u0117\u0116\3\2\2\2\u0118\u011b")
buf.write(u"\3\2\2\2\u0119\u011a\3\2\2\2\u0119\u0117\3\2\2\2\u011a")
buf.write(u"\u011c\3\2\2\2\u011b\u0119\3\2\2\2\u011c\u011d\7>\2\2")
buf.write(u"\u011d\u011e\7\61\2\2\u011e\u011f\7@\2\2\u011f\u0120")
buf.write(u"\3\2\2\2\u0120\u0121\b\30\5\2\u0121\64\3\2\2\2\u0122")
buf.write(u"\u0124\13\2\2\2\u0123\u0122\3\2\2\2\u0124\u0127\3\2\2")
buf.write(u"\2\u0125\u0126\3\2\2\2\u0125\u0123\3\2\2\2\u0126\u0128")
buf.write(u"\3\2\2\2\u0127\u0125\3\2\2\2\u0128\u0129\7>\2\2\u0129")
buf.write(u"\u012a\7\61\2\2\u012a\u012b\7u\2\2\u012b\u012c\7v\2\2")
buf.write(u"\u012c\u012d\7{\2\2\u012d\u012e\7n\2\2\u012e\u012f\7")
buf.write(u"g\2\2\u012f\u0130\7@\2\2\u0130\u0131\3\2\2\2\u0131\u0132")
buf.write(u"\b\31\5\2\u0132\66\3\2\2\2\u0133\u0135\13\2\2\2\u0134")
buf.write(u"\u0133\3\2\2\2\u0135\u0138\3\2\2\2\u0136\u0137\3\2\2")
buf.write(u"\2\u0136\u0134\3\2\2\2\u0137\u0139\3\2\2\2\u0138\u0136")
buf.write(u"\3\2\2\2\u0139\u013a\7>\2\2\u013a\u013b\7\61\2\2\u013b")
buf.write(u"\u013c\7@\2\2\u013c\u013d\3\2\2\2\u013d\u013e\b\32\5")
buf.write(u"\2\u013e8\3\2\2\2\u013f\u0141\t\n\2\2\u0140\u013f\3\2")
buf.write(u"\2\2\u0141\u0144\3\2\2\2\u0142\u0140\3\2\2\2\u0142\u0143")
buf.write(u"\3\2\2\2\u0143\u0145\3\2\2\2\u0144\u0142\3\2\2\2\u0145")
buf.write(u"\u0146\5;\34\2\u0146\u0147\3\2\2\2\u0147\u0148\b\33\5")
buf.write(u"\2\u0148:\3\2\2\2\u0149\u014f\5E!\2\u014a\u014f\5G\"")
buf.write(u"\2\u014b\u014f\5?\36\2\u014c\u014f\5A\37\2\u014d\u014f")
buf.write(u"\5C \2\u014e\u0149\3\2\2\2\u014e\u014a\3\2\2\2\u014e")
buf.write(u"\u014b\3\2\2\2\u014e\u014c\3\2\2\2\u014e\u014d\3\2\2")
buf.write(u"\2\u014f<\3\2\2\2\u0150\u0152\t\13\2\2\u0151\u0150\3")
buf.write(u"\2\2\2\u0152>\3\2\2\2\u0153\u0155\5=\35\2\u0154\u0153")
buf.write(u"\3\2\2\2\u0155\u0156\3\2\2\2\u0156\u0154\3\2\2\2\u0156")
buf.write(u"\u0157\3\2\2\2\u0157\u0159\3\2\2\2\u0158\u015a\7\"\2")
buf.write(u"\2\u0159\u0158\3\2\2\2\u0159\u015a\3\2\2\2\u015a@\3\2")
buf.write(u"\2\2\u015b\u015d\7%\2\2\u015c\u015e\t\5\2\2\u015d\u015c")
buf.write(u"\3\2\2\2\u015e\u015f\3\2\2\2\u015f\u015d\3\2\2\2\u015f")
buf.write(u"\u0160\3\2\2\2\u0160B\3\2\2\2\u0161\u0163\t\6\2\2\u0162")
buf.write(u"\u0161\3\2\2\2\u0163\u0164\3\2\2\2\u0164\u0162\3\2\2")
buf.write(u"\2\u0164\u0165\3\2\2\2\u0165\u0167\3\2\2\2\u0166\u0168")
buf.write(u"\7\'\2\2\u0167\u0166\3\2\2\2\u0167\u0168\3\2\2\2\u0168")
buf.write(u"D\3\2\2\2\u0169\u016d\7$\2\2\u016a\u016c\n\f\2\2\u016b")
buf.write(u"\u016a\3\2\2\2\u016c\u016f\3\2\2\2\u016d\u016b\3\2\2")
buf.write(u"\2\u016d\u016e\3\2\2\2\u016e\u0170\3\2\2\2\u016f\u016d")
buf.write(u"\3\2\2\2\u0170\u0171\7$\2\2\u0171F\3\2\2\2\u0172\u0176")
buf.write(u"\7)\2\2\u0173\u0175\n\r\2\2\u0174\u0173\3\2\2\2\u0175")
buf.write(u"\u0178\3\2\2\2\u0176\u0174\3\2\2\2\u0176\u0177\3\2\2")
buf.write(u"\2\u0177\u0179\3\2\2\2\u0178\u0176\3\2\2\2\u0179\u017a")
buf.write(u"\7)\2\2\u017aH\3\2\2\2&\2\3\4\5\6Q_n\u0080\u008d\u0098")
buf.write(u"\u00a3\u00a8\u00ac\u00af\u00b1\u00be\u00cf\u00dd\u00f2")
buf.write(u"\u00ff\u0102\u0107\u0119\u0125\u0136\u0142\u014e\u0151")
buf.write(u"\u0156\u0159\u015f\u0164\u0167\u016d\u0176\7\7\4\2\7")
buf.write(u"\5\2\7\3\2\6\2\2\7\6\2")
return buf.getvalue() | null |
157,312 | from io import StringIO
import sys
from antlr4 import *
from .JavaScriptBaseLexer import JavaScriptBaseLexer
def serializedATN():
with StringIO() as buf:
buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2")
buf.write(u"}\u0484\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4")
buf.write(u"\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r")
buf.write(u"\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22")
buf.write(u"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4")
buf.write(u"\30\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35")
buf.write(u"\t\35\4\36\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4")
buf.write(u"$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t")
buf.write(u",\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63")
buf.write(u"\t\63\4\64\t\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\4")
buf.write(u"9\t9\4:\t:\4;\t;\4<\t<\4=\t=\4>\t>\4?\t?\4@\t@\4A\tA")
buf.write(u"\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I\tI\4J\t")
buf.write(u"J\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S")
buf.write(u"\tS\4T\tT\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4")
buf.write(u"\\\t\\\4]\t]\4^\t^\4_\t_\4`\t`\4a\ta\4b\tb\4c\tc\4d\t")
buf.write(u"d\4e\te\4f\tf\4g\tg\4h\th\4i\ti\4j\tj\4k\tk\4l\tl\4m")
buf.write(u"\tm\4n\tn\4o\to\4p\tp\4q\tq\4r\tr\4s\ts\4t\tt\4u\tu\4")
buf.write(u"v\tv\4w\tw\4x\tx\4y\ty\4z\tz\4{\t{\4|\t|\4}\t}\4~\t~")
buf.write(u"\4\177\t\177\4\u0080\t\u0080\4\u0081\t\u0081\4\u0082")
buf.write(u"\t\u0082\4\u0083\t\u0083\4\u0084\t\u0084\4\u0085\t\u0085")
buf.write(u"\4\u0086\t\u0086\4\u0087\t\u0087\4\u0088\t\u0088\4\u0089")
buf.write(u"\t\u0089\4\u008a\t\u008a\4\u008b\t\u008b\4\u008c\t\u008c")
buf.write(u"\4\u008d\t\u008d\4\u008e\t\u008e\4\u008f\t\u008f\4\u0090")
buf.write(u"\t\u0090\4\u0091\t\u0091\4\u0092\t\u0092\4\u0093\t\u0093")
buf.write(u"\4\u0094\t\u0094\3\2\3\2\3\2\3\2\3\2\7\2\u012f\n\2\f")
buf.write(u"\2\16\2\u0132\13\2\3\3\3\3\3\3\3\3\7\3\u0138\n\3\f\3")
buf.write(u"\16\3\u013b\13\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4")
buf.write(u"\7\4\u0146\n\4\f\4\16\4\u0149\13\4\3\4\3\4\3\5\3\5\3")
buf.write(u"\5\7\5\u0150\n\5\f\5\16\5\u0153\13\5\3\5\3\5\3\5\7\5")
buf.write(u"\u0158\n\5\f\5\16\5\u015b\13\5\3\6\3\6\3\7\3\7\3\b\3")
buf.write(u"\b\3\t\3\t\3\n\3\n\3\n\3\13\3\13\3\13\3\f\3\f\3\r\3\r")
buf.write(u"\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\21\3\21\3")
buf.write(u"\22\3\22\3\23\3\23\3\23\3\24\3\24\3\24\3\25\3\25\3\26")
buf.write(u"\3\26\3\27\3\27\3\30\3\30\3\31\3\31\3\32\3\32\3\33\3")
buf.write(u"\33\3\34\3\34\3\34\3\35\3\35\3\35\3\36\3\36\3\37\3\37")
buf.write(u"\3\37\3 \3 \3 \3!\3!\3!\3!\3\"\3\"\3#\3#\3$\3$\3$\3%")
buf.write(u"\3%\3%\3&\3&\3&\3\'\3\'\3\'\3(\3(\3(\3(\3)\3)\3)\3)\3")
buf.write(u"*\3*\3+\3+\3,\3,\3-\3-\3-\3.\3.\3.\3/\3/\3/\3\60\3\60")
buf.write(u"\3\60\3\61\3\61\3\61\3\62\3\62\3\62\3\63\3\63\3\63\3")
buf.write(u"\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\66\3\66\3\66")
buf.write(u"\3\66\3\66\3\67\3\67\3\67\38\38\38\39\39\39\3:\3:\3:")
buf.write(u"\3:\3;\3;\3;\3<\3<\3<\3<\3<\3=\3=\3=\3=\3=\3=\3=\3=\3")
buf.write(u"=\5=\u01ff\n=\3>\3>\3>\3>\7>\u0205\n>\f>\16>\u0208\13")
buf.write(u">\3>\5>\u020b\n>\3>\3>\3>\7>\u0210\n>\f>\16>\u0213\13")
buf.write(u">\3>\5>\u0216\n>\3>\3>\5>\u021a\n>\5>\u021c\n>\3?\3?")
buf.write(u"\3?\3?\7?\u0222\n?\f?\16?\u0225\13?\3@\3@\6@\u0229\n")
buf.write(u"@\r@\16@\u022a\3@\3@\3A\3A\3A\3A\7A\u0233\nA\fA\16A\u0236")
buf.write(u"\13A\3B\3B\3B\3B\7B\u023c\nB\fB\16B\u023f\13B\3C\3C\3")
buf.write(u"C\3C\7C\u0245\nC\fC\16C\u0248\13C\3C\3C\3D\3D\3D\3D\7")
buf.write(u"D\u0250\nD\fD\16D\u0253\13D\3D\3D\3E\3E\3E\3E\7E\u025b")
buf.write(u"\nE\fE\16E\u025e\13E\3E\3E\3F\3F\3F\3G\3G\3G\3G\3G\3")
buf.write(u"G\3H\3H\3H\3I\3I\3I\3I\3I\3I\3I\3I\3I\3I\3I\3J\3J\3J")
buf.write(u"\3J\3J\3J\3J\3K\3K\3K\3K\3K\3L\3L\3L\3L\3L\3M\3M\3M\3")
buf.write(u"M\3N\3N\3N\3N\3O\3O\3O\3O\3O\3O\3P\3P\3P\3P\3P\3P\3P")
buf.write(u"\3P\3Q\3Q\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3R\3R\3S\3S\3S\3S\3")
buf.write(u"S\3S\3S\3S\3S\3T\3T\3T\3T\3U\3U\3U\3U\3U\3U\3U\3V\3V")
buf.write(u"\3V\3V\3V\3V\3W\3W\3W\3W\3W\3W\3W\3W\3W\3X\3X\3X\3X\3")
buf.write(u"X\3X\3X\3X\3X\3Y\3Y\3Y\3Y\3Y\3Z\3Z\3Z\3Z\3Z\3[\3[\3[")
buf.write(u"\3[\3[\3[\3[\3[\3\\\3\\\3\\\3]\3]\3]\3]\3]\3]\3^\3^\3")
buf.write(u"^\3^\3^\3^\3^\3_\3_\3_\3`\3`\3`\3`\3a\3a\3a\3b\3b\3b")
buf.write(u"\3b\3b\3c\3c\3c\3c\3c\3c\3d\3d\3d\3d\3d\3e\3e\3e\3e\3")
buf.write(u"e\3e\3e\3e\3f\3f\3f\3f\3f\3f\3g\3g\3g\3g\3g\3g\3h\3h")
buf.write(u"\3h\3h\3h\3h\3h\3i\3i\3i\3i\3i\3i\3i\3j\3j\3j\3j\3j\3")
buf.write(u"j\3k\3k\3k\3k\3k\3k\3l\3l\3l\3l\3l\3l\3l\3l\3l\3l\3l")
buf.write(u"\3l\3l\3m\3m\3m\3m\3m\3m\3n\3n\3n\3n\3n\3n\3n\3n\3n\3")
buf.write(u"n\3o\3o\3o\3o\3o\3o\3o\3o\3o\3p\3p\3p\3p\3p\3p\3p\3p")
buf.write(u"\3p\3p\3p\3p\3q\3q\3q\3q\3q\3q\3q\3q\3q\3q\3r\3r\3r\3")
buf.write(u"r\3r\3r\3r\3r\3r\3r\3r\3r\3s\3s\3s\3s\3s\3s\3s\3s\3s")
buf.write(u"\3t\3t\3t\3t\3t\3t\3t\3t\3u\3u\7u\u039d\nu\fu\16u\u03a0")
buf.write(u"\13u\3v\3v\7v\u03a4\nv\fv\16v\u03a7\13v\3v\3v\3v\7v\u03ac")
buf.write(u"\nv\fv\16v\u03af\13v\3v\5v\u03b2\nv\3v\3v\3w\3w\3w\3")
buf.write(u"w\7w\u03ba\nw\fw\16w\u03bd\13w\3w\3w\3x\6x\u03c2\nx\r")
buf.write(u"x\16x\u03c3\3x\3x\3y\3y\3y\3y\3z\3z\3z\3z\3z\3z\7z\u03d2")
buf.write(u"\nz\fz\16z\u03d5\13z\3z\3z\3z\3z\3z\3z\3{\3{\3{\3{\3")
buf.write(u"{\3{\3{\3{\3{\3{\3{\7{\u03e8\n{\f{\16{\u03eb\13{\3{\3")
buf.write(u"{\3{\3{\3{\3{\3|\3|\3|\3|\3}\3}\3}\3}\5}\u03fb\n}\3~")
buf.write(u"\3~\3~\3~\5~\u0401\n~\3\177\3\177\3\177\3\177\3\177\5")
buf.write(u"\177\u0408\n\177\3\u0080\3\u0080\5\u0080\u040c\n\u0080")
buf.write(u"\3\u0081\3\u0081\3\u0081\3\u0081\3\u0082\3\u0082\3\u0082")
buf.write(u"\3\u0082\3\u0082\3\u0082\3\u0082\3\u0082\3\u0082\3\u0082")
buf.write(u"\6\u0082\u041c\n\u0082\r\u0082\16\u0082\u041d\3\u0082")
buf.write(u"\3\u0082\5\u0082\u0422\n\u0082\3\u0083\3\u0083\3\u0083")
buf.write(u"\6\u0083\u0427\n\u0083\r\u0083\16\u0083\u0428\3\u0083")
buf.write(u"\3\u0083\3\u0084\3\u0084\3\u0085\3\u0085\3\u0086\3\u0086")
buf.write(u"\5\u0086\u0433\n\u0086\3\u0087\3\u0087\3\u0087\3\u0088")
buf.write(u"\3\u0088\3\u0089\3\u0089\3\u0089\7\u0089\u043d\n\u0089")
buf.write(u"\f\u0089\16\u0089\u0440\13\u0089\5\u0089\u0442\n\u0089")
buf.write(u"\3\u008a\3\u008a\5\u008a\u0446\n\u008a\3\u008a\6\u008a")
buf.write(u"\u0449\n\u008a\r\u008a\16\u008a\u044a\3\u008b\3\u008b")
buf.write(u"\3\u008b\3\u008b\3\u008b\5\u008b\u0452\n\u008b\3\u008c")
buf.write(u"\3\u008c\3\u008c\3\u008c\5\u008c\u0458\n\u008c\3\u008d")
buf.write(u"\5\u008d\u045b\n\u008d\3\u008e\5\u008e\u045e\n\u008e")
buf.write(u"\3\u008f\5\u008f\u0461\n\u008f\3\u0090\5\u0090\u0464")
buf.write(u"\n\u0090\3\u0091\3\u0091\3\u0091\3\u0091\7\u0091\u046a")
buf.write(u"\n\u0091\f\u0091\16\u0091\u046d\13\u0091\3\u0091\5\u0091")
buf.write(u"\u0470\n\u0091\3\u0092\3\u0092\3\u0092\3\u0092\7\u0092")
buf.write(u"\u0476\n\u0092\f\u0092\16\u0092\u0479\13\u0092\3\u0092")
buf.write(u"\5\u0092\u047c\n\u0092\3\u0093\3\u0093\5\u0093\u0480")
buf.write(u"\n\u0093\3\u0094\3\u0094\3\u0094\5\u0139\u03d3\u03e9")
buf.write(u"\2\u0095\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25")
buf.write(u"\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26")
buf.write(u"+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C")
buf.write(u"#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66")
buf.write(u"k\67m8o9q:s;u<w=y>{?}@\177A\u0081B\u0083C\u0085D\u0087")
buf.write(u"E\u0089F\u008bG\u008dH\u008fI\u0091J\u0093K\u0095L\u0097")
buf.write(u"M\u0099N\u009bO\u009dP\u009fQ\u00a1R\u00a3S\u00a5T\u00a7")
buf.write(u"U\u00a9V\u00abW\u00adX\u00afY\u00b1Z\u00b3[\u00b5\\\u00b7")
buf.write(u"]\u00b9^\u00bb_\u00bd`\u00bfa\u00c1b\u00c3c\u00c5d\u00c7")
buf.write(u"e\u00c9f\u00cbg\u00cdh\u00cfi\u00d1j\u00d3k\u00d5l\u00d7")
buf.write(u"m\u00d9n\u00dbo\u00ddp\u00dfq\u00e1r\u00e3s\u00e5t\u00e7")
buf.write(u"u\u00e9v\u00ebw\u00edx\u00efy\u00f1z\u00f3{\u00f5|\u00f7")
buf.write(u"}\u00f9\2\u00fb\2\u00fd\2\u00ff\2\u0101\2\u0103\2\u0105")
buf.write(u"\2\u0107\2\u0109\2\u010b\2\u010d\2\u010f\2\u0111\2\u0113")
buf.write(u"\2\u0115\2\u0117\2\u0119\2\u011b\2\u011d\2\u011f\2\u0121")
buf.write(u"\2\u0123\2\u0125\2\u0127\2\3\2 \5\2\f\f\17\17\u202a\u202b")
buf.write(u"\3\2\62;\4\2\62;aa\4\2ZZzz\5\2\62;CHch\3\2\629\4\2QQ")
buf.write(u"qq\4\2\629aa\4\2DDdd\3\2\62\63\4\2\62\63aa\3\2bb\6\2")
buf.write(u"\13\13\r\16\"\"\u00a2\u00a2\6\2\f\f\17\17$$^^\6\2\f\f")
buf.write(u"\17\17))^^\13\2$$))^^ddhhppttvvxx\16\2\f\f\17\17$$))")
buf.write(u"\62;^^ddhhppttvxzz\5\2\62;wwzz\6\2\62;CHaach\3\2\63;")
buf.write(u"\4\2GGgg\4\2--//\4\2&&aa\u0101\2C\\c|\u00ac\u00ac\u00b7")
buf.write(u"\u00b7\u00bc\u00bc\u00c2\u00d8\u00da\u00f8\u00fa\u0221")
buf.write(u"\u0224\u0235\u0252\u02af\u02b2\u02ba\u02bd\u02c3\u02d2")
buf.write(u"\u02d3\u02e2\u02e6\u02f0\u02f0\u037c\u037c\u0388\u0388")
buf.write(u"\u038a\u038c\u038e\u038e\u0390\u03a3\u03a5\u03d0\u03d2")
buf.write(u"\u03d9\u03dc\u03f5\u0402\u0483\u048e\u04c6\u04c9\u04ca")
buf.write(u"\u04cd\u04ce\u04d2\u04f7\u04fa\u04fb\u0533\u0558\u055b")
buf.write(u"\u055b\u0563\u0589\u05d2\u05ec\u05f2\u05f4\u0623\u063c")
buf.write(u"\u0642\u064c\u0673\u06d5\u06d7\u06d7\u06e7\u06e8\u06fc")
buf.write(u"\u06fe\u0712\u0712\u0714\u072e\u0782\u07a7\u0907\u093b")
buf.write(u"\u093f\u093f\u0952\u0952\u095a\u0963\u0987\u098e\u0991")
buf.write(u"\u0992\u0995\u09aa\u09ac\u09b2\u09b4\u09b4\u09b8\u09bb")
buf.write(u"\u09de\u09df\u09e1\u09e3\u09f2\u09f3\u0a07\u0a0c\u0a11")
buf.write(u"\u0a12\u0a15\u0a2a\u0a2c\u0a32\u0a34\u0a35\u0a37\u0a38")
buf.write(u"\u0a3a\u0a3b\u0a5b\u0a5e\u0a60\u0a60\u0a74\u0a76\u0a87")
buf.write(u"\u0a8d\u0a8f\u0a8f\u0a91\u0a93\u0a95\u0aaa\u0aac\u0ab2")
buf.write(u"\u0ab4\u0ab5\u0ab7\u0abb\u0abf\u0abf\u0ad2\u0ad2\u0ae2")
buf.write(u"\u0ae2\u0b07\u0b0e\u0b11\u0b12\u0b15\u0b2a\u0b2c\u0b32")
buf.write(u"\u0b34\u0b35\u0b38\u0b3b\u0b3f\u0b3f\u0b5e\u0b5f\u0b61")
buf.write(u"\u0b63\u0b87\u0b8c\u0b90\u0b92\u0b94\u0b97\u0b9b\u0b9c")
buf.write(u"\u0b9e\u0b9e\u0ba0\u0ba1\u0ba5\u0ba6\u0baa\u0bac\u0bb0")
buf.write(u"\u0bb7\u0bb9\u0bbb\u0c07\u0c0e\u0c10\u0c12\u0c14\u0c2a")
buf.write(u"\u0c2c\u0c35\u0c37\u0c3b\u0c62\u0c63\u0c87\u0c8e\u0c90")
buf.write(u"\u0c92\u0c94\u0caa\u0cac\u0cb5\u0cb7\u0cbb\u0ce0\u0ce0")
buf.write(u"\u0ce2\u0ce3\u0d07\u0d0e\u0d10\u0d12\u0d14\u0d2a\u0d2c")
buf.write(u"\u0d3b\u0d62\u0d63\u0d87\u0d98\u0d9c\u0db3\u0db5\u0dbd")
buf.write(u"\u0dbf\u0dbf\u0dc2\u0dc8\u0e03\u0e32\u0e34\u0e35\u0e42")
buf.write(u"\u0e48\u0e83\u0e84\u0e86\u0e86\u0e89\u0e8a\u0e8c\u0e8c")
buf.write(u"\u0e8f\u0e8f\u0e96\u0e99\u0e9b\u0ea1\u0ea3\u0ea5\u0ea7")
buf.write(u"\u0ea7\u0ea9\u0ea9\u0eac\u0ead\u0eaf\u0eb2\u0eb4\u0eb5")
buf.write(u"\u0ebf\u0ec6\u0ec8\u0ec8\u0ede\u0edf\u0f02\u0f02\u0f42")
buf.write(u"\u0f6c\u0f8a\u0f8d\u1002\u1023\u1025\u1029\u102b\u102c")
buf.write(u"\u1052\u1057\u10a2\u10c7\u10d2\u10f8\u1102\u115b\u1161")
buf.write(u"\u11a4\u11aa\u11fb\u1202\u1208\u120a\u1248\u124a\u124a")
buf.write(u"\u124c\u124f\u1252\u1258\u125a\u125a\u125c\u125f\u1262")
buf.write(u"\u1288\u128a\u128a\u128c\u128f\u1292\u12b0\u12b2\u12b2")
buf.write(u"\u12b4\u12b7\u12ba\u12c0\u12c2\u12c2\u12c4\u12c7\u12ca")
buf.write(u"\u12d0\u12d2\u12d8\u12da\u12f0\u12f2\u1310\u1312\u1312")
buf.write(u"\u1314\u1317\u131a\u1320\u1322\u1348\u134a\u135c\u13a2")
buf.write(u"\u13f6\u1403\u1678\u1683\u169c\u16a2\u16ec\u1782\u17b5")
buf.write(u"\u1822\u1879\u1882\u18aa\u1e02\u1e9d\u1ea2\u1efb\u1f02")
buf.write(u"\u1f17\u1f1a\u1f1f\u1f22\u1f47\u1f4a\u1f4f\u1f52\u1f59")
buf.write(u"\u1f5b\u1f5b\u1f5d\u1f5d\u1f5f\u1f5f\u1f61\u1f7f\u1f82")
buf.write(u"\u1fb6\u1fb8\u1fbe\u1fc0\u1fc0\u1fc4\u1fc6\u1fc8\u1fce")
buf.write(u"\u1fd2\u1fd5\u1fd8\u1fdd\u1fe2\u1fee\u1ff4\u1ff6\u1ff8")
buf.write(u"\u1ffe\u2081\u2081\u2104\u2104\u2109\u2109\u210c\u2115")
buf.write(u"\u2117\u2117\u211b\u211f\u2126\u2126\u2128\u2128\u212a")
buf.write(u"\u212a\u212c\u212f\u2131\u2133\u2135\u213b\u2162\u2185")
buf.write(u"\u3007\u3009\u3023\u302b\u3033\u3037\u303a\u303c\u3043")
buf.write(u"\u3096\u309f\u30a0\u30a3\u30fc\u30fe\u3100\u3107\u312e")
buf.write(u"\u3133\u3190\u31a2\u31b9\u3402\u4dc1\u4e02\ua48e\uac02")
buf.write(u"\uac02\ud7a5\ud7a5\uf902\ufa2f\ufb02\ufb08\ufb15\ufb19")
buf.write(u"\ufb1f\ufb1f\ufb21\ufb2a\ufb2c\ufb38\ufb3a\ufb3e\ufb40")
buf.write(u"\ufb40\ufb42\ufb43\ufb45\ufb46\ufb48\ufbb3\ufbd5\ufd3f")
buf.write(u"\ufd52\ufd91\ufd94\ufdc9\ufdf2\ufdfd\ufe72\ufe74\ufe76")
buf.write(u"\ufe76\ufe78\ufefe\uff23\uff3c\uff43\uff5c\uff68\uffc0")
buf.write(u"\uffc4\uffc9\uffcc\uffd1\uffd4\uffd9\uffdc\uffdef\2\u0302")
buf.write(u"\u0350\u0362\u0364\u0485\u0488\u0593\u05a3\u05a5\u05bb")
buf.write(u"\u05bd\u05bf\u05c1\u05c1\u05c3\u05c4\u05c6\u05c6\u064d")
buf.write(u"\u0657\u0672\u0672\u06d8\u06de\u06e1\u06e6\u06e9\u06ea")
buf.write(u"\u06ec\u06ef\u0713\u0713\u0732\u074c\u07a8\u07b2\u0903")
buf.write(u"\u0905\u093e\u093e\u0940\u094f\u0953\u0956\u0964\u0965")
buf.write(u"\u0983\u0985\u09be\u09c6\u09c9\u09ca\u09cd\u09cf\u09d9")
buf.write(u"\u09d9\u09e4\u09e5\u0a04\u0a04\u0a3e\u0a3e\u0a40\u0a44")
buf.write(u"\u0a49\u0a4a\u0a4d\u0a4f\u0a72\u0a73\u0a83\u0a85\u0abe")
buf.write(u"\u0abe\u0ac0\u0ac7\u0ac9\u0acb\u0acd\u0acf\u0b03\u0b05")
buf.write(u"\u0b3e\u0b3e\u0b40\u0b45\u0b49\u0b4a\u0b4d\u0b4f\u0b58")
buf.write(u"\u0b59\u0b84\u0b85\u0bc0\u0bc4\u0bc8\u0bca\u0bcc\u0bcf")
buf.write(u"\u0bd9\u0bd9\u0c03\u0c05\u0c40\u0c46\u0c48\u0c4a\u0c4c")
buf.write(u"\u0c4f\u0c57\u0c58\u0c84\u0c85\u0cc0\u0cc6\u0cc8\u0cca")
buf.write(u"\u0ccc\u0ccf\u0cd7\u0cd8\u0d04\u0d05\u0d40\u0d45\u0d48")
buf.write(u"\u0d4a\u0d4c\u0d4f\u0d59\u0d59\u0d84\u0d85\u0dcc\u0dcc")
buf.write(u"\u0dd1\u0dd6\u0dd8\u0dd8\u0dda\u0de1\u0df4\u0df5\u0e33")
buf.write(u"\u0e33\u0e36\u0e3c\u0e49\u0e50\u0eb3\u0eb3\u0eb6\u0ebb")
buf.write(u"\u0ebd\u0ebe\u0eca\u0ecf\u0f1a\u0f1b\u0f37\u0f37\u0f39")
buf.write(u"\u0f39\u0f3b\u0f3b\u0f40\u0f41\u0f73\u0f86\u0f88\u0f89")
buf.write(u"\u0f92\u0f99\u0f9b\u0fbe\u0fc8\u0fc8\u102e\u1034\u1038")
buf.write(u"\u103b\u1058\u105b\u17b6\u17d5\u18ab\u18ab\u20d2\u20de")
buf.write(u"\u20e3\u20e3\u302c\u3031\u309b\u309c\ufb20\ufb20\ufe22")
buf.write(u"\ufe25\26\2\62;\u0662\u066b\u06f2\u06fb\u0968\u0971\u09e8")
buf.write(u"\u09f1\u0a68\u0a71\u0ae8\u0af1\u0b68\u0b71\u0be9\u0bf1")
buf.write(u"\u0c68\u0c71\u0ce8\u0cf1\u0d68\u0d71\u0e52\u0e5b\u0ed2")
buf.write(u"\u0edb\u0f22\u0f2b\u1042\u104b\u136b\u1373\u17e2\u17eb")
buf.write(u"\u1812\u181b\uff12\uff1b\t\2aa\u2041\u2042\u30fd\u30fd")
buf.write(u"\ufe35\ufe36\ufe4f\ufe51\uff41\uff41\uff67\uff67\b\2")
buf.write(u"\f\f\17\17,,\61\61]^\u202a\u202b\7\2\f\f\17\17\61\61")
buf.write(u"]^\u202a\u202b\6\2\f\f\17\17^_\u202a\u202b\2\u04a6\2")
buf.write(u"\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3")
buf.write(u"\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2")
buf.write(u"\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2")
buf.write(u"\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2")
buf.write(u"\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2")
buf.write(u"\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2")
buf.write(u"\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3")
buf.write(u"\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2")
buf.write(u"I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2")
buf.write(u"\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2")
buf.write(u"\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2")
buf.write(u"\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3")
buf.write(u"\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2")
buf.write(u"y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081")
buf.write(u"\3\2\2\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2\2\u0087\3\2")
buf.write(u"\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2\2")
buf.write(u"\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2\2\2\u0095")
buf.write(u"\3\2\2\2\2\u0097\3\2\2\2\2\u0099\3\2\2\2\2\u009b\3\2")
buf.write(u"\2\2\2\u009d\3\2\2\2\2\u009f\3\2\2\2\2\u00a1\3\2\2\2")
buf.write(u"\2\u00a3\3\2\2\2\2\u00a5\3\2\2\2\2\u00a7\3\2\2\2\2\u00a9")
buf.write(u"\3\2\2\2\2\u00ab\3\2\2\2\2\u00ad\3\2\2\2\2\u00af\3\2")
buf.write(u"\2\2\2\u00b1\3\2\2\2\2\u00b3\3\2\2\2\2\u00b5\3\2\2\2")
buf.write(u"\2\u00b7\3\2\2\2\2\u00b9\3\2\2\2\2\u00bb\3\2\2\2\2\u00bd")
buf.write(u"\3\2\2\2\2\u00bf\3\2\2\2\2\u00c1\3\2\2\2\2\u00c3\3\2")
buf.write(u"\2\2\2\u00c5\3\2\2\2\2\u00c7\3\2\2\2\2\u00c9\3\2\2\2")
buf.write(u"\2\u00cb\3\2\2\2\2\u00cd\3\2\2\2\2\u00cf\3\2\2\2\2\u00d1")
buf.write(u"\3\2\2\2\2\u00d3\3\2\2\2\2\u00d5\3\2\2\2\2\u00d7\3\2")
buf.write(u"\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2\2\2\u00dd\3\2\2\2")
buf.write(u"\2\u00df\3\2\2\2\2\u00e1\3\2\2\2\2\u00e3\3\2\2\2\2\u00e5")
buf.write(u"\3\2\2\2\2\u00e7\3\2\2\2\2\u00e9\3\2\2\2\2\u00eb\3\2")
buf.write(u"\2\2\2\u00ed\3\2\2\2\2\u00ef\3\2\2\2\2\u00f1\3\2\2\2")
buf.write(u"\2\u00f3\3\2\2\2\2\u00f5\3\2\2\2\2\u00f7\3\2\2\2\3\u0129")
buf.write(u"\3\2\2\2\5\u0133\3\2\2\2\7\u0141\3\2\2\2\t\u014c\3\2")
buf.write(u"\2\2\13\u015c\3\2\2\2\r\u015e\3\2\2\2\17\u0160\3\2\2")
buf.write(u"\2\21\u0162\3\2\2\2\23\u0164\3\2\2\2\25\u0167\3\2\2\2")
buf.write(u"\27\u016a\3\2\2\2\31\u016c\3\2\2\2\33\u016e\3\2\2\2\35")
buf.write(u"\u0170\3\2\2\2\37\u0172\3\2\2\2!\u0174\3\2\2\2#\u0178")
buf.write(u"\3\2\2\2%\u017a\3\2\2\2\'\u017d\3\2\2\2)\u0180\3\2\2")
buf.write(u"\2+\u0182\3\2\2\2-\u0184\3\2\2\2/\u0186\3\2\2\2\61\u0188")
buf.write(u"\3\2\2\2\63\u018a\3\2\2\2\65\u018c\3\2\2\2\67\u018e\3")
buf.write(u"\2\2\29\u0191\3\2\2\2;\u0194\3\2\2\2=\u0196\3\2\2\2?")
buf.write(u"\u0199\3\2\2\2A\u019c\3\2\2\2C\u01a0\3\2\2\2E\u01a2\3")
buf.write(u"\2\2\2G\u01a4\3\2\2\2I\u01a7\3\2\2\2K\u01aa\3\2\2\2M")
buf.write(u"\u01ad\3\2\2\2O\u01b0\3\2\2\2Q\u01b4\3\2\2\2S\u01b8\3")
buf.write(u"\2\2\2U\u01ba\3\2\2\2W\u01bc\3\2\2\2Y\u01be\3\2\2\2[")
buf.write(u"\u01c1\3\2\2\2]\u01c4\3\2\2\2_\u01c7\3\2\2\2a\u01ca\3")
buf.write(u"\2\2\2c\u01cd\3\2\2\2e\u01d0\3\2\2\2g\u01d3\3\2\2\2i")
buf.write(u"\u01d7\3\2\2\2k\u01db\3\2\2\2m\u01e0\3\2\2\2o\u01e3\3")
buf.write(u"\2\2\2q\u01e6\3\2\2\2s\u01e9\3\2\2\2u\u01ed\3\2\2\2w")
buf.write(u"\u01f0\3\2\2\2y\u01fe\3\2\2\2{\u021b\3\2\2\2}\u021d\3")
buf.write(u"\2\2\2\177\u0226\3\2\2\2\u0081\u022e\3\2\2\2\u0083\u0237")
buf.write(u"\3\2\2\2\u0085\u0240\3\2\2\2\u0087\u024b\3\2\2\2\u0089")
buf.write(u"\u0256\3\2\2\2\u008b\u0261\3\2\2\2\u008d\u0264\3\2\2")
buf.write(u"\2\u008f\u026a\3\2\2\2\u0091\u026d\3\2\2\2\u0093\u0278")
buf.write(u"\3\2\2\2\u0095\u027f\3\2\2\2\u0097\u0284\3\2\2\2\u0099")
buf.write(u"\u0289\3\2\2\2\u009b\u028d\3\2\2\2\u009d\u0291\3\2\2")
buf.write(u"\2\u009f\u0297\3\2\2\2\u00a1\u029f\3\2\2\2\u00a3\u02a6")
buf.write(u"\3\2\2\2\u00a5\u02ab\3\2\2\2\u00a7\u02b4\3\2\2\2\u00a9")
buf.write(u"\u02b8\3\2\2\2\u00ab\u02bf\3\2\2\2\u00ad\u02c5\3\2\2")
buf.write(u"\2\u00af\u02ce\3\2\2\2\u00b1\u02d7\3\2\2\2\u00b3\u02dc")
buf.write(u"\3\2\2\2\u00b5\u02e1\3\2\2\2\u00b7\u02e9\3\2\2\2\u00b9")
buf.write(u"\u02ec\3\2\2\2\u00bb\u02f2\3\2\2\2\u00bd\u02f9\3\2\2")
buf.write(u"\2\u00bf\u02fc\3\2\2\2\u00c1\u0300\3\2\2\2\u00c3\u0303")
buf.write(u"\3\2\2\2\u00c5\u0308\3\2\2\2\u00c7\u030e\3\2\2\2\u00c9")
buf.write(u"\u0313\3\2\2\2\u00cb\u031b\3\2\2\2\u00cd\u0321\3\2\2")
buf.write(u"\2\u00cf\u0327\3\2\2\2\u00d1\u032e\3\2\2\2\u00d3\u0335")
buf.write(u"\3\2\2\2\u00d5\u033b\3\2\2\2\u00d7\u0341\3\2\2\2\u00d9")
buf.write(u"\u034e\3\2\2\2\u00db\u0354\3\2\2\2\u00dd\u035e\3\2\2")
buf.write(u"\2\u00df\u0367\3\2\2\2\u00e1\u0373\3\2\2\2\u00e3\u037d")
buf.write(u"\3\2\2\2\u00e5\u0389\3\2\2\2\u00e7\u0392\3\2\2\2\u00e9")
buf.write(u"\u039a\3\2\2\2\u00eb\u03b1\3\2\2\2\u00ed\u03b5\3\2\2")
buf.write(u"\2\u00ef\u03c1\3\2\2\2\u00f1\u03c7\3\2\2\2\u00f3\u03cb")
buf.write(u"\3\2\2\2\u00f5\u03dc\3\2\2\2\u00f7\u03f2\3\2\2\2\u00f9")
buf.write(u"\u03fa\3\2\2\2\u00fb\u0400\3\2\2\2\u00fd\u0407\3\2\2")
buf.write(u"\2\u00ff\u040b\3\2\2\2\u0101\u040d\3\2\2\2\u0103\u0421")
buf.write(u"\3\2\2\2\u0105\u0423\3\2\2\2\u0107\u042c\3\2\2\2\u0109")
buf.write(u"\u042e\3\2\2\2\u010b\u0432\3\2\2\2\u010d\u0434\3\2\2")
buf.write(u"\2\u010f\u0437\3\2\2\2\u0111\u0441\3\2\2\2\u0113\u0443")
buf.write(u"\3\2\2\2\u0115\u0451\3\2\2\2\u0117\u0457\3\2\2\2\u0119")
buf.write(u"\u045a\3\2\2\2\u011b\u045d\3\2\2\2\u011d\u0460\3\2\2")
buf.write(u"\2\u011f\u0463\3\2\2\2\u0121\u046f\3\2\2\2\u0123\u047b")
buf.write(u"\3\2\2\2\u0125\u047f\3\2\2\2\u0127\u0481\3\2\2\2\u0129")
buf.write(u"\u012a\6\2\2\2\u012a\u012b\7%\2\2\u012b\u012c\7#\2\2")
buf.write(u"\u012c\u0130\3\2\2\2\u012d\u012f\n\2\2\2\u012e\u012d")
buf.write(u"\3\2\2\2\u012f\u0132\3\2\2\2\u0130\u012e\3\2\2\2\u0130")
buf.write(u"\u0131\3\2\2\2\u0131\4\3\2\2\2\u0132\u0130\3\2\2\2\u0133")
buf.write(u"\u0134\7\61\2\2\u0134\u0135\7,\2\2\u0135\u0139\3\2\2")
buf.write(u"\2\u0136\u0138\13\2\2\2\u0137\u0136\3\2\2\2\u0138\u013b")
buf.write(u"\3\2\2\2\u0139\u013a\3\2\2\2\u0139\u0137\3\2\2\2\u013a")
buf.write(u"\u013c\3\2\2\2\u013b\u0139\3\2\2\2\u013c\u013d\7,\2\2")
buf.write(u"\u013d\u013e\7\61\2\2\u013e\u013f\3\2\2\2\u013f\u0140")
buf.write(u"\b\3\2\2\u0140\6\3\2\2\2\u0141\u0142\7\61\2\2\u0142\u0143")
buf.write(u"\7\61\2\2\u0143\u0147\3\2\2\2\u0144\u0146\n\2\2\2\u0145")
buf.write(u"\u0144\3\2\2\2\u0146\u0149\3\2\2\2\u0147\u0145\3\2\2")
buf.write(u"\2\u0147\u0148\3\2\2\2\u0148\u014a\3\2\2\2\u0149\u0147")
buf.write(u"\3\2\2\2\u014a\u014b\b\4\2\2\u014b\b\3\2\2\2\u014c\u014d")
buf.write(u"\7\61\2\2\u014d\u0151\5\u0121\u0091\2\u014e\u0150\5\u0123")
buf.write(u"\u0092\2\u014f\u014e\3\2\2\2\u0150\u0153\3\2\2\2\u0151")
buf.write(u"\u014f\3\2\2\2\u0151\u0152\3\2\2\2\u0152\u0154\3\2\2")
buf.write(u"\2\u0153\u0151\3\2\2\2\u0154\u0155\6\5\3\2\u0155\u0159")
buf.write(u"\7\61\2\2\u0156\u0158\5\u0115\u008b\2\u0157\u0156\3\2")
buf.write(u"\2\2\u0158\u015b\3\2\2\2\u0159\u0157\3\2\2\2\u0159\u015a")
buf.write(u"\3\2\2\2\u015a\n\3\2\2\2\u015b\u0159\3\2\2\2\u015c\u015d")
buf.write(u"\7]\2\2\u015d\f\3\2\2\2\u015e\u015f\7_\2\2\u015f\16\3")
buf.write(u"\2\2\2\u0160\u0161\7*\2\2\u0161\20\3\2\2\2\u0162\u0163")
buf.write(u"\7+\2\2\u0163\22\3\2\2\2\u0164\u0165\7}\2\2\u0165\u0166")
buf.write(u"\b\n\3\2\u0166\24\3\2\2\2\u0167\u0168\7\177\2\2\u0168")
buf.write(u"\u0169\b\13\4\2\u0169\26\3\2\2\2\u016a\u016b\7=\2\2\u016b")
buf.write(u"\30\3\2\2\2\u016c\u016d\7.\2\2\u016d\32\3\2\2\2\u016e")
buf.write(u"\u016f\7?\2\2\u016f\34\3\2\2\2\u0170\u0171\7A\2\2\u0171")
buf.write(u"\36\3\2\2\2\u0172\u0173\7<\2\2\u0173 \3\2\2\2\u0174\u0175")
buf.write(u"\7\60\2\2\u0175\u0176\7\60\2\2\u0176\u0177\7\60\2\2\u0177")
buf.write(u"\"\3\2\2\2\u0178\u0179\7\60\2\2\u0179$\3\2\2\2\u017a")
buf.write(u"\u017b\7-\2\2\u017b\u017c\7-\2\2\u017c&\3\2\2\2\u017d")
buf.write(u"\u017e\7/\2\2\u017e\u017f\7/\2\2\u017f(\3\2\2\2\u0180")
buf.write(u"\u0181\7-\2\2\u0181*\3\2\2\2\u0182\u0183\7/\2\2\u0183")
buf.write(u",\3\2\2\2\u0184\u0185\7\u0080\2\2\u0185.\3\2\2\2\u0186")
buf.write(u"\u0187\7#\2\2\u0187\60\3\2\2\2\u0188\u0189\7,\2\2\u0189")
buf.write(u"\62\3\2\2\2\u018a\u018b\7\61\2\2\u018b\64\3\2\2\2\u018c")
buf.write(u"\u018d\7\'\2\2\u018d\66\3\2\2\2\u018e\u018f\7,\2\2\u018f")
buf.write(u"\u0190\7,\2\2\u01908\3\2\2\2\u0191\u0192\7A\2\2\u0192")
buf.write(u"\u0193\7A\2\2\u0193:\3\2\2\2\u0194\u0195\7%\2\2\u0195")
buf.write(u"<\3\2\2\2\u0196\u0197\7@\2\2\u0197\u0198\7@\2\2\u0198")
buf.write(u">\3\2\2\2\u0199\u019a\7>\2\2\u019a\u019b\7>\2\2\u019b")
buf.write(u"@\3\2\2\2\u019c\u019d\7@\2\2\u019d\u019e\7@\2\2\u019e")
buf.write(u"\u019f\7@\2\2\u019fB\3\2\2\2\u01a0\u01a1\7>\2\2\u01a1")
buf.write(u"D\3\2\2\2\u01a2\u01a3\7@\2\2\u01a3F\3\2\2\2\u01a4\u01a5")
buf.write(u"\7>\2\2\u01a5\u01a6\7?\2\2\u01a6H\3\2\2\2\u01a7\u01a8")
buf.write(u"\7@\2\2\u01a8\u01a9\7?\2\2\u01a9J\3\2\2\2\u01aa\u01ab")
buf.write(u"\7?\2\2\u01ab\u01ac\7?\2\2\u01acL\3\2\2\2\u01ad\u01ae")
buf.write(u"\7#\2\2\u01ae\u01af\7?\2\2\u01afN\3\2\2\2\u01b0\u01b1")
buf.write(u"\7?\2\2\u01b1\u01b2\7?\2\2\u01b2\u01b3\7?\2\2\u01b3P")
buf.write(u"\3\2\2\2\u01b4\u01b5\7#\2\2\u01b5\u01b6\7?\2\2\u01b6")
buf.write(u"\u01b7\7?\2\2\u01b7R\3\2\2\2\u01b8\u01b9\7(\2\2\u01b9")
buf.write(u"T\3\2\2\2\u01ba\u01bb\7`\2\2\u01bbV\3\2\2\2\u01bc\u01bd")
buf.write(u"\7~\2\2\u01bdX\3\2\2\2\u01be\u01bf\7(\2\2\u01bf\u01c0")
buf.write(u"\7(\2\2\u01c0Z\3\2\2\2\u01c1\u01c2\7~\2\2\u01c2\u01c3")
buf.write(u"\7~\2\2\u01c3\\\3\2\2\2\u01c4\u01c5\7,\2\2\u01c5\u01c6")
buf.write(u"\7?\2\2\u01c6^\3\2\2\2\u01c7\u01c8\7\61\2\2\u01c8\u01c9")
buf.write(u"\7?\2\2\u01c9`\3\2\2\2\u01ca\u01cb\7\'\2\2\u01cb\u01cc")
buf.write(u"\7?\2\2\u01ccb\3\2\2\2\u01cd\u01ce\7-\2\2\u01ce\u01cf")
buf.write(u"\7?\2\2\u01cfd\3\2\2\2\u01d0\u01d1\7/\2\2\u01d1\u01d2")
buf.write(u"\7?\2\2\u01d2f\3\2\2\2\u01d3\u01d4\7>\2\2\u01d4\u01d5")
buf.write(u"\7>\2\2\u01d5\u01d6\7?\2\2\u01d6h\3\2\2\2\u01d7\u01d8")
buf.write(u"\7@\2\2\u01d8\u01d9\7@\2\2\u01d9\u01da\7?\2\2\u01daj")
buf.write(u"\3\2\2\2\u01db\u01dc\7@\2\2\u01dc\u01dd\7@\2\2\u01dd")
buf.write(u"\u01de\7@\2\2\u01de\u01df\7?\2\2\u01dfl\3\2\2\2\u01e0")
buf.write(u"\u01e1\7(\2\2\u01e1\u01e2\7?\2\2\u01e2n\3\2\2\2\u01e3")
buf.write(u"\u01e4\7`\2\2\u01e4\u01e5\7?\2\2\u01e5p\3\2\2\2\u01e6")
buf.write(u"\u01e7\7~\2\2\u01e7\u01e8\7?\2\2\u01e8r\3\2\2\2\u01e9")
buf.write(u"\u01ea\7,\2\2\u01ea\u01eb\7,\2\2\u01eb\u01ec\7?\2\2\u01ec")
buf.write(u"t\3\2\2\2\u01ed\u01ee\7?\2\2\u01ee\u01ef\7@\2\2\u01ef")
buf.write(u"v\3\2\2\2\u01f0\u01f1\7p\2\2\u01f1\u01f2\7w\2\2\u01f2")
buf.write(u"\u01f3\7n\2\2\u01f3\u01f4\7n\2\2\u01f4x\3\2\2\2\u01f5")
buf.write(u"\u01f6\7v\2\2\u01f6\u01f7\7t\2\2\u01f7\u01f8\7w\2\2\u01f8")
buf.write(u"\u01ff\7g\2\2\u01f9\u01fa\7h\2\2\u01fa\u01fb\7c\2\2\u01fb")
buf.write(u"\u01fc\7n\2\2\u01fc\u01fd\7u\2\2\u01fd\u01ff\7g\2\2\u01fe")
buf.write(u"\u01f5\3\2\2\2\u01fe\u01f9\3\2\2\2\u01ffz\3\2\2\2\u0200")
buf.write(u"\u0201\5\u0111\u0089\2\u0201\u0202\7\60\2\2\u0202\u0206")
buf.write(u"\t\3\2\2\u0203\u0205\t\4\2\2\u0204\u0203\3\2\2\2\u0205")
buf.write(u"\u0208\3\2\2\2\u0206\u0204\3\2\2\2\u0206\u0207\3\2\2")
buf.write(u"\2\u0207\u020a\3\2\2\2\u0208\u0206\3\2\2\2\u0209\u020b")
buf.write(u"\5\u0113\u008a\2\u020a\u0209\3\2\2\2\u020a\u020b\3\2")
buf.write(u"\2\2\u020b\u021c\3\2\2\2\u020c\u020d\7\60\2\2\u020d\u0211")
buf.write(u"\t\3\2\2\u020e\u0210\t\4\2\2\u020f\u020e\3\2\2\2\u0210")
buf.write(u"\u0213\3\2\2\2\u0211\u020f\3\2\2\2\u0211\u0212\3\2\2")
buf.write(u"\2\u0212\u0215\3\2\2\2\u0213\u0211\3\2\2\2\u0214\u0216")
buf.write(u"\5\u0113\u008a\2\u0215\u0214\3\2\2\2\u0215\u0216\3\2")
buf.write(u"\2\2\u0216\u021c\3\2\2\2\u0217\u0219\5\u0111\u0089\2")
buf.write(u"\u0218\u021a\5\u0113\u008a\2\u0219\u0218\3\2\2\2\u0219")
buf.write(u"\u021a\3\2\2\2\u021a\u021c\3\2\2\2\u021b\u0200\3\2\2")
buf.write(u"\2\u021b\u020c\3\2\2\2\u021b\u0217\3\2\2\2\u021c|\3\2")
buf.write(u"\2\2\u021d\u021e\7\62\2\2\u021e\u021f\t\5\2\2\u021f\u0223")
buf.write(u"\t\6\2\2\u0220\u0222\5\u010f\u0088\2\u0221\u0220\3\2")
buf.write(u"\2\2\u0222\u0225\3\2\2\2\u0223\u0221\3\2\2\2\u0223\u0224")
buf.write(u"\3\2\2\2\u0224~\3\2\2\2\u0225\u0223\3\2\2\2\u0226\u0228")
buf.write(u"\7\62\2\2\u0227\u0229\t\7\2\2\u0228\u0227\3\2\2\2\u0229")
buf.write(u"\u022a\3\2\2\2\u022a\u0228\3\2\2\2\u022a\u022b\3\2\2")
buf.write(u"\2\u022b\u022c\3\2\2\2\u022c\u022d\6@\4\2\u022d\u0080")
buf.write(u"\3\2\2\2\u022e\u022f\7\62\2\2\u022f\u0230\t\b\2\2\u0230")
buf.write(u"\u0234\t\7\2\2\u0231\u0233\t\t\2\2\u0232\u0231\3\2\2")
buf.write(u"\2\u0233\u0236\3\2\2\2\u0234\u0232\3\2\2\2\u0234\u0235")
buf.write(u"\3\2\2\2\u0235\u0082\3\2\2\2\u0236\u0234\3\2\2\2\u0237")
buf.write(u"\u0238\7\62\2\2\u0238\u0239\t\n\2\2\u0239\u023d\t\13")
buf.write(u"\2\2\u023a\u023c\t\f\2\2\u023b\u023a\3\2\2\2\u023c\u023f")
buf.write(u"\3\2\2\2\u023d\u023b\3\2\2\2\u023d\u023e\3\2\2\2\u023e")
buf.write(u"\u0084\3\2\2\2\u023f\u023d\3\2\2\2\u0240\u0241\7\62\2")
buf.write(u"\2\u0241\u0242\t\5\2\2\u0242\u0246\t\6\2\2\u0243\u0245")
buf.write(u"\5\u010f\u0088\2\u0244\u0243\3\2\2\2\u0245\u0248\3\2")
buf.write(u"\2\2\u0246\u0244\3\2\2\2\u0246\u0247\3\2\2\2\u0247\u0249")
buf.write(u"\3\2\2\2\u0248\u0246\3\2\2\2\u0249\u024a\7p\2\2\u024a")
buf.write(u"\u0086\3\2\2\2\u024b\u024c\7\62\2\2\u024c\u024d\t\b\2")
buf.write(u"\2\u024d\u0251\t\7\2\2\u024e\u0250\t\t\2\2\u024f\u024e")
buf.write(u"\3\2\2\2\u0250\u0253\3\2\2\2\u0251\u024f\3\2\2\2\u0251")
buf.write(u"\u0252\3\2\2\2\u0252\u0254\3\2\2\2\u0253\u0251\3\2\2")
buf.write(u"\2\u0254\u0255\7p\2\2\u0255\u0088\3\2\2\2\u0256\u0257")
buf.write(u"\7\62\2\2\u0257\u0258\t\n\2\2\u0258\u025c\t\13\2\2\u0259")
buf.write(u"\u025b\t\f\2\2\u025a\u0259\3\2\2\2\u025b\u025e\3\2\2")
buf.write(u"\2\u025c\u025a\3\2\2\2\u025c\u025d\3\2\2\2\u025d\u025f")
buf.write(u"\3\2\2\2\u025e\u025c\3\2\2\2\u025f\u0260\7p\2\2\u0260")
buf.write(u"\u008a\3\2\2\2\u0261\u0262\5\u0111\u0089\2\u0262\u0263")
buf.write(u"\7p\2\2\u0263\u008c\3\2\2\2\u0264\u0265\7d\2\2\u0265")
buf.write(u"\u0266\7t\2\2\u0266\u0267\7g\2\2\u0267\u0268\7c\2\2\u0268")
buf.write(u"\u0269\7m\2\2\u0269\u008e\3\2\2\2\u026a\u026b\7f\2\2")
buf.write(u"\u026b\u026c\7q\2\2\u026c\u0090\3\2\2\2\u026d\u026e\7")
buf.write(u"k\2\2\u026e\u026f\7p\2\2\u026f\u0270\7u\2\2\u0270\u0271")
buf.write(u"\7v\2\2\u0271\u0272\7c\2\2\u0272\u0273\7p\2\2\u0273\u0274")
buf.write(u"\7e\2\2\u0274\u0275\7g\2\2\u0275\u0276\7q\2\2\u0276\u0277")
buf.write(u"\7h\2\2\u0277\u0092\3\2\2\2\u0278\u0279\7v\2\2\u0279")
buf.write(u"\u027a\7{\2\2\u027a\u027b\7r\2\2\u027b\u027c\7g\2\2\u027c")
buf.write(u"\u027d\7q\2\2\u027d\u027e\7h\2\2\u027e\u0094\3\2\2\2")
buf.write(u"\u027f\u0280\7e\2\2\u0280\u0281\7c\2\2\u0281\u0282\7")
buf.write(u"u\2\2\u0282\u0283\7g\2\2\u0283\u0096\3\2\2\2\u0284\u0285")
buf.write(u"\7g\2\2\u0285\u0286\7n\2\2\u0286\u0287\7u\2\2\u0287\u0288")
buf.write(u"\7g\2\2\u0288\u0098\3\2\2\2\u0289\u028a\7p\2\2\u028a")
buf.write(u"\u028b\7g\2\2\u028b\u028c\7y\2\2\u028c\u009a\3\2\2\2")
buf.write(u"\u028d\u028e\7x\2\2\u028e\u028f\7c\2\2\u028f\u0290\7")
buf.write(u"t\2\2\u0290\u009c\3\2\2\2\u0291\u0292\7e\2\2\u0292\u0293")
buf.write(u"\7c\2\2\u0293\u0294\7v\2\2\u0294\u0295\7e\2\2\u0295\u0296")
buf.write(u"\7j\2\2\u0296\u009e\3\2\2\2\u0297\u0298\7h\2\2\u0298")
buf.write(u"\u0299\7k\2\2\u0299\u029a\7p\2\2\u029a\u029b\7c\2\2\u029b")
buf.write(u"\u029c\7n\2\2\u029c\u029d\7n\2\2\u029d\u029e\7{\2\2\u029e")
buf.write(u"\u00a0\3\2\2\2\u029f\u02a0\7t\2\2\u02a0\u02a1\7g\2\2")
buf.write(u"\u02a1\u02a2\7v\2\2\u02a2\u02a3\7w\2\2\u02a3\u02a4\7")
buf.write(u"t\2\2\u02a4\u02a5\7p\2\2\u02a5\u00a2\3\2\2\2\u02a6\u02a7")
buf.write(u"\7x\2\2\u02a7\u02a8\7q\2\2\u02a8\u02a9\7k\2\2\u02a9\u02aa")
buf.write(u"\7f\2\2\u02aa\u00a4\3\2\2\2\u02ab\u02ac\7e\2\2\u02ac")
buf.write(u"\u02ad\7q\2\2\u02ad\u02ae\7p\2\2\u02ae\u02af\7v\2\2\u02af")
buf.write(u"\u02b0\7k\2\2\u02b0\u02b1\7p\2\2\u02b1\u02b2\7w\2\2\u02b2")
buf.write(u"\u02b3\7g\2\2\u02b3\u00a6\3\2\2\2\u02b4\u02b5\7h\2\2")
buf.write(u"\u02b5\u02b6\7q\2\2\u02b6\u02b7\7t\2\2\u02b7\u00a8\3")
buf.write(u"\2\2\2\u02b8\u02b9\7u\2\2\u02b9\u02ba\7y\2\2\u02ba\u02bb")
buf.write(u"\7k\2\2\u02bb\u02bc\7v\2\2\u02bc\u02bd\7e\2\2\u02bd\u02be")
buf.write(u"\7j\2\2\u02be\u00aa\3\2\2\2\u02bf\u02c0\7y\2\2\u02c0")
buf.write(u"\u02c1\7j\2\2\u02c1\u02c2\7k\2\2\u02c2\u02c3\7n\2\2\u02c3")
buf.write(u"\u02c4\7g\2\2\u02c4\u00ac\3\2\2\2\u02c5\u02c6\7f\2\2")
buf.write(u"\u02c6\u02c7\7g\2\2\u02c7\u02c8\7d\2\2\u02c8\u02c9\7")
buf.write(u"w\2\2\u02c9\u02ca\7i\2\2\u02ca\u02cb\7i\2\2\u02cb\u02cc")
buf.write(u"\7g\2\2\u02cc\u02cd\7t\2\2\u02cd\u00ae\3\2\2\2\u02ce")
buf.write(u"\u02cf\7h\2\2\u02cf\u02d0\7w\2\2\u02d0\u02d1\7p\2\2\u02d1")
buf.write(u"\u02d2\7e\2\2\u02d2\u02d3\7v\2\2\u02d3\u02d4\7k\2\2\u02d4")
buf.write(u"\u02d5\7q\2\2\u02d5\u02d6\7p\2\2\u02d6\u00b0\3\2\2\2")
buf.write(u"\u02d7\u02d8\7v\2\2\u02d8\u02d9\7j\2\2\u02d9\u02da\7")
buf.write(u"k\2\2\u02da\u02db\7u\2\2\u02db\u00b2\3\2\2\2\u02dc\u02dd")
buf.write(u"\7y\2\2\u02dd\u02de\7k\2\2\u02de\u02df\7v\2\2\u02df\u02e0")
buf.write(u"\7j\2\2\u02e0\u00b4\3\2\2\2\u02e1\u02e2\7f\2\2\u02e2")
buf.write(u"\u02e3\7g\2\2\u02e3\u02e4\7h\2\2\u02e4\u02e5\7c\2\2\u02e5")
buf.write(u"\u02e6\7w\2\2\u02e6\u02e7\7n\2\2\u02e7\u02e8\7v\2\2\u02e8")
buf.write(u"\u00b6\3\2\2\2\u02e9\u02ea\7k\2\2\u02ea\u02eb\7h\2\2")
buf.write(u"\u02eb\u00b8\3\2\2\2\u02ec\u02ed\7v\2\2\u02ed\u02ee\7")
buf.write(u"j\2\2\u02ee\u02ef\7t\2\2\u02ef\u02f0\7q\2\2\u02f0\u02f1")
buf.write(u"\7y\2\2\u02f1\u00ba\3\2\2\2\u02f2\u02f3\7f\2\2\u02f3")
buf.write(u"\u02f4\7g\2\2\u02f4\u02f5\7n\2\2\u02f5\u02f6\7g\2\2\u02f6")
buf.write(u"\u02f7\7v\2\2\u02f7\u02f8\7g\2\2\u02f8\u00bc\3\2\2\2")
buf.write(u"\u02f9\u02fa\7k\2\2\u02fa\u02fb\7p\2\2\u02fb\u00be\3")
buf.write(u"\2\2\2\u02fc\u02fd\7v\2\2\u02fd\u02fe\7t\2\2\u02fe\u02ff")
buf.write(u"\7{\2\2\u02ff\u00c0\3\2\2\2\u0300\u0301\7c\2\2\u0301")
buf.write(u"\u0302\7u\2\2\u0302\u00c2\3\2\2\2\u0303\u0304\7h\2\2")
buf.write(u"\u0304\u0305\7t\2\2\u0305\u0306\7q\2\2\u0306\u0307\7")
buf.write(u"o\2\2\u0307\u00c4\3\2\2\2\u0308\u0309\7e\2\2\u0309\u030a")
buf.write(u"\7n\2\2\u030a\u030b\7c\2\2\u030b\u030c\7u\2\2\u030c\u030d")
buf.write(u"\7u\2\2\u030d\u00c6\3\2\2\2\u030e\u030f\7g\2\2\u030f")
buf.write(u"\u0310\7p\2\2\u0310\u0311\7w\2\2\u0311\u0312\7o\2\2\u0312")
buf.write(u"\u00c8\3\2\2\2\u0313\u0314\7g\2\2\u0314\u0315\7z\2\2")
buf.write(u"\u0315\u0316\7v\2\2\u0316\u0317\7g\2\2\u0317\u0318\7")
buf.write(u"p\2\2\u0318\u0319\7f\2\2\u0319\u031a\7u\2\2\u031a\u00ca")
buf.write(u"\3\2\2\2\u031b\u031c\7u\2\2\u031c\u031d\7w\2\2\u031d")
buf.write(u"\u031e\7r\2\2\u031e\u031f\7g\2\2\u031f\u0320\7t\2\2\u0320")
buf.write(u"\u00cc\3\2\2\2\u0321\u0322\7e\2\2\u0322\u0323\7q\2\2")
buf.write(u"\u0323\u0324\7p\2\2\u0324\u0325\7u\2\2\u0325\u0326\7")
buf.write(u"v\2\2\u0326\u00ce\3\2\2\2\u0327\u0328\7g\2\2\u0328\u0329")
buf.write(u"\7z\2\2\u0329\u032a\7r\2\2\u032a\u032b\7q\2\2\u032b\u032c")
buf.write(u"\7t\2\2\u032c\u032d\7v\2\2\u032d\u00d0\3\2\2\2\u032e")
buf.write(u"\u032f\7k\2\2\u032f\u0330\7o\2\2\u0330\u0331\7r\2\2\u0331")
buf.write(u"\u0332\7q\2\2\u0332\u0333\7t\2\2\u0333\u0334\7v\2\2\u0334")
buf.write(u"\u00d2\3\2\2\2\u0335\u0336\7c\2\2\u0336\u0337\7u\2\2")
buf.write(u"\u0337\u0338\7{\2\2\u0338\u0339\7p\2\2\u0339\u033a\7")
buf.write(u"e\2\2\u033a\u00d4\3\2\2\2\u033b\u033c\7c\2\2\u033c\u033d")
buf.write(u"\7y\2\2\u033d\u033e\7c\2\2\u033e\u033f\7k\2\2\u033f\u0340")
buf.write(u"\7v\2\2\u0340\u00d6\3\2\2\2\u0341\u0342\7k\2\2\u0342")
buf.write(u"\u0343\7o\2\2\u0343\u0344\7r\2\2\u0344\u0345\7n\2\2\u0345")
buf.write(u"\u0346\7g\2\2\u0346\u0347\7o\2\2\u0347\u0348\7g\2\2\u0348")
buf.write(u"\u0349\7p\2\2\u0349\u034a\7v\2\2\u034a\u034b\7u\2\2\u034b")
buf.write(u"\u034c\3\2\2\2\u034c\u034d\6l\5\2\u034d\u00d8\3\2\2\2")
buf.write(u"\u034e\u034f\7n\2\2\u034f\u0350\7g\2\2\u0350\u0351\7")
buf.write(u"v\2\2\u0351\u0352\3\2\2\2\u0352\u0353\6m\6\2\u0353\u00da")
buf.write(u"\3\2\2\2\u0354\u0355\7r\2\2\u0355\u0356\7t\2\2\u0356")
buf.write(u"\u0357\7k\2\2\u0357\u0358\7x\2\2\u0358\u0359\7c\2\2\u0359")
buf.write(u"\u035a\7v\2\2\u035a\u035b\7g\2\2\u035b\u035c\3\2\2\2")
buf.write(u"\u035c\u035d\6n\7\2\u035d\u00dc\3\2\2\2\u035e\u035f\7")
buf.write(u"r\2\2\u035f\u0360\7w\2\2\u0360\u0361\7d\2\2\u0361\u0362")
buf.write(u"\7n\2\2\u0362\u0363\7k\2\2\u0363\u0364\7e\2\2\u0364\u0365")
buf.write(u"\3\2\2\2\u0365\u0366\6o\b\2\u0366\u00de\3\2\2\2\u0367")
buf.write(u"\u0368\7k\2\2\u0368\u0369\7p\2\2\u0369\u036a\7v\2\2\u036a")
buf.write(u"\u036b\7g\2\2\u036b\u036c\7t\2\2\u036c\u036d\7h\2\2\u036d")
buf.write(u"\u036e\7c\2\2\u036e\u036f\7e\2\2\u036f\u0370\7g\2\2\u0370")
buf.write(u"\u0371\3\2\2\2\u0371\u0372\6p\t\2\u0372\u00e0\3\2\2\2")
buf.write(u"\u0373\u0374\7r\2\2\u0374\u0375\7c\2\2\u0375\u0376\7")
buf.write(u"e\2\2\u0376\u0377\7m\2\2\u0377\u0378\7c\2\2\u0378\u0379")
buf.write(u"\7i\2\2\u0379\u037a\7g\2\2\u037a\u037b\3\2\2\2\u037b")
buf.write(u"\u037c\6q\n\2\u037c\u00e2\3\2\2\2\u037d\u037e\7r\2\2")
buf.write(u"\u037e\u037f\7t\2\2\u037f\u0380\7q\2\2\u0380\u0381\7")
buf.write(u"v\2\2\u0381\u0382\7g\2\2\u0382\u0383\7e\2\2\u0383\u0384")
buf.write(u"\7v\2\2\u0384\u0385\7g\2\2\u0385\u0386\7f\2\2\u0386\u0387")
buf.write(u"\3\2\2\2\u0387\u0388\6r\13\2\u0388\u00e4\3\2\2\2\u0389")
buf.write(u"\u038a\7u\2\2\u038a\u038b\7v\2\2\u038b\u038c\7c\2\2\u038c")
buf.write(u"\u038d\7v\2\2\u038d\u038e\7k\2\2\u038e\u038f\7e\2\2\u038f")
buf.write(u"\u0390\3\2\2\2\u0390\u0391\6s\f\2\u0391\u00e6\3\2\2\2")
buf.write(u"\u0392\u0393\7{\2\2\u0393\u0394\7k\2\2\u0394\u0395\7")
buf.write(u"g\2\2\u0395\u0396\7n\2\2\u0396\u0397\7f\2\2\u0397\u0398")
buf.write(u"\3\2\2\2\u0398\u0399\6t\r\2\u0399\u00e8\3\2\2\2\u039a")
buf.write(u"\u039e\5\u0117\u008c\2\u039b\u039d\5\u0115\u008b\2\u039c")
buf.write(u"\u039b\3\2\2\2\u039d\u03a0\3\2\2\2\u039e\u039c\3\2\2")
buf.write(u"\2\u039e\u039f\3\2\2\2\u039f\u00ea\3\2\2\2\u03a0\u039e")
buf.write(u"\3\2\2\2\u03a1\u03a5\7$\2\2\u03a2\u03a4\5\u00f9}\2\u03a3")
buf.write(u"\u03a2\3\2\2\2\u03a4\u03a7\3\2\2\2\u03a5\u03a3\3\2\2")
buf.write(u"\2\u03a5\u03a6\3\2\2\2\u03a6\u03a8\3\2\2\2\u03a7\u03a5")
buf.write(u"\3\2\2\2\u03a8\u03b2\7$\2\2\u03a9\u03ad\7)\2\2\u03aa")
buf.write(u"\u03ac\5\u00fb~\2\u03ab\u03aa\3\2\2\2\u03ac\u03af\3\2")
buf.write(u"\2\2\u03ad\u03ab\3\2\2\2\u03ad\u03ae\3\2\2\2\u03ae\u03b0")
buf.write(u"\3\2\2\2\u03af\u03ad\3\2\2\2\u03b0\u03b2\7)\2\2\u03b1")
buf.write(u"\u03a1\3\2\2\2\u03b1\u03a9\3\2\2\2\u03b2\u03b3\3\2\2")
buf.write(u"\2\u03b3\u03b4\bv\5\2\u03b4\u00ec\3\2\2\2\u03b5\u03bb")
buf.write(u"\7b\2\2\u03b6\u03b7\7^\2\2\u03b7\u03ba\7b\2\2\u03b8\u03ba")
buf.write(u"\n\r\2\2\u03b9\u03b6\3\2\2\2\u03b9\u03b8\3\2\2\2\u03ba")
buf.write(u"\u03bd\3\2\2\2\u03bb\u03b9\3\2\2\2\u03bb\u03bc\3\2\2")
buf.write(u"\2\u03bc\u03be\3\2\2\2\u03bd\u03bb\3\2\2\2\u03be\u03bf")
buf.write(u"\7b\2\2\u03bf\u00ee\3\2\2\2\u03c0\u03c2\t\16\2\2\u03c1")
buf.write(u"\u03c0\3\2\2\2\u03c2\u03c3\3\2\2\2\u03c3\u03c1\3\2\2")
buf.write(u"\2\u03c3\u03c4\3\2\2\2\u03c4\u03c5\3\2\2\2\u03c5\u03c6")
buf.write(u"\bx\2\2\u03c6\u00f0\3\2\2\2\u03c7\u03c8\t\2\2\2\u03c8")
buf.write(u"\u03c9\3\2\2\2\u03c9\u03ca\by\2\2\u03ca\u00f2\3\2\2\2")
buf.write(u"\u03cb\u03cc\7>\2\2\u03cc\u03cd\7#\2\2\u03cd\u03ce\7")
buf.write(u"/\2\2\u03ce\u03cf\7/\2\2\u03cf\u03d3\3\2\2\2\u03d0\u03d2")
buf.write(u"\13\2\2\2\u03d1\u03d0\3\2\2\2\u03d2\u03d5\3\2\2\2\u03d3")
buf.write(u"\u03d4\3\2\2\2\u03d3\u03d1\3\2\2\2\u03d4\u03d6\3\2\2")
buf.write(u"\2\u03d5\u03d3\3\2\2\2\u03d6\u03d7\7/\2\2\u03d7\u03d8")
buf.write(u"\7/\2\2\u03d8\u03d9\7@\2\2\u03d9\u03da\3\2\2\2\u03da")
buf.write(u"\u03db\bz\2\2\u03db\u00f4\3\2\2\2\u03dc\u03dd\7>\2\2")
buf.write(u"\u03dd\u03de\7#\2\2\u03de\u03df\7]\2\2\u03df\u03e0\7")
buf.write(u"E\2\2\u03e0\u03e1\7F\2\2\u03e1\u03e2\7C\2\2\u03e2\u03e3")
buf.write(u"\7V\2\2\u03e3\u03e4\7C\2\2\u03e4\u03e5\7]\2\2\u03e5\u03e9")
buf.write(u"\3\2\2\2\u03e6\u03e8\13\2\2\2\u03e7\u03e6\3\2\2\2\u03e8")
buf.write(u"\u03eb\3\2\2\2\u03e9\u03ea\3\2\2\2\u03e9\u03e7\3\2\2")
buf.write(u"\2\u03ea\u03ec\3\2\2\2\u03eb\u03e9\3\2\2\2\u03ec\u03ed")
buf.write(u"\7_\2\2\u03ed\u03ee\7_\2\2\u03ee\u03ef\7@\2\2\u03ef\u03f0")
buf.write(u"\3\2\2\2\u03f0\u03f1\b{\2\2\u03f1\u00f6\3\2\2\2\u03f2")
buf.write(u"\u03f3\13\2\2\2\u03f3\u03f4\3\2\2\2\u03f4\u03f5\b|\6")
buf.write(u"\2\u03f5\u00f8\3\2\2\2\u03f6\u03fb\n\17\2\2\u03f7\u03f8")
buf.write(u"\7^\2\2\u03f8\u03fb\5\u00fd\177\2\u03f9\u03fb\5\u010d")
buf.write(u"\u0087\2\u03fa\u03f6\3\2\2\2\u03fa\u03f7\3\2\2\2\u03fa")
buf.write(u"\u03f9\3\2\2\2\u03fb\u00fa\3\2\2\2\u03fc\u0401\n\20\2")
buf.write(u"\2\u03fd\u03fe\7^\2\2\u03fe\u0401\5\u00fd\177\2\u03ff")
buf.write(u"\u0401\5\u010d\u0087\2\u0400\u03fc\3\2\2\2\u0400\u03fd")
buf.write(u"\3\2\2\2\u0400\u03ff\3\2\2\2\u0401\u00fc\3\2\2\2\u0402")
buf.write(u"\u0408\5\u00ff\u0080\2\u0403\u0408\7\62\2\2\u0404\u0408")
buf.write(u"\5\u0101\u0081\2\u0405\u0408\5\u0103\u0082\2\u0406\u0408")
buf.write(u"\5\u0105\u0083\2\u0407\u0402\3\2\2\2\u0407\u0403\3\2")
buf.write(u"\2\2\u0407\u0404\3\2\2\2\u0407\u0405\3\2\2\2\u0407\u0406")
buf.write(u"\3\2\2\2\u0408\u00fe\3\2\2\2\u0409\u040c\5\u0107\u0084")
buf.write(u"\2\u040a\u040c\5\u0109\u0085\2\u040b\u0409\3\2\2\2\u040b")
buf.write(u"\u040a\3\2\2\2\u040c\u0100\3\2\2\2\u040d\u040e\7z\2\2")
buf.write(u"\u040e\u040f\5\u010f\u0088\2\u040f\u0410\5\u010f\u0088")
buf.write(u"\2\u0410\u0102\3\2\2\2\u0411\u0412\7w\2\2\u0412\u0413")
buf.write(u"\5\u010f\u0088\2\u0413\u0414\5\u010f\u0088\2\u0414\u0415")
buf.write(u"\5\u010f\u0088\2\u0415\u0416\5\u010f\u0088\2\u0416\u0422")
buf.write(u"\3\2\2\2\u0417\u0418\7w\2\2\u0418\u0419\7}\2\2\u0419")
buf.write(u"\u041b\5\u010f\u0088\2\u041a\u041c\5\u010f\u0088\2\u041b")
buf.write(u"\u041a\3\2\2\2\u041c\u041d\3\2\2\2\u041d\u041b\3\2\2")
buf.write(u"\2\u041d\u041e\3\2\2\2\u041e\u041f\3\2\2\2\u041f\u0420")
buf.write(u"\7\177\2\2\u0420\u0422\3\2\2\2\u0421\u0411\3\2\2\2\u0421")
buf.write(u"\u0417\3\2\2\2\u0422\u0104\3\2\2\2\u0423\u0424\7w\2\2")
buf.write(u"\u0424\u0426\7}\2\2\u0425\u0427\5\u010f\u0088\2\u0426")
buf.write(u"\u0425\3\2\2\2\u0427\u0428\3\2\2\2\u0428\u0426\3\2\2")
buf.write(u"\2\u0428\u0429\3\2\2\2\u0429\u042a\3\2\2\2\u042a\u042b")
buf.write(u"\7\177\2\2\u042b\u0106\3\2\2\2\u042c\u042d\t\21\2\2\u042d")
buf.write(u"\u0108\3\2\2\2\u042e\u042f\n\22\2\2\u042f\u010a\3\2\2")
buf.write(u"\2\u0430\u0433\5\u0107\u0084\2\u0431\u0433\t\23\2\2\u0432")
buf.write(u"\u0430\3\2\2\2\u0432\u0431\3\2\2\2\u0433\u010c\3\2\2")
buf.write(u"\2\u0434\u0435\7^\2\2\u0435\u0436\t\2\2\2\u0436\u010e")
buf.write(u"\3\2\2\2\u0437\u0438\t\24\2\2\u0438\u0110\3\2\2\2\u0439")
buf.write(u"\u0442\7\62\2\2\u043a\u043e\t\25\2\2\u043b\u043d\t\4")
buf.write(u"\2\2\u043c\u043b\3\2\2\2\u043d\u0440\3\2\2\2\u043e\u043c")
buf.write(u"\3\2\2\2\u043e\u043f\3\2\2\2\u043f\u0442\3\2\2\2\u0440")
buf.write(u"\u043e\3\2\2\2\u0441\u0439\3\2\2\2\u0441\u043a\3\2\2")
buf.write(u"\2\u0442\u0112\3\2\2\2\u0443\u0445\t\26\2\2\u0444\u0446")
buf.write(u"\t\27\2\2\u0445\u0444\3\2\2\2\u0445\u0446\3\2\2\2\u0446")
buf.write(u"\u0448\3\2\2\2\u0447\u0449\t\4\2\2\u0448\u0447\3\2\2")
buf.write(u"\2\u0449\u044a\3\2\2\2\u044a\u0448\3\2\2\2\u044a\u044b")
buf.write(u"\3\2\2\2\u044b\u0114\3\2\2\2\u044c\u0452\5\u0117\u008c")
buf.write(u"\2\u044d\u0452\5\u011b\u008e\2\u044e\u0452\5\u011d\u008f")
buf.write(u"\2\u044f\u0452\5\u011f\u0090\2\u0450\u0452\4\u200e\u200f")
buf.write(u"\2\u0451\u044c\3\2\2\2\u0451\u044d\3\2\2\2\u0451\u044e")
buf.write(u"\3\2\2\2\u0451\u044f\3\2\2\2\u0451\u0450\3\2\2\2\u0452")
buf.write(u"\u0116\3\2\2\2\u0453\u0458\5\u0119\u008d\2\u0454\u0458")
buf.write(u"\t\30\2\2\u0455\u0456\7^\2\2\u0456\u0458\5\u0103\u0082")
buf.write(u"\2\u0457\u0453\3\2\2\2\u0457\u0454\3\2\2\2\u0457\u0455")
buf.write(u"\3\2\2\2\u0458\u0118\3\2\2\2\u0459\u045b\t\31\2\2\u045a")
buf.write(u"\u0459\3\2\2\2\u045b\u011a\3\2\2\2\u045c\u045e\t\32\2")
buf.write(u"\2\u045d\u045c\3\2\2\2\u045e\u011c\3\2\2\2\u045f\u0461")
buf.write(u"\t\33\2\2\u0460\u045f\3\2\2\2\u0461\u011e\3\2\2\2\u0462")
buf.write(u"\u0464\t\34\2\2\u0463\u0462\3\2\2\2\u0464\u0120\3\2\2")
buf.write(u"\2\u0465\u0470\n\35\2\2\u0466\u0470\5\u0127\u0094\2\u0467")
buf.write(u"\u046b\7]\2\2\u0468\u046a\5\u0125\u0093\2\u0469\u0468")
buf.write(u"\3\2\2\2\u046a\u046d\3\2\2\2\u046b\u0469\3\2\2\2\u046b")
buf.write(u"\u046c\3\2\2\2\u046c\u046e\3\2\2\2\u046d\u046b\3\2\2")
buf.write(u"\2\u046e\u0470\7_\2\2\u046f\u0465\3\2\2\2\u046f\u0466")
buf.write(u"\3\2\2\2\u046f\u0467\3\2\2\2\u0470\u0122\3\2\2\2\u0471")
buf.write(u"\u047c\n\36\2\2\u0472\u047c\5\u0127\u0094\2\u0473\u0477")
buf.write(u"\7]\2\2\u0474\u0476\5\u0125\u0093\2\u0475\u0474\3\2\2")
buf.write(u"\2\u0476\u0479\3\2\2\2\u0477\u0475\3\2\2\2\u0477\u0478")
buf.write(u"\3\2\2\2\u0478\u047a\3\2\2\2\u0479\u0477\3\2\2\2\u047a")
buf.write(u"\u047c\7_\2\2\u047b\u0471\3\2\2\2\u047b\u0472\3\2\2\2")
buf.write(u"\u047b\u0473\3\2\2\2\u047c\u0124\3\2\2\2\u047d\u0480")
buf.write(u"\n\37\2\2\u047e\u0480\5\u0127\u0094\2\u047f\u047d\3\2")
buf.write(u"\2\2\u047f\u047e\3\2\2\2\u0480\u0126\3\2\2\2\u0481\u0482")
buf.write(u"\7^\2\2\u0482\u0483\n\2\2\2\u0483\u0128\3\2\2\2\66\2")
buf.write(u"\u0130\u0139\u0147\u0151\u0159\u01fe\u0206\u020a\u0211")
buf.write(u"\u0215\u0219\u021b\u0223\u022a\u0234\u023d\u0246\u0251")
buf.write(u"\u025c\u039e\u03a5\u03ad\u03b1\u03b9\u03bb\u03c3\u03d3")
buf.write(u"\u03e9\u03fa\u0400\u0407\u040b\u041d\u0421\u0428\u0432")
buf.write(u"\u043e\u0441\u0445\u044a\u0451\u0457\u045a\u045d\u0460")
buf.write(u"\u0463\u046b\u046f\u0477\u047b\u047f\7\2\3\2\3\n\2\3")
buf.write(u"\13\3\3v\4\2\4\2")
return buf.getvalue() | null |
157,313 | import collections
import itertools
import threading
import uuid
from google.cloud import batch_v1 as batch
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import task_utils
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.metrics import logs
from . import credentials
class BatchTask:
"""Class reprensenting a ClusterFuzz task to be executed on Google Cloud
Batch."""
def __init__(self, command, job_type, input_download_url):
self.command = command
self.job_type = job_type
self.input_download_url = input_download_url
def create_uworker_main_batch_jobs(batch_tasks):
"""Creates batch jobs."""
job_specs = collections.defaultdict(list)
for batch_task in batch_tasks:
logs.log(f'Scheduling {batch_task.command}, {batch_task.job_type}.')
spec = _get_spec_from_config(batch_task.command, batch_task.job_type)
job_specs[spec].append(batch_task.input_download_url)
logs.log('Creating batch jobs.')
jobs = []
logs.log('Batching utask_mains.')
for spec, input_urls in job_specs.items():
for input_urls_portion in _bunched(input_urls, MAX_CONCURRENT_VMS_PER_JOB):
jobs.append(_create_job(spec, input_urls_portion))
return jobs
def create_uworker_main_batch_job(module, job_type, input_download_url):
command = task_utils.get_command_from_module(module)
batch_tasks = [BatchTask(command, job_type, input_download_url)]
result = create_uworker_main_batch_jobs(batch_tasks)
if result is None:
return result
return result[0] | null |
157,314 | import collections
import itertools
import threading
import uuid
from google.cloud import batch_v1 as batch
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import task_utils
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.metrics import logs
from . import credentials
TASK_BUNCH_SIZE = 20
def _bunched(iterator, bunch_size):
"""Implementation of itertools.py's batched that was added after Python3.7."""
# TODO(metzman): Replace this with itertools.batched.
assert bunch_size > -1
idx = 0
bunch = []
for item in iterator:
idx += 1
bunch.append(item)
if idx == bunch_size:
idx = 0
yield bunch
bunch = []
if bunch:
yield bunch
def create_uworker_main_batch_jobs(batch_tasks):
"""Creates batch jobs."""
job_specs = collections.defaultdict(list)
for batch_task in batch_tasks:
logs.log(f'Scheduling {batch_task.command}, {batch_task.job_type}.')
spec = _get_spec_from_config(batch_task.command, batch_task.job_type)
job_specs[spec].append(batch_task.input_download_url)
logs.log('Creating batch jobs.')
jobs = []
logs.log('Batching utask_mains.')
for spec, input_urls in job_specs.items():
for input_urls_portion in _bunched(input_urls, MAX_CONCURRENT_VMS_PER_JOB):
jobs.append(_create_job(spec, input_urls_portion))
return jobs
The provided code snippet includes necessary dependencies for implementing the `create_uworker_main_batch_jobs_bunched` function. Write a Python function `def create_uworker_main_batch_jobs_bunched(batch_tasks)` to solve the following problem:
Creates batch jobs 20 tasks at a time, lazily. This is helpful to use when batch_tasks takes a very long time to create.
Here is the function:
def create_uworker_main_batch_jobs_bunched(batch_tasks):
"""Creates batch jobs 20 tasks at a time, lazily. This is helpful to use when
batch_tasks takes a very long time to create."""
# Use term bunch instead of "batch" since "batch" has nothing to do with the
# cloud service and is thus very confusing in this context.
jobs = [
create_uworker_main_batch_jobs(bunch)
for bunch in _bunched(batch_tasks, TASK_BUNCH_SIZE)
]
return list(itertools.chain(jobs)) | Creates batch jobs 20 tasks at a time, lazily. This is helpful to use when batch_tasks takes a very long time to create. |
157,315 | import base64
import collections
import json
import threading
import googleapiclient
import httplib2
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.google_cloud_utils import credentials
from clusterfuzz._internal.system import environment
class ReceivedMessage(Message):
"""Received pubsub message."""
def __init__(self, client, subscription, data, attributes, message_id,
publish_time, ack_id):
super().__init__(data, attributes)
self._client = client
self.ack_id = ack_id
self.message_id = message_id
self.subscription = subscription
self.publish_time = publish_time
def ack(self):
"""Acknowledge the message."""
self._client.ack(self.subscription, [self.ack_id])
def modify_ack_deadline(self, seconds):
"""Modify the acknowledgement deadline."""
self._client.modify_ack_deadline(self.subscription, [self.ack_id], seconds)
def _decode_data(raw_message):
"""Decode Pub/Sub data."""
return (base64.b64decode(raw_message['data'])
if 'data' in raw_message else None)
The provided code snippet includes necessary dependencies for implementing the `_raw_message_to_received_message` function. Write a Python function `def _raw_message_to_received_message(client, subscription, raw_message_response)` to solve the following problem:
Convert a raw message response to a Message.
Here is the function:
def _raw_message_to_received_message(client, subscription,
raw_message_response):
"""Convert a raw message response to a Message."""
raw_message = raw_message_response['message']
return ReceivedMessage(client, subscription, _decode_data(raw_message),
raw_message.get('attributes'),
raw_message['messageId'], raw_message['publishTime'],
raw_message_response['ackId']) | Convert a raw message response to a Message. |
157,316 | import base64
import collections
import json
import threading
import googleapiclient
import httplib2
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.google_cloud_utils import credentials
from clusterfuzz._internal.system import environment
The provided code snippet includes necessary dependencies for implementing the `_message_to_dict` function. Write a Python function `def _message_to_dict(message)` to solve the following problem:
Convert the message to a dict.
Here is the function:
def _message_to_dict(message):
"""Convert the message to a dict."""
result = {}
if message.data:
result['data'] = base64.b64encode(message.data).decode('utf-8')
if message.attributes:
result['attributes'] = message.attributes
return result | Convert the message to a dict. |
157,317 | import os
import re
import uuid
from google.cloud import ndb
from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import storage
def get_blob_info(blob_key):
"""Get the GcsBlobInfo for the given key. Always returns a
storage.GcsBlobInfo, even for legacy blobs."""
if _is_gcs_key(blob_key):
return storage.GcsBlobInfo.from_key(blob_key)
legacy_blob_info = get_legacy_blob_info(blob_key)
if not legacy_blob_info:
return None
return storage.GcsBlobInfo.from_legacy_blob_info(legacy_blob_info)
retries=FAIL_NUM_RETRIES,
delay=FAIL_WAIT,
function='google_cloud_utils.blobs.delete_blob',
retry_on_false=True)
The provided code snippet includes necessary dependencies for implementing the `get_blob_size` function. Write a Python function `def get_blob_size(blob_key)` to solve the following problem:
Returns blob size for a given blob key.
Here is the function:
def get_blob_size(blob_key):
"""Returns blob size for a given blob key."""
if not blob_key or blob_key == 'NA':
return None
blob_info = get_blob_info(blob_key)
if not blob_info:
return None
return blob_info.size | Returns blob size for a given blob key. |
157,318 | import datetime
import random
import time
from googleapiclient.discovery import build
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.metrics import logs
def _add_metadata_key_value(items, key, value):
"""Adds a metadata key/value to the "items" list from an instance's
metadata."""
replaced_existing = False
for item in items:
if item['key'] == key:
replaced_existing = True
item['value'] = value
break
if not replaced_existing:
items.append({'key': key, 'value': value})
def _do_operation_with_retries(operation, project, zone, wait_for_completion):
"""Execute an operation, retrying on any exceptions."""
response = _execute_api_call_with_retries(operation)
if response is None:
return False
if not wait_for_completion:
# No need to wait, so we are done.
return True
for _ in range(NUM_RETRIES + 1):
try:
# This could cause exceptions when the response is not ready.
_wait_for_operation(response, project, zone)
return True
except Exception:
logs.log_error('Failed to wait for Compute Engine operation. '
'Original response is %s.' % str(response))
time.sleep(SLEEP_TIME)
continue
return False
def _get_api():
"""Return the compute engine api object."""
return build('compute', 'v1', cache_discovery=False)
def _get_metadata_and_fingerprint(instance_name, project, zone):
"""Return the metadata values and fingerprint for the given instance."""
instance_info = _get_instance_info(instance_name, project, zone)
if not instance_info:
logs.log_error('Failed to fetch instance metadata')
return None, None
fingerprint = instance_info['metadata']['fingerprint']
metadata_items = instance_info['metadata']['items']
return metadata_items, fingerprint
The provided code snippet includes necessary dependencies for implementing the `add_metadata` function. Write a Python function `def add_metadata(instance_name, project, zone, key, value, wait_for_completion)` to solve the following problem:
Add metadata to an existing instance. Replaces existing metadata values with the same key.
Here is the function:
def add_metadata(instance_name, project, zone, key, value, wait_for_completion):
"""Add metadata to an existing instance. Replaces existing metadata values
with the same key."""
existing_metadata, fingerprint = _get_metadata_and_fingerprint(
instance_name, project, zone)
if not existing_metadata:
return False
_add_metadata_key_value(existing_metadata, key, value)
api = _get_api()
operation = api.instances().setMetadata(
body={
'fingerprint': fingerprint,
'items': existing_metadata,
},
instance=instance_name,
project=project,
zone=zone)
return _do_operation_with_retries(operation, project, zone,
wait_for_completion) | Add metadata to an existing instance. Replaces existing metadata values with the same key. |
157,319 | import datetime
import random
import time
from googleapiclient.discovery import build
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.metrics import logs
GCE_INSTANCE_INFO_KEY = 'gce_instance_info'
def _add_metadata_key_value(items, key, value):
"""Adds a metadata key/value to the "items" list from an instance's
metadata."""
replaced_existing = False
for item in items:
if item['key'] == key:
replaced_existing = True
item['value'] = value
break
if not replaced_existing:
items.append({'key': key, 'value': value})
def _do_operation_with_retries(operation, project, zone, wait_for_completion):
"""Execute an operation, retrying on any exceptions."""
response = _execute_api_call_with_retries(operation)
if response is None:
return False
if not wait_for_completion:
# No need to wait, so we are done.
return True
for _ in range(NUM_RETRIES + 1):
try:
# This could cause exceptions when the response is not ready.
_wait_for_operation(response, project, zone)
return True
except Exception:
logs.log_error('Failed to wait for Compute Engine operation. '
'Original response is %s.' % str(response))
time.sleep(SLEEP_TIME)
continue
return False
def _do_instance_operation(operation, instance_name, project, zone,
wait_for_completion):
"""Do a start/reset/stop on the compute engine instance in the given project
and zone."""
api = _get_api()
operation_func = getattr(api.instances(), operation)
operation = operation_func(instance=instance_name, project=project, zone=zone)
return _do_operation_with_retries(
operation, project, zone, wait_for_completion=wait_for_completion)
def _execute_api_call_with_retries(api_func):
"""Execute the given API call, retrying if necessary. Returns the response if
successful, or None."""
last_exception = None
for i in range(NUM_RETRIES + 1):
try:
# Try to execute the operation.
response = api_func.execute()
last_exception = None
break
except Exception as e:
# Exponential backoff.
last_exception = str(e)
sleep_time = random.uniform(1, SLEEP_TIME * (1 << i))
time.sleep(sleep_time)
continue
if last_exception is not None:
# Failed, log exception with as much information as we can.
if hasattr(api_func, 'uri'):
uri = api_func.uri
else:
uri = 'unknown'
logs.log_error('Compute engine API call "%s" failed with exception:\n%s' %
(uri, last_exception))
return None
return response
def _get_api():
"""Return the compute engine api object."""
return build('compute', 'v1', cache_discovery=False)
def _get_instance_info(instance_name, project, zone):
"""Return the instance information for a given instance."""
api = _get_api()
instance_info_func = api.instances().get(
instance=instance_name, project=project, zone=zone)
return _execute_api_call_with_retries(instance_info_func)
def create_disk(disk_name,
source_image,
size_gb,
project,
zone,
wait_for_completion=False):
"""Create a disk."""
api = _get_api()
operation = api.disks().insert(
body={
'name': disk_name,
'sizeGb': size_gb,
},
sourceImage=source_image,
project=project,
zone=zone)
return _do_operation_with_retries(
operation, project, zone, wait_for_completion=wait_for_completion)
def delete_disk(disk_name, project, zone, wait_for_completion=False):
"""Delete a disk."""
api = _get_api()
operation = api.disks().delete(disk=disk_name, project=project, zone=zone)
return _do_operation_with_retries(
operation, project, zone, wait_for_completion=wait_for_completion)
The provided code snippet includes necessary dependencies for implementing the `recreate_instance_with_disks` function. Write a Python function `def recreate_instance_with_disks(instance_name, project, zone, additional_metadata=None, wait_for_completion=False)` to solve the following problem:
Recreate an instance and its disk.
Here is the function:
def recreate_instance_with_disks(instance_name,
project,
zone,
additional_metadata=None,
wait_for_completion=False):
"""Recreate an instance and its disk."""
# Get existing instance information.
# First, try to get instance info from cache.
# TODO(ochang): Make this more general in case anything else needs to use
# this method (e.g. appengine).
instance_info = persistent_cache.get_value(GCE_INSTANCE_INFO_KEY)
if instance_info is None:
instance_info = _get_instance_info(instance_name, project, zone)
# Bail out if we don't have a valid instance information.
if (not instance_info or 'disks' not in instance_info or
not instance_info['disks']):
logs.log_error(
'Failed to get disk info from existing instance, bailing on instance '
'recreation.')
return False
# Add any additional metadata required for instance booting.
if additional_metadata:
for key, value in additional_metadata.items():
items = instance_info.setdefault('metadata', {}).setdefault('items', [])
_add_metadata_key_value(items, key, value)
# Cache the latest instance information.
persistent_cache.set_value(
GCE_INSTANCE_INFO_KEY, instance_info, persist_across_reboots=True)
# Delete the instance.
if not _do_instance_operation(
'delete', instance_name, project, zone, wait_for_completion=True):
logs.log_error('Failed to delete instance.')
return False
# Get existing disks information, and recreate.
api = _get_api()
disks = instance_info['disks']
for disk in disks:
disk_source = disk['source']
disk_name = disk_source.split('/')[-1]
disk_info_func = api.disks().get(disk=disk_name, project=project, zone=zone)
disk_info = _execute_api_call_with_retries(disk_info_func)
if 'sourceImage' not in disk_info or 'sizeGb' not in disk_info:
logs.log_error(
'Failed to get source image and size from existing disk, bailing on '
'instance recreation.')
return False
size_gb = disk_info['sizeGb']
source_image = disk_info['sourceImage']
# Recreate the disk.
if not delete_disk(disk_name, project, zone, wait_for_completion=True):
logs.log_error('Failed to delete disk.')
return False
if not create_disk(
disk_name,
source_image,
size_gb,
project,
zone,
wait_for_completion=True):
logs.log_error('Failed to recreate disk.')
return False
# Recreate the instance with the exact same configurations, but not
# necessarily the same IPs.
try:
del instance_info['networkInterfaces'][0]['accessConfigs'][0]['natIP']
except:
# This is not a failure. When a bot is stopped, it has no ip/interface.
pass
try:
del instance_info['networkInterfaces'][0]['networkIP']
except:
# This is not a failure. When a bot is stopped, it has no ip/interface.
pass
operation = api.instances().insert(
body=instance_info, project=project, zone=zone)
return _do_operation_with_retries(
operation, project, zone, wait_for_completion=wait_for_completion) | Recreate an instance and its disk. |
157,320 | import datetime
import random
import time
from googleapiclient.discovery import build
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.metrics import logs
def _do_operation_with_retries(operation, project, zone, wait_for_completion):
"""Execute an operation, retrying on any exceptions."""
response = _execute_api_call_with_retries(operation)
if response is None:
return False
if not wait_for_completion:
# No need to wait, so we are done.
return True
for _ in range(NUM_RETRIES + 1):
try:
# This could cause exceptions when the response is not ready.
_wait_for_operation(response, project, zone)
return True
except Exception:
logs.log_error('Failed to wait for Compute Engine operation. '
'Original response is %s.' % str(response))
time.sleep(SLEEP_TIME)
continue
return False
def _get_api():
"""Return the compute engine api object."""
return build('compute', 'v1', cache_discovery=False)
def _get_metadata_and_fingerprint(instance_name, project, zone):
"""Return the metadata values and fingerprint for the given instance."""
instance_info = _get_instance_info(instance_name, project, zone)
if not instance_info:
logs.log_error('Failed to fetch instance metadata')
return None, None
fingerprint = instance_info['metadata']['fingerprint']
metadata_items = instance_info['metadata']['items']
return metadata_items, fingerprint
The provided code snippet includes necessary dependencies for implementing the `remove_metadata` function. Write a Python function `def remove_metadata(instance_name, project, zone, key, wait_for_completion)` to solve the following problem:
Remove a metadata key/value from an existing instance.
Here is the function:
def remove_metadata(instance_name, project, zone, key, wait_for_completion):
"""Remove a metadata key/value from an existing instance."""
existing_metadata, fingerprint = _get_metadata_and_fingerprint(
instance_name, project, zone)
if not existing_metadata:
return False
filtered_metadata = []
for item in existing_metadata:
if item['key'] != key:
filtered_metadata.append(item)
if len(filtered_metadata) == len(existing_metadata):
# Nothing to do.
return True
api = _get_api()
operation = api.instances().setMetadata(
body={
'fingerprint': fingerprint,
'items': filtered_metadata,
},
instance=instance_name,
project=project,
zone=zone)
return _do_operation_with_retries(operation, project, zone,
wait_for_completion) | Remove a metadata key/value from an existing instance. |
157,321 | import datetime
import random
import time
from googleapiclient.discovery import build
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.metrics import logs
def _do_instance_operation(operation, instance_name, project, zone,
wait_for_completion):
"""Do a start/reset/stop on the compute engine instance in the given project
and zone."""
api = _get_api()
operation_func = getattr(api.instances(), operation)
operation = operation_func(instance=instance_name, project=project, zone=zone)
return _do_operation_with_retries(
operation, project, zone, wait_for_completion=wait_for_completion)
The provided code snippet includes necessary dependencies for implementing the `reset_instance` function. Write a Python function `def reset_instance(instance_name, project, zone, wait_for_completion=False)` to solve the following problem:
Reset an instance.
Here is the function:
def reset_instance(instance_name, project, zone, wait_for_completion=False):
"""Reset an instance."""
return _do_instance_operation('reset', instance_name, project, zone,
wait_for_completion) | Reset an instance. |
157,322 | from collections import namedtuple
import os
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.system import environment
def _config_to_project(name, config):
"""Read a project config."""
clusters = []
for cluster_name, zone in config['clusters'].items():
clusters.append(
Cluster(
name=cluster_name,
gce_zone=zone['gce_zone'],
instance_count=zone['instance_count'],
instance_template=zone['instance_template'],
distribute=zone.get('distribute', False),
auto_healing_policy=zone.get('auto_healing_policy', {}),
worker=zone.get('worker', False),
high_end=zone.get('high_end', False)))
for instance_template in config['instance_templates']:
_process_instance_template(instance_template)
host_worker_assignments = []
for assignment in config.get('host_worker_assignments', []):
host_worker_assignments.append(
HostWorkerAssignment(
host=assignment['host'],
worker=assignment['worker'],
workers_per_host=assignment['workers_per_host']))
return Project(name, clusters, config['instance_templates'],
host_worker_assignments)
def _project_configs():
return local_config.Config(local_config.GCE_CLUSTERS_PATH).get()
def get_projects():
projects = []
for name, project in _project_configs().items():
projects.append(_config_to_project(name, project))
return projects | null |
157,323 | from collections import namedtuple
import os
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.system import environment
def _config_to_project(name, config):
def _project_configs():
def load_project(project_name):
config = _project_configs().get(project_name)
if not config:
return None
return _config_to_project(project_name, config) | null |
157,324 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
SIGNED_URL_EXPIRATION_MINUTES = 24 * 60
def _storage_client():
"""Get the storage client, creating it if it does not exist."""
if not hasattr(_local, 'client'):
_local.client = _create_storage_client_new()
return _local.client
def _signing_creds():
if not hasattr(_local, 'signing_creds'):
_new_signing_creds()
return _local.signing_creds
def get_bucket_name_and_path(cloud_storage_file_path):
"""Return bucket name and path given a full cloud storage path."""
filtered_path = utils.strip_from_left(cloud_storage_file_path, GS_PREFIX)
_, bucket_name_and_path = filtered_path.split('/', 1)
if '/' in bucket_name_and_path:
bucket_name, path = bucket_name_and_path.split('/', 1)
else:
bucket_name = bucket_name_and_path
path = ''
return bucket_name, path
def _integration_test_env_doesnt_support_signed_urls():
return environment.get_value('UTASK_TESTS') or environment.get_value(
'UNTRUSTED_RUNNER_TESTS')
retries=1,
delay=1,
function='google_cloud_utils.storage._download_url',
exception_types=_TRANSIENT_ERRORS)
The provided code snippet includes necessary dependencies for implementing the `_sign_url` function. Write a Python function `def _sign_url(remote_path, minutes=SIGNED_URL_EXPIRATION_MINUTES, method='GET')` to solve the following problem:
Returns a signed URL for |remote_path| with |method|.
Here is the function:
def _sign_url(remote_path, minutes=SIGNED_URL_EXPIRATION_MINUTES, method='GET'):
"""Returns a signed URL for |remote_path| with |method|."""
if _integration_test_env_doesnt_support_signed_urls():
return remote_path
minutes = datetime.timedelta(minutes=minutes)
bucket_name, object_path = get_bucket_name_and_path(remote_path)
signing_creds, access_token = _signing_creds()
client = _storage_client()
bucket = client.bucket(bucket_name)
blob = bucket.blob(object_path)
return blob.generate_signed_url(
version='v4',
expiration=minutes,
method=method,
credentials=signing_creds,
access_token=access_token,
service_account_email=signing_creds.service_account_email) | Returns a signed URL for |remote_path| with |method|. |
157,325 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
The provided code snippet includes necessary dependencies for implementing the `generate_life_cycle_config` function. Write a Python function `def generate_life_cycle_config(action, age=None, num_newer_versions=None)` to solve the following problem:
Generate GCS lifecycle management config. For the reference, see https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/managing-lifecycles.
Here is the function:
def generate_life_cycle_config(action, age=None, num_newer_versions=None):
"""Generate GCS lifecycle management config.
For the reference, see https://cloud.google.com/storage/docs/lifecycle and
https://cloud.google.com/storage/docs/managing-lifecycles.
"""
rule = {}
rule['action'] = {'type': action}
rule['condition'] = {}
if age is not None:
rule['condition']['age'] = age
if num_newer_versions is not None:
rule['condition']['numNewerVersions'] = num_newer_versions
config = {'rule': [rule]}
return config | Generate GCS lifecycle management config. For the reference, see https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/managing-lifecycles. |
157,326 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
def _provider():
"""Get the current storage provider."""
local_buckets_path = environment.get_value('LOCAL_GCS_BUCKETS_PATH')
if local_buckets_path:
return FileSystemProvider(local_buckets_path)
return GcsProvider()
The provided code snippet includes necessary dependencies for implementing the `write_stream` function. Write a Python function `def write_stream(stream, cloud_storage_file_path, metadata=None)` to solve the following problem:
Return content of a cloud storage file.
Here is the function:
def write_stream(stream, cloud_storage_file_path, metadata=None):
"""Return content of a cloud storage file."""
return _provider().write_stream(
stream, cloud_storage_file_path, metadata=metadata) | Return content of a cloud storage file. |
157,327 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
def get(cloud_storage_file_path):
"""Get GCS object data."""
return _provider().get(cloud_storage_file_path)
retries=DEFAULT_FAIL_RETRIES,
delay=DEFAULT_FAIL_WAIT,
function='google_cloud_utils.storage.get_acl')
The provided code snippet includes necessary dependencies for implementing the `get_object_size` function. Write a Python function `def get_object_size(cloud_storage_file_path)` to solve the following problem:
Get the metadata for a file.
Here is the function:
def get_object_size(cloud_storage_file_path):
"""Get the metadata for a file."""
gcs_object = get(cloud_storage_file_path)
if not gcs_object:
return gcs_object
return int(gcs_object['size']) | Get the metadata for a file. |
157,328 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
HTTP_TIMEOUT_SECONDS = 15
def read_data(cloud_storage_file_path):
"""Return content of a cloud storage file."""
return _provider().read_data(cloud_storage_file_path)
retries=DEFAULT_FAIL_RETRIES,
delay=DEFAULT_FAIL_WAIT,
function='google_cloud_utils.storage.write_data',
exception_types=_TRANSIENT_ERRORS)
def get(cloud_storage_file_path):
"""Get GCS object data."""
return _provider().get(cloud_storage_file_path)
retries=DEFAULT_FAIL_RETRIES,
delay=DEFAULT_FAIL_WAIT,
function='google_cloud_utils.storage.get_acl')
def _integration_test_env_doesnt_support_signed_urls():
return environment.get_value('UTASK_TESTS') or environment.get_value(
'UNTRUSTED_RUNNER_TESTS')
retries=1,
delay=1,
function='google_cloud_utils.storage._download_url',
exception_types=_TRANSIENT_ERRORS)
The provided code snippet includes necessary dependencies for implementing the `_download_url` function. Write a Python function `def _download_url(url)` to solve the following problem:
Downloads |url| and returns the contents.
Here is the function:
def _download_url(url):
"""Downloads |url| and returns the contents."""
if _integration_test_env_doesnt_support_signed_urls():
return read_data(url)
request = requests.get(url, timeout=HTTP_TIMEOUT_SECONDS)
if not request.ok:
raise RuntimeError('Request to %s failed. Code: %d. Reason: %s' %
(url, request.status_code, request.reason))
return request.content | Downloads |url| and returns the contents. |
157,329 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
def _pool(pool_size=16):
if (environment.get_value('PY_UNITTESTS') or
environment.platform() == 'WINDOWS'):
yield futures.ThreadPoolExecutor(pool_size)
else:
yield futures.ProcessPoolExecutor(pool_size)
def _error_tolerant_upload_signed_url(url_and_path):
url, path = url_and_path
with open(path, 'rb') as fp:
return upload_signed_url(fp, url)
def upload_signed_urls(signed_urls, files):
logs.log('Uploading URLs.')
with _pool() as pool:
result = list(
pool.map(_error_tolerant_upload_signed_url, zip(signed_urls, files)))
logs.log('Done uploading URLs.')
return result | null |
157,330 | from concurrent import futures
import contextlib
import copy
import datetime
import json
import os
import shutil
import threading
import time
import uuid
import google.auth.exceptions
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
import requests.exceptions
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import credentials
def _pool(pool_size=16):
if (environment.get_value('PY_UNITTESTS') or
environment.platform() == 'WINDOWS'):
yield futures.ThreadPoolExecutor(pool_size)
else:
yield futures.ProcessPoolExecutor(pool_size)
def _error_tolerant_delete_signed_url(url):
try:
return delete_signed_url(url)
except Exception:
return False
def delete_signed_urls(urls):
logs.log('Deleting URLs.')
with _pool() as pool:
result = list(pool.map(_error_tolerant_delete_signed_url, urls))
logs.log('Done deleting URLs.')
return result | null |
157,331 | import collections
import datetime
import re
import time
from googleapiclient import discovery
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.google_cloud_utils import credentials
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
def convert_row(raw_row, fields):
"""Convert a single raw row (from BigQuery) to a dict."""
row = {}
for index, raw_value in enumerate(raw_row['f']):
field = fields[index]
if field['mode'] == 'REPEATED':
row[field['name']] = []
for item in raw_value['v']:
row[field['name']].append(cast(item['v'], field))
else:
row[field['name']] = cast(raw_value['v'], field)
return row
The provided code snippet includes necessary dependencies for implementing the `convert` function. Write a Python function `def convert(result)` to solve the following problem:
Convert a query result into an array of dicts, each of which represents a row.
Here is the function:
def convert(result):
"""Convert a query result into an array of dicts, each of which represents
a row."""
fields = result['schema']['fields']
rows = []
for raw_row in result.get('rows', []):
rows.append(convert_row(raw_row, fields))
return rows | Convert a query result into an array of dicts, each of which represents a row. |
157,332 | import collections
import datetime
import re
import time
from googleapiclient import discovery
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.google_cloud_utils import credentials
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
The provided code snippet includes necessary dependencies for implementing the `_get_max_results` function. Write a Python function `def _get_max_results(max_results, limit, count_so_far)` to solve the following problem:
Get an appropriate max_results.
Here is the function:
def _get_max_results(max_results, limit, count_so_far):
"""Get an appropriate max_results."""
# limit is None means we get every record (no limit).
if limit is None:
return max_results
return min(max_results, limit - count_so_far) | Get an appropriate max_results. |
157,333 | import os
import shutil
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
The provided code snippet includes necessary dependencies for implementing the `_get_gsutil_path` function. Write a Python function `def _get_gsutil_path()` to solve the following problem:
Get path to gsutil executable. Returns: Path to gsutil executable on the system.
Here is the function:
def _get_gsutil_path():
"""Get path to gsutil executable.
Returns:
Path to gsutil executable on the system.
"""
gsutil_executable = 'gsutil'
if environment.platform() == 'WINDOWS':
gsutil_executable += '.cmd'
gsutil_directory = environment.get_value('GSUTIL_PATH')
if not gsutil_directory:
# Try searching the binary in path.
gsutil_absolute_path = shutil.which(gsutil_executable)
if gsutil_absolute_path:
return gsutil_absolute_path
logs.log_error('Cannot locate gsutil in PATH, set GSUTIL_PATH to directory '
'containing gsutil binary.')
return None
gsutil_absolute_path = os.path.join(gsutil_directory, gsutil_executable)
return gsutil_absolute_path | Get path to gsutil executable. Returns: Path to gsutil executable on the system. |
157,334 | import os
import shutil
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
The provided code snippet includes necessary dependencies for implementing the `_multiprocessing_args` function. Write a Python function `def _multiprocessing_args()` to solve the following problem:
Get multiprocessing args for gsutil.
Here is the function:
def _multiprocessing_args():
"""Get multiprocessing args for gsutil."""
if utils.cpu_count() == 1:
# GSUtil's default thread count is 5 as it assumes the common configuration
# is many CPUs (GSUtil uses num_cpu processes).
return ['-o', 'GSUtil:parallel_thread_count=16']
return [] | Get multiprocessing args for gsutil. |
157,335 | import os
import shutil
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
The provided code snippet includes necessary dependencies for implementing the `_filter_path` function. Write a Python function `def _filter_path(path, write=False)` to solve the following problem:
Filters path if needed. In local development environment, this uses local paths from an emulated GCS instead of real GCS. `write` indicates whether if `path` is a GCS write destination and that intermediate paths should be automatically created.
Here is the function:
def _filter_path(path, write=False):
"""Filters path if needed. In local development environment, this uses local
paths from an emulated GCS instead of real GCS. `write` indicates whether if
`path` is a GCS write destination and that intermediate paths should be
automatically created."""
if not path.startswith(storage.GS_PREFIX):
# Only applicable to GCS paths.
return path
local_buckets_path = environment.get_value('LOCAL_GCS_BUCKETS_PATH')
if not local_buckets_path:
return path
if write:
local_path = storage.FileSystemProvider(
local_buckets_path).convert_path_for_write(path)
else:
local_path = storage.FileSystemProvider(local_buckets_path).convert_path(
path)
return local_path | Filters path if needed. In local development environment, this uses local paths from an emulated GCS instead of real GCS. `write` indicates whether if `path` is a GCS write destination and that intermediate paths should be automatically created. |
157,336 | import datetime
from googleapiclient import discovery
from clusterfuzz._internal.base import retry
from . import credential_storage
from .comment import Comment
from .issue import ChangeList
from .issue import Issue
def parse_datetime(date_string):
"""Parse a date time string into a datetime object."""
datetime_obj, _, microseconds_string = date_string.partition('.')
datetime_obj = datetime.datetime.strptime(datetime_obj, '%Y-%m-%dT%H:%M:%S')
if microseconds_string:
microseconds = int(microseconds_string.rstrip('Z'), 10)
return datetime_obj + datetime.timedelta(microseconds=microseconds)
return datetime_obj
class Comment:
"""Class representing a single comment update."""
def __init__(self):
self.author = None
self.cc = None
self.comment = None
self.components = []
self.created = None
self.labels = []
self.summary = None
self.status = None
self.owner = None
self.id = 0
def has_label_containing(self, expression):
return any(self.get_labels_containing(expression))
def get_labels_containing(self, expression):
regex = re.compile(expression, re.DOTALL | re.IGNORECASE)
return [label for label in self.labels if regex.search(label)]
def has_label_matching(self, expression):
return any(self.get_labels_matching(expression))
def get_labels_matching(self, expression):
regex = re.compile(expression + r'\Z', re.DOTALL | re.IGNORECASE)
return [label for label in self.labels if regex.match(label)]
def get_labels_by_prefix(self, prefix):
return self.get_labels_matching('%s.*' % prefix)
def has_label(self, value):
for label in self.labels:
if label.lower() == value.lower():
return True
return False
class ChangeList(list):
"""List that tracks changes for incremental updates."""
def __init__(self, seq=()):
super().__init__(seq)
self.added = set()
self.removed = set()
def append(self, p_object):
list.append(self, p_object)
if p_object in self.removed:
self.removed.remove(p_object)
else:
self.added.add(p_object)
def remove(self, value):
list.remove(self, value)
if value in self.added:
self.added.remove(value)
else:
self.removed.add(value)
def is_changed(self):
return (len(self.added) + len(self.removed)) > 0
def reset(self):
self.added.clear()
self.removed.clear()
The provided code snippet includes necessary dependencies for implementing the `convert_entry_to_comment` function. Write a Python function `def convert_entry_to_comment(entry)` to solve the following problem:
Convert an issue entry object into a comment object.
Here is the function:
def convert_entry_to_comment(entry):
"""Convert an issue entry object into a comment object."""
comment = Comment()
comment.author = entry['author']['name'] if 'author' in entry else None
comment.comment = entry['content']
comment.created = parse_datetime(entry['published'])
comment.id = entry['id']
if 'updates' in entry and entry['updates']:
comment.cc = ChangeList(entry['updates'].get('cc', []))
comment.components = ChangeList(entry['updates'].get('components', []))
comment.labels = ChangeList(entry['updates'].get('labels', []))
comment.owner = entry['updates'].get('owner', None)
comment.status = entry['updates'].get('status', None)
comment.summary = entry['updates'].get('summary', None)
return comment | Convert an issue entry object into a comment object. |
157,337 | import datetime
from googleapiclient import discovery
from clusterfuzz._internal.base import retry
from . import credential_storage
from .comment import Comment
from .issue import ChangeList
from .issue import Issue
def parse_datetime(date_string):
"""Parse a date time string into a datetime object."""
datetime_obj, _, microseconds_string = date_string.partition('.')
datetime_obj = datetime.datetime.strptime(datetime_obj, '%Y-%m-%dT%H:%M:%S')
if microseconds_string:
microseconds = int(microseconds_string.rstrip('Z'), 10)
return datetime_obj + datetime.timedelta(microseconds=microseconds)
return datetime_obj
class ChangeList(list):
"""List that tracks changes for incremental updates."""
def __init__(self, seq=()):
super().__init__(seq)
self.added = set()
self.removed = set()
def append(self, p_object):
list.append(self, p_object)
if p_object in self.removed:
self.removed.remove(p_object)
else:
self.added.add(p_object)
def remove(self, value):
list.remove(self, value)
if value in self.added:
self.added.remove(value)
else:
self.removed.add(value)
def is_changed(self):
return (len(self.added) + len(self.removed)) > 0
def reset(self):
self.added.clear()
self.removed.clear()
class Issue:
"""Class representing a single issue."""
def __init__(self):
self.blocking = None
self.blocked_on = None
self.body = None
self.depends_on = None
self.cc = ChangeList()
self.closed = None
self.comment = ''
self.components = ChangeList()
self.created = None
self.id = 0
self.labels = ChangeList()
self.merged_into = None
self.merged_into_project = None
self.open = False
self.owner = None
self.reporter = None
self.status = None
self.stars = 0
self.summary = None
self.updated = None
self.dirty = False
self.send_email = True
self.new = True
self.itm = None
self.project_name = None
self.comments = None
self.comment_count = 0
self.first_comment = None
self.last_comment = None
self.changed = set()
def __getattribute__(self, item):
if item in ['body'] and not object.__getattribute__(self, item):
comment = self.get_first_comment()
self.__setattr__(item, comment.comment)
return object.__getattribute__(self, item)
def __setattr__(self, name, value):
self.__dict__[name] = value
if 'changed' in self.__dict__:
self.__dict__['changed'].add(name)
# Automatically set the project name if the itm is set.
if name == 'itm' and value and hasattr(value, 'project_name'):
self.__dict__['project_name'] = value.project_name
# Treat comments and dirty flag specially.
if name not in ('dirty', 'body', 'comments', 'itm', 'new', 'comment_count',
'first_comment', 'last_comment', 'project_name', 'changed',
'send_email'):
self.__dict__['dirty'] = True
if name in ('dirty') and not value:
self.labels.reset()
self.cc.reset()
if 'changed' in self.__dict__:
self.changed.clear()
def __getstate__(self):
"""Ensure that we don't pickle the itm.
This would raise an exception due to the way the apiary folks did their
information (i.e. OAuth kicking us once again).
"""
result_dict = self.__dict__.copy()
del result_dict['itm']
return result_dict
def __setstate__(self, new_dict):
self.__dict__.update(new_dict)
self.itm = None
def _remove_tracked_value(self, target, value):
for existing_value in target:
if existing_value.lower() == value.lower():
target.remove(existing_value)
self.dirty = True
return
def add_component(self, component):
if not self.has_component(component):
self.components.append(component)
self.dirty = True
def remove_component(self, component):
if self.has_component(component):
self._remove_tracked_value(self.components, component)
self.add_component('-%s' % component)
def remove_components_by_prefix(self, prefix):
components = self.get_components_by_prefix(prefix)
for component in components:
self.remove_label(component)
def add_label(self, label):
if not self.has_label(label):
self.labels.append(label)
self.dirty = True
def remove_label(self, label):
if self.has_label(label):
self._remove_tracked_value(self.labels, label)
self.add_label('-%s' % label)
def remove_label_by_prefix(self, prefix):
labels = self.get_labels_by_prefix(prefix)
for label in labels:
self.remove_label(label)
def add_cc(self, cc):
if not self.has_cc(cc):
self.cc.append(cc)
self.dirty = True
def remove_cc(self, cc):
if self.has_cc(cc):
self.cc.remove(cc)
self.dirty = True
def get_components_by_prefix(self, prefix):
return get_values_matching(self.components, '%s.*' % prefix)
def get_components_containing(self, expression):
return get_values_containing(self.components, expression)
def get_components_matching(self, expression):
return get_values_matching(self.components, expression)
def has_components_containing(self, expression):
return has_values_containing(self.components, expression)
def has_components_matching(self, expression):
return has_values_matching(self.components, expression)
def has_component(self, value):
return has_value(self.components, value)
def get_labels_by_prefix(self, prefix):
return get_values_matching(self.labels, '%s.*' % prefix)
def get_labels_containing(self, expression):
return get_values_containing(self.labels, expression)
def get_labels_matching(self, expression):
return get_values_matching(self.labels, expression)
def has_label_by_prefix(self, prefix):
return has_values_containing(self.labels, '%s.*' % prefix)
def has_label_containing(self, expression):
return has_values_containing(self.labels, expression)
def has_label_matching(self, expression):
return has_values_matching(self.labels, expression)
def has_label(self, value):
return has_value(self.labels, value)
def has_cc(self, value):
return has_value(self.cc, value)
def has_comment_with_label(self, label):
for comment in self.get_comments():
if comment.has_label(label):
return True
return False
def has_comment_with_label_by_prefix(self, prefix):
for comment in self.get_comments():
if comment.get_labels_by_prefix(prefix):
return True
return False
def get_comments(self):
if not self.comments and self.itm:
self.comments = self.itm.get_comments(self.id)
self.comment_count = len(self.comments)
return self.comments
def get_first_comment(self):
if not self.first_comment and self.itm:
self.first_comment = self.itm.get_first_comment(self.id)
return self.first_comment
def get_last_comment(self):
if not self.last_comment and self.itm:
self.last_comment = self.itm.get_last_comment(self.id)
return self.last_comment
def get_comment_count(self):
if not self.comment_count and self.itm:
self.comment_count = self.itm.get_comment_count(self.id)
return self.comment_count
def save(self, send_email=None):
if self.itm:
self.itm.save(self, send_email)
def refresh(self):
if self.itm:
self.comments = None
self.last_comment = None
self.comment_count = 0
self.itm.refresh(self)
return self
The provided code snippet includes necessary dependencies for implementing the `convert_entry_to_issue` function. Write a Python function `def convert_entry_to_issue(entry, itm, old_issue=None)` to solve the following problem:
Convert an issue entry object into a issue object.
Here is the function:
def convert_entry_to_issue(entry, itm, old_issue=None):
"""Convert an issue entry object into a issue object."""
if old_issue:
issue = old_issue
else:
issue = Issue()
issue.blocked_on = [e['issueId'] for e in entry.get('blockedOn', [])]
issue.blocking = [e['issueId'] for e in entry.get('blocking', [])]
issue.cc = ChangeList([e['name'] for e in entry.get('cc', [])])
issue.comments = None
issue.components = ChangeList(entry.get('components', []))
issue.created = parse_datetime(entry['published'])
issue.id = entry['id']
issue.itm = itm
issue.labels = ChangeList(entry.get('labels', []))
issue.new = False
issue.open = entry['state'] == 'open'
issue.reporter = entry['author']['name'] if 'author' in entry else None
issue.stars = entry['stars']
issue.summary = entry['summary']
issue.updated = parse_datetime(entry['updated'])
if entry.get('closed', []):
issue.closed = parse_datetime(entry.get('closed', []))
if entry.get('mergedInto'):
issue.merged_into = entry['mergedInto'].get('issueId')
issue.merged_into_project = entry['mergedInto'].get('projectId')
if entry.get('owner', []):
issue.owner = entry['owner']['name']
if entry.get('status', []):
issue.status = entry['status']
# The issue will be flagged as dirty when most of the above fields are set,
# so this must be set last.
issue.dirty = False
return issue | Convert an issue entry object into a issue object. |
157,338 | import re
def get_values_containing(target, expression):
regex = re.compile(expression, re.DOTALL | re.IGNORECASE)
return [value for value in target if regex.search(value)]
def has_values_containing(target, expression):
return any(get_values_containing(target, expression)) | null |
157,339 | import re
def get_values_matching(target, expression):
regex = re.compile(expression + r'\Z', re.DOTALL | re.IGNORECASE)
return [value for value in target if regex.match(value)]
def has_values_matching(target, expression):
return any(get_values_matching(target, expression)) | null |
157,340 | import re
def has_value(target, value):
for target_value in target:
if target_value.lower() == value.lower():
return True
return False | null |
157,341 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_extract_all_labels` function. Write a Python function `def _extract_all_labels(labels, prefix)` to solve the following problem:
Extract all label values.
Here is the function:
def _extract_all_labels(labels, prefix):
"""Extract all label values."""
results = []
labels_to_remove = []
for label in labels:
if not label.startswith(prefix):
continue
results.append(label[len(prefix):])
labels_to_remove.append(label)
for label in labels_to_remove:
labels.remove(label)
return results | Extract all label values. |
157,342 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_sanitize_oses` function. Write a Python function `def _sanitize_oses(oses)` to solve the following problem:
Sanitize the OS custom field values. The OS custom field no longer has the 'Chrome' value. It was replaced by 'ChromeOS'.
Here is the function:
def _sanitize_oses(oses):
"""Sanitize the OS custom field values.
The OS custom field no longer has the 'Chrome' value.
It was replaced by 'ChromeOS'.
"""
for i, os_field in enumerate(oses):
if os_field == 'Chrome':
oses[i] = 'ChromeOS' | Sanitize the OS custom field values. The OS custom field no longer has the 'Chrome' value. It was replaced by 'ChromeOS'. |
157,343 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_extract_label` function. Write a Python function `def _extract_label(labels, prefix)` to solve the following problem:
Extract a label value.
Here is the function:
def _extract_label(labels, prefix):
"""Extract a label value."""
for label in labels:
if not label.startswith(prefix):
continue
result = label[len(prefix):]
labels.remove(label)
return result
return None | Extract a label value. |
157,344 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_get_labels` function. Write a Python function `def _get_labels(labels_dict, prefix)` to solve the following problem:
Return all label values from labels.added or labels.removed
Here is the function:
def _get_labels(labels_dict, prefix):
"""Return all label values from labels.added or labels.removed"""
results = []
for label in labels_dict:
if not label.startswith(prefix):
continue
results.append(label[len(prefix):])
return results | Return all label values from labels.added or labels.removed |
157,345 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
def _make_user(email):
"""Makes a User."""
return {
'emailAddress': email,
}
The provided code snippet includes necessary dependencies for implementing the `_make_users` function. Write a Python function `def _make_users(emails)` to solve the following problem:
Makes Users.
Here is the function:
def _make_users(emails):
"""Makes Users."""
return [_make_user(email) for email in emails] | Makes Users. |
157,346 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_parse_datetime` function. Write a Python function `def _parse_datetime(date_string)` to solve the following problem:
Parses a datetime.
Here is the function:
def _parse_datetime(date_string):
"""Parses a datetime."""
datetime_obj, _, microseconds_string = date_string.rstrip('Z').partition('.')
datetime_obj = datetime.datetime.strptime(datetime_obj, '%Y-%m-%dT%H:%M:%S')
if microseconds_string:
microseconds = int(microseconds_string, 10)
return datetime_obj + datetime.timedelta(microseconds=microseconds)
return datetime_obj | Parses a datetime. |
157,347 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_get_query` function. Write a Python function `def _get_query(keywords, only_open)` to solve the following problem:
Gets a search query.
Here is the function:
def _get_query(keywords, only_open):
"""Gets a search query."""
query = ' '.join('"{}"'.format(keyword) for keyword in keywords)
if only_open:
query += ' status:open'
return query | Gets a search query. |
157,348 | import datetime
import enum
import urllib.parse
from google.auth import exceptions
from clusterfuzz._internal.issue_management import issue_tracker
from clusterfuzz._internal.issue_management.google_issue_tracker import client
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_get_severity_from_crash_text` function. Write a Python function `def _get_severity_from_crash_text(crash_severity_text)` to solve the following problem:
Get Google issue tracker severity from crash severity text.
Here is the function:
def _get_severity_from_crash_text(crash_severity_text):
"""Get Google issue tracker severity from crash severity text."""
if crash_severity_text == 'Critical':
return 'S0'
if crash_severity_text == 'High':
return 'S1'
if crash_severity_text == 'Medium':
return 'S2'
if crash_severity_text == 'Low':
return 'S3'
# Default case.
return 'S4' | Get Google issue tracker severity from crash severity text. |
157,349 | import google.auth
import google_auth_httplib2
from googleapiclient import discovery
from googleapiclient import errors
import httplib2
from clusterfuzz._internal.base import retry
_ROLE_ACCOUNT = "cluster-fuzz@appspot.gserviceaccount.com"
def user():
return _ROLE_ACCOUNT | null |
157,350 | from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.datastore import ndb_utils
from clusterfuzz._internal.issue_management import google_issue_tracker
from clusterfuzz._internal.issue_management import issue_tracker_policy
from clusterfuzz._internal.issue_management import jira
from clusterfuzz._internal.issue_management import monorail
from clusterfuzz._internal.system import environment
_ISSUE_TRACKER_CONSTRUCTORS = {
'monorail': monorail.get_issue_tracker,
'jira': jira.get_issue_tracker,
'google_issue_tracker': google_issue_tracker.get_issue_tracker,
}
The provided code snippet includes necessary dependencies for implementing the `register_issue_tracker` function. Write a Python function `def register_issue_tracker(tracker_type, constructor)` to solve the following problem:
Register an issue tracker implementation.
Here is the function:
def register_issue_tracker(tracker_type, constructor):
"""Register an issue tracker implementation."""
if tracker_type in _ISSUE_TRACKER_CONSTRUCTORS:
raise ValueError(
'Tracker type {type} is already registered.'.format(type=tracker_type))
_ISSUE_TRACKER_CONSTRUCTORS[tracker_type] = constructor | Register an issue tracker implementation. |
157,351 | from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.datastore import ndb_utils
from clusterfuzz._internal.issue_management import google_issue_tracker
from clusterfuzz._internal.issue_management import issue_tracker_policy
from clusterfuzz._internal.issue_management import jira
from clusterfuzz._internal.issue_management import monorail
from clusterfuzz._internal.system import environment
_ISSUE_TRACKER_CACHE_CAPACITY = 8
The provided code snippet includes necessary dependencies for implementing the `request_or_task_cache` function. Write a Python function `def request_or_task_cache(func)` to solve the following problem:
Cache that lasts for a bot task's lifetime, or an App Engine request lifetime.
Here is the function:
def request_or_task_cache(func):
"""Cache that lasts for a bot task's lifetime, or an App Engine request
lifetime."""
if environment.is_running_on_app_engine():
from libs import request_cache
return request_cache.wrap(capacity=_ISSUE_TRACKER_CACHE_CAPACITY)(func)
return memoize.wrap(memoize.FifoInMemory(256))(func) | Cache that lasts for a bot task's lifetime, or an App Engine request lifetime. |
157,352 | from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.datastore import ndb_utils
from clusterfuzz._internal.issue_management import google_issue_tracker
from clusterfuzz._internal.issue_management import issue_tracker_policy
from clusterfuzz._internal.issue_management import jira
from clusterfuzz._internal.issue_management import monorail
from clusterfuzz._internal.system import environment
def get_search_keywords(testcase):
"""Get search keywords for a testcase."""
crash_state_lines = testcase.crash_state.splitlines()
# Use top 2 frames for searching.
return crash_state_lines[:2]
The provided code snippet includes necessary dependencies for implementing the `get_similar_issues` function. Write a Python function `def get_similar_issues(issue_tracker, testcase, only_open=True)` to solve the following problem:
Get issue objects that seem to be related to a particular test case.
Here is the function:
def get_similar_issues(issue_tracker, testcase, only_open=True):
"""Get issue objects that seem to be related to a particular test case."""
# Get list of issues using the search query.
keywords = get_search_keywords(testcase)
issues = issue_tracker.find_issues(keywords=keywords, only_open=only_open)
if issues:
issues = list(issues)
else:
issues = []
issue_ids = [issue.id for issue in issues]
# Add issues from similar testcases sharing the same group id.
if testcase.group_id:
group_query = data_types.Testcase.query(
data_types.Testcase.group_id == testcase.group_id)
similar_testcases = ndb_utils.get_all_from_query(group_query)
for similar_testcase in similar_testcases:
if not similar_testcase.bug_information:
continue
# Exclude issues already added above from search terms.
issue_id = int(similar_testcase.bug_information)
if issue_id in issue_ids:
continue
# Get issue object using ID.
issue = issue_tracker.get_issue(issue_id)
if not issue:
continue
# If our search criteria allows open bugs only, then check issue and
# testcase status so as to exclude closed ones.
if (only_open and (not issue.is_open or not testcase.open)):
continue
issues.append(issue)
issue_ids.append(issue_id)
return issues | Get issue objects that seem to be related to a particular test case. |
157,353 | from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.datastore import ndb_utils
from clusterfuzz._internal.issue_management import google_issue_tracker
from clusterfuzz._internal.issue_management import issue_tracker_policy
from clusterfuzz._internal.issue_management import jira
from clusterfuzz._internal.issue_management import monorail
from clusterfuzz._internal.system import environment
def get_search_keywords(testcase):
"""Get search keywords for a testcase."""
crash_state_lines = testcase.crash_state.splitlines()
# Use top 2 frames for searching.
return crash_state_lines[:2]
The provided code snippet includes necessary dependencies for implementing the `get_similar_issues_url` function. Write a Python function `def get_similar_issues_url(issue_tracker, testcase, only_open=True)` to solve the following problem:
Get similar issues web URL.
Here is the function:
def get_similar_issues_url(issue_tracker, testcase, only_open=True):
"""Get similar issues web URL."""
keywords = get_search_keywords(testcase)
return issue_tracker.find_issues_url(keywords=keywords, only_open=only_open) | Get similar issues web URL. |
157,354 | from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.datastore import data_types
from clusterfuzz._internal.datastore import ndb_utils
from clusterfuzz._internal.issue_management import google_issue_tracker
from clusterfuzz._internal.issue_management import issue_tracker_policy
from clusterfuzz._internal.issue_management import jira
from clusterfuzz._internal.issue_management import monorail
from clusterfuzz._internal.system import environment
def get_issue_tracker_for_testcase(testcase):
"""Get the issue tracker with the given type and name."""
issue_tracker_project_name = _get_issue_tracker_project_name(testcase)
if not issue_tracker_project_name or issue_tracker_project_name == 'disabled':
return None
return get_issue_tracker(issue_tracker_project_name)
The provided code snippet includes necessary dependencies for implementing the `get_issue_url` function. Write a Python function `def get_issue_url(testcase)` to solve the following problem:
Return issue url for a testcase. This is used when rendering a testcase, details page, therefore it accounts for |group_bug_information| as well.
Here is the function:
def get_issue_url(testcase):
"""Return issue url for a testcase. This is used when rendering a testcase,
details page, therefore it accounts for |group_bug_information| as well."""
issue_tracker = get_issue_tracker_for_testcase(testcase)
if not issue_tracker:
return None
issue_id = (
testcase.bug_information
if testcase.bug_information else testcase.group_bug_information)
if not issue_id:
return None
# Use str(issue_id) as |group_bug_information| might be an integer.
return issue_tracker.issue_url(str(issue_id)) | Return issue url for a testcase. This is used when rendering a testcase, details page, therefore it accounts for |group_bug_information| as well. |
157,355 | from collections import namedtuple
from clusterfuzz._internal.config import local_config
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `_to_str_list` function. Write a Python function `def _to_str_list(values)` to solve the following problem:
Convert a list to a list of strs.
Here is the function:
def _to_str_list(values):
"""Convert a list to a list of strs."""
return [str(value) for value in values] | Convert a list to a list of strs. |
157,356 | import base64
from clusterfuzz._internal.datastore import data_types
The provided code snippet includes necessary dependencies for implementing the `get_value_for_job` function. Write a Python function `def get_value_for_job(data, target_job_type)` to solve the following problem:
Parses a value for a particular job type. If job type is not found, return the default value.
Here is the function:
def get_value_for_job(data, target_job_type):
"""Parses a value for a particular job type. If job type is not found,
return the default value."""
# All data is in a single line, just return that.
if ';' not in data:
return data
result = ''
for line in data.splitlines():
job_type, value = (line.strip()).split(';')
if job_type == target_job_type or (job_type == 'default' and not result):
result = value
return result | Parses a value for a particular job type. If job type is not found, return the default value. |
157,357 | import os
import yaml
from clusterfuzz._internal.base import errors
from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.system import environment
def _find_key_in_yaml_file(yaml_file_path, search_keys, full_key_name,
value_is_relative_path):
"""Find a key in a yaml file."""
if not os.path.isfile(yaml_file_path):
return None
result = _load_yaml_file(yaml_file_path)
if not search_keys:
# Give the entire yaml file contents.
# |value_is_relative_path| is not applicable here.
return result
for search_key in search_keys:
if not isinstance(result, dict):
raise errors.InvalidConfigKey(full_key_name)
if search_key not in result:
return None
result = result[search_key]
if value_is_relative_path:
yaml_directory = os.path.dirname(yaml_file_path)
if isinstance(result, list):
result = [os.path.join(yaml_directory, str(i)) for i in result]
else:
result = os.path.join(yaml_directory, str(result))
return result
def _get_key_location(search_path, full_key_name):
"""Get the path of the the yaml file and the key components given a full key
name."""
key_parts = full_key_name.split(SEPARATOR)
dir_path = search_path
# Find the directory components of the key path
for i, search_key in enumerate(key_parts):
search_path = os.path.join(dir_path, search_key)
if os.path.isdir(search_path):
# Don't allow both a/b/... and a/b.yaml
if os.path.isfile(search_path + YAML_FILE_EXTENSION):
raise errors.InvalidConfigKey(full_key_name)
dir_path = search_path
else:
# The remainder of the key path is a yaml_filename.key1.key2...
key_parts = key_parts[i:]
break
else:
# The entirety of the key reference a directory.
key_parts = []
if key_parts:
return dir_path, key_parts[0] + YAML_FILE_EXTENSION, key_parts[1:]
return dir_path, '', []
The provided code snippet includes necessary dependencies for implementing the `_validate_root` function. Write a Python function `def _validate_root(search_path, root)` to solve the following problem:
Validate that a root is valid.
Here is the function:
def _validate_root(search_path, root):
"""Validate that a root is valid."""
if root is None:
return True
directory, filename, search_keys = _get_key_location(search_path, root)
if not filename:
# _get_key_location already validated that the directory exists, so the root
# is valid.
return True
# Check that the yaml file and keys exist.
yaml_path = os.path.join(directory, filename)
return (_find_key_in_yaml_file(
yaml_path, search_keys, root, value_is_relative_path=False) is not None) | Validate that a root is valid. |
157,358 | import os
import yaml
from clusterfuzz._internal.base import errors
from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.system import environment
def _find_key_in_yaml_file(yaml_file_path, search_keys, full_key_name,
value_is_relative_path):
"""Find a key in a yaml file."""
if not os.path.isfile(yaml_file_path):
return None
result = _load_yaml_file(yaml_file_path)
if not search_keys:
# Give the entire yaml file contents.
# |value_is_relative_path| is not applicable here.
return result
for search_key in search_keys:
if not isinstance(result, dict):
raise errors.InvalidConfigKey(full_key_name)
if search_key not in result:
return None
result = result[search_key]
if value_is_relative_path:
yaml_directory = os.path.dirname(yaml_file_path)
if isinstance(result, list):
result = [os.path.join(yaml_directory, str(i)) for i in result]
else:
result = os.path.join(yaml_directory, str(result))
return result
def _get_key_location(search_path, full_key_name):
"""Get the path of the the yaml file and the key components given a full key
name."""
key_parts = full_key_name.split(SEPARATOR)
dir_path = search_path
# Find the directory components of the key path
for i, search_key in enumerate(key_parts):
search_path = os.path.join(dir_path, search_key)
if os.path.isdir(search_path):
# Don't allow both a/b/... and a/b.yaml
if os.path.isfile(search_path + YAML_FILE_EXTENSION):
raise errors.InvalidConfigKey(full_key_name)
dir_path = search_path
else:
# The remainder of the key path is a yaml_filename.key1.key2...
key_parts = key_parts[i:]
break
else:
# The entirety of the key reference a directory.
key_parts = []
if key_parts:
return dir_path, key_parts[0] + YAML_FILE_EXTENSION, key_parts[1:]
return dir_path, '', []
The provided code snippet includes necessary dependencies for implementing the `_search_key` function. Write a Python function `def _search_key(search_path, full_key_name, value_is_relative_path)` to solve the following problem:
Search the key in a search path.
Here is the function:
def _search_key(search_path, full_key_name, value_is_relative_path):
"""Search the key in a search path."""
directory, filename, search_keys = _get_key_location(search_path,
full_key_name)
# Search in the yaml file.
yaml_path = os.path.join(directory, filename)
return _find_key_in_yaml_file(yaml_path, search_keys, full_key_name,
value_is_relative_path) | Search the key in a search path. |
157,359 | import ast
import random
import time
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
The provided code snippet includes necessary dependencies for implementing the `get_random_gestures` function. Write a Python function `def get_random_gestures(gesture_count)` to solve the following problem:
Return list of random gesture command strings.
Here is the function:
def get_random_gestures(gesture_count):
"""Return list of random gesture command strings."""
gestures_types = [
'key,Letters', 'key,Letters', 'key,Letters', 'key,Letters', 'mouse,MA',
'mousedrag,MB', 'mousemove,MC'
]
gestures = []
for _ in range(gesture_count):
random_gesture = utils.random_element_from_list(gestures_types)
if 'Letters' in random_gesture:
num_letters = random.randint(1, 10)
letters = []
for _ in range(num_letters):
if not random.randint(0, 7):
letters.append(
utils.random_element_from_list([
'{BACK}', '{BACKSPACE}', '{BKSP}', '{CAP}', '{DEL}',
'{DELETE}', '{DOWN}', '{DOWN}', '{END}', '{ENTER}', '{ENTER}',
'{ENTER}', 'A{ESC}', '{F1}', '{F2}', '{F3}', 'A{F4}', '{F5}',
'{F6}', '{F7}', '{F8}', '{F9}', '{F10}', '{F11}', '{F12}',
'{HOME}', '{INSERT}', '{LEFT}', '{PGDN}', '{PGUP}', '{RIGHT}',
'{SPACE}', '{TAB}', '{TAB}', '{TAB}', '{TAB}', '{UP}', '{UP}',
'+', '^'
]))
else:
letters.append(
utils.random_element_from_list(
['{TAB}', '^=', '^-',
'{%s}' % chr(random.randint(32, 126))]))
random_gesture = random_gesture.replace('Letters', ''.join(letters))
if ('^c' in random_gesture.lower() or '^d' in random_gesture.lower() or
'^z' in random_gesture.lower()):
continue
if ',MA' in random_gesture:
button = utils.random_element_from_list(['left', 'right', 'middle'])
coords = '(%d,%d)' % (random.randint(0, 1000), random.randint(0, 1000))
double = utils.random_element_from_list(['True', 'False'])
random_gesture = random_gesture.replace(
'MA', '%s;%s;%s' % (button, coords, double))
if ',MB' in random_gesture:
button = utils.random_element_from_list(['left', 'right', 'middle'])
coords1 = '(%d,%d)' % (random.randint(0, 1000), random.randint(0, 1000))
coords2 = '(%d,%d)' % (random.randint(0, 1000), random.randint(0, 1000))
random_gesture = random_gesture.replace(
'MB', '%s;%s;%s' % (button, coords1, coords2))
if ',MC' in random_gesture:
button = utils.random_element_from_list(['left', 'right', 'middle'])
coords = '(%d,%d)' % (random.randint(0, 1000), random.randint(0, 1000))
random_gesture = random_gesture.replace('MC', '%s;%s' % (button, coords))
gestures.append(random_gesture)
return gestures | Return list of random gesture command strings. |
157,360 | import ast
import random
import time
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
def find_windows_for_process(process_id):
"""Return visible windows belonging to a process."""
pids = utils.get_process_ids(process_id)
if not pids:
return []
visible_windows = []
for pid in pids:
app = application.Application()
try:
app.connect(process=pid)
except:
logs.log_warn('Unable to connect to process.')
continue
try:
windows = app.windows()
except:
logs.log_warn('Unable to get application windows.')
continue
for window in windows:
try:
window.type_keys('')
except:
continue
visible_windows.append(window)
return visible_windows
The provided code snippet includes necessary dependencies for implementing the `run_gestures` function. Write a Python function `def run_gestures(gestures, process_id, process_status, start_time, timeout, windows)` to solve the following problem:
Run the provided interaction gestures.
Here is the function:
def run_gestures(gestures, process_id, process_status, start_time, timeout,
windows):
"""Run the provided interaction gestures."""
if not windows:
windows += find_windows_for_process(process_id)
for window in windows:
for gesture in gestures:
# If process had exited or our timeout interval has exceeded,
# just bail out.
if process_status.finished or time.time() - start_time >= timeout:
return
try:
tokens = gesture.split(',')
command = tokens.pop(0)
value = ','.join(tokens)
if command == 'key':
window.type_keys(value)
elif command == 'mouse':
button, coords, double = value.split(';')
window.click_input(
button=button,
coords=ast.literal_eval(coords),
double=ast.literal_eval(double))
elif command == 'mousedrag':
button, coords1, coords2 = value.split(';')
window.drag_mouse(
button=button,
press_coords=ast.literal_eval(coords1),
release_coords=ast.literal_eval(coords2))
elif command == 'mousemove':
button, coords = value.split(';')
window.move_mouse(pressed=button, coords=ast.literal_eval(coords))
except Exception:
# Several types of errors can happen. Just ignore them until a better
# solution is available. E.g. controls not visible, gestures cannot be
# run, invalid window handle, window failed to respond to gesture, etc.
pass | Run the provided interaction gestures. |
157,361 | import random
import shutil
import time
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import shell
COORDINATE_DELTA_MIN = -100
COORDINATE_DELTA_MAX = 200
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 1024
def get_text_to_type():
"""Return text to type."""
chars = []
chars_to_type_count = random.randint(1, MAX_CHARS_TO_TYPE)
meta_chars = [
'|', '&', ';', '(', ')', '<', '>', ' ', '\t', ',', '\'', '"', '`', '[',
']', '{', '}'
]
for _ in range(chars_to_type_count):
char_code = random.randint(32, 126)
char = chr(char_code)
if char in meta_chars:
continue
chars.append(char)
return ''.join(chars)
The provided code snippet includes necessary dependencies for implementing the `get_random_gestures` function. Write a Python function `def get_random_gestures(gesture_count)` to solve the following problem:
Return list of random gesture command strings.
Here is the function:
def get_random_gestures(gesture_count):
"""Return list of random gesture command strings."""
gesture_types = [
'click --repeat TIMES,mbutton',
'drag',
'key,ctrl+minus',
'key,ctrl+plus',
'key,Function',
'key,Letter',
'key,Letters',
'key,Modifier+Letter',
'keydown,Letter',
'keyup,Letter',
'type,Chars',
'type,Chars',
'mousedown,mbutton',
'mousemove --sync,x y',
'mousemove_relative --sync,nx ny',
'mouseup,mbutton',
]
if not random.randint(0, 3):
gesture_types.append('windowsize,P P')
gestures = []
for _ in range(gesture_count):
random_gesture = utils.random_element_from_list(gesture_types)
if random_gesture == 'drag':
gestures.append('mousemove,%d %d' % (random.randint(0, SCREEN_WIDTH),
random.randint(0, SCREEN_HEIGHT)))
gestures.append('mousedown,1')
gestures.append('mousemove_relative,0 1')
gestures.append('mousemove_relative,0 -')
gestures.append('mousemove,%d %d' % (random.randint(0, SCREEN_WIDTH),
random.randint(0, SCREEN_HEIGHT)))
gestures.append('mouseup,1')
continue
if 'Function' in random_gesture:
random_gesture = (
random_gesture.replace('Function', 'F%d' % random.randint(1, 12)))
elif 'mbutton' in random_gesture:
random_gesture = random_gesture.replace('TIMES', str(
random.randint(1, 3)))
picked_button = 1 if random.randint(0, 4) else random.randint(2, 5)
random_gesture = random_gesture.replace('mbutton', str(picked_button))
elif ',x y' in random_gesture:
random_gesture = random_gesture.replace(
',x y', ',%d %d' % (random.randint(0, SCREEN_WIDTH),
random.randint(0, SCREEN_HEIGHT)))
elif ',nx ny' in random_gesture:
random_gesture = random_gesture.replace(
',nx ny', ',%d %d' %
(random.randint(COORDINATE_DELTA_MIN, COORDINATE_DELTA_MAX),
random.randint(COORDINATE_DELTA_MIN, COORDINATE_DELTA_MAX)))
elif ',P P' in random_gesture:
random_gesture = random_gesture.replace(
',P P',
',%d%% %d%%' % (random.randint(10, 100), random.randint(10, 100)))
elif 'Chars' in random_gesture:
random_gesture = random_gesture.replace('Chars',
"'%s'" % get_text_to_type())
else:
if 'Modifier' in random_gesture:
random_gesture = random_gesture.replace(
'Modifier',
utils.random_element_from_list([
'alt', 'ctrl', 'control', 'meta', 'super', 'shift', 'ctrl+shift'
]))
if 'Letters' in random_gesture:
num_letters = random.randint(1, 10)
letters = []
for _ in range(num_letters):
letters.append(
utils.random_element_from_list([
'Escape', 'BackSpace', 'Delete', 'Tab', 'space', 'Down',
'Return', 'Up', 'Down', 'Left', 'Right',
chr(random.randint(48, 57)),
chr(random.randint(65, 90)),
chr(random.randint(97, 122))
]))
random_gesture = random_gesture.replace('Letters', ' '.join(letters))
elif 'Letter' in random_gesture:
random_gesture = random_gesture.replace(
'Letter',
utils.random_element_from_list([
'space',
chr(random.randint(48, 57)),
chr(random.randint(65, 90)),
chr(random.randint(97, 122))
]))
if 'ctrl+c' in random_gesture.lower():
continue
gestures.append(random_gesture)
return gestures | Return list of random gesture command strings. |
157,362 | import random
import shutil
import time
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import shell
def _xdotool_path():
"""Return full path to xdotool."""
return shutil.which('xdotool')
def find_windows_for_process(process_id):
"""Return visible windows belonging to a process."""
pids = utils.get_process_ids(process_id)
if not pids:
return []
xdotool_path = _xdotool_path()
if not xdotool_path:
logs.log_error('Xdotool not installed, cannot locate process windows.')
return []
visible_windows = []
for pid in pids:
windows = (
shell.execute_command(
'%s search --all --pid %d --onlyvisible' % (xdotool_path, pid)))
for line in windows.splitlines():
if not line.isdigit():
continue
visible_windows.append(int(line))
return visible_windows
The provided code snippet includes necessary dependencies for implementing the `run_gestures` function. Write a Python function `def run_gestures(gestures, process_id, process_status, start_time, timeout, windows)` to solve the following problem:
Run the provided interaction gestures.
Here is the function:
def run_gestures(gestures, process_id, process_status, start_time, timeout,
windows):
"""Run the provided interaction gestures."""
xdotool_path = _xdotool_path()
if not xdotool_path:
logs.log_error('Xdotool not installed, cannot emulate gestures.')
return
if not windows:
windows += find_windows_for_process(process_id)
for window in windows:
# Activate the window so that it can receive gestures.
shell.execute_command(
'%s windowactivate --sync %d' % (xdotool_path, window))
for gesture in gestures:
# If process had exited or our timeout interval has exceeded,
# just bail out.
if process_status.finished or time.time() - start_time >= timeout:
return
gesture_type, gesture_cmd = gesture.split(',')
if gesture_type == 'windowsize':
shell.execute_command(
'%s %s %d %s' % (xdotool_path, gesture_type, window, gesture_cmd))
else:
shell.execute_command(
'%s %s -- %s' % (xdotool_path, gesture_type, gesture_cmd)) | Run the provided interaction gestures. |
157,363 | import datetime
import os
import socket
import time
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.datastore import locks
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import archive
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import adb
from . import constants
from . import fetch_artifact
from . import settings
FLASH_IMAGE_REGEXES = [
r'.*[.]img',
r'.*-img-.*[.]zip',
]
FLASH_CUTTLEFISH_REGEXES = [
r'.*-img-.*[.]zip',
r'cvd-host_package.tar.gz',
]
FLASH_IMAGE_FILES = [
# Order is important here.
('bootloader', 'bootloader*.img'),
('radio', 'radio*.img'),
('boot', 'boot.img'),
('system', 'system.img'),
('recovery', 'recovery.img'),
('vendor', 'vendor.img'),
('cache', 'cache.img'),
('vbmeta', 'vbmeta.img'),
('dtbo', 'dtbo.img'),
('userdata', 'userdata.img'),
]
FLASH_DEFAULT_BUILD_TARGET = '-next-userdebug'
FLASH_DEFAULT_IMAGES_DIR = os.path.join(
environment.get_value('ROOT_DIR', ''), 'bot', 'inputs', 'images')
FLASH_INTERVAL = 1 * 24 * 60 * 60
FLASH_RETRIES = 3
FLASH_REBOOT_BOOTLOADER_WAIT = 15
FLASH_REBOOT_WAIT = 5 * 60
def download_latest_build(build_info, image_regexes, image_directory):
"""Download the latest build artifact for the given branch and target."""
# Check if our local build matches the latest build. If not, we will
# download it.
build_id = build_info['bid']
target = build_info['target']
logs.log('target stored in current build_info: %s.' % target)
last_build_info = persistent_cache.get_value(constants.LAST_FLASH_BUILD_KEY)
logs.log('last_build_info take from persisten cache: %s.' % last_build_info)
if last_build_info and last_build_info['bid'] == build_id:
return
# Clean up the images directory first.
shell.remove_directory(image_directory, recreate=True)
for image_regex in image_regexes:
image_file_paths = fetch_artifact.get(build_id, target, image_regex,
image_directory)
if not image_file_paths:
logs.log_error('Failed to download artifact %s for '
'branch %s and target %s.' %
(image_file_paths, build_info['branch'], target))
return
for file_path in image_file_paths:
if file_path.endswith('.zip') or file_path.endswith('.tar.gz'):
with archive.open(file_path) as reader:
reader.extract_all(image_directory)
The provided code snippet includes necessary dependencies for implementing the `flash_to_latest_build_if_needed` function. Write a Python function `def flash_to_latest_build_if_needed()` to solve the following problem:
Wipes user data, resetting the device to original factory state.
Here is the function:
def flash_to_latest_build_if_needed():
"""Wipes user data, resetting the device to original factory state."""
if environment.get_value('LOCAL_DEVELOPMENT'):
# Don't reimage local development devices.
return
run_timeout = environment.get_value('RUN_TIMEOUT')
if run_timeout:
# If we have a run timeout, then we are already scheduled to bail out and
# will be probably get re-imaged. E.g. using frameworks like Tradefed.
return
# Check if a flash is needed based on last recorded flash time.
last_flash_time = persistent_cache.get_value(
constants.LAST_FLASH_TIME_KEY,
constructor=datetime.datetime.utcfromtimestamp)
needs_flash = last_flash_time is None or dates.time_has_expired(
last_flash_time, seconds=FLASH_INTERVAL)
if not needs_flash:
return
is_google_device = settings.is_google_device()
if is_google_device is None:
logs.log_error('Unable to query device. Reimaging failed.')
adb.bad_state_reached()
elif not is_google_device:
# We can't reimage these, skip.
logs.log('Non-Google device found, skipping reimage.')
return
# Check if both |BUILD_BRANCH| and |BUILD_TARGET| environment variables
# are set. If not, we don't have enough data for reimaging and hence
# we bail out.
branch = environment.get_value('BUILD_BRANCH')
target = environment.get_value('BUILD_TARGET')
if not target:
logs.log('BUILD_TARGET is not set.')
build_params = settings.get_build_parameters()
if build_params:
logs.log('build_params found on device: %s.' % build_params)
if environment.is_android_cuttlefish():
target = build_params.get('target') + FLASH_DEFAULT_BUILD_TARGET
logs.log('is_android_cuttlefish() returned True. Target: %s.' % target)
else:
target = build_params.get('target') + '-userdebug'
logs.log('is_android_cuttlefish() returned False. Target: %s.' % target)
# Cache target in environment. This is also useful for cases when
# device is bricked and we don't have this information available.
environment.set_value('BUILD_TARGET', target)
else:
logs.log('build_params not found.')
if not branch or not target:
logs.log_warn(
'BUILD_BRANCH and BUILD_TARGET are not set, skipping reimage.')
return
image_directory = environment.get_value('IMAGES_DIR')
logs.log('image_directory: %s' % str(image_directory))
if not image_directory:
logs.log('no image_directory set, setting to default')
image_directory = FLASH_DEFAULT_IMAGES_DIR
logs.log('image_directory: %s' % image_directory)
build_info = fetch_artifact.get_latest_artifact_info(branch, target)
if not build_info:
logs.log_error('Unable to fetch information on latest build artifact for '
'branch %s and target %s.' % (branch, target))
return
if environment.is_android_cuttlefish():
download_latest_build(build_info, FLASH_CUTTLEFISH_REGEXES, image_directory)
adb.recreate_cuttlefish_device()
adb.connect_to_cuttlefish_device()
else:
download_latest_build(build_info, FLASH_IMAGE_REGEXES, image_directory)
# We do one device flash at a time on one host, otherwise we run into
# failures and device being stuck in a bad state.
flash_lock_key_name = 'flash:%s' % socket.gethostname()
if not locks.acquire_lock(flash_lock_key_name, by_zone=True):
logs.log_error('Failed to acquire lock for reimaging, exiting.')
return
logs.log('Reimaging started.')
logs.log('Rebooting into bootloader mode.')
for _ in range(FLASH_RETRIES):
adb.run_as_root()
adb.run_command(['reboot-bootloader'])
time.sleep(FLASH_REBOOT_BOOTLOADER_WAIT)
adb.run_fastboot_command(['oem', 'off-mode-charge', '0'])
adb.run_fastboot_command(['-w', 'reboot-bootloader'])
for partition, partition_image_filename in FLASH_IMAGE_FILES:
partition_image_file_path = os.path.join(image_directory,
partition_image_filename)
adb.run_fastboot_command(
['flash', partition, partition_image_file_path])
if partition in ['bootloader', 'radio']:
adb.run_fastboot_command(['reboot-bootloader'])
# Disable ramdump to avoid capturing ramdumps during kernel crashes.
# This causes device lockup of several minutes during boot and we intend
# to analyze them ourselves.
adb.run_fastboot_command(['oem', 'ramdump', 'disable'])
adb.run_fastboot_command('reboot')
time.sleep(FLASH_REBOOT_WAIT)
if adb.get_device_state() == 'device':
break
logs.log_error('Reimaging failed, retrying.')
locks.release_lock(flash_lock_key_name, by_zone=True)
if adb.get_device_state() != 'device':
logs.log_error('Unable to find device. Reimaging failed.')
adb.bad_state_reached()
logs.log('Reimaging finished.')
# Reset all of our persistent keys after wipe.
persistent_cache.delete_value(constants.BUILD_PROP_MD5_KEY)
persistent_cache.delete_value(constants.LAST_TEST_ACCOUNT_CHECK_KEY)
persistent_cache.set_value(constants.LAST_FLASH_BUILD_KEY, build_info)
persistent_cache.set_value(constants.LAST_FLASH_TIME_KEY, time.time()) | Wipes user data, resetting the device to original factory state. |
157,364 | import os
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
The provided code snippet includes necessary dependencies for implementing the `get_device_path` function. Write a Python function `def get_device_path(local_path)` to solve the following problem:
Returns device path for the given local path.
Here is the function:
def get_device_path(local_path):
"""Returns device path for the given local path."""
root_directory = environment.get_root_directory()
return os.path.join(android.constants.DEVICE_FUZZING_DIR,
os.path.relpath(local_path, root_directory)) | Returns device path for the given local path. |
157,365 | import os
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
The provided code snippet includes necessary dependencies for implementing the `get_local_path` function. Write a Python function `def get_local_path(device_path)` to solve the following problem:
Returns local path for the given device path.
Here is the function:
def get_local_path(device_path):
"""Returns local path for the given device path."""
if not device_path.startswith(android.constants.DEVICE_FUZZING_DIR + '/'):
logs.log_error('Bad device path: ' + device_path)
return None
root_directory = environment.get_root_directory()
return os.path.join(
root_directory,
os.path.relpath(device_path, android.constants.DEVICE_FUZZING_DIR)) | Returns local path for the given device path. |
157,366 | import os
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
The provided code snippet includes necessary dependencies for implementing the `is_testcase_deprecated` function. Write a Python function `def is_testcase_deprecated(platform_id=None)` to solve the following problem:
Whether or not the Android device is deprecated.
Here is the function:
def is_testcase_deprecated(platform_id=None):
"""Whether or not the Android device is deprecated."""
# Platform ID for Android is of the form as shown below
# |android:{codename}_{sanitizer}:{build_version}|
platform_id_fields = platform_id.split(':')
if len(platform_id_fields) != 3:
return False
codename_fields = platform_id_fields[1].split('_')
# Check if device is deprecated
if codename_fields[0] in android.constants.DEPRECATED_DEVICE_LIST:
return True
# Check if branch is deprecated
# Currently only "main" or "m" is active
# All other branches including "master" have been deprecated
branch = platform_id_fields[2]
if (branch <= 'v' or branch == 'master') and branch != 'm':
return True
return False | Whether or not the Android device is deprecated. |
157,367 | import os
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import environment
The provided code snippet includes necessary dependencies for implementing the `can_testcase_run_on_platform` function. Write a Python function `def can_testcase_run_on_platform(testcase_platform_id, current_platform_id)` to solve the following problem:
Whether or not the testcase can run on the current Android device.
Here is the function:
def can_testcase_run_on_platform(testcase_platform_id, current_platform_id):
"""Whether or not the testcase can run on the current Android device."""
del testcase_platform_id # Unused argument for now
# Platform ID for Android is of the form as shown below
# |android:{codename}_{sanitizer}:{build_version}|
current_platform_id_fields = current_platform_id.split(':')
if len(current_platform_id_fields) != 3:
return False
# Deprecated testcase should run on any latest device and on main
# So ignore device information and check for current version
# If the current version is 'm' or main, run the test case
if current_platform_id_fields[2] == 'm':
return True
return False | Whether or not the testcase can run on the current Android device. |
157,368 | import os
import re
import time
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import constants
def get_package_name(apk_path=None):
"""Return package name."""
# See if our environment is already set with this info.
package_name = environment.get_value('PKG_NAME')
if package_name:
return package_name
# See if we have the apk available to derive this info.
if not apk_path:
# Try getting apk path from APP_PATH.
apk_path = environment.get_value('APP_PATH')
if not apk_path:
return None
# Make sure that apk has the correct extension.
if not apk_path.endswith('.apk'):
return None
# Try retrieving package name using aapt.
aapt_binary_path = os.path.join(
environment.get_platform_resources_directory(), 'aapt')
aapt_command = '%s dump badging %s' % (aapt_binary_path, apk_path)
output = adb.execute_command(aapt_command, timeout=AAPT_CMD_TIMEOUT)
match = re.match('.*package: name=\'([^\']+)\'', output, re.DOTALL)
if not match:
return None
return match.group(1)
The provided code snippet includes necessary dependencies for implementing the `get_launch_command` function. Write a Python function `def get_launch_command(app_args, testcase_path, testcase_file_url)` to solve the following problem:
Get command to launch application with an optional testcase path.
Here is the function:
def get_launch_command(app_args, testcase_path, testcase_file_url):
"""Get command to launch application with an optional testcase path."""
application_launch_command = environment.get_value('APP_LAUNCH_COMMAND')
if not application_launch_command:
return ''
package_name = get_package_name() or ''
application_launch_command = application_launch_command.replace(
'%APP_ARGS%', app_args)
application_launch_command = application_launch_command.replace(
'%DEVICE_TESTCASES_DIR%', constants.DEVICE_TESTCASES_DIR)
application_launch_command = application_launch_command.replace(
'%PKG_NAME%', package_name)
application_launch_command = application_launch_command.replace(
'%TESTCASE%', testcase_path)
application_launch_command = application_launch_command.replace(
'%TESTCASE_FILE_URL%', testcase_file_url)
return application_launch_command | Get command to launch application with an optional testcase path. |
157,369 | import os
import re
import time
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import constants
CHROME_CACHE_DIRS = [
'app_chrome/*', 'app_tabs/*', 'app_textures/*', 'cache/*', 'files/*',
'shared_prefs/*'
]
def get_package_name(apk_path=None):
"""Return package name."""
# See if our environment is already set with this info.
package_name = environment.get_value('PKG_NAME')
if package_name:
return package_name
# See if we have the apk available to derive this info.
if not apk_path:
# Try getting apk path from APP_PATH.
apk_path = environment.get_value('APP_PATH')
if not apk_path:
return None
# Make sure that apk has the correct extension.
if not apk_path.endswith('.apk'):
return None
# Try retrieving package name using aapt.
aapt_binary_path = os.path.join(
environment.get_platform_resources_directory(), 'aapt')
aapt_command = '%s dump badging %s' % (aapt_binary_path, apk_path)
output = adb.execute_command(aapt_command, timeout=AAPT_CMD_TIMEOUT)
match = re.match('.*package: name=\'([^\']+)\'', output, re.DOTALL)
if not match:
return None
return match.group(1)
The provided code snippet includes necessary dependencies for implementing the `stop` function. Write a Python function `def stop()` to solve the following problem:
Stop application and cleanup state.
Here is the function:
def stop():
"""Stop application and cleanup state."""
package_name = get_package_name()
if not package_name:
return
# Device can get silently restarted in case of OOM. So, we would need to
# restart our shell as root in order to kill the application.
adb.run_as_root()
adb.kill_processes_and_children_matching_name(package_name)
# Chrome specific cleanup.
if package_name.endswith('.chrome'):
cache_dirs_absolute_paths = [
'/data/data/%s/%s' % (package_name, i) for i in CHROME_CACHE_DIRS
]
adb.run_shell_command(
['rm', '-rf', ' '.join(cache_dirs_absolute_paths)], root=True) | Stop application and cleanup state. |
157,370 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
def create_directory_if_needed(device_directory):
"""Creates a directory on the device if it doesn't already exist."""
run_shell_command(['mkdir', '-p', device_directory])
def run_command(cmd,
log_output=False,
log_error=True,
timeout=None,
recover=True):
"""Run a command in adb shell."""
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if log_output:
logs.log('Running: adb %s' % cmd)
if not timeout:
timeout = ADB_TIMEOUT
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
if not recover:
if log_output:
logs.log('Output: (%s)' % output)
return output
device_not_found_string_with_serial = DEVICE_NOT_FOUND_STRING.format(
serial=environment.get_value('ANDROID_SERIAL'))
if (output in [
DEVICE_HANG_STRING, DEVICE_OFFLINE_STRING,
device_not_found_string_with_serial
]):
logs.log_warn('Unable to query device, resetting device connection.')
if reset_device_connection():
# Device has successfully recovered, re-run command to get output.
# Continue execution and validate output next for |None| condition.
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
else:
output = DEVICE_HANG_STRING
if output is DEVICE_HANG_STRING:
# Handle the case where our command execution hung. This is usually when
# device goes into a bad state and only way to recover is to restart it.
logs.log_warn('Unable to query device, restarting device to recover.')
hard_reset()
# Wait until we've booted and try the command again.
wait_until_fully_booted()
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
if log_output:
logs.log('Output: (%s)' % output)
return output
The provided code snippet includes necessary dependencies for implementing the `copy_local_file_to_remote` function. Write a Python function `def copy_local_file_to_remote(local_file_path, remote_file_path)` to solve the following problem:
Copies local file to a device file.
Here is the function:
def copy_local_file_to_remote(local_file_path, remote_file_path):
"""Copies local file to a device file."""
create_directory_if_needed(os.path.dirname(remote_file_path))
run_command(['push', local_file_path, remote_file_path], True, True) | Copies local file to a device file. |
157,371 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
def run_command(cmd,
log_output=False,
log_error=True,
timeout=None,
recover=True):
"""Run a command in adb shell."""
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if log_output:
logs.log('Running: adb %s' % cmd)
if not timeout:
timeout = ADB_TIMEOUT
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
if not recover:
if log_output:
logs.log('Output: (%s)' % output)
return output
device_not_found_string_with_serial = DEVICE_NOT_FOUND_STRING.format(
serial=environment.get_value('ANDROID_SERIAL'))
if (output in [
DEVICE_HANG_STRING, DEVICE_OFFLINE_STRING,
device_not_found_string_with_serial
]):
logs.log_warn('Unable to query device, resetting device connection.')
if reset_device_connection():
# Device has successfully recovered, re-run command to get output.
# Continue execution and validate output next for |None| condition.
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
else:
output = DEVICE_HANG_STRING
if output is DEVICE_HANG_STRING:
# Handle the case where our command execution hung. This is usually when
# device goes into a bad state and only way to recover is to restart it.
logs.log_warn('Unable to query device, restarting device to recover.')
hard_reset()
# Wait until we've booted and try the command again.
wait_until_fully_booted()
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
if log_output:
logs.log('Output: (%s)' % output)
return output
The provided code snippet includes necessary dependencies for implementing the `copy_remote_directory_to_local` function. Write a Python function `def copy_remote_directory_to_local(remote_directory, local_directory)` to solve the following problem:
Copies local directory contents to a device directory.
Here is the function:
def copy_remote_directory_to_local(remote_directory, local_directory):
"""Copies local directory contents to a device directory."""
run_command(['pull', '%s/.' % remote_directory, local_directory]) | Copies local directory contents to a device directory. |
157,372 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
def run_command(cmd,
log_output=False,
log_error=True,
timeout=None,
recover=True):
"""Run a command in adb shell."""
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if log_output:
logs.log('Running: adb %s' % cmd)
if not timeout:
timeout = ADB_TIMEOUT
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
if not recover:
if log_output:
logs.log('Output: (%s)' % output)
return output
device_not_found_string_with_serial = DEVICE_NOT_FOUND_STRING.format(
serial=environment.get_value('ANDROID_SERIAL'))
if (output in [
DEVICE_HANG_STRING, DEVICE_OFFLINE_STRING,
device_not_found_string_with_serial
]):
logs.log_warn('Unable to query device, resetting device connection.')
if reset_device_connection():
# Device has successfully recovered, re-run command to get output.
# Continue execution and validate output next for |None| condition.
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
else:
output = DEVICE_HANG_STRING
if output is DEVICE_HANG_STRING:
# Handle the case where our command execution hung. This is usually when
# device goes into a bad state and only way to recover is to restart it.
logs.log_warn('Unable to query device, restarting device to recover.')
hard_reset()
# Wait until we've booted and try the command again.
wait_until_fully_booted()
output = execute_command(get_adb_command_line(cmd), timeout, log_error)
if log_output:
logs.log('Output: (%s)' % output)
return output
The provided code snippet includes necessary dependencies for implementing the `copy_remote_file_to_local` function. Write a Python function `def copy_remote_file_to_local(remote_file_path, local_file_path)` to solve the following problem:
Copies device file to a local file.
Here is the function:
def copy_remote_file_to_local(remote_file_path, local_file_path):
"""Copies device file to a local file."""
shell.create_directory(
os.path.dirname(local_file_path), create_intermediates=True)
run_command(['pull', remote_file_path, local_file_path]) | Copies device file to a local file. |
157,373 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
def run_shell_command(cmd,
log_output=False,
log_error=True,
root=False,
timeout=None,
recover=True):
"""Run adb shell command (with root if needed)."""
def _escape_specials(command):
return command.replace('\\', '\\\\').replace('"', '\\"')
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if cmd[0] not in ['"', "'"]:
cmd = '"{}"'.format(_escape_specials(cmd))
if root:
root_cmd_prefix = 'su root sh -c '
# The arguments to adb shell need to be quoted, so if we're using
# su root sh -c, quote the combined command
full_cmd = 'shell \'{}{}\''.format(root_cmd_prefix, cmd)
else:
full_cmd = 'shell {}'.format(cmd)
return run_command(
full_cmd,
log_output=log_output,
log_error=log_error,
timeout=timeout,
recover=recover)
The provided code snippet includes necessary dependencies for implementing the `directory_exists` function. Write a Python function `def directory_exists(directory_path)` to solve the following problem:
Return whether a directory exists or not.
Here is the function:
def directory_exists(directory_path):
"""Return whether a directory exists or not."""
expected = '0'
result = run_shell_command(
'\'test -d "%s"; echo $?\'' % directory_path, log_error=False)
return result == expected | Return whether a directory exists or not. |
157,374 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
def file_exists(file_path):
"""Return whether a file exists or not."""
expected = '0'
result = run_shell_command(
'\'test -f "%s"; echo $?\'' % file_path, log_error=False)
return result == expected
def run_shell_command(cmd,
log_output=False,
log_error=True,
root=False,
timeout=None,
recover=True):
"""Run adb shell command (with root if needed)."""
def _escape_specials(command):
return command.replace('\\', '\\\\').replace('"', '\\"')
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if cmd[0] not in ['"', "'"]:
cmd = '"{}"'.format(_escape_specials(cmd))
if root:
root_cmd_prefix = 'su root sh -c '
# The arguments to adb shell need to be quoted, so if we're using
# su root sh -c, quote the combined command
full_cmd = 'shell \'{}{}\''.format(root_cmd_prefix, cmd)
else:
full_cmd = 'shell {}'.format(cmd)
return run_command(
full_cmd,
log_output=log_output,
log_error=log_error,
timeout=timeout,
recover=recover)
The provided code snippet includes necessary dependencies for implementing the `get_file_size` function. Write a Python function `def get_file_size(file_path)` to solve the following problem:
Return file's size.
Here is the function:
def get_file_size(file_path):
"""Return file's size."""
if not file_exists(file_path):
return None
return int(run_shell_command(['stat', '-c%s', file_path])) | Return file's size. |
157,375 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
KERNEL_LOG_FILES = [
'/proc/last_kmsg',
'/sys/fs/pstore/console-ramoops',
]
def read_data_from_file(file_path):
"""Return device's file content."""
if not file_exists(file_path):
return None
return run_shell_command(['cat', '"%s"' % file_path])
The provided code snippet includes necessary dependencies for implementing the `get_kernel_log_content` function. Write a Python function `def get_kernel_log_content()` to solve the following problem:
Return content of kernel logs.
Here is the function:
def get_kernel_log_content():
"""Return content of kernel logs."""
kernel_log_content = ''
for kernel_log_file in KERNEL_LOG_FILES:
kernel_log_content += read_data_from_file(kernel_log_file) or ''
return kernel_log_content | Return content of kernel logs. |
157,376 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
WAIT_FOR_DEVICE_TIMEOUT = 600
RECOVERY_CMD_TIMEOUT = 60 * 2
RAMOOPS_READER_GCS_PATH = 'gs://haiku-storage/trusty/ramoops_reader.py'
def run_fastboot_command(cmd, log_output=True, log_error=True, timeout=None):
"""Run a command in fastboot shell."""
if environment.is_android_cuttlefish():
# We can't run fastboot commands on Android cuttlefish instances.
return None
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if log_output:
logs.log('Running: fastboot %s' % cmd)
if not timeout:
timeout = ADB_TIMEOUT
output = execute_command(get_fastboot_command_line(cmd), timeout, log_error)
return output
def wait_until_fully_booted():
"""Wait until device is fully booted or timeout expires."""
def boot_completed():
expected = '1'
result = run_shell_command('getprop sys.boot_completed', log_error=False)
return result == expected
def drive_ready():
expected = '0'
result = run_shell_command('\'test -d "/"; echo $?\'', log_error=False)
return result == expected
def package_manager_ready():
expected = 'package:/system/framework/framework-res.apk'
result = run_shell_command('pm path android', log_error=False)
if not result:
return False
# Ignore any extra messages before or after the result we want.
return expected in result.splitlines()
# Make sure we are not already recursing inside this function.
if utils.is_recursive_call():
return False
# Wait until device is online.
wait_for_device()
start_time = time.time()
is_boot_completed = False
is_drive_ready = False
is_package_manager_ready = False
while time.time() - start_time < REBOOT_TIMEOUT:
# TODO(mbarbella): Investigate potential optimizations.
# The package manager check should also work for shell restarts.
if not is_drive_ready:
is_drive_ready = drive_ready()
if not is_package_manager_ready:
is_package_manager_ready = package_manager_ready()
if not is_boot_completed:
is_boot_completed = boot_completed()
if is_drive_ready and is_package_manager_ready and is_boot_completed:
return True
time.sleep(BOOT_WAIT_INTERVAL)
factory_reset()
if environment.is_android_emulator():
#Device may be in recovery mode
hard_reset()
logs.log_fatal_and_exit(
'Device failed to finish boot. Reset to factory settings and exited.')
# Not reached.
return False
The provided code snippet includes necessary dependencies for implementing the `extract_logcat_from_ramdump_and_reboot` function. Write a Python function `def extract_logcat_from_ramdump_and_reboot()` to solve the following problem:
Extracts logcat from ramdump kernel log and reboots.
Here is the function:
def extract_logcat_from_ramdump_and_reboot():
"""Extracts logcat from ramdump kernel log and reboots."""
run_fastboot_command(
['oem', 'ramdump', 'stage_file', 'kernel.log'],
timeout=RECOVERY_CMD_TIMEOUT)
run_fastboot_command(
['get_staged', 'kernel.log'], timeout=WAIT_FOR_DEVICE_TIMEOUT)
storage.copy_file_from(RAMOOPS_READER_GCS_PATH, 'ramoops_reader.py')
subprocess.run(
'python ramoops_reader.py kernel.log > logcat.log',
shell=True,
check=False)
with open('logcat.log') as file:
logcat = file.read()
files_to_delete = ['ramoops_reader.py', 'kernel.log', 'logcat.log']
for filepath in files_to_delete:
os.remove(filepath)
run_fastboot_command('reboot')
wait_until_fully_booted()
return logcat | Extracts logcat from ramdump kernel log and reboots. |
157,377 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
CUTTLEFISH_CVD_PORT = 6520
def get_cuttlefish_device_ip():
"""Return the ip address of cuttlefish device."""
try:
return socket.gethostbyname('cuttlefish')
except socket.gaierror:
logs.log_fatal_and_exit('Unable to get cvd ip address on cuttlefish host.')
return None
The provided code snippet includes necessary dependencies for implementing the `set_cuttlefish_device_serial` function. Write a Python function `def set_cuttlefish_device_serial()` to solve the following problem:
Set the ANDROID_SERIAL to cuttlefish ip and port.
Here is the function:
def set_cuttlefish_device_serial():
"""Set the ANDROID_SERIAL to cuttlefish ip and port."""
device_serial = '%s:%d' % (get_cuttlefish_device_ip(), CUTTLEFISH_CVD_PORT)
environment.set_value('ANDROID_SERIAL', device_serial)
logs.log('Set cuttlefish device serial: %s' % device_serial) | Set the ANDROID_SERIAL to cuttlefish ip and port. |
157,378 | import collections
import os
import re
import signal
import socket
import subprocess
import tempfile
import threading
import time
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
def run_shell_command(cmd,
log_output=False,
log_error=True,
root=False,
timeout=None,
recover=True):
"""Run adb shell command (with root if needed)."""
def _escape_specials(command):
return command.replace('\\', '\\\\').replace('"', '\\"')
if isinstance(cmd, list):
cmd = ' '.join([str(i) for i in cmd])
if cmd[0] not in ['"', "'"]:
cmd = '"{}"'.format(_escape_specials(cmd))
if root:
root_cmd_prefix = 'su root sh -c '
# The arguments to adb shell need to be quoted, so if we're using
# su root sh -c, quote the combined command
full_cmd = 'shell \'{}{}\''.format(root_cmd_prefix, cmd)
else:
full_cmd = 'shell {}'.format(cmd)
return run_command(
full_cmd,
log_output=log_output,
log_error=log_error,
timeout=timeout,
recover=recover)
The provided code snippet includes necessary dependencies for implementing the `time_since_last_reboot` function. Write a Python function `def time_since_last_reboot()` to solve the following problem:
Return time in seconds since last reboot.
Here is the function:
def time_since_last_reboot():
"""Return time in seconds since last reboot."""
uptime_string = run_shell_command(['cat', '/proc/uptime']).split(
' ', maxsplit=1)[0]
try:
return float(uptime_string)
except ValueError:
# Sometimes, adb can just hang or return null output. In these cases, just
# return infinity uptime value.
return float('inf') | Return time in seconds since last reboot. |
157,379 | import os
import random
from . import adb
The provided code snippet includes necessary dependencies for implementing the `get_random_gestures` function. Write a Python function `def get_random_gestures(_)` to solve the following problem:
Return a random gesture seed from monkey framework natively supported by Android OS.
Here is the function:
def get_random_gestures(_):
"""Return a random gesture seed from monkey framework natively supported by
Android OS."""
random_seed = random.getrandbits(32)
gesture = 'monkey,%s' % str(random_seed)
return [gesture] | Return a random gesture seed from monkey framework natively supported by Android OS. |
157,380 | import os
import random
from . import adb
MONKEY_THROTTLE_DELAY = 100
NUM_MONKEY_EVENTS = 25
The provided code snippet includes necessary dependencies for implementing the `run_gestures` function. Write a Python function `def run_gestures(gestures, *_)` to solve the following problem:
Run the provided interaction gestures.
Here is the function:
def run_gestures(gestures, *_):
"""Run the provided interaction gestures."""
package_name = os.getenv('PKG_NAME')
if not package_name:
# No package to send gestures to, bail out.
return
if len(gestures) != 1 or not gestures[0].startswith('monkey'):
# Bad gesture string, bail out.
return
monkey_seed = gestures[0].split(',')[-1]
adb.run_shell_command([
'monkey', '-p', package_name, '-s', monkey_seed, '--throttle',
str(MONKEY_THROTTLE_DELAY), '--ignore-security-exceptions',
str(NUM_MONKEY_EVENTS)
]) | Run the provided interaction gestures. |
157,381 | import re
from clusterfuzz._internal.system import environment
from . import adb
The provided code snippet includes necessary dependencies for implementing the `get_cpu_arch` function. Write a Python function `def get_cpu_arch()` to solve the following problem:
Return cpu architecture.
Here is the function:
def get_cpu_arch():
"""Return cpu architecture."""
return adb.get_property('ro.product.cpu.abi') | Return cpu architecture. |
157,382 | import os
import zipfile
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.platforms.android import adb
from clusterfuzz._internal.platforms.android import fetch_artifact
from clusterfuzz._internal.platforms.android import kernel_utils
from clusterfuzz._internal.platforms.android import settings
from clusterfuzz._internal.system import archive
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import shell
from . import constants
def download_artifact_if_needed(
build_id, artifact_directory, artifact_archive_path,
targets_with_type_and_san, artifact_file_name, output_filename_override):
"""Downloads artifact to actifacts_archive_path if needed"""
# Delete existing symbols directory first.
shell.remove_directory(artifact_directory, recreate=True)
for target_with_type_and_san in targets_with_type_and_san:
# Fetch the artifact now.
fetch_artifact.get(build_id, target_with_type_and_san, artifact_file_name,
artifact_directory, output_filename_override)
if os.path.exists(artifact_archive_path):
break
The provided code snippet includes necessary dependencies for implementing the `download_trusty_symbols_if_needed` function. Write a Python function `def download_trusty_symbols_if_needed(symbols_directory, app_name, bid)` to solve the following problem:
Downloads and extracts Trusted App ELF files
Here is the function:
def download_trusty_symbols_if_needed(symbols_directory, app_name, bid):
"""Downloads and extracts Trusted App ELF files"""
ab_target = ''
device = settings.get_build_parameters().get('target')
if device in ['cheetah', 'panther']:
ab_target = 'cloudripper-fuzz-test-debug'
if device in ['oriole', 'raven', 'bluejay']:
ab_target = 'slider-fuzz-test-debug'
branch = 'polygon-trusty-whitechapel-master'
if not bid:
bid = fetch_artifact.get_latest_artifact_info(branch, ab_target)['bid']
artifact_filename = f'{ab_target}-{bid}.syms.zip'
symbols_archive_path = os.path.join(symbols_directory, artifact_filename)
download_artifact_if_needed(bid, symbols_directory, symbols_archive_path,
[ab_target], artifact_filename, None)
with zipfile.ZipFile(symbols_archive_path, 'r') as symbols_zipfile:
for filepath in symbols_zipfile.namelist():
if f'{app_name}.syms.elf' in filepath:
symbols_zipfile.extract(filepath, symbols_directory)
os.rename(f'{symbols_directory}/{filepath}',
f'{symbols_directory}/{app_name}.syms.elf')
if 'lk.elf' == filepath:
symbols_zipfile.extract(filepath, symbols_directory) | Downloads and extracts Trusted App ELF files |
157,383 | import os
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import constants
from . import settings
The provided code snippet includes necessary dependencies for implementing the `get_ld_library_path_for_memory_tools` function. Write a Python function `def get_ld_library_path_for_memory_tools()` to solve the following problem:
Return LD_LIBRARY_PATH setting for memory tools, None otherwise.
Here is the function:
def get_ld_library_path_for_memory_tools():
"""Return LD_LIBRARY_PATH setting for memory tools, None otherwise."""
tool = settings.get_sanitizer_tool_name()
if tool:
return constants.DEVICE_SANITIZER_DIR
tool = settings.is_mte_build()
if tool:
return constants.DEVICE_MTE_DIR
return None | Return LD_LIBRARY_PATH setting for memory tools, None otherwise. |
157,384 | import os
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import constants
from . import settings
def get_options_file_path(sanitizer_tool_name):
"""Return path for the sanitizer options file."""
# If this a full sanitizer system build, then update the options file in
# /system, else just put it in device temp directory.
sanitizer_directory = ('/system' if settings.get_sanitizer_tool_name() else
constants.DEVICE_TMP_DIR)
sanitizer_filename = SANITIZER_TOOL_TO_FILE_MAPPINGS.get(
sanitizer_tool_name.lower())
if sanitizer_filename is None:
logs.log_error('Unsupported sanitizer: ' + sanitizer_tool_name)
return None
return os.path.join(sanitizer_directory, sanitizer_filename)
The provided code snippet includes necessary dependencies for implementing the `set_options` function. Write a Python function `def set_options(sanitizer_tool_name, sanitizer_options)` to solve the following problem:
Set sanitizer options on the disk file.
Here is the function:
def set_options(sanitizer_tool_name, sanitizer_options):
"""Set sanitizer options on the disk file."""
sanitizer_options_file_path = get_options_file_path(sanitizer_tool_name)
if not sanitizer_options_file_path:
return
adb.write_data_to_file(sanitizer_options, sanitizer_options_file_path) | Set sanitizer options on the disk file. |
157,385 | import copy
import datetime
import os
import time
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.config import db_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import app
from . import constants
from . import logger
from . import sanitizer
from . import settings
from . import ui
from . import wifi
The provided code snippet includes necessary dependencies for implementing the `clear_temp_directories` function. Write a Python function `def clear_temp_directories()` to solve the following problem:
Clear temp directories.
Here is the function:
def clear_temp_directories():
"""Clear temp directories."""
adb.remove_directory(constants.DEVICE_DOWNLOAD_DIR, recreate=True)
adb.remove_directory(constants.DEVICE_TMP_DIR, recreate=True)
adb.remove_directory(constants.DEVICE_FUZZING_DIR, recreate=True) | Clear temp directories. |
157,386 | import copy
import datetime
import os
import time
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.config import db_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import app
from . import constants
from . import logger
from . import sanitizer
from . import settings
from . import ui
from . import wifi
The provided code snippet includes necessary dependencies for implementing the `initialize_environment` function. Write a Python function `def initialize_environment()` to solve the following problem:
Set common environment variables for easy access.
Here is the function:
def initialize_environment():
"""Set common environment variables for easy access."""
environment.set_value('BUILD_FINGERPRINT', settings.get_build_fingerprint())
environment.set_value('BUILD_VERSION', settings.get_build_version())
environment.set_value('DEVICE_CODENAME', settings.get_device_codename())
environment.set_value('DEVICE_PATH', adb.get_device_path())
environment.set_value('PLATFORM_ID', settings.get_platform_id())
environment.set_value('PRODUCT_BRAND', settings.get_product_brand())
environment.set_value('SANITIZER_TOOL_NAME',
settings.get_sanitizer_tool_name())
environment.set_value('SECURITY_PATCH_LEVEL',
settings.get_security_patch_level())
environment.set_value('LOG_TASK_TIMES', True) | Set common environment variables for easy access. |
157,387 | import copy
import datetime
import os
import time
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.config import db_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import app
from . import constants
from . import logger
from . import sanitizer
from . import settings
from . import ui
from . import wifi
def clear_testcase_directory():
"""Clears testcase directory."""
adb.remove_directory(constants.DEVICE_TESTCASES_DIR, recreate=True)
The provided code snippet includes necessary dependencies for implementing the `push_testcases_to_device` function. Write a Python function `def push_testcases_to_device()` to solve the following problem:
Pushes testcases from local fuzz directory onto device.
Here is the function:
def push_testcases_to_device():
"""Pushes testcases from local fuzz directory onto device."""
# Attempt to ensure that the local state is the same as the state on the
# device by clearing existing files on device before pushing.
clear_testcase_directory()
local_testcases_directory = environment.get_value('FUZZ_INPUTS')
if not os.listdir(local_testcases_directory):
# Directory is empty, nothing to push.
logs.log('No testcases to copy to device, skipping.')
return
adb.copy_local_directory_to_remote(local_testcases_directory,
constants.DEVICE_TESTCASES_DIR) | Pushes testcases from local fuzz directory onto device. |
157,388 | import copy
import datetime
import os
import time
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.config import db_config
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import app
from . import constants
from . import logger
from . import sanitizer
from . import settings
from . import ui
from . import wifi
def initialize_device():
"""Prepares android device for app install."""
if environment.is_engine_fuzzer_job() or environment.is_kernel_fuzzer_job():
# These steps are not applicable to libFuzzer and syzkaller jobs and can
# brick a device on trying to configure device build settings.
return
adb.setup_adb()
# General device configuration settings.
configure_system_build_properties()
configure_device_settings()
add_test_accounts_if_needed()
# Setup AddressSanitizer if needed.
sanitizer.setup_asan_if_needed()
# Reboot device as above steps would need it and also it brings device in a
# good state.
reboot()
# Make sure we are running as root after restart.
adb.run_as_root()
# Other configuration tasks (only to done after reboot).
wifi.configure()
setup_host_and_device_forwarder_if_needed()
settings.change_se_linux_to_permissive_mode()
app.wait_until_optimization_complete()
ui.clear_notifications()
ui.unlock_screen()
# FIXME: Should we should revert back to regular user permission ?
def install_application_if_needed(apk_path, force_update):
"""Install application package if it does not exist on device
or if force_update is set."""
# Make sure that apk exists and has non-zero size. Otherwise, it means we
# are using a system package that we just want to fuzz, but not care about
# installation.
if (not apk_path or not os.path.exists(apk_path) or
not os.path.getsize(apk_path)):
return
# If we don't have a package name, we can't uninstall the app. This is needed
# for installation workflow.
package_name = app.get_package_name()
if not package_name:
return
# Add |REINSTALL_APP_BEFORE_EACH_TASK| to force update decision.
reinstall_app_before_each_task = environment.get_value(
'REINSTALL_APP_BEFORE_EACH_TASK', False)
force_update = force_update or reinstall_app_before_each_task
# Install application if it is not found in the device's
# package list or force_update flag has been set.
if force_update or not app.is_installed(package_name):
app.uninstall(package_name)
app.install(apk_path)
if not app.is_installed(package_name):
logs.log_error(
'Package %s was not installed successfully.' % package_name)
return
logs.log('Package %s is successfully installed using apk %s.' %
(package_name, apk_path))
app.reset()
The provided code snippet includes necessary dependencies for implementing the `update_build` function. Write a Python function `def update_build(apk_path, force_update=True, should_initialize_device=True)` to solve the following problem:
Prepares the device and updates the build if necessary.
Here is the function:
def update_build(apk_path, force_update=True, should_initialize_device=True):
"""Prepares the device and updates the build if necessary."""
# Prepare device for app install.
if should_initialize_device:
initialize_device()
# On Android, we may need to write a command line file. We do this in
# advance so that we do not have to write this to the device multiple
# times.
# TODO(mbarbella): Platforms code should not depend on bot.
from clusterfuzz._internal.bot import testcase_manager
testcase_manager.get_command_line_for_application(
write_command_line_file=True)
# Install the app if it does not exist.
install_application_if_needed(apk_path, force_update=force_update) | Prepares the device and updates the build if necessary. |
157,389 | import datetime
import re
import time
from clusterfuzz._internal.base import dates
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from . import adb
from . import settings
BATTERY_CHARGE_INTERVAL = 30 * 60
BATTERY_CHECK_INTERVAL = 15 * 60
EXPECTED_BATTERY_LEVEL = 60
EXPECTED_BATTERY_TEMPERATURE = 35.0
LOW_BATTERY_LEVEL_THRESHOLD = 30
MAX_BATTERY_TEMPERATURE_THRESHOLD = 37.0
LAST_BATTERY_CHECK_TIME_KEY = 'android_last_battery_check'
def get_battery_level_and_temperature():
"""Return device's battery and temperature levels."""
output = adb.run_shell_command(['dumpsys', 'battery'])
# Get battery level.
m_battery_level = re.match(r'.*level: (\d+).*', output, re.DOTALL)
if not m_battery_level:
logs.log_error('Error occurred while getting battery status.')
return None
# Get battery temperature.
m_battery_temperature = re.match(r'.*temperature: (\d+).*', output, re.DOTALL)
if not m_battery_temperature:
logs.log_error('Error occurred while getting battery temperature.')
return None
level = int(m_battery_level.group(1))
temperature = float(m_battery_temperature.group(1)) / 10.0
return {'level': level, 'temperature': temperature}
The provided code snippet includes necessary dependencies for implementing the `wait_until_good_state` function. Write a Python function `def wait_until_good_state()` to solve the following problem:
Check battery and make sure it is charged beyond minimum level and temperature thresholds.
Here is the function:
def wait_until_good_state():
"""Check battery and make sure it is charged beyond minimum level and
temperature thresholds."""
# Battery levels are not applicable on GCE.
if environment.is_android_cuttlefish() or settings.is_automotive():
return
# Make sure device is online.
adb.wait_for_device()
# Skip battery check if done recently.
last_battery_check_time = persistent_cache.get_value(
LAST_BATTERY_CHECK_TIME_KEY,
constructor=datetime.datetime.utcfromtimestamp)
if last_battery_check_time and not dates.time_has_expired(
last_battery_check_time, seconds=BATTERY_CHECK_INTERVAL):
return
# Initialize variables.
battery_level_threshold = environment.get_value('LOW_BATTERY_LEVEL_THRESHOLD',
LOW_BATTERY_LEVEL_THRESHOLD)
battery_temperature_threshold = environment.get_value(
'MAX_BATTERY_TEMPERATURE_THRESHOLD', MAX_BATTERY_TEMPERATURE_THRESHOLD)
device_restarted = False
while True:
battery_information = get_battery_level_and_temperature()
if battery_information is None:
logs.log_error('Failed to get battery information, skipping check.')
return
battery_level = battery_information['level']
battery_temperature = battery_information['temperature']
logs.log('Battery information: level (%d%%), temperature (%.1f celsius).' %
(battery_level, battery_temperature))
if (battery_level >= battery_level_threshold and
battery_temperature <= battery_temperature_threshold):
persistent_cache.set_value(LAST_BATTERY_CHECK_TIME_KEY, time.time())
return
logs.log('Battery in bad battery state, putting device in sleep mode.')
if not device_restarted:
adb.reboot()
device_restarted = True
# Change thresholds to expected levels (only if they were below minimum
# thresholds).
if battery_level < battery_level_threshold:
battery_level_threshold = EXPECTED_BATTERY_LEVEL
if battery_temperature > battery_temperature_threshold:
battery_temperature_threshold = EXPECTED_BATTERY_TEMPERATURE
# Stopping shell should help with shutting off a lot of services that would
# otherwise use up the battery. However, we need to turn it back on to get
# battery status information.
adb.stop_shell()
time.sleep(BATTERY_CHARGE_INTERVAL)
adb.start_shell() | Check battery and make sure it is charged beyond minimum level and temperature thresholds. |
157,390 | import re
import time
from clusterfuzz._internal.metrics import logs
from . import adb
def log_output(additional_flags=''):
"""Return log data without noise and some normalization."""
output = adb.run_command('logcat -d -v brief %s *:V' % additional_flags)
return filter_log_output(output)
The provided code snippet includes necessary dependencies for implementing the `log_output_before_last_reboot` function. Write a Python function `def log_output_before_last_reboot()` to solve the following problem:
Return log data from last reboot without noise and some normalization.
Here is the function:
def log_output_before_last_reboot():
"""Return log data from last reboot without noise and some normalization."""
return log_output(additional_flags='-L') | Return log data from last reboot without noise and some normalization. |
157,391 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
class UndercoatError(Exception):
"""Error for errors while running undercoat."""
def get_version():
"""Get undercoat API version as (major, minor, patch) tuple."""
version = undercoat_api_command('version', timeout=30).output
if not version.startswith('v'):
raise UndercoatError('Invalid version reported: %s' % version)
parts = version[1:].split('.')
if len(parts) != 3:
raise UndercoatError('Invalid version reported: %s' % version)
try:
return tuple(int(part) for part in parts)
except ValueError as e:
raise UndercoatError('Invalid version reported: %s' % version) from e
The provided code snippet includes necessary dependencies for implementing the `validate_api_version` function. Write a Python function `def validate_api_version()` to solve the following problem:
Check that the undercoat API version is supported. Raises an error if it is not.
Here is the function:
def validate_api_version():
"""Check that the undercoat API version is supported. Raises an error if it is
not."""
major, minor, patch = get_version()
if major > 0:
raise UndercoatError(
'Unsupported API version: %d.%d.%d' % (major, minor, patch)) | Check that the undercoat API version is supported. Raises an error if it is not. |
157,392 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
def add_running_handle(handle):
"""Record a handle as potentially needing to be cleaned up on restart."""
new_handle_list = list(set(get_running_handles()) | {handle})
persistent_cache.set_value(
HANDLE_CACHE_KEY, new_handle_list, persist_across_reboots=True)
def undercoat_api_command(*args, timeout=None):
"""Make an API call to the undercoat binary."""
logs.log(f'Running undercoat command {args}')
bundle_dir = environment.get_value('FUCHSIA_RESOURCES_DIR')
undercoat_path = os.path.join(bundle_dir, 'undercoat', 'undercoat')
undercoat = new_process.ProcessRunner(undercoat_path, args)
# The undercoat log is sent to stderr, which we capture to a tempfile
with tempfile.TemporaryFile() as undercoat_log:
result = undercoat.run_and_wait(
timeout=timeout,
stderr=undercoat_log,
extra_env={'TMPDIR': get_temp_dir()})
result.output = utils.decode_to_unicode(result.output)
if result.return_code != 0:
# Dump the undercoat log to assist in debugging
log_data = utils.read_from_handle_truncated(undercoat_log, 1024 * 1024)
logs.log_warn('Log output from undercoat: ' +
utils.decode_to_unicode(log_data))
# The API error message is returned on stdout
raise UndercoatError(
'Error running undercoat command %s: %s' % (args, result.output))
return result
The provided code snippet includes necessary dependencies for implementing the `start_instance` function. Write a Python function `def start_instance()` to solve the following problem:
Start an instance via undercoat.
Here is the function:
def start_instance():
"""Start an instance via undercoat."""
handle = undercoat_api_command('start_instance').output.strip()
logs.log('Started undercoat instance with handle %s' % handle)
# Immediately save the handle in case we crash before stop_instance()
# is called
add_running_handle(handle)
return handle | Start an instance via undercoat. |
157,393 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
def remove_running_handle(handle):
"""Remove a handle from the tracked set."""
new_handle_list = list(set(get_running_handles()) - {handle})
persistent_cache.set_value(
HANDLE_CACHE_KEY, new_handle_list, persist_across_reboots=True)
def get_running_handles():
"""Get a list of potentially stale handles from previous runs."""
return persistent_cache.get_value(HANDLE_CACHE_KEY, default_value=[])
def get_temp_dir():
"""Define a tempdir for undercoat to store its data in.
This tempdir needs to be of a scope that persists across invocations of the
bot, to ensure proper cleanup of stale handles/data."""
temp_dir = os.path.join(environment.get_value('ROOT_DIR'), 'bot', 'undercoat')
os.makedirs(temp_dir, exist_ok=True)
return temp_dir
class UndercoatError(Exception):
"""Error for errors while running undercoat."""
def undercoat_instance_command(command,
handle,
*args,
timeout=None,
abort_on_error=True):
"""Helper for the subset of undercoat commands that operate on an instance."""
try:
return undercoat_api_command(
command, '-handle', handle, *args, timeout=timeout)
except UndercoatError:
if abort_on_error:
# Try to print extra logs and shut down
# TODO(eep): Should we be attempting to automatically restart?
dump_instance_logs(handle)
stop_instance(handle)
raise
The provided code snippet includes necessary dependencies for implementing the `stop_all` function. Write a Python function `def stop_all()` to solve the following problem:
Attempt to stop any running undercoat instances that may have not been cleanly shut down.
Here is the function:
def stop_all():
"""Attempt to stop any running undercoat instances that may have not been
cleanly shut down."""
for handle in get_running_handles():
try:
undercoat_instance_command('stop_instance', handle, abort_on_error=False)
except UndercoatError:
pass
# Even if we failed to stop_instance above, there's no point in trying
# again later
remove_running_handle(handle)
# At this point, all handles/data should have been cleaned up, but if any is
# remaining then we clear it out here
shutil.rmtree(get_temp_dir()) | Attempt to stop any running undercoat instances that may have not been cleanly shut down. |
157,394 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
def undercoat_instance_command(command,
handle,
*args,
timeout=None,
abort_on_error=True):
"""Helper for the subset of undercoat commands that operate on an instance."""
try:
return undercoat_api_command(
command, '-handle', handle, *args, timeout=timeout)
except UndercoatError:
if abort_on_error:
# Try to print extra logs and shut down
# TODO(eep): Should we be attempting to automatically restart?
dump_instance_logs(handle)
stop_instance(handle)
raise
The provided code snippet includes necessary dependencies for implementing the `list_fuzzers` function. Write a Python function `def list_fuzzers(handle)` to solve the following problem:
List fuzzers available on an instance, via undercoat.
Here is the function:
def list_fuzzers(handle):
"""List fuzzers available on an instance, via undercoat."""
return undercoat_instance_command('list_fuzzers', handle).output.split('\n') | List fuzzers available on an instance, via undercoat. |
157,395 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
def undercoat_instance_command(command,
handle,
*args,
timeout=None,
abort_on_error=True):
"""Helper for the subset of undercoat commands that operate on an instance."""
try:
return undercoat_api_command(
command, '-handle', handle, *args, timeout=timeout)
except UndercoatError:
if abort_on_error:
# Try to print extra logs and shut down
# TODO(eep): Should we be attempting to automatically restart?
dump_instance_logs(handle)
stop_instance(handle)
raise
The provided code snippet includes necessary dependencies for implementing the `prepare_fuzzer` function. Write a Python function `def prepare_fuzzer(handle, fuzzer)` to solve the following problem:
Prepare a fuzzer of the given name for use, via undercoat.
Here is the function:
def prepare_fuzzer(handle, fuzzer):
"""Prepare a fuzzer of the given name for use, via undercoat."""
return undercoat_instance_command('prepare_fuzzer', handle, '-fuzzer', fuzzer) | Prepare a fuzzer of the given name for use, via undercoat. |
157,396 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
def undercoat_instance_command(command,
handle,
*args,
timeout=None,
abort_on_error=True):
"""Helper for the subset of undercoat commands that operate on an instance."""
try:
return undercoat_api_command(
command, '-handle', handle, *args, timeout=timeout)
except UndercoatError:
if abort_on_error:
# Try to print extra logs and shut down
# TODO(eep): Should we be attempting to automatically restart?
dump_instance_logs(handle)
stop_instance(handle)
raise
The provided code snippet includes necessary dependencies for implementing the `run_fuzzer` function. Write a Python function `def run_fuzzer(handle, fuzzer, outdir, args, timeout=None)` to solve the following problem:
Run a fuzzer of the given name, via undercoat.
Here is the function:
def run_fuzzer(handle, fuzzer, outdir, args, timeout=None):
"""Run a fuzzer of the given name, via undercoat."""
# TODO(fxbug.dev/47490): Pass back raw return code from libFuzzer?
undercoat_args = ['-fuzzer', fuzzer]
if outdir:
undercoat_args += ['-artifact-dir', outdir]
args = undercoat_args + ['--'] + args
return undercoat_instance_command(
'run_fuzzer', handle, *args, timeout=timeout) | Run a fuzzer of the given name, via undercoat. |
157,397 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
def undercoat_instance_command(command,
handle,
*args,
timeout=None,
abort_on_error=True):
"""Helper for the subset of undercoat commands that operate on an instance."""
try:
return undercoat_api_command(
command, '-handle', handle, *args, timeout=timeout)
except UndercoatError:
if abort_on_error:
# Try to print extra logs and shut down
# TODO(eep): Should we be attempting to automatically restart?
dump_instance_logs(handle)
stop_instance(handle)
raise
The provided code snippet includes necessary dependencies for implementing the `put_data` function. Write a Python function `def put_data(handle, fuzzer, src, dst)` to solve the following problem:
Put files for a fuzzer onto an instance, via undercoat. If src is a directory, it will be copied recursively. Standard globs are supported.
Here is the function:
def put_data(handle, fuzzer, src, dst):
"""Put files for a fuzzer onto an instance, via undercoat.
If src is a directory, it will be copied recursively. Standard globs are
supported."""
return undercoat_instance_command('put_data', handle, '-fuzzer', fuzzer,
'-src', src, '-dst', dst).output | Put files for a fuzzer onto an instance, via undercoat. If src is a directory, it will be copied recursively. Standard globs are supported. |
157,398 | import os
import shutil
import tempfile
from clusterfuzz._internal.base import persistent_cache
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment
from clusterfuzz._internal.system import new_process
class UndercoatError(Exception):
"""Error for errors while running undercoat."""
def undercoat_instance_command(command,
handle,
*args,
timeout=None,
abort_on_error=True):
"""Helper for the subset of undercoat commands that operate on an instance."""
try:
return undercoat_api_command(
command, '-handle', handle, *args, timeout=timeout)
except UndercoatError:
if abort_on_error:
# Try to print extra logs and shut down
# TODO(eep): Should we be attempting to automatically restart?
dump_instance_logs(handle)
stop_instance(handle)
raise
The provided code snippet includes necessary dependencies for implementing the `get_data` function. Write a Python function `def get_data(handle, fuzzer, src, dst)` to solve the following problem:
Get files from a fuzzer on an instance, via undercoat. If src is a directory, it will be copied recursively. Standard globs are supported.
Here is the function:
def get_data(handle, fuzzer, src, dst):
"""Get files from a fuzzer on an instance, via undercoat.
If src is a directory, it will be copied recursively. Standard globs are
supported."""
try:
return undercoat_instance_command(
'get_data',
handle,
'-fuzzer',
fuzzer,
'-src',
src,
'-dst',
dst,
abort_on_error=False).output
except UndercoatError:
return None | Get files from a fuzzer on an instance, via undercoat. If src is a directory, it will be copied recursively. Standard globs are supported. |
157,399 | import re
def _complex_tokenize(s, limit):
"""Tokenize a string into complex tokens. For example, a:b:c is tokenized into
['a', 'b', 'c', 'a:b', 'a:b:c', 'b:c']. This method works recursively. It
generates all possible complex tokens starting from the first token. Then,
it cuts off the first token and calls _complex_tokenize(..) with the rest
of `s`.
`limit` restricts the number of atomic tokens."""
if not s:
return set()
tokens = []
second_token_index = len(s)
count = 0
for end_index, next_start_index in _token_indices(s):
tokens.append(s[0:(end_index + 1)])
count += 1
second_token_index = min(next_start_index, second_token_index)
if count >= limit:
break
tokens = {t.lower() for t in tokens if t.strip()}
tokens |= _complex_tokenize(s[second_token_index:], limit=limit)
return tokens
The provided code snippet includes necessary dependencies for implementing the `tokenize` function. Write a Python function `def tokenize(s)` to solve the following problem:
Tokenize a string, by line, into atomic tokens and complex tokens.
Here is the function:
def tokenize(s):
"""Tokenize a string, by line, into atomic tokens and complex tokens."""
if not s:
s = ''
s = '%s' % s
tokens = set()
lines = s.splitlines()
for line in lines:
line = line.strip()
only_ascii = re.sub(r'\s*[^\x00-\x7F]+\s*', ' ', line)
tokens |= _complex_tokenize(only_ascii, limit=10)
tokens.add(line.lower())
return tokens | Tokenize a string, by line, into atomic tokens and complex tokens. |
157,400 | import re
The provided code snippet includes necessary dependencies for implementing the `tokenize_bug_information` function. Write a Python function `def tokenize_bug_information(testcase)` to solve the following problem:
Tokenize bug information for searching.
Here is the function:
def tokenize_bug_information(testcase):
"""Tokenize bug information for searching."""
bug_indices = []
if testcase.bug_information:
bug_indices.append(testcase.bug_information.lower().strip())
if testcase.group_bug_information:
bug_indices.append(str(testcase.group_bug_information))
return bug_indices | Tokenize bug information for searching. |
157,401 | import re
The provided code snippet includes necessary dependencies for implementing the `tokenize_impact_version` function. Write a Python function `def tokenize_impact_version(version)` to solve the following problem:
Tokenize impact.
Here is the function:
def tokenize_impact_version(version):
"""Tokenize impact."""
if not version:
return []
tokens = set()
splitted = version.split('.')
for index in range(len(splitted)):
tokens.add('.'.join(splitted[0:(index + 1)]))
return [t for t in tokens if t.strip()] | Tokenize impact. |
157,402 | import re
The provided code snippet includes necessary dependencies for implementing the `prepare_search_keyword` function. Write a Python function `def prepare_search_keyword(s)` to solve the following problem:
Prepare the search keywords into the form that is appropriate for searching according to our tokenization algorithm.
Here is the function:
def prepare_search_keyword(s):
"""Prepare the search keywords into the form that is appropriate for searching
according to our tokenization algorithm."""
return s.lower().strip() | Prepare the search keywords into the form that is appropriate for searching according to our tokenization algorithm. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.