Created
November 3, 2016 19:12
-
-
Save cas--/0ee1095c2de2e5c18b76afe69fc31d9a to your computer and use it in GitHub Desktop.
Python script to convert quotes in a `git format-patch -1 <sha1>` to apply to converted quotes branch `git am < <patch>`
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 | |
new_lines = [] | |
os.chdir('/home/ubuntu/deluge.git/') | |
patchfile = '0001-Fix-pylint-warnings.patch' | |
with open(patchfile) as file_: | |
for line in file_.readlines(): | |
line_strip = line.lstrip('-').lstrip('+').strip() | |
if '"' in line and not "'" in line and not '"""' in line and not '\\"' in line: | |
if '#' in line and '"' in line.split('#')[1]: | |
new_lines.append(line) | |
else: | |
new_lines.append(line.replace('"', "'")) | |
else: | |
new_lines.append(line) | |
with open(patchfile + '.new', 'w') as file_: | |
file_.write(''.join(new_lines)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment