aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/text.py
diff options
context:
space:
mode:
authordunkyp <dunkyp@gmail.com>2012-11-06 13:32:48 +0000
committerSebastian Spaeth <Sebastian@SSpaeth.de>2012-11-14 08:38:24 +0100
commit36c7d934816d36f45b0987c893836757d933f581 (patch)
tree474dc92c37b817b974e384e0c3a166fa5f962760 /mediagoblin/tools/text.py
parentee62c51d797ab317366fa099f5e012f33f42857f (diff)
downloadmediagoblin-36c7d934816d36f45b0987c893836757d933f581.tar.lz
mediagoblin-36c7d934816d36f45b0987c893836757d933f581.tar.xz
mediagoblin-36c7d934816d36f45b0987c893836757d933f581.zip
Remove tag delimiter configurability (#390), fixed pep-8 compliance
Hardcode commas as tag delimiters per discussion in issue 390. Also improved PEP-8'ness of the file while touching. Includes some improvements suggested by gandaro. Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'mediagoblin/tools/text.py')
-rw-r--r--mediagoblin/tools/text.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/mediagoblin/tools/text.py b/mediagoblin/tools/text.py
index ea231244..09d172a6 100644
--- a/mediagoblin/tools/text.py
+++ b/mediagoblin/tools/text.py
@@ -38,13 +38,12 @@ HTML_CLEANER = Cleaner(
allow_tags=[
'div', 'b', 'i', 'em', 'strong', 'p', 'ul', 'ol', 'li', 'a', 'br',
'pre', 'code'],
- remove_unknown_tags=False, # can't be used with allow_tags
+ remove_unknown_tags=False, # can't be used with allow_tags
safe_attrs_only=True,
- add_nofollow=True, # for now
+ add_nofollow=True, # for now
host_whitelist=(),
whitelist_tags=set([]))
-TAGS_DELIMITER=',';
def clean_html(html):
# clean_html barfs on an empty string
@@ -68,8 +67,7 @@ def convert_to_tag_list_of_dicts(tag_string):
stripped_tag_string = u' '.join(tag_string.strip().split())
# Split the tag string into a list of tags
- for tag in stripped_tag_string.split(
- TAGS_DELIMITER):
+ for tag in stripped_tag_string.split(','):
# Ignore empty or duplicate tags
if tag.strip() and tag.strip() not in [t['name'] for t in taglist]:
@@ -87,8 +85,9 @@ def media_tags_as_string(media_entry_tags):
"""
media_tag_string = ''
if media_entry_tags:
- media_tag_string = (TAGS_DELIMITER+u' ').join(
- [tag['name'] for tag in media_entry_tags])
+ media_tag_string = u', '.join(
+ [tag['name']
+ for tag in media_entry_tags])
return media_tag_string
@@ -107,7 +106,7 @@ def tag_length_validator(form, field):
if too_long_tags:
raise wtforms.ValidationError(
- TOO_LONG_TAG_WARNING % (mg_globals.app_config['tags_max_length'], \
+ TOO_LONG_TAG_WARNING % (mg_globals.app_config['tags_max_length'],
', '.join(too_long_tags)))