Changeset f04e634 in osmose-backend


Ignore:
Timestamp:
Mar 7, 2013 7:10:56 PM (7 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
c793635, a910761
Parents:
bd7d68f
Message:

Detect duplicate wikipedia tag as suffix and preffix in wikipedia plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/TagFix_Wikipedia.py

    r65e7bef rf04e634  
    3333        self.errors[30314] = { "item": 3031, "level": 2, "tag": ["value", "wikipedia"], "desc": {"en": u"Missing primary Wikipedia tag", "fr": u"Un tag 'wikipedia' doit être présent avant d'utiliser des tags 'wikipedia:LANG'"} } 
    3434        self.errors[30315] = { "item": 3031, "level": 2, "tag": ["value", "wikipedia"], "desc": {"en": u"Invalid wikipedia sufix", "fr": u"Utilisation incorrect d'un tag 'wikipedia:xxx', xxx devrait être un autre attribut ou un code langue"} } 
     35        self.errors[30316] = { "item": 3031, "level": 2, "tag": ["value", "wikipedia"], "desc": {"en": u"Duplicate wikipedia tag as suffix and preffix", "fr": u"Double tag wikipedia comme prefixe et suffixe"} } 
    3536 
    3637        import re 
     
    5960            if not self.lang_regexp.match(tags[wikipediaTag]): 
    6061                err.append((30312, 2, {})) 
     62            else: 
     63                prefix = tags[wikipediaTag].split(':', 1)[0] 
     64                tag = wikipediaTag+':'+prefix 
     65                if tag in tags: 
     66                    err.append((30316, 6, {"fix": {'-': [tag]}} )) 
    6167            if "%" in tags[wikipediaTag] or "_" in tags[wikipediaTag]: 
    6268                err.append((30313, 3, {"fix": {wikipediaTag: self.human_readable(tags[wikipediaTag])}} )) 
     
    219225        has_error = u"Invalid wikipedia sufix 'toto'") 
    220226 
     227    check( { "wikipedia:fr": "quelque chose", "wikipedia": "fr:autre chose"}, 
     228        has_error = u"Duplicate wikipedia tag as suffix and preffix") 
     229 
    221230    if err: 
    222231        print "%i errors" % err 
Note: See TracChangeset for help on using the changeset viewer.