You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							35 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							35 lines
						
					
					
						
							1.2 KiB
						
					
					
				| #!/usr/bin/env python2
 | |
| import os
 | |
| import re
 | |
| 
 | |
| cur_path = os.path.dirname(os.path.realpath(__file__))
 | |
| generator_path = os.path.join(cur_path, '../')
 | |
| 
 | |
| for dir_name, _, _ in os.walk(cur_path):
 | |
|     if dir_name == cur_path:
 | |
|         continue
 | |
| 
 | |
|     print dir_name
 | |
| 
 | |
|     for filename in os.listdir(dir_name):
 | |
|         if filename.startswith('_'):
 | |
|             continue
 | |
| 
 | |
|         print filename
 | |
|         dbc_file = open(os.path.join(dir_name, filename)).read()
 | |
|         include = re.search(r'CM_ "IMPORT (.*?)"', dbc_file)
 | |
|         if include is not None:
 | |
|             dbc_file = dbc_file.replace(include.group(0), '\nCM_ "%s starts here"' % filename)
 | |
|             include_path = os.path.join(dir_name, include.group(1))
 | |
| 
 | |
|             # Load included file
 | |
|             include_file = open(include_path).read()
 | |
|             include_file = 'CM_ "Imported file %s starts here"\n' % include.group(1) + include_file
 | |
|             dbc_file = include_file + dbc_file
 | |
| 
 | |
|         dbc_file = 'CM_ "AUTOGENERATED FILE, DO NOT EDIT"\n' + dbc_file
 | |
| 
 | |
|         output_filename = filename.replace('.dbc', '_generated.dbc')
 | |
|         output_dbc_file = open(os.path.join(generator_path, output_filename), 'w')
 | |
|         output_dbc_file.write(dbc_file)
 | |
|         output_dbc_file.close()
 | |
| 
 |