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


Python utils.parse_tags函数代码示例

本文整理汇总了Python中taggit.utils.parse_tags函数的典型用法代码示例。如果您正苦于以下问题:Python parse_tags函数的具体用法?Python parse_tags怎么用?Python parse_tags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_custom_comma_splitter

 def test_custom_comma_splitter(self):
     self.assertEqual(parse_tags("   Cued Speech "), ["Cued Speech"])
     self.assertEqual(parse_tags(" ,Cued Speech, "), ["Cued Speech"])
     self.assertEqual(parse_tags("Cued Speech"), ["Cued Speech"])
     self.assertEqual(
         parse_tags("Cued Speech, dictionary"), ["Cued Speech", "dictionary"]
     )
开发者ID:alex,项目名称:django-taggit,代码行数:7,代码来源:tests.py

示例2: test_with_comma_delimited_multiple_words_disabled_space_split

 def test_with_comma_delimited_multiple_words_disabled_space_split(self, mocked_settings):
     mocked_settings.TAGGIT_ENABLE_SPACE_SPLIT_IF_NOT_QUOTES = False
     tools.assert_equals(parse_tags(',one'), [u'one'])
     tools.assert_equals(parse_tags(',one two'), [u'one two'])
     tools.assert_equals(parse_tags(',one two three'), [u'one two three'])
     tools.assert_equals(parse_tags('a one, a-two and a-three'),
         [u'a one', u'a-two and a-three'])
开发者ID:FinalsClub,项目名称:django-taggit,代码行数:7,代码来源:test_models.py

示例3: test_tags_with_double_quotes_can_contain_commas

 def test_tags_with_double_quotes_can_contain_commas(self):
     """
     Double quotes can contain commas
     """
     self.assertEqual(parse_tags('a-one "a-two, and a-three"'),
         [u'a-one', u'a-two, and a-three'])
     self.assertEqual(parse_tags('"two", one, one, two, "one"'),
         [u'one', u'two'])
开发者ID:feuervogel,项目名称:django-taggit,代码行数:8,代码来源:tests.py

示例4: test_with_simple_space_delimited_tags

 def test_with_simple_space_delimited_tags(self):
     """
     Test with simple space-delimited tags.
     """
     self.assertEqual(parse_tags('one'), [u'one'])
     self.assertEqual(parse_tags('one two'), [u'one', u'two'])
     self.assertEqual(parse_tags('one two three'), [u'one', u'three', u'two'])
     self.assertEqual(parse_tags('one one two two'), [u'one', u'two'])
开发者ID:feuervogel,项目名称:django-taggit,代码行数:8,代码来源:tests.py

示例5: test_with_simple_space_delimited_tags

 def test_with_simple_space_delimited_tags(self):
     """
     Test with simple space-delimited tags.
     """
     self.assertEqual(parse_tags("one"), ["one"])
     self.assertEqual(parse_tags("one two"), ["one", "two"])
     self.assertEqual(parse_tags("one two three"), ["one", "three", "two"])
     self.assertEqual(parse_tags("one one two two"), ["one", "two"])
开发者ID:adeleinr,项目名称:django-taggit,代码行数:8,代码来源:tests.py

示例6: test_with_comma_delimited_multiple_words

 def test_with_comma_delimited_multiple_words(self):
     """
     Test with comma-delimited multiple words.
     An unquoted comma in the input will trigger this.
     """
     self.assertEqual(parse_tags(",one"), ["one"])
     self.assertEqual(parse_tags(",one two"), ["one two"])
     self.assertEqual(parse_tags(",one two three"), ["one two three"])
     self.assertEqual(parse_tags("a-one, a-two and a-three"), ["a-one", "a-two and a-three"])
开发者ID:adeleinr,项目名称:django-taggit,代码行数:9,代码来源:tests.py

示例7: test_with_double_quoted_multiple_words

 def test_with_double_quoted_multiple_words(self):
     """
     Test with double-quoted multiple words.
     A completed quote will trigger this.  Unclosed quotes are ignored.
     """
     self.assertEqual(parse_tags('"one'), ["one"])
     self.assertEqual(parse_tags('"one two'), ["one", "two"])
     self.assertEqual(parse_tags('"one two three'), ["one", "three", "two"])
     self.assertEqual(parse_tags('"one two"'), ["one two"])
     self.assertEqual(parse_tags('a-one "a-two and a-three"'), ["a-one", "a-two and a-three"])
开发者ID:adeleinr,项目名称:django-taggit,代码行数:10,代码来源:tests.py

示例8: clean_expertise

    def clean_expertise(self):
        """Enforce expertise as a subset of interests"""
        # bug 709938 - don't assume interests passed validation
        interests = set(parse_tags(self.cleaned_data.get("interests", "")))
        expertise = set(parse_tags(self.cleaned_data["expertise"]))

        if len(expertise) > 0 and not expertise.issubset(interests):
            raise forms.ValidationError(_("Areas of expertise must be a " "subset of interests"))

        return self.cleaned_data["expertise"]
