|  | @@ -1,7 +1,6 @@
 | 
	
		
			
				|  |  | -from pathlib import Path
 | 
	
		
			
				|  |  |  import re
 | 
	
		
			
				|  |  | -import plac
 | 
	
		
			
				|  |  |  from collections import defaultdict
 | 
	
		
			
				|  |  | +from pathlib import Path
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  class IqdConverter:
 | 
	
	
		
			
				|  | @@ -56,10 +55,13 @@ class IqdConverter:
 | 
	
		
			
				|  |  |          match = re.findall(r"(\"([^\"]+)\"\.)?\"([^\"]+)\"\ (T\d+)", query)
 | 
	
		
			
				|  |  |          tables = dict([(t[3], t[2]) for t in match])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        query_from_ori = re.search(r"from ([^\s].*)where", query, re.DOTALL).group(1)
 | 
	
		
			
				|  |  | -        query_from = query_from_ori.replace("(", "").replace(")", "")
 | 
	
		
			
				|  |  | +        query_split = query.split("select")[-1]
 | 
	
		
			
				|  |  | +        query_from_ori = re.search(r"from ([^\s].*)where", query_split, re.DOTALL)
 | 
	
		
			
				|  |  | +        if not query_from_ori:
 | 
	
		
			
				|  |  | +            return ""
 | 
	
		
			
				|  |  | +        query_from = query_from_ori.group(1).replace("(", "").replace(")", "")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        query_where_ori = re.search(r"where (.*)", query, re.DOTALL).group(1)
 | 
	
		
			
				|  |  | +        query_where_ori = re.search(r"where (.*)", query_split, re.DOTALL).group(1)
 | 
	
		
			
				|  |  |          query_where = re.sub(r"-- order by.*", "", query_where_ori)
 | 
	
		
			
				|  |  |          # query_where = query_where_ori.replace("(", "").replace(")", "")
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -168,8 +170,6 @@ class IqdConverter:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  if __name__ == "__main__":
 | 
	
		
			
				|  |  | -    # IqdConverter().convert('C:\\GlobalCube_LOCOSOFT\\System\\LOCOSOFT\\IQD\\Serv_Teile\\offene_Auftraege_Ums_ben_AW.iqd')
 | 
	
		
			
				|  |  |      iqdconv = IqdConverter()
 | 
	
		
			
				|  |  |      iqdconv.output_dir = "C:\\GlobalCube_LOCOSOFT\\System\\LOCOSOFT\\SQL\\schema\\LOCOSOFT\\views_imr"
 | 
	
		
			
				|  |  |      iqdconv.run_folder("C:\\GlobalCube_LOCOSOFT\\System\\LOCOSOFT\\IQD")
 | 
	
		
			
				|  |  | -    # plac.Interpreter.call(IqdConverter)
 |