Created
October 22, 2017 10:39
-
-
Save pigeonflight/f8d5d6efbadf8cb341d6a44d17de3d59 to your computer and use it in GitHub Desktop.
remove query strings on static resources downloaded with wget
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
""" | |
Often after performing a wget -p -k http://example.com | |
The resulting files will include static resources with query strings appended. | |
For example: | |
wp-content/themes/salient/css/fonts/fontawesome-webfont.woff?v=4.2 | |
etc.. | |
This script strips away the query strings so that you can serve the site statically. | |
This is the first step in porting a theme from another CMS to a Diazo based Plone theme | |
""" | |
import os | |
for root, dirs, files in os.walk("."): | |
for file in files: | |
if '?' in file: | |
newname = file.split('?')[0] | |
oldpath = root + os.sep + file | |
newpath = root + os.sep + newname | |
os.rename(oldpath,newpath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment