Skip to content

Commit 8081739

Browse files
authored
Merge pull request #14 from HyperionGray/generator_improvements
Generator improvements
2 parents 989c5ed + a55c586 commit 8081739

21 files changed

Lines changed: 218 additions & 229 deletions

cdp/browser.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ def get_histograms(
302302
'''
303303
Get Chrome histograms.
304304
305-
:param query: Requested substring in name. Only histograms which have query as a
306-
substring in their name are extracted. An empty or absent query returns
307-
all histograms.
305+
:param query: Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms.
308306
:param delta: If true, retrieve delta since last call.
309307
:returns: Histograms.
310308
'''
@@ -398,8 +396,7 @@ def set_window_bounds(
398396
Set position and/or size of the browser window.
399397
400398
:param window_id: Browser window id.
401-
:param bounds: New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined
402-
with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
399+
:param bounds: New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
403400
'''
404401
params: T_JSON_DICT = dict()
405402
params['windowId'] = window_id.to_json()

cdp/debugger.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ def enable(
297297
Enables debugger for the given page. Clients should not assume that the debugging has been
298298
enabled until the result for this command is received.
299299
300-
:param max_scripts_cache_size: The maximum size in bytes of collected scripts (not referenced by other heap objects)
301-
the debugger can hold. Puts no limit if paramter is omitted.
300+
:param max_scripts_cache_size: The maximum size in bytes of collected scripts (not referenced by other heap objects) the debugger can hold. Puts no limit if paramter is omitted.
302301
:returns: Unique identifier of the debugger.
303302
'''
304303
params: T_JSON_DICT = dict()
@@ -328,12 +327,9 @@ def evaluate_on_call_frame(
328327
329328
:param call_frame_id: Call frame identifier to evaluate on.
330329
:param expression: Expression to evaluate.
331-
:param object_group: String object group name to put result into (allows rapid releasing resulting object handles
332-
using ``releaseObjectGroup``).
333-
:param include_command_line_api: Specifies whether command line API should be available to the evaluated expression, defaults
334-
to false.
335-
:param silent: In silent mode exceptions thrown during evaluation are not reported and do not pause
336-
execution. Overrides ``setPauseOnException`` state.
330+
:param object_group: String object group name to put result into (allows rapid releasing resulting object handles using ``releaseObjectGroup``).
331+
:param include_command_line_api: Specifies whether command line API should be available to the evaluated expression, defaults to false.
332+
:param silent: In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides ``setPauseOnException`` state.
337333
:param return_by_value: Whether the result is expected to be a JSON object that should be sent by value.
338334
:param generate_preview: Whether preview should be generated for the result.
339335
:param throw_on_side_effect: Whether to throw an exception if side effect cannot be ruled out during evaluation.
@@ -380,8 +376,7 @@ def get_possible_breakpoints(
380376
the same.
381377
382378
:param start: Start of range to search possible breakpoint locations in.
383-
:param end: End of range to search possible breakpoint locations in (excluding). When not specified, end
384-
of scripts is used as end of range.
379+
:param end: End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range.
385380
:param restrict_to_function: Only consider locations which are in the same (non-nested) function as start.
386381
:returns: List of the possible breakpoint locations.
387382
'''
@@ -551,8 +546,7 @@ def set_async_call_stack_depth(
551546
'''
552547
Enables or disables async call stacks tracking.
553548
554-
:param max_depth: Maximum depth of async call stacks. Setting to ``0`` will effectively disable collecting async
555-
call stacks (default).
549+
:param max_depth: Maximum depth of async call stacks. Setting to ``0`` will effectively disable collecting async call stacks (default).
556550
'''
557551
params: T_JSON_DICT = dict()
558552
params['maxDepth'] = max_depth
@@ -613,8 +607,7 @@ def set_breakpoint(
613607
Sets JavaScript breakpoint at a given location.
614608
615609
:param location: Location to set breakpoint in.
616-
:param condition: Expression to use as a breakpoint condition. When specified, debugger will only stop on the
617-
breakpoint if this expression evaluates to true.
610+
:param condition: Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
618611
:returns: a tuple with the following items:
619612
0. breakpointId: Id of the created breakpoint for further reference.
620613
1. actualLocation: Location this breakpoint resolved into.
@@ -669,12 +662,10 @@ def set_breakpoint_by_url(
669662
670663
:param line_number: Line number to set breakpoint at.
671664
:param url: URL of the resources to set breakpoint on.
672-
:param url_regex: Regex pattern for the URLs of the resources to set breakpoints on. Either ``url`` or
673-
``urlRegex`` must be specified.
665+
:param url_regex: Regex pattern for the URLs of the resources to set breakpoints on. Either ``url`` or ``urlRegex`` must be specified.
674666
:param script_hash: Script hash of the resources to set breakpoint on.
675667
:param column_number: Offset in the line to set breakpoint at.
676-
:param condition: Expression to use as a breakpoint condition. When specified, debugger will only stop on the
677-
breakpoint if this expression evaluates to true.
668+
:param condition: Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
678669
:returns: a tuple with the following items:
679670
0. breakpointId: Id of the created breakpoint for further reference.
680671
1. locations: List of the locations this breakpoint resolved into upon addition.
@@ -712,8 +703,7 @@ def set_breakpoint_on_function_call(
712703
calling it will also trigger the breakpoint.
713704
714705
:param object_id: Function object id.
715-
:param condition: Expression to use as a breakpoint condition. When specified, debugger will
716-
stop on the breakpoint if this expression evaluates to true.
706+
:param condition: Expression to use as a breakpoint condition. When specified, debugger will stop on the breakpoint if this expression evaluates to true.
717707
:returns: Id of the created breakpoint for further reference.
718708
'''
719709
params: T_JSON_DICT = dict()
@@ -790,8 +780,7 @@ def set_script_source(
790780
791781
:param script_id: Id of the script to edit.
792782
:param script_source: New content of the script.
793-
:param dry_run: If true the change will not actually be applied. Dry run may be used to get result
794-
description without actually modifying the code.
783+
:param dry_run: If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code.
795784
:returns: a tuple with the following items:
796785
0. callFrames: (Optional) New stack trace in case editing has happened while VM was stopped.
797786
1. stackChanged: (Optional) Whether current call stack was modified after applying the changes.
@@ -845,8 +834,7 @@ def set_variable_value(
845834
Changes value of variable in a callframe. Object-based scopes are not supported and must be
846835
mutated manually.
847836
848-
:param scope_number: 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch'
849-
scope types are allowed. Other scopes could be manipulated manually.
837+
:param scope_number: 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually.
850838
:param variable_name: Variable name.
851839
:param new_value: New variable value.
852840
:param call_frame_id: Id of callframe that holds variable.
@@ -869,8 +857,7 @@ def step_into(
869857
'''
870858
Steps into the function call.
871859
872-
:param break_on_async_call: Debugger will issue additional Debugger.paused notification if any async task is scheduled
873-
before next pause.
860+
:param break_on_async_call: Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause.
874861
'''
875862
params: T_JSON_DICT = dict()
876863
if break_on_async_call is not None:

cdp/dom.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,7 @@ def copy_to(
498498
499499
:param node_id: Id of the node to copy.
500500
:param target_node_id: Id of the element to drop the copy into.
501-
:param insert_before_node_id: Drop the copy before this node (if absent, the copy becomes the last child of
502-
``targetNodeId``).
501+
:param insert_before_node_id: Drop the copy before this node (if absent, the copy becomes the last child of ``targetNodeId``).
503502
:returns: Id of the node clone.
504503
'''
505504
params: T_JSON_DICT = dict()
@@ -529,10 +528,8 @@ def describe_node(
529528
:param node_id: Identifier of the node.
530529
:param backend_node_id: Identifier of the backend node.
531530
:param object_id: JavaScript object id of the node wrapper.
532-
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the
533-
entire subtree or provide an integer larger than 0.
534-
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree
535-
(default is false).
531+
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
532+
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
536533
:returns: Node description.
537534
'''
538535
params: T_JSON_DICT = dict()
@@ -701,10 +698,8 @@ def get_document(
701698
'''
702699
Returns the root DOM node (and optionally the subtree) to the caller.
703700
704-
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the
705-
entire subtree or provide an integer larger than 0.
706-
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree
707-
(default is false).
701+
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
702+
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
708703
:returns: Resulting node.
709704
'''
710705
params: T_JSON_DICT = dict()
@@ -727,10 +722,8 @@ def get_flattened_document(
727722
'''
728723
Returns the root DOM node (and optionally the subtree) to the caller.
729724
730-
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the
731-
entire subtree or provide an integer larger than 0.
732-
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree
733-
(default is false).
725+
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
726+
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
734727
:returns: Resulting node.
735728
'''
736729
params: T_JSON_DICT = dict()
@@ -901,8 +894,7 @@ def move_to(
901894
902895
:param node_id: Id of the node to move.
903896
:param target_node_id: Id of the element to drop the moved node into.
904-
:param insert_before_node_id: Drop node before this one (if absent, the moved node becomes the last child of
905-
``targetNodeId``).
897+
:param insert_before_node_id: Drop node before this one (if absent, the moved node becomes the last child of ``targetNodeId``).
906898
:returns: New id of the moved node.
907899
'''
908900
params: T_JSON_DICT = dict()
@@ -1088,10 +1080,8 @@ def request_child_nodes(
10881080
the specified depth.
10891081
10901082
:param node_id: Id of the node to get children for.
1091-
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the
1092-
entire subtree or provide an integer larger than 0.
1093-
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the sub-tree
1094-
(default is false).
1083+
:param depth: The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
1084+
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false).
10951085
'''
10961086
params: T_JSON_DICT = dict()
10971087
params['nodeId'] = node_id.to_json()
@@ -1193,8 +1183,7 @@ def set_attributes_as_text(
11931183
11941184
:param node_id: Id of the element to set attributes for.
11951185
:param text: Text with a number of attributes. Will parse this text using HTML parser.
1196-
:param name: Attribute name to replace with new attributes derived from text in case text parsed
1197-
successfully.
1186+
:param name: Attribute name to replace with new attributes derived from text in case text parsed successfully.
11981187
'''
11991188
params: T_JSON_DICT = dict()
12001189
params['nodeId'] = node_id.to_json()

cdp/dom_debugger.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ def get_event_listeners(
110110
Returns event listeners of the given object.
111111
112112
:param object_id: Identifier of the object to return listeners for.
113-
:param depth: The maximum depth at which Node children should be retrieved, defaults to 1. Use -1 for the
114-
entire subtree or provide an integer larger than 0.
115-
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree
116-
(default is false). Reports listeners for all contexts if pierce is enabled.
113+
:param depth: The maximum depth at which Node children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
114+
:param pierce: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Reports listeners for all contexts if pierce is enabled.
117115
:returns: Array of relevant listeners.
118116
'''
119117
params: T_JSON_DICT = dict()
@@ -233,8 +231,7 @@ def set_event_listener_breakpoint(
233231
Sets breakpoint on particular DOM event.
234232
235233
:param event_name: DOM Event name to stop on (any DOM event will do).
236-
:param target_name: EventTarget interface name to stop on. If equal to ``"*"`` or not provided, will stop on any
237-
EventTarget.
234+
:param target_name: EventTarget interface name to stop on. If equal to ``"*"`` or not provided, will stop on any EventTarget.
238235
'''
239236
params: T_JSON_DICT = dict()
240237
params['eventName'] = event_name

cdp/dom_snapshot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from . import dom
1717
from . import dom_debugger
1818
from . import page
19+
from deprecated.sphinx import deprecated # type: ignore
1920

2021

2122
@dataclass
@@ -738,13 +739,16 @@ def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
738739
json = yield cmd_dict
739740

740741

742+
@deprecated(version="1.3")
741743
def get_snapshot(
742744
computed_style_whitelist: typing.List[str],
743745
include_event_listeners: typing.Optional[bool] = None,
744746
include_paint_order: typing.Optional[bool] = None,
745747
include_user_agent_shadow_tree: typing.Optional[bool] = None
746748
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List['DOMNode'], typing.List['LayoutTreeNode'], typing.List['ComputedStyle']]]:
747749
'''
750+
.. deprecated:: 1.3
751+
748752
Returns a document snapshot, including the full DOM tree of the root node (including iframes,
749753
template contents, and imported documents) in a flattened array, as well as layout and
750754
white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is

0 commit comments

Comments
 (0)