• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Copyright (c) 2024 Huawei Device Co., Ltd.
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9    http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16
17Description: Python CDP Runtime.
18"""
19
20from typing import Optional
21
22
23def enable():
24    command = {'method': 'Runtime.enable'}
25    return command
26
27
28def run_if_waiting_for_debugger():
29    command = {'method': 'Runtime.runIfWaitingForDebugger'}
30    return command
31
32
33def get_properties(object_id: str,
34                   own_properties: Optional[bool] = None,
35                   accessor_properties_only: Optional[bool] = None,
36                   generate_preview: Optional[bool] = None,
37                   non_indexed_properties_only: Optional[bool] = None):
38    command = {'method': 'Runtime.getProperties'}
39    params = {'objectId': object_id}
40    if own_properties is not None:
41        params['ownProperties'] = own_properties
42    if accessor_properties_only is not None:
43        params['accessorPropertiesOnly'] = accessor_properties_only
44    if generate_preview is not None:
45        params['generatePreview'] = generate_preview
46    if non_indexed_properties_only is not None:
47        params['nonIndexedPropertiesOnly'] = non_indexed_properties_only
48    command['params'] = params
49    return command
50