Commit b0a339db authored by Fabrice Allain's avatar Fabrice Allain
Browse files

Maptype checker updated -> show error msg only after 2nd line

parent a36c0e26
......@@ -275,20 +275,18 @@ class MapFile(RegexFile):
# Check first and second line of file
for index, line in enumerate(infile):
if self.filetype in self.types:
LOG.info("Given format (%s) should be supported",
self.filetype)
match = self.types[self.filetype].get("regex").match(line)
else:
match = None
LOG.error("Format %s not supported !", self.filetype)
match = None
if match:
LOG.debug("Format type correct")
LOG.info("Format type correct")
return [
self.types[self.filetype].get("regex"),
self.filetype,
self.types[self.filetype].get("score_field")
]
else:
if index > 2:
LOG.warning("Given type do not correspond, checking default"
" format for contactlist or empty file...")
for subformat in defaults:
......@@ -299,9 +297,8 @@ class MapFile(RegexFile):
self.filetype,
self.types[subformat].get("score_field")
]
if index > 2:
# Stop checking after second line
LOG.error("Error reading %s file.", self.filetype)
LOG.error("Can't read %s file.", self.filetype)
break
LOG.error("Wrong format type given ...")
return [None] * 3
......
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment