(path, max_length, ignoreEmptyFilesAndNewLines=False)
| 123 | return ok |
| 124 | |
| 125 | def check_raw(path, max_length, ignoreEmptyFilesAndNewLines=False): |
| 126 | ok = True |
| 127 | with open(path, 'r') as f: |
| 128 | text = f.read() |
| 129 | if not ignoreEmptyFilesAndNewLines: |
| 130 | if not text: |
| 131 | ok = error(path, "empty") |
| 132 | elif text[-1] == os.linesep: |
| 133 | text = text[:-1] |
| 134 | else: |
| 135 | ok = error(path, "missing new line") |
| 136 | else: |
| 137 | text = text.strip() |
| 138 | |
| 139 | cur_length = len(text) |
| 140 | if cur_length > max_length: |
| 141 | ok = error(path, f'too long {cur_length} (max {max_length})') |
| 142 | return ok, text |
| 143 | |
| 144 | def check_text(path, max, optional=False, ignoreEmptyFilesAndNewLines=False): |
| 145 | try: |
no test coverage detected