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


Python _compat.string_types方法代碼示例

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


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

示例1: check_iterator

# 需要導入模塊: from werkzeug import _compat [as 別名]
# 或者: from werkzeug._compat import string_types [as 別名]
def check_iterator(self, app_iter):
        if isinstance(app_iter, string_types):
            warn(WSGIWarning('application returned string.  Response will '
                             'send character for character to the client '
                             'which will kill the performance.  Return a '
                             'list or iterable instead.'), stacklevel=3) 
開發者ID:jpush,項目名稱:jbox,代碼行數:8,代碼來源:lint.py

示例2: __init__

# 需要導入模塊: from werkzeug import _compat [as 別名]
# 或者: from werkzeug._compat import string_types [as 別名]
def __init__(self, title=None, entries=None, **kwargs):
        self.title = title
        self.title_type = kwargs.get('title_type', 'text')
        self.url = kwargs.get('url')
        self.feed_url = kwargs.get('feed_url', self.url)
        self.id = kwargs.get('id', self.feed_url)
        self.updated = kwargs.get('updated')
        self.author = kwargs.get('author', ())
        self.icon = kwargs.get('icon')
        self.logo = kwargs.get('logo')
        self.rights = kwargs.get('rights')
        self.rights_type = kwargs.get('rights_type')
        self.subtitle = kwargs.get('subtitle')
        self.subtitle_type = kwargs.get('subtitle_type', 'text')
        self.generator = kwargs.get('generator')
        if self.generator is None:
            self.generator = self.default_generator
        self.links = kwargs.get('links', [])
        self.entries = entries and list(entries) or []

        if not hasattr(self.author, '__iter__') \
           or isinstance(self.author, string_types + (dict,)):
            self.author = [self.author]
        for i, author in enumerate(self.author):
            if not isinstance(author, dict):
                self.author[i] = {'name': author}

        if not self.title:
            raise ValueError('title is required')
        if not self.id:
            raise ValueError('id is required')
        for author in self.author:
            if 'name' not in author:
                raise TypeError('author must contain at least a name') 
開發者ID:jpush,項目名稱:jbox,代碼行數:36,代碼來源:atom.py

示例3: eval

# 需要導入模塊: from werkzeug import _compat [as 別名]
# 或者: from werkzeug._compat import string_types [as 別名]
def eval(self, code, mode='single'):
        """Evaluate code in the context of the frame."""
        if isinstance(code, string_types):
            if PY2 and isinstance(code, unicode):
                code = UTF8_COOKIE + code.encode('utf-8')
            code = compile(code, '<interactive>', mode)
        return eval(code, self.globals, self.locals) 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:9,代碼來源:tbtools.py


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