Changeset 114:97ad221acad6 in livinglogic.python.orasql

Show
Ignore:
Timestamp:
05/16/06 12:00:38 (14 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Update scripts: itercolumns() has moved to TableDefinition?. Update
for astyle.

Location:
scripts
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • scripts/oradiff.py

    r101 r114  
    1515 
    1616 
    17 c4comment = astyle.Style.fromenv("LL_ORASQL_REPRANSI_COMMENT", "black:black:bold") 
    18 c4addedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDFILE", "black:green") 
    19 c4addedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDLINE", "green:black") 
    20 c4removedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDFILE", "black:red") 
    21 c4removedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDLINE", "red:black") 
    22 c4changedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDFILE", "black:blue") 
    23 c4changedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDLINE", "blue:black") 
    24 c4pos = astyle.Style.fromenv("LL_ORASQL_REPRANSI_POS", "black:black:bold") 
    25 c4connectstring = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CONNECTSTRING", "green:black") 
    26 c4definition = astyle.Style.fromenv("LL_ORASQL_REPRANSI_DEFINITION", "blue:black") 
     17s4comment = astyle.Style.fromenv("LL_ORASQL_REPRANSI_COMMENT", "black:black:bold") 
     18s4addedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDFILE", "black:green") 
     19s4addedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDLINE", "green:black") 
     20s4removedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDFILE", "black:red") 
     21s4removedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDLINE", "red:black") 
     22s4changedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDFILE", "black:blue") 
     23s4changedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDLINE", "blue:black") 
     24s4pos = astyle.Style.fromenv("LL_ORASQL_REPRANSI_POS", "black:black:bold") 
     25s4connectstring = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CONNECTSTRING", "green:black") 
     26s4definition = astyle.Style.fromenv("LL_ORASQL_REPRANSI_DEFINITION", "blue:black") 
    2727 
    2828 
    2929def cs(cursor): 
    30     return c4connectstring(cursor.connection.connectstring()) 
     30    return s4connectstring(cursor.connection.connectstring()) 
    3131 
    3232 
    3333def df(definition): 
    34     return c4definition(repr(definition)) 
     34    return s4definition(repr(definition)) 
    3535 
    3636 
    3737def comment(msg, color): 
    38     return c4comment("-- ", msg) 
     38    return s4comment("-- ", msg) 
    3939 
    4040 
     
    9090    for group in difflib.SequenceMatcher(None, ddl1, ddl2).get_grouped_opcodes(context): 
    9191        if not started: 
    92             out.writeln(header("---", c4removedfile, cursor1)) 
    93             out.writeln(header("+++", c4addedfile, cursor2)) 
     92            out.writeln(header("---", s4removedfile, cursor1)) 
     93            out.writeln(header("+++", s4addedfile, cursor2)) 
    9494            started = True 
    9595        (i1, i2, j1, j2) = group[0][1], group[-1][2], group[0][3], group[-1][4] 
    96         out.writeln(c4pos("@@ -%d,%d +%d,%d @@" % (i1+1, i2-i1, j1+1, j2-j1))) 
     96        out.writeln(s4pos("@@ -%d,%d +%d,%d @@" % (i1+1, i2-i1, j1+1, j2-j1))) 
    9797        for (tag, i1, i2, j1, j2) in group: 
    9898            if tag == "equal": 
     
    102102            if tag == "replace" or tag == "delete": 
    103103                for line in ddl1[i1:i2]: 
    104                     out.writeln(c4removedline("-", line.originalline)) 
     104                    out.writeln(s4removedline("-", line.originalline)) 
    105105            if tag == "replace" or tag == "insert": 
    106106                for line in ddl2[j1:j2]: 
    107                     out.writeln(c4addedline("+", line.originalline)) 
     107                    out.writeln(s4addedline("+", line.originalline)) 
    108108 
    109109 
     
    146146            keep = "$" not in definition.name or options.keepdollar 
    147147            if options.verbose: 
    148                 msg = astyle.default("oradiff.py: ", cs(cursor), ": fetching #%d " % (i+1), df(definition)) 
     148                msg = astyle.style_default("oradiff.py: ", cs(cursor), ": fetching #%d " % (i+1), df(definition)) 
    149149                if not keep: 
    150150                    msg += " (skipped)" 
  • scripts/oradrop.py

    r101 r114  
    1515 
    1616 
    17 c4warning = astyle.Style.fromenv("LL_ORASQL_REPRANSI_WARNING", "red:black") 
    18 c4error = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ERROR", "red:black") 
    19 c4connectstring = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CONNECTSTRING", "green:black") 
    20 c4definition = astyle.Style.fromenv("LL_ORASQL_REPRANSI_DEFINITION", "blue:black") 
     17s4warning = astyle.Style.fromenv("LL_ORASQL_REPRANSI_WARNING", "red:black") 
     18s4error = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ERROR", "red:black") 
     19s4connectstring = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CONNECTSTRING", "green:black") 
     20s4definition = astyle.Style.fromenv("LL_ORASQL_REPRANSI_DEFINITION", "blue:black") 
    2121 
    2222 
     
    5252    term = not options.execute 
    5353     
    54     cs = c4connectstring(cursor.connection.connectstring()) 
     54    cs = s4connectstring(cursor.connection.connectstring()) 
    5555 
    5656    ddls = [] 
     
    7373        # Progress report 
    7474        if options.verbose: 
    75             msg = astyle.default("oradrop.py: ", cs, ": fetching #%d " % (i+1), c4definition(repr(definition))) 
     75            msg = astyle.style_default("oradrop.py: ", cs, ": fetching #%d " % (i+1), s4definition(repr(definition))) 
    7676            if action is not None: 
    7777                msg += " (%s)" % action 
     
    8989        for (i, (definition, ddl)) in enumerate(ddls): 
    9090            if options.verbose: 
    91                 stderr.writeln("oradrop.py: ", cs, ": dropping #%d/%d " % (i+1, len(ddls)), c4definition(repr(definition))) 
     91                stderr.writeln("oradrop.py: ", cs, ": dropping #%d/%d " % (i+1, len(ddls)), s4definition(repr(definition))) 
    9292            try: 
    9393                cursor.execute(ddl) 
     
    9595                if not options.ignore or "ORA-01013" in str(exc): 
    9696                    raise 
    97                 stderr.writeln("oradrop.py: ", c4error("%s: %s" % (exc.__class__, str(exc).strip()))) 
     97                stderr.writeln("oradrop.py: ", s4error("%s: %s" % (exc.__class__, str(exc).strip()))) 
  • scripts/oramerge.py

    r101 r114  
    1515 
    1616 
    17 c4warning = astyle.Style.fromenv("LL_ORASQL_REPRANSI_WARNING", "red:black") 
    18 c4error = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ERROR", "red:black") 
    19 c4comment = astyle.Style.fromenv("LL_ORASQL_REPRANSI_COMMENT", "black:black:bold") 
    20 c4addedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDFILE", "black:green") 
    21 c4addedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDLINE", "green:black") 
    22 c4removedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDFILE", "black:red") 
    23 c4removedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDLINE", "red:black") 
    24 c4changedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDFILE", "black:blue") 
    25 c4changedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDLINE", "blue:black") 
    26 c4pos = astyle.Style.fromenv("LL_ORASQL_REPRANSI_POS", "black:black:bold") 
    27 c4connectstring = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CONNECTSTRING", "green:black") 
    28 c4definition = astyle.Style.fromenv("LL_ORASQL_REPRANSI_DEFINITION", "blue:black") 
     17s4warning = astyle.Style.fromenv("LL_ORASQL_REPRANSI_WARNING", "red:black") 
     18s4error = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ERROR", "red:black") 
     19s4comment = astyle.Style.fromenv("LL_ORASQL_REPRANSI_COMMENT", "black:black:bold") 
     20s4addedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDFILE", "black:green") 
     21s4addedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_ADDEDLINE", "green:black") 
     22s4removedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDFILE", "black:red") 
     23s4removedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_REMOVEDLINE", "red:black") 
     24s4changedfile = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDFILE", "black:blue") 
     25s4changedline = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CHANGEDLINE", "blue:black") 
     26s4pos = astyle.Style.fromenv("LL_ORASQL_REPRANSI_POS", "black:black:bold") 
     27s4connectstring = astyle.Style.fromenv("LL_ORASQL_REPRANSI_CONNECTSTRING", "green:black") 
     28s4definition = astyle.Style.fromenv("LL_ORASQL_REPRANSI_DEFINITION", "blue:black") 
    2929 
    3030 
    3131 
    3232def cs(cursor): 
    33     return c4connectstring(cursor.connection.connectstring()) 
     33    return s4connectstring(cursor.connection.connectstring()) 
    3434 
    3535 
    3636def df(definition): 
    37     return c4definition(repr(definition)) 
     37    return s4definition(repr(definition)) 
    3838 
    3939 
    4040def comment(*msg): 
    41     return c4comment("-- ", *msg) 
     41    return s4comment("-- ", *msg) 
    4242 
    4343 
    4444def conflictmarker(prefix, *text): 
    45     return astyle.color(c4error(prefix), " ", *text) 
     45    return astyle.style_default(s4error(prefix), " ", *text) 
    4646 
    4747 
     
    100100            keep = "$" not in definition.name or options.keepdollar 
    101101            if options.verbose: 
    102                 msg = astyle.color("oramerge.py: ", cs(cursor), " fetching #%d " % (i+1), df(definition)) 
     102                msg = astyle.style_default("oramerge.py: ", cs(cursor), " fetching #%d " % (i+1), df(definition)) 
    103103                if not keep: 
    104104                    msg += " (skipped)" 
     
    128128        if in1 != in2: # ignore changes from in2 to in3, because only if something changed in the sources we have to do something 
    129129            if not in1 and in2 and not in3: # added in in2 => copy it to db3 
    130                 msg = astyle.default(df(definition), ": added in ", cs(cursor2), " => add it to ", cs(cursor3)) 
     130                msg = astyle.style_default(df(definition), ": added in ", cs(cursor2), " => add it to ", cs(cursor3)) 
    131131                action = "create" 
    132132            elif not in1 and in2 and in3: # added in both in2 and in3 => collision? 
    133133                if definition.createddl(cursor2) != definition.createddl(cursor3): 
    134                     msg = astyle.default(df(definition), ": added in ", cs(cursor2), " and ", cs(cursor3), " => ", c4error("conflict")) 
     134                    msg = astyle.style_default(df(definition), ": added in ", cs(cursor2), " and ", cs(cursor3), " => ", s4error("conflict")) 
    135135                    action = "collision" 
    136136                    retcode = 2 
    137137                else: 
    138                     msg = astyle.default(df(definition), ": added in ", cs(cursor2), " and ", cs(cursor3), " and identical => keep it") 
     138                    msg = astyle.style_default(df(definition), ": added in ", cs(cursor2), " and ", cs(cursor3), " and identical => keep it") 
    139139                    action = None 
    140140            elif in1 and not in2 and not in3: # removed in in2 and in3 => not needed 
    141                 msg = astyle.default(df(definition), ": removed in ", cs(cursor2), " and ", cs(cursor3), " => not needed") 
     141                msg = astyle.style_default(df(definition), ": removed in ", cs(cursor2), " and ", cs(cursor3), " => not needed") 
    142142                action = None 
    143143            elif in1 and not in2 and in3: # removed in in2 => remove in db3 
    144                 msg = astyle.default(df(definition), ": removed in ", cs(cursor2), " => remove in ", cs(cursor3)) 
     144                msg = astyle.style_default(df(definition), ": removed in ", cs(cursor2), " => remove in ", cs(cursor3)) 
    145145                action = "drop" 
    146146            else: 
     
    157157                # If it's a table, we do not output a merged "create table" statement, but the appropriate "alter table" statements 
    158158                if isinstance(definition, orasql.TableDefinition): 
    159                     fields1 = set(cursor1.itercolumns(definition)) 
    160                     fields2 = set(cursor2.itercolumns(definition)) 
    161                     fields3 = set(cursor3.itercolumns(definition)) 
     159                    fields1 = set(definition.itercolumns(cursor1)) 
     160                    fields2 = set(definition.itercolumns(cursor2)) 
     161                    fields3 = set(definition.itercolumns(cursor3)) 
    162162                    for field in fields1 | fields2 | fields3: 
    163163                        if options.verbose: 
     
    192192                                    stdout.writeln(ddl) 
    193193                else: 
    194                     msg = astyle.default(df(definition), ": merge them") 
     194                    msg = astyle.style_default(df(definition), ": merge them") 
    195195                    action = "merge" 
    196196            else: 
    197                 msg = astyle.default(df(definition), ": identical") 
     197                msg = astyle.style_default(df(definition), ": identical") 
    198198                action = None 
    199199