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 | |
for root, dirs, files in os.walk("."): | |
for file in files: | |
if file.endswith(".py"): | |
my_path = os.path.join(root, file) | |
# sed does not work on truly empty file | |
os.system("sed -i '1s;^;import os\\nos.system(\"echo DEBUT \" + os.path.abspath(__file__) + \" >> /tmp/montest\")\\n;' " + my_path) | |
os.system("echo '\\nos.system(\"echo FIN \" + os.path.abspath(__file__) + \" >> /tmp/montest\")' >> " + my_path) | |
# A variant to avoid complicated escaping |
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
""" | |
Convert a Django HTTPRequest object (or dictionary of such a request) into a | |
cURL command. | |
""" | |
def get_curl(request): | |
def convert(word, delim='-'): | |
return delim.join(x.capitalize() or '_' for x in word.split('_')) | |
def get_headers(request): | |
headers = { |