本文整理匯總了Python中globaleaks.utils.structures.Rosetta.get_localized_attrs方法的典型用法代碼示例。如果您正苦於以下問題:Python Rosetta.get_localized_attrs方法的具體用法?Python Rosetta.get_localized_attrs怎麽用?Python Rosetta.get_localized_attrs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類globaleaks.utils.structures.Rosetta
的用法示例。
在下文中一共展示了Rosetta.get_localized_attrs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: anon_serialize_node
# 需要導入模塊: from globaleaks.utils.structures import Rosetta [as 別名]
# 或者: from globaleaks.utils.structures.Rosetta import get_localized_attrs [as 別名]
def anon_serialize_node(store, language=GLSetting.memory_copy.default_language):
node = store.find(models.Node).one()
# Contexts and Receivers relationship
associated = store.find(models.ReceiverContext).count()
custom_homepage = False
try:
custom_homepage = os.path.isfile(os.path.join(GLSetting.static_path, "custom_homepage.html"))
except:
pass
node_dict = {
'name': node.name,
'hidden_service': node.hidden_service,
'public_site': node.public_site,
'email': node.email,
'languages_enabled': node.languages_enabled,
'languages_supported': LANGUAGES_SUPPORTED,
'default_language' : node.default_language,
# extended settings info:
'maximum_namesize': node.maximum_namesize,
'maximum_textsize': node.maximum_textsize,
'maximum_filesize': node.maximum_filesize,
# public serialization use GLSetting memory var, and
# not the real one, because needs to bypass
# Tor2Web unsafe deny default settings
'tor2web_admin': GLSetting.memory_copy.tor2web_admin,
'tor2web_submission': GLSetting.memory_copy.tor2web_submission,
'tor2web_receiver': GLSetting.memory_copy.tor2web_receiver,
'tor2web_unauth': GLSetting.memory_copy.tor2web_unauth,
'ahmia': node.ahmia,
'postpone_superpower': node.postpone_superpower,
'can_delete_submission': node.can_delete_submission,
'wizard_done': node.wizard_done,
'anomaly_checks': node.anomaly_checks,
'allow_unencrypted': node.allow_unencrypted,
'x_frame_options_mode': node.x_frame_options_mode,
'x_frame_options_allow_from': node.x_frame_options_allow_from,
'receipt_regexp': node.receipt_regexp,
'configured': True if associated else False,
'password': u"",
'old_password': u"",
'custom_homepage': custom_homepage,
'disable_privacy_badge': node.disable_privacy_badge,
'disable_security_awareness_badge': node.disable_security_awareness_badge,
'disable_security_awareness_questions': node.disable_security_awareness_questions
}
mo = Rosetta()
mo.acquire_storm_object(node)
for attr in mo.get_localized_attrs():
node_dict[attr] = mo.dump_translated(attr, language)
return node_dict
示例2: anon_serialize_node
# 需要導入模塊: from globaleaks.utils.structures import Rosetta [as 別名]
# 或者: from globaleaks.utils.structures.Rosetta import get_localized_attrs [as 別名]
def anon_serialize_node(store, language=GLSetting.memory_copy.default_language):
node = store.find(models.Node).one()
# Contexts and Receivers relationship
associated = store.find(models.ReceiverContext).count()
node_dict = {
'name': unicode(node.name),
'hidden_service': unicode(node.hidden_service),
'public_site': unicode(node.public_site),
'email': unicode(node.email),
'languages_enabled': node.languages_enabled,
'languages_supported': LANGUAGES_SUPPORTED,
'default_language' : node.default_language,
'configured': True if associated else False,
# extended settings info:
'maximum_namesize': node.maximum_namesize,
'maximum_textsize': node.maximum_textsize,
'maximum_filesize': node.maximum_filesize,
# public serialization use GLSetting memory var, and
# not the real one, because needs to bypass
# Tor2Web unsafe deny default settings
'tor2web_admin': GLSetting.memory_copy.tor2web_admin,
'tor2web_submission': GLSetting.memory_copy.tor2web_submission,
'tor2web_tip': GLSetting.memory_copy.tor2web_tip,
'tor2web_receiver': GLSetting.memory_copy.tor2web_receiver,
'tor2web_unauth': GLSetting.memory_copy.tor2web_unauth,
'postpone_superpower': node.postpone_superpower,
}
mo = Rosetta()
mo.acquire_storm_object(node)
for attr in mo.get_localized_attrs():
node_dict[attr] = mo.dump_translated(attr, language)
return node_dict