Changeset 4519:c4c0660af381 in livinglogic.python.xist

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:
5 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r4517 r4519  
     1Changes in 3.22 (released 07/14/2011) 
     2------------------------------------- 
     3 
     4*   The scripts ``oracreate``, ``oradrop`` and ``oragrant`` have new options 
     5    :option:`--include` and :option:`--exclude` that can be used to filter the 
     6    objects that will be output. 
     7 
     8 
    19Changes in 3.21 (released 06/03/2011) 
    210------------------------------------- 
  • setup.py

    r4515 r4519  
    228228args = dict( 
    229229    name="ll-xist", 
    230     version="3.21", 
     230    version="3.22", 
    231231    description="Extensible HTML/XML generator, cross-platform templating language, Oracle utilities and various other tools", 
    232232    long_description=description, 
  • src/ll/orasql/scripts/oracreate.py

    r4473 r4519  
    5656        The encoding of the output (if ``-x`` is not given; default is ``utf-8``). 
    5757 
     58    ``--include`` : regexp 
     59        Only include objects in the output if their name contains the regular 
     60        expression. 
     61 
     62    ``--exclude`` : regexp 
     63        Exclude objects from the output if their name contains the regular 
     64        expression. 
    5865 
    5966Examples 
     
    7077 
    7178 
    72 import sys, os, argparse 
     79import sys, os, re, argparse 
    7380 
    7481from ll import misc, astyle, orasql 
     
    94101    p.add_argument("-i", "--ignore", dest="ignore", help="Ignore errors? (default %(default)s)", default=False, action=misc.FlagAction) 
    95102    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) 
    96105 
    97106    args = p.parse_args(args) 
     
    122131        if obj.owner is not None: 
    123132            return False 
    124         if args.keepjunk: 
    125             return True 
    126133        # output pk, fks etc. only when they belong to a table we do output 
    127134        if isinstance(obj, (orasql.Constraint, orasql.Index)): 
    128135            obj = obj.table() 
    129         if "$" in obj.name or obj.name.startswith("SYS_EXPORT_SCHEMA_"): 
     136        if ("$" in obj.name or "/" in obj.name or obj.name.startswith("SYS_EXPORT_SCHEMA_")) and not args.keepjunk: 
     137            return False 
     138        if args.include is not None and args.include.search(obj.name) is None: 
     139            return False 
     140        if args.exclude is not None and args.exclude.search(obj.name) is not None: 
    130141            return False 
    131142        return True 
  • 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 
  • 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