You've already forked adareducer
mirror of
https://github.com/AdaCore/adareducer.git
synced 2026-02-12 13:10:07 -08:00
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"
23 lines
608 B
Python
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
|