@@ -10,7 +10,7 @@ import logging
1010import  os 
1111import  sys 
1212
13- from  codebasin  import  config , finder , report , util 
13+ from  codebasin  import  CodeBase ,  config , finder , report , util 
1414from  codebasin .walkers .platform_mapper  import  PlatformMapper 
1515
1616version  =  "1.2.0" 
@@ -107,14 +107,7 @@ def main():
107107    # Determine the root directory based on where codebasin is run. 
108108    rootdir  =  os .path .realpath (os .getcwd ())
109109
110-     # Set up a default codebase and configuration object. 
111-     codebase  =  {
112-         "files" : [],
113-         "platforms" : [],
114-         "exclude_files" : set (),
115-         "exclude_patterns" : args .excludes ,
116-         "rootdir" : rootdir ,
117-     }
110+     # Set up a default configuration object. 
118111    configuration  =  {}
119112
120113    # Load the analysis file if it exists. 
@@ -132,8 +125,7 @@ def main():
132125
133126        if  "codebase"  in  analysis_toml :
134127            if  "exclude"  in  analysis_toml ["codebase" ]:
135-                 excludes  =  analysis_toml ["codebase" ]["exclude" ]
136-                 codebase ["exclude_patterns" ] +=  excludes 
128+                 args .excludes  +=  analysis_toml ["codebase" ]["exclude" ]
137129
138130        for  name  in  args .platforms :
139131            if  name  not  in analysis_toml ["platform" ].keys ():
@@ -142,16 +134,20 @@ def main():
142134                    +  "does not exist in the configuration file." ,
143135                )
144136
137+         cmd_platforms  =  args .platforms .copy ()
145138        for  name  in  analysis_toml ["platform" ].keys ():
146-             if  args . platforms  and  name  not  in args . platforms :
139+             if  cmd_platforms  and  name  not  in cmd_platforms :
147140                continue 
148141            if  "commands"  not  in analysis_toml ["platform" ][name ]:
149142                raise  ValueError (f"Missing 'commands' for platform { name }  )
150143            p  =  analysis_toml ["platform" ][name ]["commands" ]
151144            db  =  config .load_database (p , rootdir )
152-             codebase [ " platforms" ] .append (name )
145+             args . platforms .append (name )
153146            configuration .update ({name : db })
154147
148+     # Construct a codebase object associated with the root directory. 
149+     codebase  =  CodeBase (rootdir , exclude_patterns = args .excludes )
150+ 
155151    # Parse the source tree, and determine source line associations. 
156152    # The trees and associations are housed in state. 
157153    state  =  finder .find (
@@ -180,8 +176,7 @@ def main():
180176    if  report_enabled ("clustering" ):
181177        basename  =  os .path .basename (args .analysis_file )
182178        filename  =  os .path .splitext (basename )[0 ]
183-         platform_names  =  [p  for  p  in  codebase ["platforms" ]]
184-         output_prefix  =  "-" .join ([filename ] +  platform_names )
179+         output_prefix  =  "-" .join ([filename ] +  args .platforms )
185180
186181        clustering_output_name  =  output_prefix  +  "-dendrogram.png" 
187182        clustering  =  report .clustering (clustering_output_name , setmap )
0 commit comments