Files
adareducer/ada_reducer/delete_empty_units.py
Nicolas Setton ec89ff0cc7 Add an "adareducer" script at the toplevel
For the benefit of the development environment, or any
users who only "git clone" this repository and work from it.

Fix the testsuite using this.

Rename the "adareducer" source dir to "ada_reducer"
2022-02-02 16:18:41 +00:00

23 lines
608 B
Python

import os
from ada_reducer.types import Buffer
from ada_reducer.interfaces import StrategyInterface
class DeleteEmptyUnits(StrategyInterface):
""" Remove blank lines and standalone comments """
def run_on_file(self, context, file, predicate):
buf = Buffer(file)
# for now don't even use LAL, just delete files that look small
if len(buf.lines) <= 5:
os.remove(file)
if predicate():
return True
else:
# if the predicate failed, put back the original file
buf.save()
return False