|
66 | 66 | with as comma-seperated list. |
67 | 67 | --check-ending-with <string> Drop lines ending with string, can be multiple strings. Specify multiple |
68 | 68 | with as comma-seperated list. |
| 69 | + --check-contains <string> Drop lines containing string, can be multiple strings. Specify multiple |
| 70 | + with as comma-seperated list. |
69 | 71 | --check-empty-line Drop lines that are empty or only contain whitespace characters |
70 | 72 | --check-regex <string> Drop lines that do not match the regex. Regex is a comma seperated list of |
71 | 73 | regexes. Example: [a-z]{1,8},[0-9]{1,8} |
|
169 | 171 | from unidecode import unidecode |
170 | 172 |
|
171 | 173 |
|
172 | | -version = '4.4.0' |
| 174 | +version = '4.5.0' |
173 | 175 |
|
174 | 176 | # Search from start to finish for the string $HEX[], with block of a-f0-9 with even number |
175 | 177 | # of hex chars. The first match group is repeated. |
@@ -615,6 +617,23 @@ def check_ending_with(line, strings): |
615 | 617 | return False |
616 | 618 |
|
617 | 619 |
|
| 620 | +def check_contains(line, strings): |
| 621 | + """Checks if a line does not contain specific strings |
| 622 | +
|
| 623 | + Params: |
| 624 | + line (unicode) |
| 625 | + strings[str] |
| 626 | +
|
| 627 | + Returns: |
| 628 | + true if line does contain any one of the strings |
| 629 | +
|
| 630 | + """ |
| 631 | + for string in strings: |
| 632 | + if string in line: |
| 633 | + return True |
| 634 | + return False |
| 635 | + |
| 636 | + |
618 | 637 | def check_empty_line(line): |
619 | 638 | """Checks if a line is empty or only contains whitespace chars |
620 | 639 |
|
@@ -1231,6 +1250,12 @@ def clean_up(lines): |
1231 | 1250 | log.append(f'Check_ending_with; dropped line because {to_check} found; {line_decoded}{linesep}') |
1232 | 1251 | stop = True |
1233 | 1252 |
|
| 1253 | + if config.get('check-contains') and not stop: |
| 1254 | + to_check = config.get("check-contains") |
| 1255 | + if check_contains(line_decoded, to_check): |
| 1256 | + log.append(f'Check-contains; dropped line because {to_check} found; {line_decoded}{linesep}') |
| 1257 | + stop = True |
| 1258 | + |
1234 | 1259 | if config.get('check-empty-line') and not stop: |
1235 | 1260 | if check_empty_line(line_decoded): |
1236 | 1261 | log_line = "Check_empty_line; dropped line because is empty or only contains whitespace;" |
@@ -1390,6 +1415,7 @@ def main(): |
1390 | 1415 | 'check-starting-with': False, |
1391 | 1416 | 'check-uuid': False, |
1392 | 1417 | 'check-ending-with': False, |
| 1418 | + 'check-contains': False, |
1393 | 1419 | 'check-empty-line': False, |
1394 | 1420 | 'check-regex': False, |
1395 | 1421 | 'check-min-digits': 0, |
@@ -1550,6 +1576,12 @@ def main(): |
1550 | 1576 | else: |
1551 | 1577 | config['check-ending-with'] = [arguments.get('--check-ending-with')] |
1552 | 1578 |
|
| 1579 | + if arguments.get('--check-contains'): |
| 1580 | + if ',' in arguments.get('--check-contains'): |
| 1581 | + config['check-contains'] = arguments.get('--check-contains').split(',') |
| 1582 | + else: |
| 1583 | + config['check-contains'] = [arguments.get('--check-contains')] |
| 1584 | + |
1553 | 1585 | if arguments.get('--check-empty-line'): |
1554 | 1586 | config['check-empty-line'] = True |
1555 | 1587 |
|
|
0 commit comments