Advertisement
stefano_p

check_of_format

Apr 28th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. a=['questo e un testo con stile', [0, 2,"bold"], [5,8, "italics"]]      #true
  2.  
  3. b=['questo e un testo con stile', [0, 2,"bold"], [5,8, "BLAAAAAAAA"]]   #true perchè nel b[1][2] c'è il 'blond' e quindi
  4.                                                                         #tra 0 e 2 il testo è di formato blond
  5.  
  6. c=['questo e un testo con stile', [0, 2], [5,8,"italics"]]              #false
  7.  
  8. d= ['questo e un testo con stile', [0, "bold"], [5,8,"italics"]]        #false
  9.  
  10. e= [[0, 3, "bold"], [5,8,"italics"]]                                    #false
  11.  
  12.  
  13.  
  14.  
  15. def check_of_format(textList):
  16. #@ param textList : list
  17.  
  18.   if isinstance ( textList , list) == false:
  19.     showInformation("il formato non e' un testo con stile")
  20.     return false
  21.    
  22.   elif isinstance (textList[0] , str ) == false :
  23.     showInformation("il formato non e' un testo con stile")
  24.     return false
  25.    
  26.   for i in range(1 , len(textList)):
  27.       if len(textList[i]) == 3:
  28.        
  29.         check1= isinstance(textList[i][0] , int)
  30.         check2= isinstance(textList[i][1] , int)
  31.         check3= isinstance(textList[i][2] , str)
  32.       else:
  33.         showInformation("il formato non e' un testo con stile")
  34.         return false
  35.       if(check1 and check2 and check3):
  36.          
  37.          checkFormat1= 'italics' in textList[1][2]
  38.          checkFormat2= 'plain' in textList[1][2]
  39.          checkFormat3= 'bold' in textList[1][2]
  40.          checkFormat4= 'underlined' in textList[1][2]
  41.          if checkFormat1 or checkFormat2 or checkFormat3 or checkFormat4 :
  42.          
  43.            showInformation("il formato e' un testo con stile")
  44.            return true
  45.            
  46.          else :
  47.            showInformation("il formato non e' un testo con stile")
  48.            return false
  49.        else :
  50.           return false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement