Skip to content

Commit d617041

Browse files
author
AutomatedTester
committed
updated docstrings for easier formatting on things like RTDs
1 parent 8b838a4 commit d617041

File tree

8 files changed

+252
-95
lines changed

8 files changed

+252
-95
lines changed

browsermobproxy/client.py

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ class Client(object):
66
def __init__(self, url):
77
"""
88
Initialises a new Client object
9-
:Args:
10-
- url: This is where the BrowserMob Proxy lives
9+
10+
url: str
11+
This is where the BrowserMob Proxy lives
1112
"""
1213
self.host = "http://" + url
1314
resp = requests.post('%s/proxy' % self.host, urlencode(''))
@@ -66,13 +67,15 @@ def har(self):
6667
def new_har(self, ref=None, options={}):
6768
"""
6869
This sets a new HAR to be recorded
69-
:Args:
70-
- ref: A reference for the HAR. Defaults to None
71-
- options: A dictionary that will be passed to BrowserMob Proxy \
70+
71+
- ref: unicode
72+
A reference for the HAR. Defaults to None
73+
- options: dict
74+
A dictionary that will be passed to BrowserMob Proxy \
7275
with specific keywords. Keywords are: \
73-
captureHeaders - Boolean, capture headers \
74-
captureContent - Boolean, capture content bodies \
75-
captureBinaryContent - Boolean, capture binary content
76+
captureHeaders - Boolean, capture headers \
77+
captureContent - Boolean, capture content bodies \
78+
captureBinaryContent - Boolean, capture binary content
7679
"""
7780
if ref:
7881
payload = {"initialPageRef": ref}
@@ -90,8 +93,9 @@ def new_har(self, ref=None, options={}):
9093
def new_page(self, ref=None):
9194
"""
9295
This sets a new page to be recorded
93-
:Args:
94-
- ref: A reference for the new page. Defaults to None
96+
97+
- ref: unicode
98+
A reference for the new page. Defaults to None
9599
"""
96100
if ref:
97101
payload = {"pageRef": ref}
@@ -104,10 +108,12 @@ def new_page(self, ref=None):
104108
def blacklist(self, regexp, status_code):
105109
"""
106110
Sets a list of URL patterns to blacklist
107-
:Args:
108-
- regex: a comma separated list of regular expressions
109-
- status_code: the HTTP status code to return for URLs that do not \
110-
match the blacklist
111+
112+
- regex: unicode
113+
a comma separated list of regular expressions
114+
- status_code: unicode
115+
the HTTP status code to return for URLs that do not \
116+
match the blacklist
111117
112118
"""
113119
r = requests.put('%s/proxy/%s/blacklist' % (self.host, self.port),
@@ -117,10 +123,12 @@ def blacklist(self, regexp, status_code):
117123
def whitelist(self, regexp, status_code):
118124
"""
119125
Sets a list of URL patterns to whitelist
120-
:Args:
121-
- regex: a comma separated list of regular expressions
122-
- status_code: the HTTP status code to return for URLs that do not \
123-
match the whitelist
126+
127+
- regex: unicode
128+
a comma separated list of regular expressions
129+
- status_code: unicode
130+
the HTTP status code to return for URLs that do not \
131+
match the whitelist
124132
"""
125133
r = requests.put('%s/proxy/%s/whitelist' % (self.host, self.port),
126134
{'regex': regexp, 'status': status_code})
@@ -129,10 +137,13 @@ def whitelist(self, regexp, status_code):
129137
def basic_authentication(self, domain, username, password):
130138
"""
131139
This add automatic basic authentication
132-
:Args:
133-
- domain: domain to set authentication credentials for
134-
- username: valid username to use when authenticating
135-
- password: valid password to use when authenticating
140+
141+
- domain: unicode
142+
domain to set authentication credentials for
143+
- username: unicode
144+
valid username to use when authenticating
145+
- password: unicode
146+
valid password to use when authenticating
136147
"""
137148
r = requests.post(url='%s/proxy/%s/auth/basic/%s' % (self.host, self.port, domain),
138149
data=json.dumps({'username': username, 'password': password}),
@@ -142,8 +153,9 @@ def basic_authentication(self, domain, username, password):
142153
def headers(self, headers):
143154
"""
144155
This sets the headers that will set by the proxy on all requests
145-
:Args:
146-
- headers: this is a dictionary of the headers to be set
156+
157+
- headers: dict
158+
this is a dictionary of the headers to be set
147159
"""
148160
if not isinstance(headers, dict):
149161
raise TypeError("headers needs to be dictionary")
@@ -156,8 +168,9 @@ def headers(self, headers):
156168
def response_interceptor(self, js):
157169
"""
158170
Executes the javascript against each response
159-
:Args:
160-
- js: the javascript to execute
171+
172+
- js: unicode
173+
the javascript to execute
161174
"""
162175
r = requests.post(url='%s/proxy/%s/interceptor/response' % (self.host, self.port),
163176
data=js,
@@ -167,8 +180,9 @@ def response_interceptor(self, js):
167180
def request_interceptor(self, js):
168181
"""
169182
Executes the javascript against each request
170-
:Args:
171-
- js: the javascript to execute
183+
184+
- js: unicode
185+
the javascript to execute
172186
"""
173187
r = requests.post(url='%s/proxy/%s/interceptor/request' % (self.host, self.port),
174188
data=js,
@@ -184,8 +198,9 @@ def request_interceptor(self, js):
184198
def limits(self, options):
185199
"""
186200
Limit the bandwidth through the proxy.
187-
:Args:
188-
- options: A dictionary with all the details you want to set. \
201+
202+
- options: dict
203+
A dictionary with all the details you want to set. \
189204
downstreamKbps - Sets the downstream kbps \
190205
upstreamKbps - Sets the upstream kbps \
191206
latency - Add the given latency to each HTTP request
@@ -215,8 +230,9 @@ def limits(self, options):
215230
def timeouts(self, options):
216231
"""
217232
Configure various timeouts in the proxy
218-
:Args:
219-
- options: A dictionary with all the details you want to set. \
233+
234+
- options: dict
235+
A dictionary with all the details you want to set. \
220236
request - request timeout (in seconds) \
221237
read - read timeout (in seconds) \
222238
connection - connection timeout (in seconds) \
@@ -240,9 +256,11 @@ def timeouts(self, options):
240256
def remap_hosts(self, address, ip_address):
241257
"""
242258
Remap the hosts for a specific URL
243-
:Args:
244-
- address - url that you wish to remap
245-
- ip_address - IP Address that will handle all traffic for the address passed in
259+
260+
- address: unicode
261+
url that you wish to remap
262+
- ip_address: unicode
263+
IP Address that will handle all traffic for the address passed in
246264
"""
247265
assert address is not None and ip_address is not None
248266
r = requests.post('%s/proxy/%s/hosts' % (self.host, self.port),
@@ -253,9 +271,11 @@ def remap_hosts(self, address, ip_address):
253271
def wait_for_traffic_to_stop(self, quiet_period, timeout):
254272
"""
255273
Waits for the network to be quiet
256-
:Args:
257-
- quiet_period - number of seconds the network needs to be quiet for
258-
- timeout - max number of seconds to wait
274+
275+
- quiet_period: int
276+
number of seconds the network needs to be quiet for
277+
- timeout: int
278+
max number of seconds to wait
259279
"""
260280
r = requests.put('%s/proxy/%s/wait' % (self.host, self.port),
261281
{'quietPeriodInMs': quiet_period, 'timeoutInMs': timeout})
@@ -271,9 +291,11 @@ def clear_dns_cache(self):
271291
def rewrite_url(self, match, replace):
272292
"""
273293
Rewrites the requested url.
274-
:Args:
275-
- match - a regex to match requests with
276-
- replace - a string to replace the matches with
294+
295+
- match: unicode
296+
a regex to match requests with
297+
- replace: unicode
298+
a string to replace the matches with
277299
"""
278300
params = {
279301
"matchRegex": match,
@@ -286,8 +308,9 @@ def rewrite_url(self, match, replace):
286308
def retry(self, retry_count):
287309
"""
288310
Retries. No idea what its used for, but its in the API...
289-
:Args:
290-
- retry_count - the number of retries
311+
312+
- retry_count: int
313+
the number of retries
291314
"""
292315
r = requests.put('%s/proxy/%s/retry' % (self.host, self.port),
293316
{'retrycount': retry_count})
18.3 KB
Binary file not shown.
-217 Bytes
Binary file not shown.
-1.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)