Created
March 23, 2017 19:03
-
-
Save elyezer/f53b46c03d857857deacf923e582f8ed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import os | |
import re | |
def edit_case_importance(): | |
for dirpath, _, filenames in os.walk('tests/foreman'): | |
for filename in filenames: | |
path = os.path.join(dirpath, filename) | |
if path.endswith('.py') and '__init__.py' not in path: | |
print(path) | |
diff = 0 | |
with open(path) as handler: | |
edited = handler.readlines() | |
diff = 0 | |
for index, line in enumerate(tuple(edited)): | |
match = re.search(r'@tier1', line) | |
if match: | |
edit_line = index + diff | |
while not edited[edit_line].endswith('"""\n'): | |
edit_line += 1 | |
edited.insert(edit_line, '\n{}:CaseLevel: Critical\n'.format( | |
edited[edit_line].replace('"""\n', ''), | |
)) | |
diff += 1 | |
with open(path, 'w') as handler: | |
handler.write(''.join(edited)) | |
if __name__ == "__main__": | |
edit_case_importance() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment