File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ import re
2+ from abc import ABC , abstractmethod
3+
4+
5+ def _strip (value : str ) -> str :
6+ return value .strip ()
7+
8+
9+ def _normalize_spaces (value : str ) -> str :
10+ return re .sub (r"\s+" , " " , value )
11+
12+
13+ def _apply_to_expected (value : str ) -> str :
14+ return value
15+
16+
17+ def _case_insensitive (value : str ) -> str :
18+ return value .lower ()
19+
20+
21+ FormatRules = {
22+ "normalize spaces" : _normalize_spaces ,
23+ "strip" : _strip ,
24+ "apply to expected" : _apply_to_expected ,
25+ "case insensitive" : _case_insensitive ,
26+ }
27+
28+
29+ class Formatter (ABC ):
30+ @abstractmethod
31+ def get_formatter (self , keyword ): ...
32+
33+ @abstractmethod
34+ def set_formatter (self , keyword , formatter ): ...
35+
36+ def normalize_keyword (self , name : str ):
37+ return name .lower ().replace (" " , "_" )
38+
39+ def formatters_to_method (self , kw_formatter : list ) -> list :
40+ return [FormatRules [formatter .lower ()] for formatter in kw_formatter ]
You can’t perform that action at this time.
0 commit comments