-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53f6fb8
commit 1d282b3
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import List | ||
|
||
from norma2.checkers.haskell.header import check_header | ||
from norma2.errors.norm import _TemplateNormError | ||
from norma2.parser.hsfile import HSFile | ||
|
||
checkerss = [ | ||
check_header, | ||
] | ||
|
||
|
||
def check(file: HSFile) -> List[_TemplateNormError]: | ||
errs: List[_TemplateNormError] = [] | ||
for checker in checkerss: | ||
errs.extend(checker(file)) | ||
return errs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import List | ||
|
||
from norma2.errors.norm import FileHeader, _TemplateNormError | ||
from norma2.parser.hsfile import HSFile | ||
|
||
|
||
def check_header(file: HSFile) -> List[_TemplateNormError]: | ||
lines = file.lines_origin[:] | ||
if len(lines) < 6: | ||
return [FileHeader(file.filepath, 0, "No header..")] | ||
if lines[0] != "{-": | ||
return [FileHeader(file.filepath, 1, "No header..")] | ||
if not lines[1].startswith("-- EPITECH PROJECT, "): | ||
return [ | ||
FileHeader(file.filepath, 2, "line must starts with `** EPITECH PROJECT, `") | ||
] | ||
if len(lines[2]) < 4 or not lines[2].startswith("-- "): | ||
return [FileHeader(file.filepath, 3, "line must starts with `** `")] | ||
if lines[3] != "-- File description:": | ||
return [FileHeader(file.filepath, 4, "line must be `** File description:`")] | ||
i = 4 | ||
while i < len(lines) and lines[i] != "-}": | ||
if len(lines[i]) < 4 or not lines[i].startswith("-- "): | ||
return [FileHeader(file.filepath, i + 1, "line must starts with `** `")] | ||
i += 1 | ||
if i >= len(lines): | ||
return [FileHeader(file.filepath, i + 1, "File with only header ?")] | ||
if lines[i] != "-}": | ||
return [FileHeader(file.filepath, i + 1, "line must be `*/`")] | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import List | ||
|
||
from norma2.config.config_class import Config | ||
from norma2.parser._file import _File | ||
from norma2.errors.norm import _TemplateNormError | ||
|
||
class HSFile(_File): | ||
def __init__(self, filepath: str, config: Config) -> None: | ||
super().__init__(filepath, config) | ||
|
||
def init(self): | ||
if not self.text_origin: | ||
return | ||
self.lines_origin = self.text_origin.split("\n") | ||
self.is_init = True | ||
|
||
def check_norm(self) -> List[_TemplateNormError]: | ||
return [] |