~ubuntu-branches/ubuntu/lucid/loggerhead/lucid-security

« back to all changes in this revision

Viewing changes to loggerhead/util.py

  • Committer: Bazaar Package Importer
  • Author(s): James Westby, Roland Mas, Jelmer Vernooij, James Westby
  • Date: 2009-08-26 13:18:03 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090826131803-0ce1fhaetci8b0c5
Tags: 1.17-0ubuntu1
[ Roland Mas ]
* Use the YUI library provided by libjs-yui. (Closes: #511286)

[ Jelmer Vernooij ]
* Use my debian.org address in Uploaders field.
* Add ${misc:Depends} to please lintian.
* Suggest recent version of paste, which doesn't expose internal port
  numbers in links. (Closes: #507000)
* Bump standards version to 3.8.1.

[ James Westby ]
* New upstream release.
* Drop get-orig-source rule in favour of debian/watch.
* Add python-pkg-resources and python-paste to Build-Depends,
  python-pkg-resources to Depends and python-simplejson to
  Recommends due to dependency changes.

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
 
27
29
import base64
28
30
import cgi
29
31
import datetime
179
181
        return '%s at %s' % (username, domains[-2])
180
182
    return '%s at %s' % (username, domains[0])
181
183
 
 
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
182
192
 
183
193
# only do this if unicode turns out to be a problem
184
194
#_BADCHARS_RE = re.compile(ur'[\u007f-\uffff]')
222
232
            s = s.decode('iso-8859-15')
223
233
        return s
224
234
 
 
235
HSC = HTMLStructureCleaner()
225
236
 
226
237
def fixed_width(s):
227
238
    """
238
249
            s = s.decode('utf-8')
239
250
        except UnicodeDecodeError:
240
251
            s = s.decode('iso-8859-15')
241
 
    return s.expandtabs().replace(' ', NONBREAKING_SPACE)
 
252
 
 
253
    s = cgi.escape(s).expandtabs().replace(' ', NONBREAKING_SPACE)
 
254
 
 
255
    return HSC.clean(s).replace('\n', '<br/>')
242
256
 
243
257
 
244
258
def fake_permissions(kind, executable):
370
384
    """
371
385
    # Is our root directory itself a branch?
372
386
    if is_root:
373
 
        if view == 'directory':
374
 
            directory = 'files'
375
387
        breadcrumbs = [{
376
388
            'dir_name': path,
377
389
            'path': '',
435
447
    return new_decorator
436
448
 
437
449
 
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
 
 
457
450
 
458
451
@decorator
459
452
def lsprof(f):