Mercurial > hg > config
comparison python/urlhash.py @ 801:bea4dd61ae45
cleanup
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Fri, 28 Oct 2016 16:14:10 -0700 |
| parents | 3c193788a0db |
| children |
comparison
equal
deleted
inserted
replaced
| 800:8275fa887f2b | 801:bea4dd61ae45 |
|---|---|
| 6 | 6 |
| 7 import random | 7 import random |
| 8 import urllib | 8 import urllib |
| 9 | 9 |
| 10 chars = [ chr(i) for i in range(0,255) ] | 10 chars = [ chr(i) for i in range(0,255) ] |
| 11 allowed = [ urllib.quote_plus(i) for i in chars | 11 allowed = [ urllib.quote_plus(i) for i in chars |
| 12 if urllib.quote_plus(i) in chars ] | 12 if urllib.quote_plus(i) in chars ] |
| 13 | 13 |
| 14 def urlhash(len=10): | 14 def urlhash(len=10): |
| 15 chars = random.sample(allowed, len) | 15 chars = random.sample(allowed, len) |
| 16 string = ''.join(chars) | 16 string = ''.join(chars) |
