~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/util.py

  • Committer: Michael Hudson
  • Date: 2009-03-03 21:29:11 UTC
  • Revision ID: michael.hudson@canonical.com-20090303212911-j7d70q4li0rsa4cb
delete trailing whitespace in changelog.pt

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
except ImportError:
25
25
    from elementtree import ElementTree as ET
26
26
 
27
 
from simpletal.simpleTALUtils import HTMLStructureCleaner
28
 
 
29
27
import base64
30
28
import cgi
31
29
import datetime
181
179
        return '%s at %s' % (username, domains[-2])
182
180
    return '%s at %s' % (username, domains[0])
183
181
 
184
 
def hide_emails(emails):
185
 
    """
186
 
    try to obscure any email address in a list of bazaar committers' names.
187
 
    """
188
 
    result = []
189
 
    for email in emails:
190
 
        result.append(hide_email(email))
191
 
    return result
192
182
 
193
183
# only do this if unicode turns out to be a problem
194
184
#_BADCHARS_RE = re.compile(ur'[\u007f-\uffff]')
232
222
            s = s.decode('iso-8859-15')
233
223
        return s
234
224
 
235
 
HSC = HTMLStructureCleaner()
236
225
 
237
226
def fixed_width(s):
238
227
    """
249
238
            s = s.decode('utf-8')
250
239
        except UnicodeDecodeError:
251
240
            s = s.decode('iso-8859-15')
252
 
 
253
 
    s = s.expandtabs().replace(' ', NONBREAKING_SPACE)
254
 
 
255
 
    return HSC.clean(s).replace('\n', '<br/>')
 
241
    return s.expandtabs().replace(' ', NONBREAKING_SPACE)
256
242
 
257
243
 
258
244
def fake_permissions(kind, executable):
449
435
    return new_decorator
450
436
 
451
437
 
 
438
# common threading-lock decorator
 
439
 
 
440
 
 
441
def with_lock(lockname, debug_name=None):
 
442
    if debug_name is None:
 
443
        debug_name = lockname
 
444
 
 
445
    @decorator
 
446
    def _decorator(unbound):
 
447
 
 
448
        def locked(self, *args, **kw):
 
449
            getattr(self, lockname).acquire()
 
450
            try:
 
451
                return unbound(self, *args, **kw)
 
452
            finally:
 
453
                getattr(self, lockname).release()
 
454
        return locked
 
455
    return _decorator
 
456
 
452
457
 
453
458
@decorator
454
459
def lsprof(f):