Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Created October 22, 2017 10:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonflight/f8d5d6efbadf8cb341d6a44d17de3d59 to your computer and use it in GitHub Desktop.
Save pigeonflight/f8d5d6efbadf8cb341d6a44d17de3d59 to your computer and use it in GitHub Desktop.
remove query strings on static resources downloaded with wget
"""
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