Changeset 256:d4cf27b08d92 in livinglogic.python.orasql

Show
Ignore:
Timestamp:
04/04/08 17:27:53 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Tags:
rel-1-23-4
Message:

Add an encoding parameter to all all scripts.

Files:
7 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r254 r256  
     1Changes in 1.23.4 (released 04/04/2008) 
     2--------------------------------------- 
     3 
     4*   All database scripts now have an additional option :option:`encoding` that 
     5    specifies the encoding for the output script. 
     6 
     7 
    18Changes in 1.23.3 (released 04/03/2008) 
    29--------------------------------------- 
  • setup.py

    r254 r256  
    5656args=dict( 
    5757    name="ll-orasql", 
    58     version="1.23.3", 
     58    version="1.23.4", 
    5959    description="Utilities for working with cx_Oracle", 
    6060    long_description=descr, 
  • src/ll/orasql/scripts/oracreate.py

    r254 r256  
    3030    p.add_option("-k", "--keepjunk", dest="keepjunk", help="Output objects with '$' or 'SYS_EXPORT_SCHEMA_' in their name?", default=False, action="store_true") 
    3131    p.add_option("-i", "--ignore", dest="ignore", help="Ignore errors?", default=False, action="store_true") 
     32    p.add_option("-e", "--encoding", dest="encoding", help="Encoding for output", default="utf-8") 
    3233 
    3334    (options, args) = p.parse_args(args) 
     
    9697                        stderr.writeln("oracreate.py: ", s4error("%s: %s" % (exc.__class__.__name__, str(exc).strip()))) 
    9798                else: 
    98                     stdout.writeln(ddl) 
     99                    stdout.writeln(ddl.encode(options.encoding)) 
    99100                    stdout.writeln() 
    100101 
  • src/ll/orasql/scripts/oradiff.py

    r222 r256  
    8585 
    8686 
    87 def showudiff(out, obj, ddl1, ddl2, connection1, connection2, context=3, timeformat="%c"): 
     87def showudiff(out, obj, ddl1, ddl2, connection1, connection2, encoding="utf-8", context=3, timeformat="%c"): 
    8888    def header(prefix, style, connection): 
    8989        return style("%s %r in %s: %s" % (prefix, obj, connection.connectstring(), gettimestamp(obj, connection, timeformat))) 
     
    100100            if tag == "equal": 
    101101                for line in ddl1[i1:i2]: 
    102                     out.writeln(" %s" % line.originalline) 
     102                    out.writeln((" %s" % line.originalline).encode(encoding)) 
    103103                continue 
    104104            if tag == "replace" or tag == "delete": 
    105105                for line in ddl1[i1:i2]: 
    106                     out.writeln(s4removedline("-", line.originalline)) 
     106                    out.writeln(s4removedline("-", line.originalline.encode(encoding))) 
    107107            if tag == "replace" or tag == "insert": 
    108108                for line in ddl2[j1:j2]: 
    109                     out.writeln(s4addedline("+", line.originalline)) 
     109                    out.writeln(s4addedline("+", line.originalline.encode(encoding))) 
    110110 
    111111 
     
    121121    p.add_option("-k", "--keepjunk", dest="keepjunk", help="Output objects with '$' or 'SYS_EXPORT_SCHEMA_' in their name?", default=False, action="store_true") 
    122122    p.add_option("-b", "--blank", dest="blank", help="How to treat whitespace (%s)" % ", ".join(blanks), default="literal", choices=blanks) 
     123    p.add_option("-e", "--encoding", dest="encoding", help="Encoding for output", default="utf-8") 
    123124 
    124125    (options, args) = p.parse_args(args) 
     
    178179        elif options.mode == "udiff": 
    179180            ddl = getcanonicalddl(obj.createddl(connection1), options.blank) 
    180             showudiff(stdout, obj, ddl, [], connection1, connection2, options.context) 
     181            showudiff(stdout, obj, ddl, [], connection1, connection2, options.encoding, options.context) 
    181182 
    182183    onlyin2 = objects2 - objects1 
     
    193194        elif options.mode == "udiff": 
    194195            ddl = getcanonicalddl(obj.createddl(connection2), options.blank) 
    195             showudiff(stdout, obj, [], ddl, connection1, connection2, options.context) 
     196            showudiff(stdout, obj, [], ddl, connection1, connection2, options.encoding, options.context) 
    196197 
    197198    common = objects1 & objects2 
     
    210211                stdout.write(obj.createddl(connection2)) 
    211212            elif options.mode == "udiff": 
    212                 showudiff(stdout, obj, ddl1c, ddl2c, connection1, connection2, options.context) 
     213                showudiff(stdout, obj, ddl1c, ddl2c, connection1, connection2, options.encoding, options.context) 
    213214 
    214215 
  • src/ll/orasql/scripts/oradrop.py

    r254 r256  
    3131    p.add_option("-k", "--keepjunk", dest="keepjunk", help="Output objects with '$' in their name?", default=False, action="store_true") 
    3232    p.add_option("-i", "--ignore", dest="ignore", help="Ignore errors?", default=False, action="store_true") 
     33    p.add_option("-e", "--encoding", dest="encoding", help="Encoding for output", default="utf-8") 
    3334 
    3435    (options, args) = p.parse_args(args) 
     
    9293                ddls.append((obj, ddl)) 
    9394            else: 
    94                 stdout.write(ddl) 
     95                stdout.write(ddl.encode(options.encoding)) 
    9596 
    9697    # Execute DDL 
  • src/ll/orasql/scripts/oragrant.py

    r254 r256  
    3030    p.add_option("-i", "--ignore", dest="ignore", help="Ignore errors?", default=False, action="store_true") 
    3131    p.add_option("-m", "--mapgrantee", dest="mapgrantee", help="Map grantees (Python expression: list or dict)", default="True", type="str") 
     32    p.add_option("-e", "--encoding", dest="encoding", help="Encoding for output", default="utf-8") 
    3233 
    3334    (options, args) = p.parse_args(args) 
     
    9091                        stderr.writeln("oragrant.py: ", s4error("%s: %s" % (exc.__class__.__name__, str(exc).strip()))) 
    9192                else: 
    92                     stdout.writeln(ddl) 
     93                    stdout.writeln(ddl.encode(options.encoding)) 
    9394                    stdout.writeln() 
    9495 
  • src/ll/orasql/scripts/oramerge.py

    r222 r256  
    9696    p.add_option("-c", "--color", dest="color", help="Color output (%s)" % ", ".join(colors), default="auto", choices=colors) 
    9797    p.add_option("-k", "--keepjunk", dest="keepjunk", help="Output objects with '$' in their name?", default=False, action="store_true") 
     98    p.add_option("-e", "--encoding", dest="encoding", help="Encoding for output", default="utf-8") 
    9899 
    99100    (options, args) = p.parse_args(args) 
     
    289290                file1 = open(filename1, "wb") 
    290291                try: 
    291                     write(file1, ddl1) 
     292                    write(file1, ddl1.encode(options.encoding)) 
    292293 
    293294                    file2 = open(filename2, "wb") 
    294295                    try: 
    295                         write(file2, ddl2) 
     296                        write(file2, ddl2.encode(options.encoding)) 
    296297 
    297298                        file3 = open(filename3, "wb") 
    298299                        try: 
    299                             write(file3, ddl3) 
     300                            write(file3, ddl3.encode(options.encoding)) 
    300301 
    301302                            # do the diffing