1e509ee18Sopenharmony_ci#!/usr/bin/env python3 2e509ee18Sopenharmony_ci# -*- coding: utf-8 -*- 3e509ee18Sopenharmony_ci""" 4e509ee18Sopenharmony_ciCopyright (c) 2024 Huawei Device Co., Ltd. 5e509ee18Sopenharmony_ciLicensed under the Apache License, Version 2.0 (the "License"); 6e509ee18Sopenharmony_ciyou may not use this file except in compliance with the License. 7e509ee18Sopenharmony_ciYou may obtain a copy of the License at 8e509ee18Sopenharmony_ci 9e509ee18Sopenharmony_ci http://www.apache.org/licenses/LICENSE-2.0 10e509ee18Sopenharmony_ci 11e509ee18Sopenharmony_ciUnless required by applicable law or agreed to in writing, software 12e509ee18Sopenharmony_cidistributed under the License is distributed on an "AS IS" BASIS, 13e509ee18Sopenharmony_ciWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14e509ee18Sopenharmony_ciSee the License for the specific language governing permissions and 15e509ee18Sopenharmony_cilimitations under the License. 16e509ee18Sopenharmony_ci 17e509ee18Sopenharmony_ciDescription: Python CDP Runtime. 18e509ee18Sopenharmony_ci""" 19e509ee18Sopenharmony_ci 20e509ee18Sopenharmony_cifrom dataclasses import dataclass 21e509ee18Sopenharmony_cifrom typing import Optional 22e509ee18Sopenharmony_ci 23e509ee18Sopenharmony_ci 24e509ee18Sopenharmony_ci@dataclass 25e509ee18Sopenharmony_ciclass GetPropertiesParams: 26e509ee18Sopenharmony_ci object_id: str = "" 27e509ee18Sopenharmony_ci own_properties: bool = True 28e509ee18Sopenharmony_ci accessor_properties_only: bool = False 29e509ee18Sopenharmony_ci generate_preview: bool = True 30e509ee18Sopenharmony_ci non_indexed_properties_only: Optional[bool] = None 31e509ee18Sopenharmony_ci 32e509ee18Sopenharmony_ci 33e509ee18Sopenharmony_cidef enable(): 34e509ee18Sopenharmony_ci command = {'method': 'Runtime.enable'} 35e509ee18Sopenharmony_ci return command 36e509ee18Sopenharmony_ci 37e509ee18Sopenharmony_ci 38e509ee18Sopenharmony_cidef run_if_waiting_for_debugger(): 39e509ee18Sopenharmony_ci command = {'method': 'Runtime.runIfWaitingForDebugger'} 40e509ee18Sopenharmony_ci return command 41e509ee18Sopenharmony_ci 42e509ee18Sopenharmony_ci 43e509ee18Sopenharmony_cidef get_properties(params: GetPropertiesParams): 44e509ee18Sopenharmony_ci command = {'method': 'Runtime.getProperties', 45e509ee18Sopenharmony_ci 'params': {'objectId': params.object_id, 46e509ee18Sopenharmony_ci 'ownProperties': params.own_properties, 47e509ee18Sopenharmony_ci 'accessorPropertiesOnly': params.accessor_properties_only, 48e509ee18Sopenharmony_ci 'generatePreview': params.generate_preview}} 49e509ee18Sopenharmony_ci if params.non_indexed_properties_only is not None: 50e509ee18Sopenharmony_ci command['params']['nonIndexedPropertiesOnly'] = params.non_indexed_properties_only 51e509ee18Sopenharmony_ci return command 52e509ee18Sopenharmony_ci 53e509ee18Sopenharmony_ci 54e509ee18Sopenharmony_cidef get_heap_usage(): 55e509ee18Sopenharmony_ci return {'method': 'Runtime.getHeapUsage'}