| Total Complexity | 11 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | #!/usr/bin/env python |
||
| 2 | # -*- coding: utf-8 -*- |
||
| 3 | # |
||
| 4 | # doxygen_filter.py |
||
| 5 | # |
||
| 6 | # Copyright (C) 2015-2019, Takazumi Shirayanagi |
||
| 7 | # This software is released under the new BSD License, |
||
| 8 | # see LICENSE |
||
| 9 | # |
||
| 10 | |||
| 11 | import sys |
||
| 12 | import io |
||
| 13 | import os |
||
| 14 | import codecs |
||
| 15 | |||
| 16 | def filter(path, encoding): |
||
| 17 | f = codecs.open(path, 'r', encoding) |
||
| 18 | n = 0 |
||
| 19 | fname = os.path.basename(path) |
||
| 20 | if fname == "iutest_config.hpp": |
||
| 21 | n = 2 |
||
| 22 | if f: |
||
| 23 | for line in f: |
||
| 24 | sys.stdout.write(line) |
||
| 25 | if n < 2: |
||
| 26 | if line.find("//=========================================================") != -1: |
||
| 27 | n += 1 |
||
| 28 | if n == 2: |
||
| 29 | print('#include "iutest_config.hpp"') |
||
| 30 | f.close() |
||
| 31 | |||
| 32 | |||
| 33 | def main(): |
||
| 34 | path = sys.argv[1] |
||
| 35 | if not sys.stdout.encoding == 'utf-8': |
||
| 36 | try: |
||
| 37 | sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') |
||
| 38 | except AttributeError: |
||
| 39 | sys.stdout = codecs.getwriter('utf-8')(sys.stdout) |
||
| 40 | try: |
||
| 41 | filter(path, 'utf-8-sig') |
||
| 42 | except UnicodeDecodeError: |
||
| 43 | filter(path, 'utf-8') |
||
| 44 | |||
| 45 | |||
| 46 | if __name__ == '__main__': |
||
| 47 | main() |
||
| 48 |