예제 #1
0
def ParsePropertyName(text):
    from settings import PrivateDefinition,PublicDefinition
    from settings import ProtectedDefinition,StaticDefinition
    p = Property()
    words = text.split()
    for word in words:
        if (word==PrivateDefinition.replace(" ","")):
            p.Private=True
            text=text.replace(word,"")
        elif (word==PublicDefinition.replace(" ","")):
            p.Public =True
            text=text.replace(word,"")
        elif (word==ProtectedDefinition.replace(" ","")):
            p.Protected=True
            text=text.replace(word,"")
        elif (word==StaticDefinition.replace(" ","")):
            p.Static=True
            text=text.replace(word,"")
        elif (word in DataTypes):
            p.Type=word
            text=text.replace(word,"")    
            
    if len(text.split())==2:
        p.Type=text.split()[0]
        p.Name=text.split()[1]
    elif len(text.split())==1:
        p.Name=text.split()[0]
    else:
        raise ValueError("nerozpoznane paramtre v nazve property v pocte "+str(len(text.split()))+" text: ",text)    
    return p    
예제 #2
0
def ParseMethodName(text):
    from settings import PrivateDefinition,PublicDefinition
    from settings import ProtectedDefinition,StaticDefinition
    from settings import OverrideDefinition,AbstractDefinition
    from settings import VirtualDefinition
    Parameters=[]
    original = text
    if (text.find("(")>-1):
        Parameters=ParseParameters(text[text.find("(")+1:text.find(")")])
        text = text[:text.find("(")]
    text=text+" " 
    original = text
    m  = Method()
    words = text.split()
    for word in words:
        if (word==PrivateDefinition.replace(" ","")):
            m.Private=True
            text=text.replace(word,"")
        elif (word==PublicDefinition.replace(" ","")):
            m.Public =True
            text=text.replace(word,"")
        elif (word==ProtectedDefinition.replace(" ","")):
            m.Protected=True
            text=text.replace(word,"")
        elif (word==StaticDefinition.replace(" ","")):
            m.Static=True
            text=text.replace(word,"")
        elif (word==OverrideDefinition.replace(" ","")):
            m.Override=True
            text=text.replace(word,"")
        elif (word==AbstractDefinition.replace(" ","")):
            m.Abstract=True
            text=text.replace(word,"")
        elif (word==VirtualDefinition.replace(" ","")):
            m.Virtual=True
            text=text.replace(word,"")
        elif (word in DataTypes):
            m.ReturnType=word
            text=text.replace(word,"")
            
    if len(text.split())==2:
        m.ReturnType=text.split()[0]
        m.Name=text.split()[1]
    elif len(text.split())==1:
        m.ReturnType = ""
        m.Name=text.split()[0]
    else:
        raise ValueError("nerozpoznane paramtre v nazve metody v pocte "+str(len(text.split()))+" text: ",text)
        
    m.Parameters = Parameters
    return m
예제 #3
0
def GetAttributes(text):
    from settings import AttributeDefinition,FinalDefinition
    from settings import PrivateDefinition,PublicDefinition
    from settings import ProtectedDefinition,StaticDefinition
    text = CleanUnusedLogicalBlocks(text)
    Attributes = []
    for attributedef in AttributeDefinition:
        lines = text.split(attributedef[1])
        for line in lines:
            type = ""
            tmp_line = line.replace("\n","").replace("  "," ")
            if tmp_line.replace(" ","") =="":
                break
            for attribute in tmp_line.split(','):
                a = Attribute()
                atr = attribute
                if atr.find("=")>-1:
                    a.Value=atr[atr.find("=")+1:]
                    atr = atr[:atr.find("=")]
                for word in atr.split():
                    if (word==PrivateDefinition.replace(" ","")):
                        a.Private=True
                        atr= atr.replace(word,"")
                    elif (word==PublicDefinition.replace(" ","")):
                        a.Public =True
                        atr= atr.replace(word,"")
                    elif (word==ProtectedDefinition.replace(" ","")):
                        a.Protected=True
                        atr= atr.replace(word,"")
                    elif (word==FinalDefinition.replace(" ","")):
                        a.Final = True
                        atr=atr.replace(word,"")
                    elif (word==StaticDefinition.replace(" ","")):
                        a.Static=True
                        atr= atr.replace(word,"")
                    elif (word in DataTypes):
                        type=word
                        atr= atr.replace(word,"")
                        
                if len(atr.split())==1:
                    a.Name=atr.split()[0]
                elif len(atr.split())==2:
                    type = atr.split()[0]
                    a.Name=atr.split()[1]
                else:
                    raise ValueError("nerozpoznane paramtre v nazve atributu v pocte "+str(len(atr.split()))+" text: ",atr)
                a.Type = type
                Attributes.append(a)
        text = text.replace(line,"")
    return Attributes,text