Beispiel #1
0
 def testRename(self):
     #rename
     self.assertEqual(self.v0.s, Mk4py.property('S','s'))
     x2 = self.v0.rename('s', 'stringprop')
     self.assertEqual(x2.stringprop, Mk4py.property('S','stringprop'))
     self.assertNotEqual(x2.structure(), self.v0.structure())
     self.assertEqual(len(x2.structure()), 2)
     self.assertEqual(x2.i, self.v0.i)
Beispiel #2
0
 def __init__(self, file_or_filepath):
   # Note: we keep self.db around to avoid the db getting GC'd
   if hasattr(file_or_filepath, 'mode'):
     self.db = Mk4py.storage(file_or_filepath)
   else:
     self.db = Mk4py.storage(file_or_filepath, 0)
   dirs = self.db.view('dirs')
   self.table = dirs[0].files[0]._B
Beispiel #3
0
 def testRename(self):
     #rename
     self.assertEqual(self.v0.s, Mk4py.property('S', 's'))
     x2 = self.v0.rename('s', 'stringprop')
     self.assertEqual(x2.stringprop, Mk4py.property('S', 'stringprop'))
     self.assertNotEqual(x2.structure(), self.v0.structure())
     self.assertEqual(len(x2.structure()), 2)
     self.assertEqual(x2.i, self.v0.i)
    def __init__(self):
        # open the IDA Sync database, creating it if it doesn't exist.
        self.db = mk.storage("databases/ida_sync.db", 1)

        # if it doesn't already exist, define a view to track user updates.
        description = "__last__[username:S,project:S,timestamp:L]"
        self.last_view = self.db.getas(description)
Beispiel #5
0
    def __init__(self):
        # open the IDA Sync database, creating it if it doesn't exist.
        self.db = mk.storage("databases/ida_sync.db", 1)

        # if it doesn't already exist, define a view to track user updates.
        description = "__last__[username:S,project:S,timestamp:L]"
        self.last_view = self.db.getas(description)
Beispiel #6
0
 def testGetAttr(self):
     r = self.v[0]
     attrs = r.__attrs__
     self.assertEqual(len(attrs), 8)
     self.assertEqual(attrs[0].name, 'i')
     self.assertEqual(attrs[0].type, 'I')
     self.assertEqual(attrs[0].id, Mk4py.property('I', 'i').id)
     self.assertEqual(attrs[7].name, 'm')
     self.assertEqual(attrs[7].type, 'B')
     self.assertEqual(attrs[7].id, Mk4py.property('M', 'm').id)
     #self.assertEqual(r.__view__, v)    what's r.__view__ good for??
     self.assertEqual(r.__index__, 0)
     self.assertEqual(r.i, 0)
     self.assertEqual(r.l, 0)
     self.assertEqual(r.f, 0.0)
     self.assertEqual(r.d, 0.0)
     self.assertEqual(r.s, '')
     self.assertEqual(len(r.v, ), 0)
     self.assertEqual(type(r.v), Mk4py.ViewType)
     self.assertEqual(r.b, '')
     self.assertEqual(r.m, '')
Beispiel #7
0
 def testGetAttr(self):
     r = self.v[0]
     attrs = r.__attrs__
     self.assertEqual(len(attrs), 8)
     self.assertEqual(attrs[0].name, 'i')
     self.assertEqual(attrs[0].type, 'I')
     self.assertEqual(attrs[0].id, Mk4py.property('I','i').id)
     self.assertEqual(attrs[7].name, 'm')
     self.assertEqual(attrs[7].type, 'B')
     self.assertEqual(attrs[7].id, Mk4py.property('M','m').id)
     #self.assertEqual(r.__view__, v)    what's r.__view__ good for??
     self.assertEqual(r.__index__, 0)
     self.assertEqual(r.i, 0)
     self.assertEqual(r.l, 0)
     self.assertEqual(r.f, 0.0)
     self.assertEqual(r.d, 0.0)
     self.assertEqual(r.s, '')
     self.assertEqual(len(r.v, ), 0)
     self.assertEqual(type(r.v), Mk4py.ViewType)
     self.assertEqual(r.b, '')
     self.assertEqual(r.m, '')
Beispiel #8
0
 def setUpViews(self):
     self.s = s = Mk4py.storage()
     self.v0 = s.getas('v0[s:S,i:I]')
     self.v1 = s.getas('v1[s:S,f:D]')
     self.v2 = s.getas('v2[i:I,b:M]')
     for vals in [('a',1),('b',2),('c',3)]:
         self.v0.append(vals)
     for vals in [('c',1.0),('b',2.0),('a',3.0)]:
         self.v1.append(vals)
     for vals in [(2,'\2'),(3,'\3'),(4,'\4')]:
         self.v2.append(vals)
     t = self.v1.rename('s', 't')
     self.p0 = t.product(self.v0)
     self.g0 = self.p0.groupby(self.p0.t, self.p0.f, 'details')
     self.f0 = self.g0.flatten(self.g0.details)
     self.f1 = self.f0[3:]
     self.m0 = self.f1.copy()
     def f(row):
         row.i = row.i + 1
     self.m0.map(f)
