Esempio n. 1
0
 def populate(self):
     tokens=self.tokens
     if len(tokens)==2:
         self.containsExternalCode=True
         self.isJustExternalCode=True
         if tokens[0]=='assert':
             self.addReturns=False
             self.throws=False
         elif tokens[0]=='throws':
             self.throws=True
             self.addReturns=False
         elif tokens[0]=='returns':
             self.addReturns=True
             self.throws=False
         else: raise SemanticException('Invalid Partition Check Item')
         self.code=tokens[1]
     elif len(tokens)==3:
         self.addReturns=tokens[0]=='returns'
         self.throws=not self.addReturns
         tok=self.tokens[2]
         self.comparator=self.tokens[1]
         parse=QuotedString ("<%", "\\", None, False, unquoteResults=True, endQuoteChar="%>")
         self.isJustExternalCode=False
         try:
             self.code=parse.parseString(tok)[0]
             self.containsExternalCode=True
         except ParseException:
             self.containsExternalCode=False
             self.code=tok
     else:
         raise SemanticException("Check is invalid")
Esempio n. 2
0
    def foldersByAnnotation(folderlist, type):
        result = []
        parse = QuotedString('"') + QuotedString('"') + Suppress("(") + Group(OneOrMore(QuotedString('"'))) + Suppress(")")

        for folder in folderlist:
            tmp = parse.parseString( folder )
            if type in tmp[2][1]:
                result.append(tmp[0])

        return result