Changeset 4519:c4c0660af381 in livinglogic.python.xist for src/ll/orasql/scripts/oradrop.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/oradrop.py

    r4473 r4519  
    5858    ``-e``, ``--encoding`` : encoding 
    5959        The encoding of the output (if ``-x`` is not given; default is ``utf-8``). 
     60 
     61    ``--include`` : regexp 
     62        Only include objects in the output if their name contains the regular 
     63        expression. 
     64 
     65    ``--exclude`` : regexp 
     66        Exclude objects from the output if their name contains the regular 
     67        expression. 
     68 
    6069""" 
    6170 
    6271 
    63 import sys, os, argparse 
     72import sys, os, re, argparse 
    6473 
    6574from ll import misc, astyle, orasql 
     
    8594    p.add_argument("-i", "--ignore", dest="ignore", help="Ignore errors? (default %(default)s)", default=False, action=misc.FlagAction) 
    8695    p.add_argument("-e", "--encoding", dest="encoding", help="Encoding for output (default %(default)s)", default="utf-8") 
     96    p.add_argument(      "--include", dest="include", metavar="REGEXP", help="Include only objects whose name contains PATTERN (default: %(default)s)", type=re.compile) 
     97    p.add_argument(      "--exclude", dest="exclude", metavar="REGEXP", help="Exclude objects whose name contains PATTERN (default: %(default)s)", type=re.compile) 
    8798 
    8899    args = p.parse_args(args) 
     
    107118        if obj.owner is not None and not isinstance(obj, orasql.ForeignKey): 
    108119            return False 
    109         if args.keepjunk: 
    110             return True 
    111         if "$" in obj.name: 
     120        if ("$" in obj.name or obj.name.startswith("SYS_EXPORT_SCHEMA_")) and not args.keepjunk: 
     121            return False 
     122        if args.include is not None and args.include.search(obj.name) is None: 
     123            return False 
     124        if args.exclude is not None and args.exclude.search(obj.name) is not None: 
    112125            return False 
    113126        return True