Added common function for generating colour ranges, and added test for the common file

This commit is contained in:
Veronica K. B. Olsen
2019-05-12 21:32:09 +02:00
parent 1de245eea7
commit 8d8fc72cc1
3 changed files with 89 additions and 2 deletions
+12 -1
View File
@@ -3,6 +3,7 @@
"""
from os import path, mkdir
from itertools import chain
def ensureDir(theDir):
if not path.isdir(theDir):
@@ -28,7 +29,7 @@ def cmpFiles(fileOne, fileTwo, ignoreLines=[]):
if n+1 in ignoreLines:
print("Ignoring line %d" % (n+1))
continue
if lnOne != lnTwo:
print("Diff on line %d:" % (n+1))
print(" << '%s'" % lnOne)
@@ -39,3 +40,13 @@ def cmpFiles(fileOne, fileTwo, ignoreLines=[]):
foTwo.close()
return not diffFound
def cmpList(listOne, listTwo):
flatOne = list(chain.from_iterable([listOne]))
flatTwo = list(chain.from_iterable([listTwo]))
if len(flatOne) != len(flatTwo):
return False
for i in range(len(flatOne)):
if flatOne[i] != flatTwo[i]:
return False
return True