当前位置: 首页>>代码示例>>Python>>正文


Python lorem_ipsum.paragraphs方法代码示例

本文整理汇总了Python中django.utils.lorem_ipsum.paragraphs方法的典型用法代码示例。如果您正苦于以下问题:Python lorem_ipsum.paragraphs方法的具体用法?Python lorem_ipsum.paragraphs怎么用?Python lorem_ipsum.paragraphs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.lorem_ipsum的用法示例。


在下文中一共展示了lorem_ipsum.paragraphs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_paragraphs_not_common

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import paragraphs [as 别名]
def test_paragraphs_not_common(self, mock_randint, mock_choice, mock_sample):
        """
        paragraphs(1, common=False) generating one paragraph that's not the
        COMMON_P paragraph.
        """
        # Make creating 2 sentences use 2 phrases.
        mock_randint.return_value = 2
        mock_sample.return_value = ['exercitationem', 'perferendis']
        mock_choice.return_value = '.'
        self.assertEqual(
            paragraphs(1, common=False),
            [
                'Exercitationem perferendis, exercitationem perferendis. '
                'Exercitationem perferendis, exercitationem perferendis.'
            ]
        )
        self.assertEqual(mock_randint.call_count, 7) 
开发者ID:nesdis,项目名称:djongo,代码行数:19,代码来源:test_lorem_ipsum.py

示例2: render

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import paragraphs [as 别名]
def render(self, context):
        try:
            count = int(self.count.resolve(context))
        except (ValueError, TypeError):
            count = 1
        if self.method == 'w':
            return words(count, common=self.common)
        else:
            paras = paragraphs(count, common=self.common)
        if self.method == 'p':
            paras = ['<p>%s</p>' % p for p in paras]
        return '\n\n'.join(paras) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:14,代码来源:defaulttags.py

示例3: test_paragraphs

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import paragraphs [as 别名]
def test_paragraphs(self):
        """paragraphs(1) uses the COMMON_P paragraph."""
        self.assertEqual(
            paragraphs(1), [
                'Lorem ipsum dolor sit amet, consectetur adipisicing elit, '
                'sed do eiusmod tempor incididunt ut labore et dolore magna '
                'aliqua. Ut enim ad minim veniam, quis nostrud exercitation '
                'ullamco laboris nisi ut aliquip ex ea commodo consequat. '
                'Duis aute irure dolor in reprehenderit in voluptate velit '
                'esse cillum dolore eu fugiat nulla pariatur. Excepteur sint '
                'occaecat cupidatat non proident, sunt in culpa qui officia '
                'deserunt mollit anim id est laborum.'
            ]
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:16,代码来源:test_lorem_ipsum.py

示例4: lorem

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import paragraphs [as 别名]
def lorem(parser, token):
    """
    Creates random Latin text useful for providing test data in templates.

    Usage format::

        {% lorem [count] [method] [random] %}

    ``count`` is a number (or variable) containing the number of paragraphs or
    words to generate (default is 1).

    ``method`` is either ``w`` for words, ``p`` for HTML paragraphs, ``b`` for
    plain-text paragraph blocks (default is ``b``).

    ``random`` is the word ``random``, which if given, does not use the common
    paragraph (starting "Lorem ipsum dolor sit amet, consectetuer...").

    Examples:

    * ``{% lorem %}`` will output the common "lorem ipsum" paragraph
    * ``{% lorem 3 p %}`` will output the common "lorem ipsum" paragraph
      and two random paragraphs each wrapped in HTML ``<p>`` tags
    * ``{% lorem 2 w random %}`` will output two random latin words
    """
    bits = list(token.split_contents())
    tagname = bits[0]
    # Random bit
    common = bits[-1] != 'random'
    if not common:
        bits.pop()
    # Method bit
    if bits[-1] in ('w', 'p', 'b'):
        method = bits.pop()
    else:
        method = 'b'
    # Count bit
    if len(bits) > 1:
        count = bits.pop()
    else:
        count = '1'
    count = parser.compile_filter(count)
    if len(bits) != 1:
        raise TemplateSyntaxError("Incorrect format for %r tag" % tagname)
    return LoremNode(count, method, common) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:46,代码来源:defaulttags.py

示例5: lorem

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import paragraphs [as 别名]
def lorem(parser, token):
    """
    Create random Latin text useful for providing test data in templates.

    Usage format::

        {% lorem [count] [method] [random] %}

    ``count`` is a number (or variable) containing the number of paragraphs or
    words to generate (default is 1).

    ``method`` is either ``w`` for words, ``p`` for HTML paragraphs, ``b`` for
    plain-text paragraph blocks (default is ``b``).

    ``random`` is the word ``random``, which if given, does not use the common
    paragraph (starting "Lorem ipsum dolor sit amet, consectetuer...").

    Examples:

    * ``{% lorem %}`` outputs the common "lorem ipsum" paragraph
    * ``{% lorem 3 p %}`` outputs the common "lorem ipsum" paragraph
      and two random paragraphs each wrapped in HTML ``<p>`` tags
    * ``{% lorem 2 w random %}`` outputs two random latin words
    """
    bits = list(token.split_contents())
    tagname = bits[0]
    # Random bit
    common = bits[-1] != 'random'
    if not common:
        bits.pop()
    # Method bit
    if bits[-1] in ('w', 'p', 'b'):
        method = bits.pop()
    else:
        method = 'b'
    # Count bit
    if len(bits) > 1:
        count = bits.pop()
    else:
        count = '1'
    count = parser.compile_filter(count)
    if len(bits) != 1:
        raise TemplateSyntaxError("Incorrect format for %r tag" % tagname)
    return LoremNode(count, method, common) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:46,代码来源:defaulttags.py


注:本文中的django.utils.lorem_ipsum.paragraphs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。