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


Python lorem_ipsum.words方法代码示例

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


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

示例1: render

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [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

示例2: test_negative_words

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_negative_words(self):
        """words(n) returns n + 19 words, even if n is negative."""
        self.assertEqual(
            words(-5),
            'lorem ipsum dolor sit amet consectetur adipisicing elit sed do '
            'eiusmod tempor incididunt ut'
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:9,代码来源:test_lorem_ipsum.py

示例3: test_same_or_less_common_words

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_same_or_less_common_words(self):
        """words(n) for n < 19."""
        self.assertEqual(words(7), 'lorem ipsum dolor sit amet consectetur adipisicing') 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_lorem_ipsum.py

示例4: test_common_words_in_string

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_common_words_in_string(self):
        """words(n) starts with the 19 standard lorem ipsum words for n > 19."""
        self.assertTrue(
            words(25).startswith(
                'lorem ipsum dolor sit amet consectetur adipisicing elit sed '
                'do eiusmod tempor incididunt ut labore et dolore magna aliqua'
            )
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:test_lorem_ipsum.py

示例5: test_more_words_than_common

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_more_words_than_common(self):
        """words(n) returns n words for n > 19."""
        self.assertEqual(len(words(25).split()), 25) 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_lorem_ipsum.py

示例6: test_common_large_number_of_words

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_common_large_number_of_words(self):
        """words(n) has n words when n is greater than len(WORDS)."""
        self.assertEqual(len(words(500).split()), 500) 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_lorem_ipsum.py

示例7: test_sentence

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_sentence(self, mock_randint, mock_choice, mock_sample):
        """
        Sentences are built using some number of phrases and a set of words.
        """
        mock_randint.return_value = 2  # Use two phrases.
        mock_sample.return_value = ['exercitationem', 'perferendis']
        mock_choice.return_value = '?'
        value = sentence()
        self.assertEqual(mock_randint.call_count, 3)
        self.assertEqual(mock_sample.call_count, 2)
        self.assertEqual(mock_choice.call_count, 1)
        self.assertEqual(value, 'Exercitationem perferendis, exercitationem perferendis?') 
开发者ID:nesdis,项目名称:djongo,代码行数:14,代码来源:test_lorem_ipsum.py

示例8: test_not_common_words

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [as 别名]
def test_not_common_words(self, mock_sample):
        """words(n, common=False) returns random words."""
        mock_sample.return_value = ['exercitationem', 'perferendis']
        self.assertEqual(words(2, common=False), 'exercitationem perferendis') 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_lorem_ipsum.py

示例9: lorem

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [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

示例10: lorem

# 需要导入模块: from django.utils import lorem_ipsum [as 别名]
# 或者: from django.utils.lorem_ipsum import words [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.words方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。