Ignore:
Timestamp:
Oct 29, 2008, 12:44:46 AM (15 years ago)
Author:
price
Message:

use run-parts semantics in conf.d directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-base/python/invirt/config.py

    r1422 r1423  
    88from contextlib import closing
    99import yaml
     10import re
    1011
    1112try:    loader = yaml.CSafeLoader
     
    3435    return d1
    3536
     37def run_parts_list(dirname):
     38    """Reimplements Debian's run-parts --list.
     39
     40    One difference from run-parts's behavior: run-parts --list /foo/
     41    will give output like /foo//bar, because Python code tends to expect this.
     42
     43    Matches documented behavior of run-parts in debianutils v2.28.2, dated 2007.
     44    """
     45    # From run-parts(8).
     46    lanana_re   = re.compile('^[a-z0-9]+$')
     47    lsb_re      = re.compile('^_?([a-z0-9_.]+-)+[a-z0-9]+$')
     48    deb_cron_re = re.compile('^[a-z0-9][a-z0-9-]*$')
     49    for name in os.listdir(dirname):
     50        if lanana_re.match(name) or lsb_re.match(name) or deb_cron_re.match(name):
     51            yield os.path.join(dirname, name)
     52
    3653def list_files():
    3754    yield src_path
    38     for name in os.listdir(src_dirpath):
    39         yield os.path.join(src_dirpath, name)
     55    for name in run_parts_list(src_dirpath):
     56        yield name
    4057
    4158def load_master():
Note: See TracChangeset for help on using the changeset viewer.