Skip to content

Instantly share code, notes, and snippets.

@jonjensen
Created May 12, 2015 16:09
Show Gist options
  • Select an option

  • Save jonjensen/402c9a3b1803dcf764bc to your computer and use it in GitHub Desktop.

Select an option

Save jonjensen/402c9a3b1803dcf764bc to your computer and use it in GitHub Desktop.

Revisions

  1. jonjensen created this gist May 12, 2015.
    19 changes: 19 additions & 0 deletions decode-GECommonSettings
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/env python2

    import fileinput
    import re
    import urllib

    def decode_ucs(matchobj):
    c = matchobj.group(0)[2:]
    i = int(c, 16)
    return unichr(i)

    for line in fileinput.input():
    url = re.sub('_', '/', line)
    url = re.sub(r'\\', '', url)
    url = urllib.unquote(url).decode('utf8')
    url = re.sub('%U[A-F0-9]{4}', decode_ucs, url)

    description = re.sub('^http://kh.google.com:80/', '', url)
    print(line + description)