[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/examples/python schema.py
From: |
Neil Tiffin |
Subject: |
gnue/geas/examples/python schema.py |
Date: |
Mon, 01 Oct 2001 13:33:36 -0400 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/10/01 13:33:36
Modified files:
geas/examples/python: schema.py
Log message:
First attempt to cleanup output format.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/schema.py.diff?cvsroot=OldCVS&tr1=1.12&tr2=1.13&r1=text&r2=text
Patches:
Index: gnue/geas/examples/python/schema.py
diff -u gnue/geas/examples/python/schema.py:1.12
gnue/geas/examples/python/schema.py:1.13
--- gnue/geas/examples/python/schema.py:1.12 Thu Sep 27 13:16:30 2001
+++ gnue/geas/examples/python/schema.py Mon Oct 1 13:33:36 2001
@@ -7,7 +7,7 @@
# a test file: relies on GEAS being run from gnue/geas/src
# and this from gnue/geas/examples/python
#
-# $Id: schema.py,v 1.12 2001/09/27 17:16:30 ntiffin Exp $
+# $Id: schema.py,v 1.13 2001/10/01 17:33:36 ntiffin Exp $
import re
import sys
@@ -109,75 +109,113 @@
else:
print rjust(str(i),4) + " " + ljust(name,32) + " ",
i = i + 1
+ else:
+ data = get_numeric_input( "Select a class number to display [q,return]",
0, len(classnames) )
+ if data != 0:
+ return data
- return data
+ return None
def show_fields( class_definition ):
- if len(class_definition.fields) == 0: print " (None)"
- else: print ""
+ if len(class_definition.fields) == 0:
+ print " (None)"
+ else:
+ print ""
+ temp_string = "Field Name"
+ print temp_string.ljust(16),
+ temp_string = "Type"
+ print temp_string.ljust(16)
+ print "---------------- ---------------"
for f in class_definition.fields:
- print "Field Name: " + f.name
- print " Defined in: " + f.classname
- show_help_info( f.classname, f.name)
- print " Type : ",
+ print f.name.ljust(16),
+ # print " Defined in: " + f.classname
+ # show_help_info( f.classname, f.name)
+ # print " Type : ",
if f.type == GEAS.basic :
- print "Basic"
+ # print "Basic",
+ pass
elif f.type == GEAS.lookup :
- print "Lookup"
+ print "LOOKUP" % f.datatypeclass,
d = con.getReferenceDefinition( classnames[idx-1] , f.name )
if d != None:
if d.type == GEAS.lookup:
- print " Type 'Lookup'"
+ # print " Type 'Lookup'"
+ pass
else:
print "Wrong Type!"
- print
- print " Field '" + d.loadfield +"'"
- print " Fields (",
- for x in d.srcfields: print x,
- print ") match (",
- for x in d.thisfields: print x,
- print ")"
+ # print "WHERE " + d.classname + "."
+ pre_char = "WHERE " + d.classname + "."
+ for x in d.srcfields:
+ print pre_char + x,
+ pre_char = ","
+ # print " = "+f.classname + ".("
+ pre_char = "= "+f.classname + "."
+ for x in d.thisfields:
+ print pre_char + x,
+ pre_char = ","
+ print "",
elif f.type == GEAS.reference :
- print "Reference"
+ print "REF TO %s" % f.datatypeclass,
d = con.getReferenceDefinition( classnames[idx-1] , f.name )
if d != None:
if d.type == GEAS.reference:
- print " Type 'Reference'"
+ # print " Type 'Reference'"
+ pass
else:
- print "Wrong Type!"
- print " Load '" + d.classname +"'"
- print " Fields (",
- for x in d.srcfields: print x,
- print ") match (",
- for x in d.thisfields: print x,
- print ")"
+ print "*** Wrong Type Error! ***"
+ # print "WHERE " + d.classname + "."
+ pre_char = "WHERE " + d.classname + "."
+ for x in d.srcfields:
+ print pre_char + x,
+ pre_char = ","
+ # print " = "+f.classname + ".("
+ pre_char = "= "+f.classname + "."
+ for x in d.thisfields:
+ print pre_char + x,
+ pre_char = ","
+ print "",
elif f.type == GEAS.list :
- print "List"
+ print "LIST %s" % f.datatypeclass,
d = con.getReferenceDefinition( classnames[idx-1] , f.name )
if d != None:
if d.type == GEAS.list:
- print " Type 'List'"
+ # print " Type 'List'"
+ pass
else:
print "Wrong Type!"
- print " Load '" + d.classname +"'"
- print " Fields (",
- for x in d.srcfields: print x,
- print ") match (",
- for x in d.thisfields: print x,
- print ")"
- elif f.type == GEAS.method : print "Method"
- elif f.type == GEAS.calculated : print "Calculated"
- elif f.type == GEAS.nowrite : print "Read Only"
- else: print "Unknown"
- print " Datatype : ",
+ # print "WHERE " + d.classname + "."
+ pre_char = "WHERE " + d.classname + "."
+ for x in d.srcfields:
+ print pre_char + x,
+ pre_char = ","
+ # print " = "+f.classname + ".("
+ pre_char = "= "+f.classname + "."
+ for x in d.thisfields:
+ print pre_char + x,
+ pre_char = ","
+ print "",
+ elif f.type == GEAS.method:
+ print "Method, ",
+ elif f.type == GEAS.calculated:
+ print "Calculated"
+ elif f.type == GEAS.nowrite:
+ print "Read Only"
+ else:
+ print "Unknown"
+
+ # print " Datatype : ",
+ if f.type == GEAS.basic:
+ # print ""
+ # print " ",
+ pass
if f.datatype == GEAS.Char: print "char",
elif f.datatype == GEAS.Int: print "int",
elif f.datatype == GEAS.Int16: print "int16",
elif f.datatype == GEAS.Int32: print "int32",
elif f.datatype == GEAS.Int64: print "int64",
elif f.datatype == GEAS.Text: print "text",
- elif f.datatype == GEAS.Class: print "class ("+f.datatypeclass+")",
+ elif f.datatype == GEAS.Class: pass # print "class
("+f.datatypeclass+")",
elif f.datatype == GEAS.Date: print "date",
elif f.datatype == GEAS.Bool: print "bool",
elif f.datatype == GEAS.Boolean: print "boolean",
@@ -190,9 +228,9 @@
if len(f.format) > 0: print "<"+ f.format +">",
if f.defaultvalue != None and len(f.defaultvalue) > 0:
print " = " + f.defaultvalue,
- print ""
+ # print ", ",
- print " Flags : ",
+ # print " Flags : ",
needcomma = 0
if f.notnull:
print "Not Null",
@@ -201,9 +239,9 @@
if needcomma == 1: print ", "
print "Read Only",
needcomma = 1
- if needcomma == 0: print "<None set>", # only happens if no flags are
printed
- print ""
+ # if needcomma == 0: print "<None set>", # only happens if no flags are
printed
print ""
+ # print ""
return
@@ -252,8 +290,9 @@
try:
print ""
classnames = con.classes
- idx = show_classnames( classnames )
-
+ idx = None
+ while idx == None:
+ idx = show_classnames( classnames )
c = con.getFullClassDefinition( classnames[idx-1] )
show_classname( c )
show_fields( c )
- gnue/geas/examples/python schema.py,
Neil Tiffin <=