Skip to content

Instantly share code, notes, and snippets.

@elyezer
Created March 23, 2017 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elyezer/f53b46c03d857857deacf923e582f8ed to your computer and use it in GitHub Desktop.
Save elyezer/f53b46c03d857857deacf923e582f8ed to your computer and use it in GitHub Desktop.
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