comparison MoinMoin/wikiutil.py @ 1868:64507f46beb2

reduce usage of has_key()
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 10 Mar 2007 22:01:07 +0100
parents 0194beaf511e
children 9406e02388cf
comparison
equal deleted inserted replaced
1867:8166b37db555 1868:64507f46beb2
630 @rtype: tuple 630 @rtype: tuple
631 @return: (wikitag, wikiurl, wikitail, err) 631 @return: (wikitag, wikiurl, wikitail, err)
632 """ 632 """
633 _interwiki_list = load_wikimap(request) 633 _interwiki_list = load_wikimap(request)
634 wikiname, pagename, linktext = split_wiki(wikiurl) 634 wikiname, pagename, linktext = split_wiki(wikiurl)
635 if _interwiki_list.has_key(wikiname): 635 if wikiname in _interwiki_list:
636 return (wikiname, _interwiki_list[wikiname], pagename, False) 636 return (wikiname, _interwiki_list[wikiname], pagename, False)
637 else: 637 else:
638 return (wikiname, request.getScriptname(), "/InterWiki", True) 638 return (wikiname, request.getScriptname(), "/InterWiki", True)
639 639
640 def join_wiki(wikiurl, wikitail): 640 def join_wiki(wikiurl, wikitail):
910 for param in parameters: 910 for param in parameters:
911 key, value = param.split('=') 911 key, value = param.split('=')
912 if value[0] == '"' and value[-1] == '"': # remove quotes 912 if value[0] == '"' and value[-1] == '"': # remove quotes
913 value = value[1:-1] 913 value = value[1:-1]
914 self.params[key.lower()] = value 914 self.params[key.lower()] = value
915 if self.params.has_key('charset'): 915 if 'charset' in self.params:
916 self.charset = self.params['charset'].lower() 916 self.charset = self.params['charset'].lower()
917 self.sanitize() 917 self.sanitize()
918 918
919 def parse_format(self, format): 919 def parse_format(self, format):
920 """ maps from what we currently use on-page in a #format xxx processing 920 """ maps from what we currently use on-page in a #format xxx processing
1365 else: 1365 else:
1366 value = None 1366 value = None
1367 1367
1368 parameter_list.append(value) 1368 parameter_list.append(value)
1369 if match.group("name"): 1369 if match.group("name"):
1370 if not self.param_dict.has_key(match.group("name")): 1370 if match.group("name") not in self.param_dict:
1371 raise ValueError, "Unknown parameter name '%s'" % match.group("name") 1371 raise ValueError, "Unknown parameter name '%s'" % match.group("name")
1372 nr = self.param_dict[match.group("name")] 1372 nr = self.param_dict[match.group("name")]
1373 if check_list[nr]: 1373 if check_list[nr]:
1374 #raise ValueError, "Parameter specified twice" 1374 #raise ValueError, "Parameter specified twice"
1375 #TODO: Something saner that raising an exception. This is pretty good, since it ignores it. 1375 #TODO: Something saner that raising an exception. This is pretty good, since it ignores it.
1530 @rtype: string 1530 @rtype: string
1531 @return: formatted link tag 1531 @return: formatted link tag
1532 """ 1532 """
1533 if formatter is None: 1533 if formatter is None:
1534 formatter = request.html_formatter 1534 formatter = request.html_formatter
1535 if kw.has_key('css_class'): 1535 if 'css_class' in kw:
1536 css_class = kw['css_class'] 1536 css_class = kw['css_class']
1537 del kw['css_class'] # one time is enough 1537 del kw['css_class'] # one time is enough
1538 else: 1538 else:
1539 css_class = None 1539 css_class = None
1540 id = kw.get('id', None) 1540 id = kw.get('id', None)