开发者ID:nikhilkuria,项目名称:kuma,代码行数:10,代码来源:forms.py

示例9: test_with_comma_delimited_multiple_words

 def test_with_comma_delimited_multiple_words(self):
     """
     Test with comma-delimited multiple words.
     An unquoted comma in the input will trigger this.
     """
     self.assertEqual(parse_tags(',one'), [u'one'])
     self.assertEqual(parse_tags(',one two'), [u'one two'])
     self.assertEqual(parse_tags(',one two three'), [u'one two three'])
     self.assertEqual(parse_tags('a-one, a-two and a-three'),
         [u'a-one', u'a-two and a-three'])
开发者ID:feuervogel,项目名称:django-taggit,代码行数:10,代码来源:tests.py

示例10: test_with_double_quoted_multiple_words

 def test_with_double_quoted_multiple_words(self):
     """
     Test with double-quoted multiple words.
     A completed quote will trigger this.  Unclosed quotes are ignored.
     """
     tools.assert_equals(parse_tags('"one'), [u'one'])
     tools.assert_equals(parse_tags('"one two'), [u'one', u'two'])
     tools.assert_equals(parse_tags('"one two three'), [u'one', u'three', u'two'])
     tools.assert_equals(parse_tags('"one two"'), [u'one two'])
     tools.assert_equals(parse_tags('a-one "a-two and a-three"'),
         [u'a-one', u'a-two and a-three'])
开发者ID:FinalsClub,项目名称:django-taggit,代码行数:11,代码来源:test_models.py

示例11: clean_expertise

    def clean_expertise(self):
        """Enforce expertise as a subset of interests"""
        cleaned_data = self.cleaned_data

        interests = set(parse_tags(cleaned_data['interests']))
        expertise = set(parse_tags(cleaned_data['expertise']))

        if len(expertise) > 0 and not expertise.issubset(interests):
            raise forms.ValidationError(_("Areas of expertise must be a " 
                "subset of interests"))

        return cleaned_data['expertise']
开发者ID:tantek,项目名称:kuma,代码行数:12,代码来源:forms.py

示例12: render

 def render(self, name, value, attrs=None):
     if value is not None:
         if isinstance(value, basestring):
             value = parse_tags(value)
         else:
             value = edit_string_for_tags([o.tag for o in value.select_related("tag")])
     return super(TagWidget, self).render(name, value, attrs)
开发者ID:QPmedia,项目名称:django-taggit,代码行数:7,代码来源:forms.py

示例13: search

    def search(self):
        # First, store the SearchQuerySet received from other processing.
        if self.cleaned_data['q']:
            sqs = super(objectSearchForm, self).search()
        else:
            sqs= SearchQuerySet().exclude(draft=True)
  
        if not self.is_valid():
            return self.no_query_found()
        # Check to see if a start_date was chosen.
        if self.cleaned_data['tags']:
            sqs = sqs.filter(tags=parse_tags(self.cleaned_data['tags']))


#        if 'start_date' in self.cleaned_data:
#            sqs = sqs.filter(created__gte=self.cleaned_data['start_date'])

        # Check to see if an end_date was chosen.
#        if 'end_date' in self.cleaned_data:
#            sqs = sqs.filter(created=self.cleaned_data['end_date'])

        if not self.cleaned_data['sort'] or self.cleaned_data['sort'] == "votes":
            sqs = sqs.order_by('-ratingSortBest')
        elif self.cleaned_data['sort'] == "new":
            sqs = sqs.order_by('-created')

        return sqs
开发者ID:RTLShadow,项目名称:rhombik-object-repository,代码行数:27,代码来源:forms.py

示例14: clean

	def clean(self, value):
		value = super(TagField, self).clean(value)
		value = ','.join(SIO(value))
		try:
			return parse_tags(value)
		except ValueError:
			raise forms.ValidationError(_("Please provide a comma-separated list of tags."))
开发者ID:theatlantic,项目名称:django-taggit,代码行数:7,代码来源:forms.py

示例15: read_csv

    def read_csv(source, csv_stream):
        """
        Reads metadata from a CSV for a specified source name.
        """
        if not isinstance(source, Source):
            source = Source.objects.get(name=source)

        from csvkit import CSVKitReader
        rows = list(CSVKitReader(csv_stream, delimiter='\t'))
        fields = dict(enumerate(rows[0]))

        errors = []
        for row in rows[1:]:
            try:
                data = {fields[idx]: value for idx, value in enumerate(row)}
                tags = data.pop('tags', None)
                dataset = Dataset(**data)
                dataset.source = source
                dataset.save()

                if tags:
                    dataset.tags.add(*parse_tags(tags))
            except Exception, e:
                logger.exception('Cannot import a dataset from CSV')
                errors.append(repr(e))
开发者ID:FBK-WED,项目名称:wed-pipe,代码行数:25,代码来源:importer.py


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