Reusable minor helpers for www (tendril.utils.www.helpers)

TODO Some introduction

tendril.utils.www.helpers.get_http_proxy_url()[source]

Constructs the proxy URL for HTTP proxies from relevant tendril.config Config options, and returns the URL string in the form:

http://[NP_USER:NP_PASS@]NP_IP[:NP_PORT]

where NP_xxx is obtained from the tendril.config ConfigOption NETWORK_PROXY_xxx.

tendril.utils.www.helpers._get_proxy_dict()[source]

Construct a dict containing the proxy settings in a format compatible with the requests.Session. This function is used to construct the _proxy_dict.

tendril.utils.www.helpers.proxy_dict = None

A dict containing the proxy settings in a format compatible with the requests.Session.

tendril.utils.www.helpers.strencode(string)[source]

This function converts unicode strings to ASCII, using python’s str.encode(), replacing any unicode characters present in the string. Unicode characters which Tendril expects to see in web content related to it are specifically replaced first with ASCII characters or character sequences which reasonably reproduce the original meanings.

Parameters

string – unicode string to be encoded.

Returns

ASCII version of the string.

Warning

This function is marked for deprecation by the general (but gradual) move towards unicode across tendril.