Skip to content

Commit e003bc3

Browse files
authored
Merge pull request #97 from Pennycook/remove-yaml-config-files
Remove YAML configuration files
2 parents f078b6e + 1394d93 commit e003bc3

36 files changed

+742
-856
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
include codebasin/schema/analysis.schema
22
include codebasin/schema/compilation-database.schema
3-
include codebasin/schema/config.schema
43
include codebasin/schema/coverage-0.1.0.schema
54
include codebasin/schema/cbiconfig.schema

bin/codebasin

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,13 @@ import argparse
99
import logging
1010
import os
1111
import sys
12-
import warnings
1312

1413
from codebasin import config, finder, report, util
1514
from codebasin.walkers.platform_mapper import PlatformMapper
1615

1716
version = "1.2.0"
1817

1918

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-
4119
def main():
4220
# Read command-line arguments
4321
parser = argparse.ArgumentParser(
@@ -56,15 +34,6 @@ def main():
5634
version=f"Code Base Investigator {version}",
5735
help="Display version information and exit.",
5836
)
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-
)
6837
parser.add_argument(
6938
"-v",
7039
"--verbose",
@@ -114,11 +83,9 @@ def main():
11483
+ "May be specified multiple times. "
11584
+ "If not specified, all platforms will be included.",
11685
)
117-
# The analysis-file argument is optional while we support the -c option.
11886
parser.add_argument(
11987
"analysis_file",
12088
metavar="<analysis-file>",
121-
nargs="?",
12289
help="TOML file describing the analysis to be performed, "
12390
+ "including the codebase and platform descriptions.",
12491
)
@@ -140,22 +107,6 @@ def main():
140107
# Determine the root directory based on where codebasin is run.
141108
rootdir = os.path.realpath(os.getcwd())
142109

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-
159110
# Set up a default codebase and configuration object.
160111
codebase = {
161112
"files": [],
@@ -166,25 +117,6 @@ def main():
166117
}
167118
configuration = {}
168119

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-
188120
# Load the analysis file if it exists.
189121
if args.analysis_file is not None:
190122
path = os.path.realpath(args.analysis_file)
@@ -222,12 +154,11 @@ def main():
222154

223155
# Parse the source tree, and determine source line associations.
224156
# The trees and associations are housed in state.
225-
legacy_warnings = True if config_file else False
226157
state = finder.find(
227158
rootdir,
228159
codebase,
229160
configuration,
230-
legacy_warnings=legacy_warnings,
161+
legacy_warnings=False,
231162
)
232163

233164
# Count lines for platforms
@@ -247,16 +178,10 @@ def main():
247178

248179
# Print clustering report
249180
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)
260185

261186
clustering_output_name = output_prefix + "-dendrogram.png"
262187
clustering = report.clustering(clustering_output_name, setmap)

0 commit comments

Comments
 (0)