Changeset 4519:c4c0660af381 in livinglogic.python.xist for src/ll/orasql/scripts/oragrant.py

Show
Ignore:
Timestamp:
07/14/11 13:06:40 (8 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Tags:
rel-3-22
Message:

Added options --include and --exclude to oracreate, oradrop and oragrant.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/orasql/scripts/oragrant.py

    r4470 r4519  
    5858        The encoding of the output (if ``-x`` is not given; default is ``utf-8``). 
    5959 
     60    ``--include`` : regexp 
     61        Only include objects in the output if their name contains the regular 
     62        expression. 
     63 
     64    ``--exclude`` : regexp 
     65        Exclude objects from the output if their name contains the regular 
     66        expression. 
     67 
    6068 
    6169Example 
     
    6977 
    7078 
    71 import sys, os, argparse 
     79import sys, os, re, argparse 
    7280 
    7381from ll import misc, astyle, orasql 
     
    93101    p.add_argument("-m", "--mapgrantee", dest="mapgrantee", help="Map grantees (Python expression: list or dict)", default="True") 
    94102    p.add_argument("-e", "--encoding", dest="encoding", help="Encoding for output (default %(default)s)", default="utf-8") 
     103    p.add_argument(      "--include", dest="include", metavar="REGEXP", help="Include only objects whose name contains PATTERN (default: %(default)s)", type=re.compile) 
     104    p.add_argument(      "--exclude", dest="exclude", metavar="REGEXP", help="Exclude objects whose name contains PATTERN (default: %(default)s)", type=re.compile) 
    95105 
    96106    args = p.parse_args(args) 
     
    121131 
    122132    def keep(obj): 
    123         if args.keepjunk: 
    124             return True 
    125         if "$" in obj.name or "/" in obj.name or obj.name.startswith("SYS_EXPORT_SCHEMA_"): 
     133        if ("$" in obj.name or "/" in obj.name or obj.name.startswith("SYS_EXPORT_SCHEMA_")) and not args.keepjunk: 
     134            return False 
     135        if args.include is not None and args.include.search(obj.name) is None: 
     136            return False 
     137        if args.exclude is not None and args.exclude.search(obj.name) is not None: 
    126138            return False 
    127139        return True