From a0e5c8fba484af23f0d01e406b5a3541ce647a6c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 6 Jul 2008 15:00:06 +0200 Subject: [PATCH 1/3] move and rename some --- oxlib/__init__.py | 5 +++-- oxlib/cache.py | 2 +- oxlib/{hashes.py => file.py} | 2 +- oxlib/html.py | 2 +- oxlib/{lang.py => iso.py} | 4 ++-- oxlib/net.py | 1 + oxlib/normalize.py | 4 ++-- oxlib/text.py | 2 +- oxlib/torrent.py | 2 +- 9 files changed, 13 insertions(+), 11 deletions(-) rename oxlib/{hashes.py => file.py} (90%) rename oxlib/{lang.py => iso.py} (99%) diff --git a/oxlib/__init__.py b/oxlib/__init__.py index 240a5c1..7fb11f5 100644 --- a/oxlib/__init__.py +++ b/oxlib/__init__.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -# 2008 +# GPL 2008 -from hashes import * +from file import * from html import * from text import * from format import * import net import cache +from iso import * #only works if BitTornado is installed try: diff --git a/oxlib/cache.py b/oxlib/cache.py index 7c65505..0b7277f 100644 --- a/oxlib/cache.py +++ b/oxlib/cache.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -# 2008 +# GPL 2008 import gzip import StringIO import os diff --git a/oxlib/hashes.py b/oxlib/file.py similarity index 90% rename from oxlib/hashes.py rename to oxlib/file.py index 4d03684..940b2b7 100644 --- a/oxlib/hashes.py +++ b/oxlib/file.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -# GPL written 2008 by j@pad.ma +# GPL 2008 import sha import os diff --git a/oxlib/html.py b/oxlib/html.py index afceafb..fb36574 100644 --- a/oxlib/html.py +++ b/oxlib/html.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -# GPL written 2008 by j@pad.ma +# GPL 2008 import re import string from htmlentitydefs import name2codepoint diff --git a/oxlib/lang.py b/oxlib/iso.py similarity index 99% rename from oxlib/lang.py rename to oxlib/iso.py index 789cab3..ab6475b 100644 --- a/oxlib/lang.py +++ b/oxlib/iso.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 - +# GPL 2008 _iso639_languages = [ ("Unknown", "", "", "und"), @@ -227,7 +227,7 @@ def langCode2To3(code): def langCode3To2(code): langTo2Code(codeToLang(code)) -def englishName(lang): +def langEnglishName(lang): lang = lang.lower() for l in _iso639_languages: if l[1].lower() == lang: diff --git a/oxlib/net.py b/oxlib/net.py index f07b8d0..ebeb515 100644 --- a/oxlib/net.py +++ b/oxlib/net.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 +# GPL 2008 import gzip import StringIO import urllib diff --git a/oxlib/normalize.py b/oxlib/normalize.py index 4df4405..a990c56 100644 --- a/oxlib/normalize.py +++ b/oxlib/normalize.py @@ -1,6 +1,6 @@ -# -*- Mode: Python; -*- # -*- coding: utf-8 -*- -# vi:si:et:sw=4:sts=4:ts=4 +# vi:si:et:sw=4:sts=4:ts=4 +# GPL 2008 import re _articles = ('the', 'la', 'a', 'die', 'der', 'le', 'el', diff --git a/oxlib/text.py b/oxlib/text.py index a3c746b..7453d80 100644 --- a/oxlib/text.py +++ b/oxlib/text.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -# GPL written 2008 by j@pad.ma +# GPL 2008 import re diff --git a/oxlib/torrent.py b/oxlib/torrent.py index 6f53d5b..5b30749 100644 --- a/oxlib/torrent.py +++ b/oxlib/torrent.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -# Written 2007 by j@mailb.org +# GPL 2007 from threading import Event import sha From d6d408e1175db189b36ce0502207ca74aed6f0ed Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 6 Jul 2008 15:01:19 +0200 Subject: [PATCH 2/3] move and rename some --- oxlib/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oxlib/__init__.py b/oxlib/__init__.py index 7fb11f5..9d39994 100644 --- a/oxlib/__init__.py +++ b/oxlib/__init__.py @@ -3,12 +3,12 @@ # GPL 2008 from file import * -from html import * -from text import * from format import * -import net -import cache +from html import * from iso import * +from text import * +import cache +import net #only works if BitTornado is installed try: From 5204e27488917a8544a69f8deb49374ce2f3a1be Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 6 Jul 2008 17:21:27 +0200 Subject: [PATCH 3/3] _cache_timeout is public --- oxlib/cache.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oxlib/cache.py b/oxlib/cache.py index 0b7277f..a7095c0 100644 --- a/oxlib/cache.py +++ b/oxlib/cache.py @@ -16,9 +16,9 @@ import net from net import DEFAULT_HEADERS, getEncoding -_cache_timeout = 30*24*60*60 # default is 30 days +cache_timeout = 30*24*60*60 # default is 30 days -def status(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): +def status(url, data=None, headers=DEFAULT_HEADERS, timeout=cache_timeout): ''' >>> status('http://google.com') 200 @@ -28,7 +28,7 @@ def status(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): headers = getHeaders(url, data, headers) return int(headers['status']) -def exists(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): +def exists(url, data=None, headers=DEFAULT_HEADERS, timeout=cache_timeout): ''' >>> exists('http://google.com') True @@ -40,7 +40,7 @@ def exists(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): return True return False -def getHeaders(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): +def getHeaders(url, data=None, headers=DEFAULT_HEADERS, timeout=cache_timeout): url_cache_file = "%s.headers" % _getUrlCacheFile(url, data, headers) url_headers = _loadUrlCache(url_cache_file, timeout) if url_headers: @@ -50,7 +50,7 @@ def getHeaders(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): _saveUrlHeaders(url_cache_file, url_headers) return url_headers -def getUrl(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): +def getUrl(url, data=None, headers=DEFAULT_HEADERS, timeout=cache_timeout): url_cache_file = _getUrlCacheFile(url, data, headers) result = _loadUrlCache(url_cache_file, timeout) if not result: @@ -65,7 +65,7 @@ def getUrl(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout): _saveUrlCache(url_cache_file, result, url_headers) return result -def getUrlUnicode(url, data=None, headers=DEFAULT_HEADERS, timeout=_cache_timeout, _getUrl=getUrl): +def getUrlUnicode(url, data=None, headers=DEFAULT_HEADERS, timeout=cache_timeout, _getUrl=getUrl): data = _getUrl(url, data, headers, timeout) encoding = getEncoding(data) if not encoding: @@ -84,7 +84,7 @@ def _getUrlCacheFile(url, data=None, headers=DEFAULT_HEADERS): domain = ".".join(urlparse.urlparse(url)[1].split('.')[-2:]) return os.path.join(_getCacheBase(), domain, url_hash[:2], url_hash[2:4], url_hash[4:6], url_hash) -def _loadUrlCache(url_cache_file, timeout=_cache_timeout): +def _loadUrlCache(url_cache_file, timeout=cache_timeout): if timeout == 0: return None if os.path.exists(url_cache_file):