blob: 4dec0084efdffb4ce6f29e23e20beebbcc80c4fb [file] [log] [blame]
Joe Gregorioad8013f2012-08-03 08:44:02 -04001<?xml version="1.0" encoding="ascii"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5<head>
6 <title>oauth2client.util</title>
7 <link rel="stylesheet" href="epydoc.css" type="text/css" />
8 <script type="text/javascript" src="epydoc.js"></script>
9</head>
10
11<body bgcolor="white" text="black" link="blue" vlink="#204080"
12 alink="#204080">
13<!-- ==================== NAVIGATION BAR ==================== -->
14<table class="navbar" border="0" width="100%" cellpadding="0"
15 bgcolor="#a0c0ff" cellspacing="0">
16 <tr valign="middle">
17
18 <!-- Tree link -->
19 <th>&nbsp;&nbsp;&nbsp;<a
20 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
21
22 <!-- Index link -->
23 <th>&nbsp;&nbsp;&nbsp;<a
24 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
25
26 <!-- Help link -->
27 <th>&nbsp;&nbsp;&nbsp;<a
28 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
29
30 <th class="navbar" width="100%"></th>
31 </tr>
32</table>
33<table width="100%" cellpadding="0" cellspacing="0">
34 <tr valign="top">
35 <td width="100%">
36 <span class="breadcrumbs">
37 <a href="oauth2client-module.html">Package&nbsp;oauth2client</a> ::
38 Module&nbsp;util
39 </span>
40 </td>
41 <td>
42 <table cellpadding="0" cellspacing="0">
43 <!-- hide/show private -->
44 <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
45 onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
46 <tr><td align="right"><span class="options"
47 >[<a href="frames.html" target="_top">frames</a
48 >]&nbsp;|&nbsp;<a href="oauth2client.util-module.html"
49 target="_top">no&nbsp;frames</a>]</span></td></tr>
50 </table>
51 </td>
52 </tr>
53</table>
54<!-- ==================== MODULE DESCRIPTION ==================== -->
Joe Gregorio1b425aa2012-08-24 12:04:34 -040055<h1 class="epydoc">Module util</h1><p class="nomargin-top"><span class="codelink"><a href="oauth2client.util-pysrc.html">source&nbsp;code</a></span></p>
Joe Gregorioad8013f2012-08-03 08:44:02 -040056<pre class="literalblock">
57Common utility library.
58
59</pre>
60
61<hr />
62<div class="fields"> <dl><dt>Authors:</dt>
63 <dd>
64 rafek@google.com (Rafe Kaplan),
65 guido@google.com (Guido van Rossum)
66 </dd>
67 </dl>
68</div><!-- ==================== FUNCTIONS ==================== -->
69<a name="section-Functions"></a>
70<table class="summary" border="1" cellpadding="3"
71 cellspacing="0" width="100%" bgcolor="white">
72<tr bgcolor="#70b0f0" class="table-header">
73 <td colspan="2" class="table-header">
74 <table border="0" cellpadding="0" cellspacing="0" width="100%">
75 <tr valign="top">
76 <td align="left"><span class="table-header">Functions</span></td>
77 <td align="right" valign="top"
78 ><span class="options">[<a href="#section-Functions"
79 class="privatelink" onclick="toggle_private();"
80 >hide private</a>]</span></td>
81 </tr>
82 </table>
83 </td>
84</tr>
85<tr>
86 <td width="15%" align="right" valign="top" class="summary">
87 <span class="summary-type">&nbsp;</span>
88 </td><td class="summary">
89 <table width="100%" cellpadding="0" cellspacing="0" border="0">
90 <tr>
91 <td><span class="summary-sig"><a href="oauth2client.util-module.html#positional" class="summary-sig-name">positional</a>(<span class="summary-sig-arg">max_positional_args</span>)</span><br />
92 A decorator to declare that only the first N arguments my be positional.</td>
93 <td align="right" valign="top">
Joe Gregorio1b425aa2012-08-24 12:04:34 -040094 <span class="codelink"><a href="oauth2client.util-pysrc.html#positional">source&nbsp;code</a></span>
Joe Gregorioad8013f2012-08-03 08:44:02 -040095
96 </td>
97 </tr>
98 </table>
99
100 </td>
101 </tr>
Joe Gregorio52a5c532013-01-24 16:19:07 -0500102<tr class="private">
103 <td width="15%" align="right" valign="top" class="summary">
104 <span class="summary-type">&nbsp;</span>
105 </td><td class="summary">
106 <table width="100%" cellpadding="0" cellspacing="0" border="0">
107 <tr>
108 <td><span class="summary-sig"><a href="oauth2client.util-module.html#scopes_to_string" class="summary-sig-name" onclick="show_private();">scopes_to_string</a>(<span class="summary-sig-arg">scopes</span>)</span><br />
109 Converts scope value to a string.</td>
110 <td align="right" valign="top">
111 <span class="codelink"><a href="oauth2client.util-pysrc.html#scopes_to_string">source&nbsp;code</a></span>
112
113 </td>
114 </tr>
115 </table>
116
117 </td>
118 </tr>
119<tr class="private">
120 <td width="15%" align="right" valign="top" class="summary">
121 <span class="summary-type">&nbsp;</span>
122 </td><td class="summary">
123 <table width="100%" cellpadding="0" cellspacing="0" border="0">
124 <tr>
125 <td><span class="summary-sig"><a href="oauth2client.util-module.html#dict_to_tuple_key" class="summary-sig-name" onclick="show_private();">dict_to_tuple_key</a>(<span class="summary-sig-arg">dictionary</span>)</span><br />
126 Converts a dictionary to a tuple that can be used as an immutable key.</td>
127 <td align="right" valign="top">
128 <span class="codelink"><a href="oauth2client.util-pysrc.html#dict_to_tuple_key">source&nbsp;code</a></span>
129
130 </td>
131 </tr>
132 </table>
133
134 </td>
135 </tr>
Joe Gregorioad8013f2012-08-03 08:44:02 -0400136</table>
137<!-- ==================== VARIABLES ==================== -->
138<a name="section-Variables"></a>
139<table class="summary" border="1" cellpadding="3"
140 cellspacing="0" width="100%" bgcolor="white">
141<tr bgcolor="#70b0f0" class="table-header">
142 <td colspan="2" class="table-header">
143 <table border="0" cellpadding="0" cellspacing="0" width="100%">
144 <tr valign="top">
145 <td align="left"><span class="table-header">Variables</span></td>
146 <td align="right" valign="top"
147 ><span class="options">[<a href="#section-Variables"
148 class="privatelink" onclick="toggle_private();"
149 >hide private</a>]</span></td>
150 </tr>
151 </table>
152 </td>
153</tr>
154<tr class="private">
155 <td width="15%" align="right" valign="top" class="summary">
156 <span class="summary-type">&nbsp;</span>
157 </td><td class="summary">
Joe Gregorio1b425aa2012-08-24 12:04:34 -0400158 <a name="logger"></a><span class="summary-name">logger</span> = <code title="logging.getLogger(__name__)">logging.getLogger(__name__)</code>
159 </td>
160 </tr>
161<tr class="private">
162 <td width="15%" align="right" valign="top" class="summary">
163 <span class="summary-type">&nbsp;</span>
164 </td><td class="summary">
Joe Gregorioad8013f2012-08-03 08:44:02 -0400165 <a name="FLAGS"></a><span class="summary-name">FLAGS</span> = <code title="gflags.FLAGS">gflags.FLAGS</code>
166 </td>
167 </tr>
Joe Gregorioad8013f2012-08-03 08:44:02 -0400168</table>
169<!-- ==================== FUNCTION DETAILS ==================== -->
170<a name="section-FunctionDetails"></a>
171<table class="details" border="1" cellpadding="3"
172 cellspacing="0" width="100%" bgcolor="white">
173<tr bgcolor="#70b0f0" class="table-header">
174 <td colspan="2" class="table-header">
175 <table border="0" cellpadding="0" cellspacing="0" width="100%">
176 <tr valign="top">
177 <td align="left"><span class="table-header">Function Details</span></td>
178 <td align="right" valign="top"
179 ><span class="options">[<a href="#section-FunctionDetails"
180 class="privatelink" onclick="toggle_private();"
181 >hide private</a>]</span></td>
182 </tr>
183 </table>
184 </td>
185</tr>
186</table>
187<a name="positional"></a>
188<div>
189<table class="details" border="1" cellpadding="3"
190 cellspacing="0" width="100%" bgcolor="white">
191<tr><td>
192 <table width="100%" cellpadding="0" cellspacing="0" border="0">
193 <tr valign="top"><td>
194 <h3 class="epydoc"><span class="sig"><span class="sig-name">positional</span>(<span class="sig-arg">max_positional_args</span>)</span>
195 </h3>
196 </td><td align="right" valign="top"
Joe Gregorio1b425aa2012-08-24 12:04:34 -0400197 ><span class="codelink"><a href="oauth2client.util-pysrc.html#positional">source&nbsp;code</a></span>&nbsp;
Joe Gregorioad8013f2012-08-03 08:44:02 -0400198 </td>
199 </tr></table>
200
201 <pre class="literalblock">
202A decorator to declare that only the first N arguments my be positional.
203
204This decorator makes it easy to support Python 3 style key-word only
Joe Gregorio52a5c532013-01-24 16:19:07 -0500205parameters. For example, in Python 3 it is possible to write:
Joe Gregorioad8013f2012-08-03 08:44:02 -0400206
207 def fn(pos1, *, kwonly1=None, kwonly1=None):
208 ...
209
210All named parameters after * must be a keyword:
211
212 fn(10, 'kw1', 'kw2') # Raises exception.
213 fn(10, kwonly1='kw1') # Ok.
214
215Example:
216 To define a function like above, do:
217
218 @positional(1)
219 def fn(pos1, kwonly1=None, kwonly2=None):
220 ...
221
222 If no default value is provided to a keyword argument, it becomes a required
223 keyword argument:
224
225 @positional(0)
226 def fn(required_kw):
227 ...
228
229 This must be called with the keyword parameter:
230
231 fn() # Raises exception.
232 fn(10) # Raises exception.
233 fn(required_kw=10) # Ok.
234
235 When defining instance or class methods always remember to account for
236 'self' and 'cls':
237
238 class MyClass(object):
239
240 @positional(2)
241 def my_method(self, pos1, kwonly1=None):
242 ...
243
244 @classmethod
245 @positional(2)
246 def my_method(cls, pos1, kwonly1=None):
247 ...
248
249The positional decorator behavior is controlled by the
250--positional_parameters_enforcement flag. The flag may be set to 'EXCEPTION',
251'WARNING' or 'IGNORE' to raise an exception, log a warning, or do nothing,
252respectively, if a declaration is violated.
253
254Args:
Joe Gregorio52a5c532013-01-24 16:19:07 -0500255 max_positional_arguments: Maximum number of positional arguments. All
Joe Gregorioad8013f2012-08-03 08:44:02 -0400256 parameters after the this index must be keyword only.
257
258Returns:
259 A decorator that prevents using arguments after max_positional_args from
260 being used as positional parameters.
261
262Raises:
263 TypeError if a key-word only argument is provided as a positional parameter,
264 but only if the --positional_parameters_enforcement flag is set to
265 'EXCEPTION'.
266
267</pre>
268 <dl class="fields">
269 </dl>
270</td></tr></table>
271</div>
Joe Gregorio52a5c532013-01-24 16:19:07 -0500272<a name="scopes_to_string"></a>
273<div class="private">
274<table class="details" border="1" cellpadding="3"
275 cellspacing="0" width="100%" bgcolor="white">
276<tr><td>
277 <table width="100%" cellpadding="0" cellspacing="0" border="0">
278 <tr valign="top"><td>
279 <h3 class="epydoc"><span class="sig"><span class="sig-name">scopes_to_string</span>(<span class="sig-arg">scopes</span>)</span>
280 </h3>
281 </td><td align="right" valign="top"
282 ><span class="codelink"><a href="oauth2client.util-pysrc.html#scopes_to_string">source&nbsp;code</a></span>&nbsp;
283 </td>
284 </tr></table>
285
286 <pre class="literalblock">
287Converts scope value to a string.
288
289If scopes is a string then it is simply passed through. If scopes is an
290iterable then a string is returned that is all the individual scopes
291concatenated with spaces.
292
293Args:
294 scopes: string or iterable of strings, the scopes.
295
296Returns:
297 The scopes formatted as a single string.
298
299</pre>
300 <dl class="fields">
301 </dl>
302</td></tr></table>
303</div>
304<a name="dict_to_tuple_key"></a>
305<div class="private">
306<table class="details" border="1" cellpadding="3"
307 cellspacing="0" width="100%" bgcolor="white">
308<tr><td>
309 <table width="100%" cellpadding="0" cellspacing="0" border="0">
310 <tr valign="top"><td>
311 <h3 class="epydoc"><span class="sig"><span class="sig-name">dict_to_tuple_key</span>(<span class="sig-arg">dictionary</span>)</span>
312 </h3>
313 </td><td align="right" valign="top"
314 ><span class="codelink"><a href="oauth2client.util-pysrc.html#dict_to_tuple_key">source&nbsp;code</a></span>&nbsp;
315 </td>
316 </tr></table>
317
318 <pre class="literalblock">
319Converts a dictionary to a tuple that can be used as an immutable key.
320
321The resulting key is always sorted so that logically equivalent dictionaries
322always produce an identical tuple for a key.
323
324Args:
325 dictionary: the dictionary to use as the key.
326
327Returns:
328 A tuple representing the dictionary in it's naturally sorted ordering.
329
330</pre>
331 <dl class="fields">
332 </dl>
333</td></tr></table>
334</div>
Joe Gregorioad8013f2012-08-03 08:44:02 -0400335<br />
336<!-- ==================== NAVIGATION BAR ==================== -->
337<table class="navbar" border="0" width="100%" cellpadding="0"
338 bgcolor="#a0c0ff" cellspacing="0">
339 <tr valign="middle">
340
341 <!-- Tree link -->
342 <th>&nbsp;&nbsp;&nbsp;<a
343 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
344
345 <!-- Index link -->
346 <th>&nbsp;&nbsp;&nbsp;<a
347 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
348
349 <!-- Help link -->
350 <th>&nbsp;&nbsp;&nbsp;<a
351 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
352
353 <th class="navbar" width="100%"></th>
354 </tr>
355</table>
356<table border="0" cellpadding="0" cellspacing="0" width="100%%">
357 <tr>
358 <td align="left" class="footer">
Joe Gregorio52a5c532013-01-24 16:19:07 -0500359 Generated by Epydoc 3.0.1 on Thu Jan 24 16:14:32 2013
Joe Gregorioad8013f2012-08-03 08:44:02 -0400360 </td>
361 <td align="right" class="footer">
362 <a target="mainFrame" href="http://epydoc.sourceforge.net"
363 >http://epydoc.sourceforge.net</a>
364 </td>
365 </tr>
366</table>
367
368<script type="text/javascript">
369 <!--
370 // Private objects are initially displayed (because if
371 // javascript is turned off then we want them to be
372 // visible); but by default, we want to hide them. So hide
373 // them unless we have a cookie that says to show them.
374 checkCookie();
375 // -->
376</script>
377</body>
378</html>