bridgedb.strings

Commonly used string constants.

Todo

The instructions for the OpenPGP keys in BRIDGEDB_OPENPGP_KEY are not translated… should we translate them? Should we tell users where to obtain GPG4Win/GPGTools/gnupg? Should those instruction be that verbose? Or should we get rid of the instructions altogether, and assume that any encouragement towards using GPG will just make users more frustrated, and (possibly) (mis-)direct that frustration at Tor or BridgeDB?

_(text)[source]

This is necessary because strings are translated when they’re imported. Otherwise this would make it impossible to switch languages more than once.

Returns:The text.
WELCOME = {0: u'BridgeDB can provide bridges with several %stypes of Pluggable Transports%s,\nwhich can help obfuscate your connections to the Tor Network, making it more\ndifficult for anyone watching your internet traffic to determine that you are\nusing Tor.\n\n', 1: u"Some bridges with IPv6 addresses are also available, though some Pluggable\nTransports aren't IPv6 compatible.\n\n", 2: u"Additionally, BridgeDB has plenty of plain-ol'-vanilla bridges %s without any\nPluggable Transports %s which maybe doesn't sound as cool, but they can still\nhelp to circumvent internet censorship in many cases.\n\n"}

These strings should go on the first “Welcome” email sent by the EmailServer, as well as on the index.html template used by the server. They are used as an introduction to explain what Tor bridges are, what bridges do, and why someone might want to use bridges.

SUPPORTED_TRANSPORTS = {}

SUPPORTED TRANSPORTS is dictionary mapping all Pluggable Transports methodname to whether or not we actively distribute them. The ones which we distribute SHOULD have the following properties:

  1. The PT is in a widely accepted, usable state for most Tor users.
  2. The PT is currently publicly deployed en masse”.
  3. The PT is included within the transports which Tor Browser offers in the stable releases.

These will be sorted by methodname in alphabetical order.

*Don’t change this setting here; change it in :file:`bridgedb.conf`.*

DEFAULT_TRANSPORT = u''

DEFAULT_TRANSPORT is a string. It should be the PT methodname of the transport which is selected by default (e.g. in the webserver dropdown menu).

*Don’t change this setting here; change it in :file:`bridgedb.conf`.*

_getSupportedTransports()[source]

Get the list of currently supported transports.

Return type:list
Returns:A list of strings, one for each supported Pluggable Transport methodname, sorted in alphabetical order.
_setDefaultTransport(transport)[source]
_getDefaultTransport()[source]
_setSupportedTransports(transports)[source]

Set the list of currently supported transports.

Parameters:transports (dict) – A mapping of Pluggable Transport methodnames (strings) to booleans. If the boolean is True, then the Pluggable Transport is one which we will (more easily) distribute to clients. If False, then we (sort of) don’t distribute it.
_getSupportedAndDefaultTransports()[source]

Get a dictionary of currently supported transports, along with a boolean marking which transport is the default.

It is returned as a collections.OrderedDict, because if it is a regular dict, then the dropdown menu would populated in random order each time the page is rendered. It is sorted in alphabetical order.

Return type:collections.OrderedDict
Returns:An OrderedDict of the Pluggable Transport methodnames from SUPPORTED_TRANSPORTS whose value in SUPPORTED_TRANSPORTS is True. If DEFAULT_TRANSPORT is set, then the PT methodname in the DEFAULT_TRANSPORT setting is added to the OrderedDict, with the value True. Every other transport in the returned OrderedDict has its value set to False, so that only the one which should be the default PT is True.
EMAIL_SPRINTF = {u'WELCOME0': (u'', u'[0]'), u'HELP0': u'help@rt.torproject.org', u'WELCOME2': (u'-', u'-'), u'HOWTO_TBB1': (u'', u'[0]')}

EMAIL_SPRINTF is a dictionary that maps translated strings which contain format specifiers (i.e. %s) to what those format specifiers should be replaced with in a given template system.

For example, a string which needs a pair of HTML ("<a href=''">, "</a>") tags (for the templates used by bridgedb.https.server) would need some alternative replacements for the EmailServer, because the latter uses templates with a text/plain mimetype instead of HTML. For the EmailServer, the format strings specifiers are replaced with an empty string where the opening <a> tags would go, and a numbered Markdown link specifier where the closing </a> tags would go.

The keys in this dictionary are the Python variable names of the corresponding strings which are being formatted, i.e. WELCOME0 would be the string replacements for strings.WELCOME.get(0).

For example, the 0 string in WELCOME above has the substring:

"%s without Pluggable Transport %s"

and so to replace the two %s format specifiers, you would use this mapping like so:

>>> from bridgedb import strings
>>> welcome = strings.WELCOME[0] % strings.EMAIL_SPRINTF["WELCOME0"]
>>> print welcome.split('

‘)[0] BridgeDB can provide bridges with several types of Pluggable Transports[0],