Skip to content

Commit

Permalink
Merge pull request #92 from Pennycook/remove-dump-option
Browse files Browse the repository at this point in the history
Remove --dump option
  • Loading branch information
Pennycook authored Apr 4, 2024
2 parents 2a834ac + 5d87c42 commit f078b6e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 76 deletions.
24 changes: 0 additions & 24 deletions bin/codebasin
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ def main():
+ "May be specified multiple times. "
+ "If not specified, all reports will be generated.",
)
deprecated_args.add_argument(
"-d",
"--dump",
dest="dump",
metavar="<file.json>",
action="store",
help="Dump out annotated platform/parsing tree to <file.json>.",
)
parser.add_argument(
"-x",
"--exclude",
Expand Down Expand Up @@ -140,13 +132,6 @@ def main():
max(1, logging.WARNING - 10 * (args.verbose - args.quiet)),
)

# Warnings for deprecated functionality with no planned replacement.
if args.dump:
warnings.warn(
"--dump will be removed in a future release.",
DeprecationWarning,
)

# If no specific report was specified, generate all reports.
# Handled here to prevent "all" always being in the list.
if len(args.reports) == 0:
Expand Down Expand Up @@ -249,15 +234,6 @@ def main():
platform_mapper = PlatformMapper(codebase)
setmap = platform_mapper.walk(state)

if args.dump:
if util.ensure_json(args.dump):
report.annotated_dump(args.dump, state)
else:
logging.getLogger("codebasin").warning(
"Output path for annotation dump does not end with .json: "
f"'{args.dump}'. Skipping dump.",
)

def report_enabled(name):
if "all" in args.reports:
return True
Expand Down
40 changes: 0 additions & 40 deletions codebasin/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,6 @@ def add_child(self, child):
self.children.append(child)
child.parent = self

def to_json(self, assoc):
return {
"platforms": list(assoc[self]),
"children": [x.to_json(assoc) for x in self.children],
}

@staticmethod
def is_start_node():
"""
Expand Down Expand Up @@ -614,17 +608,6 @@ def __compute_file_hash(self):

return hasher.hexdigest()

def to_json(self, assoc):
parent_json = super().to_json(assoc)
mydict = {
"type": "file",
"file": self.filename,
"name": os.path.basename(self.filename),
"sloc": self.total_sloc,
}
parent_json.update(mydict)
return parent_json

def __repr__(self):
return _representation_string(self, attrs=["filename"])

Expand Down Expand Up @@ -653,23 +636,6 @@ def __init__(self, start_line=-1, end_line=-1, num_lines=0, source=None):
self.num_lines = num_lines
self.source = source

def to_json(self, assoc):
parent_json = super().to_json(assoc)
if self.source:
source = "\n".join(self.source)
else:
source = None

mydict = {
"type": "code",
"start_line": self.start_line,
"end_line": self.end_line,
"sloc": self.num_lines,
"source": source,
}
parent_json.update(mydict)
return parent_json

def __repr__(self):
return _representation_string(
self,
Expand Down Expand Up @@ -707,12 +673,6 @@ class DirectiveNode(CodeNode):
def __init__(self):
super().__init__()

def to_json(self, assoc):
parent_json = super().to_json(assoc)
mydict = {"type": "directive", "source": "\n".join(self.spelling())}
parent_json.update(mydict)
return parent_json


class UnrecognizedDirectiveNode(DirectiveNode):
"""
Expand Down
12 changes: 0 additions & 12 deletions codebasin/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import itertools as it
import json
import logging
import warnings

Expand All @@ -14,17 +13,6 @@
log = logging.getLogger("codebasin")


def annotated_dump(output_file, state):
outlist = []
for fname in state.get_filenames():
source_tree = state.get_tree(fname)
node_associations = state.get_map(fname)
outlist.append(source_tree.root.to_json(node_associations))

with open(output_file, "w") as fp:
fp.write(json.dumps(outlist, indent=2))


def extract_platforms(setmap):
"""
Extract a list of unique platforms from a set map
Expand Down

0 comments on commit f078b6e

Please sign in to comment.