當前位置: 首頁>>代碼示例>>Python>>正文


Python L10n.is_defined方法代碼示例

本文整理匯總了Python中dNG.data.text.l10n.L10n.is_defined方法的典型用法代碼示例。如果您正苦於以下問題:Python L10n.is_defined方法的具體用法?Python L10n.is_defined怎麽用?Python L10n.is_defined使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dNG.data.text.l10n.L10n的用法示例。


在下文中一共展示了L10n.is_defined方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute_error

# 需要導入模塊: from dNG.data.text.l10n import L10n [as 別名]
# 或者: from dNG.data.text.l10n.L10n import is_defined [as 別名]
    def execute_error(self):
        """
Action for "error"

:since: v1.0.0
        """

        code = InputFilter.filter_int(self.request.get_parameter("code", "500"))

        if (L10n.is_defined("errors_pas_http_core_{0:d}".format(code))):
            if (self.response.is_supported("headers")):
                self.response.set_header("HTTP",
                                         ("HTTP/2.0 {0:d} {1}".format(code, self.error_messages[code])
                                          if (code in self.error_messages) else
                                          "HTTP/2.0 500 Internal Server Error"
                                         ),
                                         True
                                        )
            #

            self.response.handle_error("pas_http_core_{0:d}".format(code))
        else:
            if (self.response.is_supported("headers")): self.response.set_header("HTTP", "HTTP/2.0 500 Internal Server Error", True)
            self.response.handle_critical_error("core_unknown_error")
開發者ID:dNG-git,項目名稱:pas_http_core,代碼行數:26,代碼來源:http.py

示例2: __init__

# 需要導入模塊: from dNG.data.text.l10n import L10n [as 別名]
# 或者: from dNG.data.text.l10n.L10n import is_defined [as 別名]
    def __init__(self):
        """
Constructor __init__(ControlPoint)

:since: v0.2.00
        """

        AbstractTimed.__init__(self)

        self.bootid = 0
        """
UPnP bootId value (bootid.upnp.org); nextbootid.upnp.org += 1
        """
        self.configid = 0
        """
UPnP configId value (configid.upnp.org)
        """
        self.devices = { }
        """
List of devices with its services
        """
        self.gena = None
        """
UPnP GENA manager
        """
        self.http_host = None
        """
HTTP Accept-Language value
        """
        self.http_language = (L10n.get("lang_rfc_region") if (L10n.is_defined("lang_rfc_region")) else None)
        """
HTTP Accept-Language value
        """
        self.http_port = None
        """
HTTP Accept-Language value
        """
        self.listener_ipv4 = None
        """
Unicast IPv4 listener
        """
        self.listener_port = int(Settings.get("pas_upnp_device_port", 1900))
        """
Unicast port in the range 49152-65535 (searchport.upnp.org)
        """
        self.listeners_multicast = { }
        """
Multicast listeners
        """
        self.listeners_multicast_ipv4 = 0
        """
Number of IPv4 multicast listeners
        """
        self.listeners_multicast_ipv6 = 0
        """
Number of IPv6 multicast listeners
        """
        self.managed_devices = { }
        """
List of managed devices
        """
        self.rootdevices = [ ]
        """
List of UPnP root devices
        """
        self.tasks = [ ]
        """
List of tasks (e.g. timed out services) to run
        """
        self.upnp_desc = { }
        """
Received UPnP descriptions
        """
        self.upnp_desc_unread = { }
        """
Unread UPnP description URLs
        """
        self.usns = { }
        """
List of devices with its services
        """

        Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data")))

        self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False)

        if (self.http_language is None):
            system_language = getlocale()[0]

            http_language = (Settings.get("core_lang", "en_US")
                             if (system_language is None or system_language == "c") else
                             system_language
                            )

            http_language = http_language.replace("_", "")
            http_language = re.sub("\\W", "", http_language)
        else: http_language = self.http_language.replace("_", "")

        if (Settings.is_defined("core_lang_{0}".format(http_language))): http_language = Settings.get("core_lang_{0}".format(http_language))
        elif (Settings.is_defined("core_lang_{0}".format(http_language[:2]))): http_language = Settings.get("core_lang_{0}".format(http_language[:2]))
#.........這裏部分代碼省略.........
開發者ID:dNG-git,項目名稱:pas_upnp,代碼行數:103,代碼來源:control_point.py


注:本文中的dNG.data.text.l10n.L10n.is_defined方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。