~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2006-03-24 19:01:30 UTC
  • Revision ID: abentley@panoramicfeedback.com-20060324190130-2208c693486a8b33
Added apache index scraping to the branches command

Show diffs side-by-side

added added

removed removed

Lines of Context:
303
303
    return new_committer
304
304
 
305
305
 
306
 
def iter_branches(t):
 
306
def apache_ls(t):
 
307
    """Screen-scrape Apache listings"""
 
308
    apache_dir = '<IMG border="0" src="/icons/folder.gif" ALT="[DIR]">'\
 
309
        ' <A HREF="'
 
310
    lines = t.get('.')
 
311
    for line in lines:
 
312
        if line.startswith(apache_dir):
 
313
            url = line[len(apache_dir):].split('"')[0]
 
314
            yield url.rstrip('/')
 
315
 
 
316
 
 
317
def iter_branches(t, lister=None):
307
318
    """Iterate through all the branches under a transport"""
308
 
    for bzrdir in iter_bzrdirs(t):
 
319
    for bzrdir in iter_bzrdirs(t, lister):
309
320
        try:
310
321
            branch = bzrdir.open_branch()
311
322
            if branch.bzrdir is bzrdir:
313
324
        except (NotBranchError, UnsupportedFormatError):
314
325
            pass
315
326
 
316
 
def iter_branch_tree(t):
317
 
    for bzrdir in iter_bzrdirs(t):
 
327
 
 
328
def iter_branch_tree(t, lister=None):
 
329
    for bzrdir in iter_bzrdirs(t, lister):
318
330
        try:
319
331
            wt = bzrdir.open_workingtree()
320
332
            yield wt.branch, wt
326
338
            except (NotBranchError, UnsupportedFormatError):
327
339
                continue
328
340
 
329
 
def iter_bzrdirs(t):
 
341
def iter_bzrdirs(t, lister=None):
 
342
    if lister is None:
 
343
        def lister(t):
 
344
            return t.list_dir('.')
330
345
    try:
331
346
        bzrdir = bzrdir_from_transport(t)
332
347
        yield bzrdir
333
348
    except (NotBranchError, UnsupportedFormatError, TransportError):
334
349
        pass
335
350
    try:
336
 
        for directory in t.list_dir('.'):
 
351
        for directory in lister(t):
337
352
            if directory == ".bzr":
338
353
                continue
339
354
            subt = t.clone(directory)