mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-04 04:38:02 +00:00 
			
		
		
		
	Realm: better value handling
This commit is contained in:
		
							
								
								
									
										49
									
								
								Realm.py
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								Realm.py
									
									
									
									
									
								
							@@ -68,25 +68,40 @@ class Realm:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      matchedList = []
 | 
					      matchedList = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for name in list:
 | 
					      prefix = ""
 | 
				
			||||||
 | 
					      for portname in list:
 | 
				
			||||||
         if (pattern.index("+") > 0):
 | 
					         if (pattern.index("+") > 0):
 | 
				
			||||||
            prefix = re.search(r"^([^+]+)[+]$", pattern)
 | 
					            try:
 | 
				
			||||||
            if prefix:
 | 
					               match = re.search(r"^([^+]+)[+]$", pattern)
 | 
				
			||||||
               print(prefix)
 | 
					               if match.group(1):
 | 
				
			||||||
               if (name.index(prefix) == 0):
 | 
					                  print("name:", portname, " Group 1: ",match.group(1))
 | 
				
			||||||
                  matchedList.append(name)
 | 
					                  prefix = match.group(1)
 | 
				
			||||||
         elif (pattern.index("*") > 0):
 | 
					                  if (portname.index(prefix) == 0):
 | 
				
			||||||
            prefix = re.search(r"^([^\*]+)[\*]$", pattern)
 | 
					                     matchedList.append(portname)
 | 
				
			||||||
            if prefix:
 | 
					            except ValueError as e:
 | 
				
			||||||
               print(prefix)
 | 
					               print(e)
 | 
				
			||||||
               if (name.index(prefix) == 0):
 | 
					 | 
				
			||||||
                  matchedList.append(name)
 | 
					 | 
				
			||||||
            if (pattern.index("[") > 0):
 | 
					 | 
				
			||||||
               match3 = re.search(r"^([^\[]+)\[(\d+)\.\.(\d+)\]$", pattern)
 | 
					 | 
				
			||||||
               if match3:
 | 
					 | 
				
			||||||
                  print(match3)
 | 
					 | 
				
			||||||
                  matchedList.append(name)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         elif (pattern.index("*") > 0):
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					               match = re.search(r"^([^\*]+)[\*]$", pattern)
 | 
				
			||||||
 | 
					               if match.group(1):
 | 
				
			||||||
 | 
					                  prefix = match.group(1)
 | 
				
			||||||
 | 
					                  print("group 1: ",prefix)
 | 
				
			||||||
 | 
					                  if (portname.index(prefix) == 0):
 | 
				
			||||||
 | 
					                     matchedList.append(portname)
 | 
				
			||||||
 | 
					            except ValueError as e:
 | 
				
			||||||
 | 
					               print(e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         elif (pattern.index("[") > 0):
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					               match = re.search(r"^([^\[]+)\[(\d+)\.\.(\d+)\]$", pattern)
 | 
				
			||||||
 | 
					               if match.group(0):
 | 
				
			||||||
 | 
					                  print("[group1]: ", match.group(1))
 | 
				
			||||||
 | 
					                  prefix = match.group(1)
 | 
				
			||||||
 | 
					                  if (portname.index(prefix)):
 | 
				
			||||||
 | 
					                     matchedList.append(portname) # wrong but better
 | 
				
			||||||
 | 
					            except ValueError as e:
 | 
				
			||||||
 | 
					               print(e)
 | 
				
			||||||
      return matchedList
 | 
					      return matchedList
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CxProfile:
 | 
					class CxProfile:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user