Changeset 4382:7ffba82ac396 in livinglogic.python.xist for src/ll/scripts/ucat.py

Show
Ignore:
Timestamp:
03/03/11 18:00:28 (9 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Move mathing against the -e/-e patterns into separate function.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/scripts/ucat.py

    r4381 r4382  
    2727 
    2828def main(args=None): 
     29    def match(strurl): 
     30        if args.include is not None and args.include.search(strurl) is None: 
     31            return False 
     32        if args.exclude is not None and args.exclude.search(strurl) is not None: 
     33            return False 
     34        return True 
     35 
    2936    def catone(urlread): 
    3037        strurlread = str(urlread) 
     
    3643                raise IOError(errno.EISDIR, "Is a directory", strurlread) 
    3744        else: 
    38             do = True 
    39             if args.include is not None and args.include.search(strurlread) is None: 
    40                 do = False 
    41             if args.exclude is not None and args.exclude.search(strurlread) is not None: 
    42                 do = False 
    43             if do: 
     45            if match(strurlread): 
    4446                try: 
    4547                    with contextlib.closing(urlread.open("rb")) as fileread: