<s> from __future__ import absolute_import , division , print_function <EOL> import base64 <EOL> from six . moves . urllib . parse import quote , urlencode <EOL> def _generate_uri ( hotp , type_name , account_name , issuer , extra_parameters ) : <EOL> parameters = [ <EOL> ( "<STR_LIT>" , hotp . _length ) , <EOL> ( "<STR_LIT>" , base64 . b32encode ( hotp . _key ) ) , <EOL> ( "<STR_LIT>" , hotp . _algorithm . name . upper ( ) ) , <EOL> ] <EOL> if issuer is not None : <EOL> parameters . append ( ( "<STR_LIT>" , issuer ) ) <EOL> parameters . extend ( extra_parameters ) <EOL> uriparts = { <EOL> "<STR_LIT:type>" : type_name , <EOL> "<STR_LIT:label>" : ( "<STR_LIT>" % ( quote ( issuer ) , quote ( account_name ) ) if issuer <EOL> else quote ( account_name ) ) , <EOL> "<STR_LIT>" : urlencode ( parameters ) , <EOL> } <EOL> return "<STR_LIT>" . format ( ** uriparts ) </s>
