Skip to content
Permalink
Browse files

Cleanup code

  • Loading branch information...
jngrad committed Aug 12, 2019
1 parent 3fc6171 commit 7be8e6d63ac9ea5bf27cff971519c284c622da07
Showing with 10 additions and 11 deletions.
  1. +10 −11 src/config/check_myconfig.py
@@ -14,7 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sys import argv
import sys
from subprocess import CalledProcessError

@@ -49,7 +48,7 @@ def damerau_levenshtein_distance(s1, s2):
return d[lenstr1 - 1, lenstr2 - 1]


def handle_unkown(f, all_features):
def handle_unknown(f, all_features):
match = None
max_dist = max(2, len(f) // 2)
for d in all_features:
@@ -74,8 +73,8 @@ def print_exception(ex):


def check_myconfig(compiler, feature_file, myconfig, pre_header=None):
# This does not work on all compilers, so if the parsing fails
# we just bail out.
# This does not work on all compilers, so if the parsing fails
# we just bail out.
external_defs = []

if pre_header:
@@ -93,7 +92,7 @@ def check_myconfig(compiler, feature_file, myconfig, pre_header=None):
print_exception(ex)
return

# Parse feature file
# Parse feature file
defs = featuredefs.defs(feature_file)

error_state = False
@@ -107,21 +106,21 @@ def check_myconfig(compiler, feature_file, myconfig, pre_header=None):
if u.startswith('__'):
continue
error_state = True
handle_unkown(u, defs.features)
handle_unknown(u, defs.features)

if error_state:
raise FeatureError("There were errors in '{}'".format(argv[3]))
raise FeatureError("There were errors in '{}'".format(sys.argv[3]))
else:
return

if __name__ == "__main__":
if(len(argv) > 4):
pre_header = argv[4]
if len(sys.argv) > 4:
pre_header = sys.argv[4]
else:
pre_header = None

try:
check_myconfig(argv[1], argv[2], argv[3], pre_header)
check_myconfig(sys.argv[1], sys.argv[2], sys.argv[3], pre_header)
sys.exit()
except FeatureError:
sys.exit("There were errors in '{}'".format(argv[3]))
sys.exit("There were errors in '{}'".format(sys.argv[3]))

0 comments on commit 7be8e6d

Please sign in to comment.
You can’t perform that action at this time.