@@ -9,35 +9,13 @@ import argparse
9
9
import logging
10
10
import os
11
11
import sys
12
- import warnings
13
12
14
13
from codebasin import config , finder , report , util
15
14
from codebasin .walkers .platform_mapper import PlatformMapper
16
15
17
16
version = "1.2.0"
18
17
19
18
20
- def guess_project_name (config_path ):
21
- """
22
- Guess a useful name from the given path so that we can pick
23
- meaningful filenames for output.
24
- """
25
- fullpath = os .path .realpath (config_path )
26
- (thedir , thename ) = os .path .split (fullpath )
27
- if config_path == "config.yaml" :
28
- (base , end ) = os .path .split (thedir )
29
- res = end .strip ()
30
- else :
31
- (base , end ) = os .path .splitext (thename )
32
- res = base .strip ()
33
- if not res :
34
- logging .getLogger ("codebasin" ).warning (
35
- "Can't guess meaningful output name from input" ,
36
- )
37
- res = "unknown"
38
- return res
39
-
40
-
41
19
def main ():
42
20
# Read command-line arguments
43
21
parser = argparse .ArgumentParser (
@@ -56,15 +34,6 @@ def main():
56
34
version = f"Code Base Investigator { version } " ,
57
35
help = "Display version information and exit." ,
58
36
)
59
- deprecated_args = parser .add_argument_group ("deprecated options" )
60
- deprecated_args .add_argument (
61
- "-c" ,
62
- "--config" ,
63
- dest = "config_file" ,
64
- metavar = "<config-file>" ,
65
- action = "store" ,
66
- help = "Configuration YAML file. " + "Defaults to config.yaml." ,
67
- )
68
37
parser .add_argument (
69
38
"-v" ,
70
39
"--verbose" ,
@@ -114,11 +83,9 @@ def main():
114
83
+ "May be specified multiple times. "
115
84
+ "If not specified, all platforms will be included." ,
116
85
)
117
- # The analysis-file argument is optional while we support the -c option.
118
86
parser .add_argument (
119
87
"analysis_file" ,
120
88
metavar = "<analysis-file>" ,
121
- nargs = "?" ,
122
89
help = "TOML file describing the analysis to be performed, "
123
90
+ "including the codebase and platform descriptions." ,
124
91
)
@@ -140,22 +107,6 @@ def main():
140
107
# Determine the root directory based on where codebasin is run.
141
108
rootdir = os .path .realpath (os .getcwd ())
142
109
143
- if args .config_file and args .analysis_file :
144
- raise RuntimeError (
145
- "Cannot use --config (-c) with TOML analysis files." ,
146
- )
147
-
148
- # If no file is specified, legacy behavior checks for config.yaml
149
- config_file = args .config_file
150
- if args .config_file is None and args .analysis_file is None :
151
- warnings .warn (
152
- "Implicitly defined configuration files are deprecated." ,
153
- DeprecationWarning ,
154
- )
155
- config_file = os .path .join (rootdir , "config.yaml" )
156
- if not os .path .exists (config_file ):
157
- raise RuntimeError (f"Could not find config file { config_file } " )
158
-
159
110
# Set up a default codebase and configuration object.
160
111
codebase = {
161
112
"files" : [],
@@ -166,25 +117,6 @@ def main():
166
117
}
167
118
configuration = {}
168
119
169
- # Load the configuration file if it exists, obeying any platform filter.
170
- if config_file is not None :
171
- warnings .warn (
172
- "YAML configuration files are deprecated. "
173
- + "Use TOML analysis files instead." ,
174
- DeprecationWarning ,
175
- )
176
- if not util .ensure_yaml (config_file ):
177
- logging .getLogger ("codebasin" ).error (
178
- "Configuration file does not have YAML file extension." ,
179
- )
180
- sys .exit (1 )
181
- codebase , configuration = config .load (
182
- config_file ,
183
- rootdir ,
184
- exclude_patterns = args .excludes ,
185
- filtered_platforms = args .platforms ,
186
- )
187
-
188
120
# Load the analysis file if it exists.
189
121
if args .analysis_file is not None :
190
122
path = os .path .realpath (args .analysis_file )
@@ -222,12 +154,11 @@ def main():
222
154
223
155
# Parse the source tree, and determine source line associations.
224
156
# The trees and associations are housed in state.
225
- legacy_warnings = True if config_file else False
226
157
state = finder .find (
227
158
rootdir ,
228
159
codebase ,
229
160
configuration ,
230
- legacy_warnings = legacy_warnings ,
161
+ legacy_warnings = False ,
231
162
)
232
163
233
164
# Count lines for platforms
@@ -247,16 +178,10 @@ def main():
247
178
248
179
# Print clustering report
249
180
if report_enabled ("clustering" ):
250
- # Legacy behavior: guess prefix from YAML filename
251
- if config_file is not None :
252
- output_prefix = os .path .realpath (guess_project_name (config_file ))
253
-
254
- # Modern behavior: append platforms to TOML filename
255
- else :
256
- basename = os .path .basename (args .analysis_file )
257
- filename = os .path .splitext (basename )[0 ]
258
- platform_names = [p for p in codebase ["platforms" ]]
259
- output_prefix = "-" .join ([filename ] + platform_names )
181
+ basename = os .path .basename (args .analysis_file )
182
+ filename = os .path .splitext (basename )[0 ]
183
+ platform_names = [p for p in codebase ["platforms" ]]
184
+ output_prefix = "-" .join ([filename ] + platform_names )
260
185
261
186
clustering_output_name = output_prefix + "-dendrogram.png"
262
187
clustering = report .clustering (clustering_output_name , setmap )
0 commit comments