From bb35daa95c5d56174d486ba476c24d09440f750a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 14 Aug 2012 16:12:43 +0200 Subject: [PATCH] replace all CammelCase with under_score in ox --- README | 10 ++--- ox/html.py | 14 +++---- ox/location.py | 2 +- ox/movie.py | 18 ++++----- ox/normalize.py | 42 ++++++++++----------- ox/oembed.py | 6 +-- ox/srt.py | 4 +- ox/text.py | 80 ++++++++++++++++++++-------------------- ox/web/allmovie.py | 22 +++++------ ox/web/amazon.py | 16 ++++---- ox/web/criterion.py | 26 ++++++------- ox/web/duckduckgo.py | 4 +- ox/web/epguides.py | 6 +-- ox/web/flixter.py | 2 +- ox/web/freebase.py | 4 +- ox/web/google.py | 4 +- ox/web/imdb.py | 14 +++---- ox/web/impawards.py | 22 +++++------ ox/web/itunes.py | 64 ++++++++++++++++---------------- ox/web/lyricsfly.py | 10 ++--- ox/web/metacritic.py | 6 +-- ox/web/mininova.py | 20 +++++----- ox/web/movieposterdb.py | 4 +- ox/web/opensubtitles.py | 4 +- ox/web/rottentomatoes.py | 16 ++++---- ox/web/siteparser.py | 6 +-- ox/web/spiegel.py | 6 +-- ox/web/thepiratebay.py | 24 ++++++------ ox/web/tv.py | 10 ++--- ox/web/vimeo.py | 2 +- ox/web/wikipedia.py | 18 ++++----- 31 files changed, 242 insertions(+), 244 deletions(-) diff --git a/README b/README index 3749823..c45ba3c 100644 --- a/README +++ b/README @@ -10,12 +10,12 @@ Depends: Usage: import ox - data = ox.cache.readUrl('http:/...') - text = ox.stripTags(data) - ox.normalizeNewlines(text) - ox.formatBytes(len(data)) + data = ox.cache.read_url('http:/...') + text = ox.strip_tags(data) + ox.normalize_newlines(text) + ox.format_bytes(len(data)) - ox.formatBytes(1234567890) + ox.format_bytes(1234567890) '1.15 GB' import ox.web.imdb diff --git a/ox/html.py b/ox/html.py index 6950e01..20aeb45 100644 --- a/ox/html.py +++ b/ox/html.py @@ -56,15 +56,15 @@ def strip_tags(value): stripTags = strip_tags -def stripSpacesBetweenTags(value): +def strip_spaces_between_tags(value): "Returns the given HTML with spaces between tags normalized to a single space" return re.sub(r'>\s+<', '> <', value) -def stripEntities(value): +def strip_entities(value): "Returns the given HTML with all entities (&something;) stripped" return re.sub(r'&(?:\w+|#\d);', '', value) -def fixAmpersands(value): +def fix_ampersands(value): "Returns the given HTML with all unencoded ampersands encoded correctly" return unencoded_ampersands_re.sub('&', value) @@ -113,11 +113,11 @@ def clean_html(text): * Removes stuff like "
", but only if it's at the bottom of the text. """ - from text import normalizeNewlines - text = normalizeNewlines(text) + from text import normalize_newlines + text = normalize_newlines(text) text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text) text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text) - text = fixAmpersands(text) + text = fix_ampersands(text) # Remove all target="" attributes from tags. text = link_target_attribute_re.sub('\\1', text) # Trim stupid HTML such as
(.*?)
(.*?)
SYNOPSIS: (.*?)
")) + data["synopsis"] = strip_tags(find_re(html, "SYNOPSIS: (.*?)
")) - result = findRe(html, "(.*?) \('))
+ data['year'] = find_re(html, '\((.*?)\)')
data['posters'] = []
- poster = findRe(html, '')) + 1
+ pages = int(find_re(html, '')) + 1
for page in range(pages, 0, -1):
for id in getIdsByPage(page):
if not id in ids:
@@ -81,7 +81,7 @@ def getIdsByPage(page):
def getUrl(id):
url = u"http://www.impawards.com/%s.html" % id
html = read_url(url, unicode=True)
- if findRe(html, "No Movie Posters on This Page"):
+ if find_re(html, "No Movie Posters on This Page"):
url = u"http://www.impawards.com/%s_ver1.html" % id
return url
diff --git a/ox/web/itunes.py b/ox/web/itunes.py
index 30b3094..951b121 100644
--- a/ox/web/itunes.py
+++ b/ox/web/itunes.py
@@ -4,9 +4,9 @@ import re
import urllib
from ox.cache import read_url
-from ox.html import decodeHtml, strip_tags
-from ox.text import findRe
-from ox.text import findString
+from ox.html import decode_html, strip_tags
+from ox.text import find_re
+from ox.text import find_string
# to sniff itunes traffic, use something like
@@ -65,26 +65,26 @@ def parseXmlDict(xml):
strings = xml.split(' .(.*?):(.*?) (.*?) (.*?)(.*?)
')
if '(' in r['title']:
- r['year'] = findRe(r['title'], '\((\d*?)\)')
+ r['year'] = find_re(r['title'], '\((\d*?)\)')
r['title'] = strip_tags(re.sub('\((\d*?)\)', '', r['title'])).strip()
- r['summary'] = strip_tags(findRe(data, '