Commits

March Liu committed d3b772f

modify a word write error

Comments (0)

Files changed (3)

src/socrates/core.py

         subjects = Subject.table
         String = self.registed_type["string"]
         strings = String.table
-        pid = self.get_preidcate_id_by_name(name)
+        pid = self.get_predicate_id_by_name(name)
         if not pid:
             pid = self.sequence()
         objType = self.get_type_id_by_name(objtype_name)
             sid = subject_id
         else:
             sid = self.sequence()
-        pid = self.get_preidcate_id_by_name(pname)
+        pid = self.get_predicate_id_by_name(pname)
         SegmentType = self.registed_type[tnames[0][0]]
         segment = SegmentType(sid, pid, obj)
         self.Session.add(segment)
 1
         """
         pname, tnames = self.parsePredicateExpression(predicate_segment)
-        pid = self.get_preidcate_id_by_name(pname)
+        pid = self.get_predicate_id_by_name(pname)
         for tname in tnames:
             SegmentType = self.registed_type[tnames[0][0]]
             for row in self.Session.query(SegmentType).filter(SegmentType.predicate_id==pid).filter(SegmentType.obj==obj):
         else:
             subjects = self.registed_type['subject']
             strings = self.registed_type['string']
-            pid = self.get_preidcate_id_by_name(pname)
+            pid = self.get_predicate_id_by_name(pname)
             objType = self.Session.query(subjects.obj).\
                 filter(subjects.subject_id==pid).\
                 filter(subjects.predicate_id==meta.OBJTYPE).scalar() 
     def get_type_id_by_name(self, name):
         """
 >>> storage = Storage("sqlite://", create=True)
->>> storage.get_preidcate_id_by_name("no true")
->>> print storage.get_preidcate_id_by_name("name")==meta.NAME
+>>> storage.get_predicate_id_by_name("no true")
+>>> print storage.get_predicate_id_by_name("name")==meta.NAME
 True
         """
         if name == 'subject':
         #session.close()
         return re
 
-    def get_preidcate_id_by_name(self, name):
+    def get_predicate_id_by_name(self, name):
         """
 >>> storage = Storage("sqlite://", create=True)
->>> storage.get_preidcate_id_by_name("no true")
->>> print storage.get_preidcate_id_by_name("name")==meta.NAME
+>>> storage.get_predicate_id_by_name("no true")
+>>> print storage.get_predicate_id_by_name("name")==meta.NAME
 True
         """
         SegmentString = self.registed_type['string']

src/socrates/parser.py

 ('test subject:page', 'subject array')
 >>> parser('"test subject:page":"subject array:integer"')
 ('test subject:page', 'subject array:integer')
+>>> parser('"test subject:page":"subject array:integer"')
+('test "subject:page', 'subject array:integer')
+
     """
     syntax=re.compile(r'^(?:\")?((?<=\")(?:[^\"]|(?<=\\).)*(?=\")|(?:[^\:]*))(?:\")?(?:\:(?:\")?((?<=\")(?:[^\"]|(?<=\\).)*(?=\")|(?:[^\:]*))(?:\")?)?$')
     def __call__(self, prdstr):
             name, objType = m.groups()
             return name, objType
         else:
-            raise "Unkown format"
+            raise Exception("Unkown format")
 
 
 if __name__=="__main__":

src/socrates/types.py

     def __eq__(self, obj):
         return self.subject_id==obj.sbuject_id
     def predicates(self):
-        return tuple(set(segment.preidcate for segment in self.segments))
+        return tuple(set(segment.predicate for segment in self.segments))
     def objects(self, pname):
-        pid = self.__storage.get_preidcate_id_by_name(pname)
+        pid = self.__storage.get_predicate_id_by_name(pname)
         return [segment.object for segment in self.segments if segment.predicate_id==pid]
 
     pnames = property(lambda self:set(segment.predicate.name for segment in self.segments))