Ejemplo n.º 1
0
Archivo: test1.py Proyecto: badi/pith
from pith import Pith

p = Pith()
l = '8 :&: int :&: TYPE :&: 1 :&: NEW :&: run :&: FIELD :&: 38 :&: int :&: TYPE :&: 1 :&: NEW :&: clone :&: FIELD :&: 291 :&: int :&: TYPE :&: 1 :&: NEW :&: gen :&: FIELD :&: 984 :&: int :&: TYPE :&: 1 :&: NEW :&: frame :&: FIELD :&: 4.21349235547 :&: float :&: TYPE :&: 1 :&: NEW :&: rmsd :&: FIELD :&: protolyze.db.results.Result :&: SOMETYPE :&: 5 :&: OBJECT'

obj = p.read(l)
print dir(obj)
orig = obj.construct_original()
print type(orig)
print dir(orig)
print orig.primary_key()

print obj
for k,v in obj.__dict__.iteritems():
    print '\t', k,'=', v


print p.show(obj)
Ejemplo n.º 2
0
Archivo: test2.py Proyecto: badi/pith
# Test sequences

from pith import Pith

p = Pith(sep="|")

for grp in [(1, 2, 3), [1, 2, 3], {"a": 1, "b": 2, "c": 3}, [42, {"hello": "world"}], {}, {True: False}]:
    print type(grp), grp
    s = p.show(grp)
    print "show:", s
    r = p.read(s)
    print "read:", r

    print "success =", grp == r
Ejemplo n.º 3
0
Archivo: test3.py Proyecto: badi/pith
from pith import Pith

s = "/pscratch/csweet1/lcls/fah/data/PROJ10012/RUN3404/CLONE0/results-001.xtc :&: str :&: TYPE :&: 1 :&: NEW :&: trajectory :&: FIELD :&: 750 :&: int :&: TYPE :&: 1 :&: NEW :&: frame :&: FIELD :&: 1.1131634 :&: float :&: TYPE :&: 1 :&: NEW :&: rmsd :&: FIELD :&: __main__.RMSD_Result :&: SOMETYPE :&: 3 :&: OBJECT"

s = "list :&: TYPE :&: 0 :&: NEW"

s = "list :&: TYPE :&: 0 :&: NEW :&: _extra_dbcolumns :&: FIELD :&: 3404 :&: int :&: TYPE :&: 1 :&: NEW :&: run :&: FIELD :&: 0 :&: int :&: TYPE :&: 1 :&: NEW :&: clone :&: FIELD :&: 1 :&: int :&: TYPE :&: 1 :&: NEW :&: gen :&: FIELD :&: list :&: TYPE :&: 0 :&: NEW :&: _fields :&: FIELD :&: 750 :&: int :&: TYPE :&: 1 :&: NEW :&: frame :&: FIELD :&: protolyze.db.results.Result :&: SOMETYPE :&: 6 :&: OBJECT"

p = Pith(debug=False)

print p.read(s)
Ejemplo n.º 4
0
Archivo: test4.py Proyecto: badi/pith
from pith import Pith

import protolyze.db.results as dbr

DEBUG=False

p = Pith(debug=DEBUG)

r = dbr.Result(run=1,clone=2,gen=3,frame=4)


column_name = 'my_column_name'
column = dbr.DBColumn()
column.set_name(column_name)
column.set_type('float')
column.set_column_kwargs(index=True)

s = p.show(column)
read = p.read(s)
print 'show    ', s
print 'original', column
print 'read    ', read
print 'recreate', read.construct_original(debug=DEBUG)

# r.value(column, 42)

# shown = r.show()
# print 'shown =', shown
# read = p.read(shown)
# print 'read =', read.construct_original().__dict__