comparison MoinMoin/themes/__init__.py @ 969:5bf6d7a2ffcf

Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
author Vedran Mileti? <rivanvx@gmail.com>
date Sun, 16 Oct 2011 02:26:35 +0200
parents 9a7889c04a25
children ee71ed6e97c6 b703c5e590a3
comparison
equal deleted inserted replaced
968:26bd2c7936f9 969:5bf6d7a2ffcf
34 else: 34 else:
35 theme_name = app.cfg.theme_default 35 theme_name = app.cfg.theme_default
36 try: 36 try:
37 return get_theme(theme_name) 37 return get_theme(theme_name)
38 except KeyError: 38 except KeyError:
39 logging.warning("theme %s was not found; using default of %s instead." % (theme_name, app.cfg.theme_default)) 39 logging.warning("Theme {0} was not found; using default of {1} instead.".format(theme_name, app.cfg.theme_default))
40 theme_name = app.cfg.theme_default 40 theme_name = app.cfg.theme_default
41 return get_theme(theme_name) 41 return get_theme(theme_name)
42 42
43 43
44 44
125 aliasname = user.aliasname 125 aliasname = user.aliasname
126 if not aliasname: 126 if not aliasname:
127 aliasname = name 127 aliasname = name
128 128
129 wikiname, itemname = getInterwikiHome(name) 129 wikiname, itemname = getInterwikiHome(name)
130 title = "%s @ %s" % (aliasname, wikiname) 130 title = "{0} @ {1}".format(aliasname, wikiname)
131 # link to (interwiki) user homepage 131 # link to (interwiki) user homepage
132 if is_local_wiki(wikiname): 132 if is_local_wiki(wikiname):
133 exists = self.storage.has_item(itemname) 133 exists = self.storage.has_item(itemname)
134 else: 134 else:
135 # We cannot check if wiki pages exists in remote wikis 135 # We cannot check if wiki pages exists in remote wikis
227 sisteritems[item_name.decode('utf-8')] = item_url 227 sisteritems[item_name.decode('utf-8')] = item_url
228 except: 228 except:
229 pass # ignore invalid lines 229 pass # ignore invalid lines
230 f.close() 230 f.close()
231 app.cache.set(cid, sisteritems) 231 app.cache.set(cid, sisteritems)
232 logging.info("Site: %s Status: Updated. Pages: %d" % (sistername, len(sisteritems))) 232 logging.info("Site: {0} Status: Updated. Pages: {1}".format(sistername, len(sisteritems)))
233 except IOError as err: 233 except IOError as err:
234 (title, code, msg, headers) = err.args # code e.g. 304 234 (title, code, msg, headers) = err.args # code e.g. 304
235 logging.warning("Site: %s Status: Not updated." % sistername) 235 logging.warning("Site: {0} Status: Not updated.".format(sistername))
236 logging.exception("exception was:") 236 logging.exception("exception was:")
237 if current in sisteritems: 237 if current in sisteritems:
238 url = sisteritems[current] 238 url = sisteritems[current]
239 items.append(('sisterwiki', url, sistername, '')) 239 items.append(('sisterwiki', url, sistername, ''))
240 flaskg.clock.stop('navibar') 240 flaskg.clock.stop('navibar')
281 email = None # pure email address of author 281 email = None # pure email address of author
282 if app.cfg.show_hosts and addr: 282 if app.cfg.show_hosts and addr:
283 # only tell ip / hostname if show_hosts is True 283 # only tell ip / hostname if show_hosts is True
284 if hostname: 284 if hostname:
285 text = hostname[:15] # 15 = len(ipaddr) 285 text = hostname[:15] # 15 = len(ipaddr)
286 name = title = '%s[%s]' % (hostname, addr) 286 name = title = '{0}[{1}]'.format(hostname, addr)
287 css = 'editor host' 287 css = 'editor host'
288 else: 288 else:
289 name = text = addr 289 name = text = addr
290 title = '[%s]' % (addr, ) 290 title = '[{0}]'.format(addr)
291 css = 'editor ip' 291 css = 'editor ip'
292 292
293 userid = meta.get(USERID) 293 userid = meta.get(USERID)
294 if userid: 294 if userid:
295 u = user.User(userid) 295 u = user.User(userid)
298 aliasname = u.aliasname 298 aliasname = u.aliasname
299 if not aliasname: 299 if not aliasname:
300 aliasname = name 300 aliasname = name
301 if title: 301 if title:
302 # we already have some address info 302 # we already have some address info
303 title = "%s @ %s" % (aliasname, title) 303 title = "{0} @ {1}".format(aliasname, title)
304 else: 304 else:
305 title = aliasname 305 title = aliasname
306 if u.mailto_author and u.email: 306 if u.mailto_author and u.email:
307 email = u.email 307 email = u.email
308 css = 'editor mail' 308 css = 'editor mail'
339 if len(name) > length: 339 if len(name) > length:
340 name = name.split('/')[-1] 340 name = name.split('/')[-1]
341 # If it's not enough, replace the middle with '...' 341 # If it's not enough, replace the middle with '...'
342 if len(name) > length: 342 if len(name) > length:
343 half, left = divmod(length - 3, 2) 343 half, left = divmod(length - 3, 2)
344 name = u'%s...%s' % (name[:half + left], name[-half:]) 344 name = u'{0}...{1}'.format(name[:half + left], name[-half:])
345 return name 345 return name
346 346
347 347
348 MIMETYPE_TO_CLASS = { 348 MIMETYPE_TO_CLASS = {
349 'application/pdf': 'pdf', 349 'application/pdf': 'pdf',
361 """ 361 """
362 cls = MIMETYPE_TO_CLASS.get(contenttype) 362 cls = MIMETYPE_TO_CLASS.get(contenttype)
363 if not cls: 363 if not cls:
364 # just use the major part of mimetype 364 # just use the major part of mimetype
365 cls = contenttype.split('/', 1)[0] 365 cls = contenttype.split('/', 1)[0]
366 return 'moin-mime-%s' % cls 366 return 'moin-mime-{0}'.format(cls)
367 367
368 368
369 def utctimestamp(dt): 369 def utctimestamp(dt):
370 """ 370 """
371 convert a datetime object (UTC) to a UNIX timestamp (UTC) 371 convert a datetime object (UTC) to a UNIX timestamp (UTC)