euscan: add an optional persistent cache
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
parent
7f56dd4ac4
commit
d7f655cdde
@ -20,7 +20,8 @@ CONFIG = {
|
||||
'scan-dir': True,
|
||||
'oneshot': False,
|
||||
'user-agent' : 'escan (http://euscan.iksaif.net)',
|
||||
'skip-robots-txt' : False
|
||||
'skip-robots-txt' : False,
|
||||
'cache' : False
|
||||
}
|
||||
|
||||
output = EOutput(CONFIG['quiet'])
|
||||
|
@ -267,11 +267,15 @@ def urlopen(url, timeout=None, verb="GET"):
|
||||
|
||||
request.add_header('User-Agent', CONFIG['user-agent'])
|
||||
|
||||
handlers = []
|
||||
|
||||
if CONFIG['cache']:
|
||||
from cache import CacheHandler
|
||||
handlers.append(CacheHandler(CONFIG['cache']))
|
||||
|
||||
if CONFIG['verbose']:
|
||||
debuglevel = CONFIG['verbose'] - 1
|
||||
handlers = [urllib2.HTTPHandler(debuglevel=debuglevel)]
|
||||
else:
|
||||
handlers = []
|
||||
handlers.append(urllib2.HTTPHandler(debuglevel=debuglevel))
|
||||
|
||||
opener = urllib2.build_opener(*handlers)
|
||||
|
||||
|
@ -20,6 +20,7 @@ def filter_versions(cp, versions):
|
||||
|
||||
for url, version in versions:
|
||||
|
||||
|
||||
''' Try to keep the most specific urls (determinted by the length) '''
|
||||
if version in filtered and len(url) < len(filtered[version]):
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user