Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 1 | <?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> <a |
| 20 | href="module-tree.html">Trees</a> </th> |
| 21 | |
| 22 | <!-- Index link --> |
| 23 | <th> <a |
| 24 | href="identifier-index.html">Indices</a> </th> |
| 25 | |
| 26 | <!-- Help link --> |
| 27 | <th> <a |
| 28 | href="help.html">Help</a> </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 oauth2client</a> :: |
| 38 | Module 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 private</a>]</span></td></tr> |
| 46 | <tr><td align="right"><span class="options" |
| 47 | >[<a href="frames.html" target="_top">frames</a |
| 48 | >] | <a href="oauth2client.util-module.html" |
| 49 | target="_top">no frames</a>]</span></td></tr> |
| 50 | </table> |
| 51 | </td> |
| 52 | </tr> |
| 53 | </table> |
| 54 | <!-- ==================== MODULE DESCRIPTION ==================== --> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 55 | <h1 class="epydoc">Module util</h1><p class="nomargin-top"><span class="codelink"><a href="oauth2client.util-pysrc.html">source code</a></span></p> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 56 | <pre class="literalblock"> |
| 57 | Common 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"> </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 Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 94 | <span class="codelink"><a href="oauth2client.util-pysrc.html#positional">source code</a></span> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 95 | |
| 96 | </td> |
| 97 | </tr> |
| 98 | </table> |
| 99 | |
| 100 | </td> |
| 101 | </tr> |
Joe Gregorio | 52a5c53 | 2013-01-24 16:19:07 -0500 | [diff] [blame] | 102 | <tr class="private"> |
| 103 | <td width="15%" align="right" valign="top" class="summary"> |
| 104 | <span class="summary-type"> </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 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"> </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 code</a></span> |
| 129 | |
| 130 | </td> |
| 131 | </tr> |
| 132 | </table> |
| 133 | |
| 134 | </td> |
| 135 | </tr> |
Joe Gregorio | 41be8e8 | 2013-03-07 10:31:47 -0500 | [diff] [blame] | 136 | <tr class="private"> |
| 137 | <td width="15%" align="right" valign="top" class="summary"> |
| 138 | <span class="summary-type"> </span> |
| 139 | </td><td class="summary"> |
| 140 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 141 | <tr> |
| 142 | <td><span class="summary-sig"><a href="oauth2client.util-module.html#_add_query_parameter" class="summary-sig-name" onclick="show_private();">_add_query_parameter</a>(<span class="summary-sig-arg">url</span>, |
| 143 | <span class="summary-sig-arg">name</span>, |
| 144 | <span class="summary-sig-arg">value</span>)</span><br /> |
| 145 | Adds a query parameter to a url.</td> |
| 146 | <td align="right" valign="top"> |
| 147 | <span class="codelink"><a href="oauth2client.util-pysrc.html#_add_query_parameter">source code</a></span> |
| 148 | |
| 149 | </td> |
| 150 | </tr> |
| 151 | </table> |
| 152 | |
| 153 | </td> |
| 154 | </tr> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 155 | </table> |
| 156 | <!-- ==================== VARIABLES ==================== --> |
| 157 | <a name="section-Variables"></a> |
| 158 | <table class="summary" border="1" cellpadding="3" |
| 159 | cellspacing="0" width="100%" bgcolor="white"> |
| 160 | <tr bgcolor="#70b0f0" class="table-header"> |
| 161 | <td colspan="2" class="table-header"> |
| 162 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 163 | <tr valign="top"> |
| 164 | <td align="left"><span class="table-header">Variables</span></td> |
| 165 | <td align="right" valign="top" |
| 166 | ><span class="options">[<a href="#section-Variables" |
| 167 | class="privatelink" onclick="toggle_private();" |
| 168 | >hide private</a>]</span></td> |
| 169 | </tr> |
| 170 | </table> |
| 171 | </td> |
| 172 | </tr> |
| 173 | <tr class="private"> |
| 174 | <td width="15%" align="right" valign="top" class="summary"> |
| 175 | <span class="summary-type"> </span> |
| 176 | </td><td class="summary"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 177 | <a name="logger"></a><span class="summary-name">logger</span> = <code title="logging.getLogger(__name__)">logging.getLogger(__name__)</code> |
| 178 | </td> |
| 179 | </tr> |
| 180 | <tr class="private"> |
| 181 | <td width="15%" align="right" valign="top" class="summary"> |
| 182 | <span class="summary-type"> </span> |
| 183 | </td><td class="summary"> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 184 | <a name="FLAGS"></a><span class="summary-name">FLAGS</span> = <code title="gflags.FLAGS">gflags.FLAGS</code> |
| 185 | </td> |
| 186 | </tr> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 187 | </table> |
| 188 | <!-- ==================== FUNCTION DETAILS ==================== --> |
| 189 | <a name="section-FunctionDetails"></a> |
| 190 | <table class="details" border="1" cellpadding="3" |
| 191 | cellspacing="0" width="100%" bgcolor="white"> |
| 192 | <tr bgcolor="#70b0f0" class="table-header"> |
| 193 | <td colspan="2" class="table-header"> |
| 194 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 195 | <tr valign="top"> |
| 196 | <td align="left"><span class="table-header">Function Details</span></td> |
| 197 | <td align="right" valign="top" |
| 198 | ><span class="options">[<a href="#section-FunctionDetails" |
| 199 | class="privatelink" onclick="toggle_private();" |
| 200 | >hide private</a>]</span></td> |
| 201 | </tr> |
| 202 | </table> |
| 203 | </td> |
| 204 | </tr> |
| 205 | </table> |
| 206 | <a name="positional"></a> |
| 207 | <div> |
| 208 | <table class="details" border="1" cellpadding="3" |
| 209 | cellspacing="0" width="100%" bgcolor="white"> |
| 210 | <tr><td> |
| 211 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 212 | <tr valign="top"><td> |
| 213 | <h3 class="epydoc"><span class="sig"><span class="sig-name">positional</span>(<span class="sig-arg">max_positional_args</span>)</span> |
| 214 | </h3> |
| 215 | </td><td align="right" valign="top" |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 216 | ><span class="codelink"><a href="oauth2client.util-pysrc.html#positional">source code</a></span> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 217 | </td> |
| 218 | </tr></table> |
| 219 | |
| 220 | <pre class="literalblock"> |
| 221 | A decorator to declare that only the first N arguments my be positional. |
| 222 | |
| 223 | This decorator makes it easy to support Python 3 style key-word only |
Joe Gregorio | 52a5c53 | 2013-01-24 16:19:07 -0500 | [diff] [blame] | 224 | parameters. For example, in Python 3 it is possible to write: |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 225 | |
| 226 | def fn(pos1, *, kwonly1=None, kwonly1=None): |
| 227 | ... |
| 228 | |
| 229 | All named parameters after * must be a keyword: |
| 230 | |
| 231 | fn(10, 'kw1', 'kw2') # Raises exception. |
| 232 | fn(10, kwonly1='kw1') # Ok. |
| 233 | |
| 234 | Example: |
| 235 | To define a function like above, do: |
| 236 | |
| 237 | @positional(1) |
| 238 | def fn(pos1, kwonly1=None, kwonly2=None): |
| 239 | ... |
| 240 | |
| 241 | If no default value is provided to a keyword argument, it becomes a required |
| 242 | keyword argument: |
| 243 | |
| 244 | @positional(0) |
| 245 | def fn(required_kw): |
| 246 | ... |
| 247 | |
| 248 | This must be called with the keyword parameter: |
| 249 | |
| 250 | fn() # Raises exception. |
| 251 | fn(10) # Raises exception. |
| 252 | fn(required_kw=10) # Ok. |
| 253 | |
| 254 | When defining instance or class methods always remember to account for |
| 255 | 'self' and 'cls': |
| 256 | |
| 257 | class MyClass(object): |
| 258 | |
| 259 | @positional(2) |
| 260 | def my_method(self, pos1, kwonly1=None): |
| 261 | ... |
| 262 | |
| 263 | @classmethod |
| 264 | @positional(2) |
| 265 | def my_method(cls, pos1, kwonly1=None): |
| 266 | ... |
| 267 | |
| 268 | The positional decorator behavior is controlled by the |
| 269 | --positional_parameters_enforcement flag. The flag may be set to 'EXCEPTION', |
| 270 | 'WARNING' or 'IGNORE' to raise an exception, log a warning, or do nothing, |
| 271 | respectively, if a declaration is violated. |
| 272 | |
| 273 | Args: |
Joe Gregorio | 52a5c53 | 2013-01-24 16:19:07 -0500 | [diff] [blame] | 274 | max_positional_arguments: Maximum number of positional arguments. All |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 275 | parameters after the this index must be keyword only. |
| 276 | |
| 277 | Returns: |
| 278 | A decorator that prevents using arguments after max_positional_args from |
| 279 | being used as positional parameters. |
| 280 | |
| 281 | Raises: |
| 282 | TypeError if a key-word only argument is provided as a positional parameter, |
| 283 | but only if the --positional_parameters_enforcement flag is set to |
| 284 | 'EXCEPTION'. |
| 285 | |
| 286 | </pre> |
| 287 | <dl class="fields"> |
| 288 | </dl> |
| 289 | </td></tr></table> |
| 290 | </div> |
Joe Gregorio | 52a5c53 | 2013-01-24 16:19:07 -0500 | [diff] [blame] | 291 | <a name="scopes_to_string"></a> |
| 292 | <div class="private"> |
| 293 | <table class="details" border="1" cellpadding="3" |
| 294 | cellspacing="0" width="100%" bgcolor="white"> |
| 295 | <tr><td> |
| 296 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 297 | <tr valign="top"><td> |
| 298 | <h3 class="epydoc"><span class="sig"><span class="sig-name">scopes_to_string</span>(<span class="sig-arg">scopes</span>)</span> |
| 299 | </h3> |
| 300 | </td><td align="right" valign="top" |
| 301 | ><span class="codelink"><a href="oauth2client.util-pysrc.html#scopes_to_string">source code</a></span> |
| 302 | </td> |
| 303 | </tr></table> |
| 304 | |
| 305 | <pre class="literalblock"> |
| 306 | Converts scope value to a string. |
| 307 | |
| 308 | If scopes is a string then it is simply passed through. If scopes is an |
| 309 | iterable then a string is returned that is all the individual scopes |
| 310 | concatenated with spaces. |
| 311 | |
| 312 | Args: |
| 313 | scopes: string or iterable of strings, the scopes. |
| 314 | |
| 315 | Returns: |
| 316 | The scopes formatted as a single string. |
| 317 | |
| 318 | </pre> |
| 319 | <dl class="fields"> |
| 320 | </dl> |
| 321 | </td></tr></table> |
| 322 | </div> |
| 323 | <a name="dict_to_tuple_key"></a> |
| 324 | <div class="private"> |
| 325 | <table class="details" border="1" cellpadding="3" |
| 326 | cellspacing="0" width="100%" bgcolor="white"> |
| 327 | <tr><td> |
| 328 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 329 | <tr valign="top"><td> |
| 330 | <h3 class="epydoc"><span class="sig"><span class="sig-name">dict_to_tuple_key</span>(<span class="sig-arg">dictionary</span>)</span> |
| 331 | </h3> |
| 332 | </td><td align="right" valign="top" |
| 333 | ><span class="codelink"><a href="oauth2client.util-pysrc.html#dict_to_tuple_key">source code</a></span> |
| 334 | </td> |
| 335 | </tr></table> |
| 336 | |
| 337 | <pre class="literalblock"> |
| 338 | Converts a dictionary to a tuple that can be used as an immutable key. |
| 339 | |
| 340 | The resulting key is always sorted so that logically equivalent dictionaries |
| 341 | always produce an identical tuple for a key. |
| 342 | |
| 343 | Args: |
| 344 | dictionary: the dictionary to use as the key. |
| 345 | |
| 346 | Returns: |
| 347 | A tuple representing the dictionary in it's naturally sorted ordering. |
| 348 | |
| 349 | </pre> |
| 350 | <dl class="fields"> |
| 351 | </dl> |
| 352 | </td></tr></table> |
| 353 | </div> |
Joe Gregorio | 41be8e8 | 2013-03-07 10:31:47 -0500 | [diff] [blame] | 354 | <a name="_add_query_parameter"></a> |
| 355 | <div class="private"> |
| 356 | <table class="details" border="1" cellpadding="3" |
| 357 | cellspacing="0" width="100%" bgcolor="white"> |
| 358 | <tr><td> |
| 359 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 360 | <tr valign="top"><td> |
| 361 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_add_query_parameter</span>(<span class="sig-arg">url</span>, |
| 362 | <span class="sig-arg">name</span>, |
| 363 | <span class="sig-arg">value</span>)</span> |
| 364 | </h3> |
| 365 | </td><td align="right" valign="top" |
| 366 | ><span class="codelink"><a href="oauth2client.util-pysrc.html#_add_query_parameter">source code</a></span> |
| 367 | </td> |
| 368 | </tr></table> |
| 369 | |
| 370 | <pre class="literalblock"> |
| 371 | Adds a query parameter to a url. |
| 372 | |
| 373 | Replaces the current value if it already exists in the URL. |
| 374 | |
| 375 | Args: |
| 376 | url: string, url to add the query parameter to. |
| 377 | name: string, query parameter name. |
| 378 | value: string, query parameter value. |
| 379 | |
| 380 | Returns: |
| 381 | Updated query parameter. Does not update the url if value is None. |
| 382 | |
| 383 | </pre> |
| 384 | <dl class="fields"> |
| 385 | </dl> |
| 386 | </td></tr></table> |
| 387 | </div> |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 388 | <br /> |
| 389 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 390 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 391 | bgcolor="#a0c0ff" cellspacing="0"> |
| 392 | <tr valign="middle"> |
| 393 | |
| 394 | <!-- Tree link --> |
| 395 | <th> <a |
| 396 | href="module-tree.html">Trees</a> </th> |
| 397 | |
| 398 | <!-- Index link --> |
| 399 | <th> <a |
| 400 | href="identifier-index.html">Indices</a> </th> |
| 401 | |
| 402 | <!-- Help link --> |
| 403 | <th> <a |
| 404 | href="help.html">Help</a> </th> |
| 405 | |
| 406 | <th class="navbar" width="100%"></th> |
| 407 | </tr> |
| 408 | </table> |
| 409 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 410 | <tr> |
| 411 | <td align="left" class="footer"> |
Joe Gregorio | 41be8e8 | 2013-03-07 10:31:47 -0500 | [diff] [blame] | 412 | Generated by Epydoc 3.0.1 on Thu Mar 7 10:31:23 2013 |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 413 | </td> |
| 414 | <td align="right" class="footer"> |
| 415 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 416 | >http://epydoc.sourceforge.net</a> |
| 417 | </td> |
| 418 | </tr> |
| 419 | </table> |
| 420 | |
| 421 | <script type="text/javascript"> |
| 422 | <!-- |
| 423 | // Private objects are initially displayed (because if |
| 424 | // javascript is turned off then we want them to be |
| 425 | // visible); but by default, we want to hide them. So hide |
| 426 | // them unless we have a cookie that says to show them. |
| 427 | checkCookie(); |
| 428 | // --> |
| 429 | </script> |
| 430 | </body> |
| 431 | </html> |