Beispiel #9
0
    def setUpViews(self):
        self.s = s = Mk4py.storage()
        self.v0 = s.getas('v0[s:S,i:I]')
        self.v1 = s.getas('v1[s:S,f:D]')
        self.v2 = s.getas('v2[i:I,b:M]')
        for vals in [('a', 1), ('b', 2), ('c', 3)]:
            self.v0.append(vals)
        for vals in [('c', 1.0), ('b', 2.0), ('a', 3.0)]:
            self.v1.append(vals)
        for vals in [(2, '\2'), (3, '\3'), (4, '\4')]:
            self.v2.append(vals)
        t = self.v1.rename('s', 't')
        self.p0 = t.product(self.v0)
        self.g0 = self.p0.groupby(self.p0.t, self.p0.f, 'details')
        self.f0 = self.g0.flatten(self.g0.details)
        self.f1 = self.f0[3:]
        self.m0 = self.f1.copy()

        def f(row):
            row.i = row.i + 1

        self.m0.map(f)
Beispiel #10
0
for file in os.listdir("modules"):
    if (file.endswith(".py")):
        file = file.split(".")[0]
        exec("from " + file + " import *")

try:
    module = sys.argv[1]
    cmd    = sys.argv[2]
    
    if (cmd == "create" or cmd == "drop" or cmd == "dump"):
        project = sys.argv[3]
except:
    print "usage: dbs <module> [list] [<create|drop|dump> <proj>]" 
    sys.exit(1)

db = mk.storage("databases/" + module + ".db", 1)

### LIST ###############################################################################################################
if (cmd == "list"):
    print "views:",
    
    for table in db.contents().properties():
        if (table.startswith("__") and table.endswith("__")):
            continue
            
        print table,

    #view = db.view(table)
    #for struct in view.structure():
    #    print "\t",
    #    print struct
Beispiel #11
0
 def testAddProperty(self):
     x0 = self.v0.copy()
     x0.addproperty(Mk4py.property('I', 'shoesize'))
     self.assertEqual(len(x0.structure()), 3)
     self.assertEqual(x0.shoesize, x0.structure()[-1])
Beispiel #12
0
 def setUpView(self):
     self.s = s = Mk4py.storage()
     self.v = v = s.getas('test[i:I,l:L,f:F,d:D,s:S,v[s:S],b:B,m:M]')
     v.append()
Beispiel #13
0
 def testAddProperty(self):
     x0 = self.v0.copy()
     x0.addproperty(Mk4py.property('I','shoesize'))
     self.assertEqual(len(x0.structure()), 3)
     self.assertEqual(x0.shoesize, x0.structure()[-1]) 
Beispiel #14
0
 def setUpView(self):
     self.s = s = Mk4py.storage()
     self.v = v = s.getas('test[i:I,l:L,f:F,d:D,s:S,v[s:S],b:B,m:M]')
     v.append()
    def __init__(self):
        # open the users database, creating it if it doesn't exist.
        self.db = mk.storage("databases/users.db", 1)

        # define the user table (view) if it doesn't already exist.
        self.view = self.db.getas("users[username:S,password:S,realname:S]")
Beispiel #16
0
for file in os.listdir("modules"):
    if (file.endswith(".py")):
        file = file.split(".")[0]
        exec("from " + file + " import *")

try:
    module = sys.argv[1]
    cmd = sys.argv[2]

    if (cmd == "create" or cmd == "drop" or cmd == "dump"):
        project = sys.argv[3]
except:
    print "usage: dbs <module> [list] [<create|drop|dump> <proj>]"
    sys.exit(1)

db = mk.storage("databases/" + module + ".db", 1)

### LIST ###############################################################################################################
if (cmd == "list"):
    print "views:",

    for table in db.contents().properties():
        if (table.startswith("__") and table.endswith("__")):
            continue

        print table,

    #view = db.view(table)
    #for struct in view.structure():
    #    print "\t",
    #    print struct
Beispiel #17
0
    def __init__(self):
        # open the users database, creating it if it doesn't exist.
        self.db = mk.storage("databases/users.db", 1)

        # define the user table (view) if it doesn't already exist.
        self.view = self.db.getas("users[username:S,password:S,realname:S]")