Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[offline-renderer] fix some warnings detected by Flymake

This emacs extension detect python errors and warnings while editing
on ubuntu: sudo apt-get install pyflakes

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
commit 00b7f8358cbf012d95dbd6e9cd2ef066ee911a4f 1 parent fd7d211
@hxw hxw authored
View
5 host-tools/offline-renderer/ArticleIndex.py
@@ -7,7 +7,8 @@
# Christopher Hall <hsw@openmoko.com>
from __future__ import with_statement
-import os, sys, re
+import os
+import sys
import struct
from LittleParser import LittleParser
import urllib
@@ -592,6 +593,8 @@ def bigram_encode(title):
return SearchKey.compact_spaces(result)
+index_matrix = None # ensure initialised
+
def output_fnd(filename_format, article_index, language_processor, truncate_title):
"""create bigram table"""
global bigram
View
4 host-tools/offline-renderer/ArticleParser.py
@@ -7,7 +7,6 @@
# Christopher Hall <hsw@openmoko.com>
import os, sys, traceback
-import re
import subprocess
import time
import getopt
@@ -15,7 +14,6 @@
import sqlite3
import TidyUp
import PrintLog
-from types import *
verbose = False
@@ -170,7 +168,7 @@ def main():
filename = offset_cursor.fetchone()[0]
input_file = open(filename, 'rb')
if not input_file:
- PrintlogLog.message('Failed to open: {0:s}'.format(filename))
+ PrintLog.message('Failed to open: {0:s}'.format(filename))
current_file_id = None
continue
if verbose:
View
9 host-tools/offline-renderer/ArticleRenderer.py
@@ -6,7 +6,7 @@
# AUTHORS: Sean Moss-Pultz <sean@openmoko.com>
# Christopher Hall <hsw@openmoko.com>
-import sys, os, struct, os.path, re
+import sys, os, struct, re
import io
import time
import HTMLParser
@@ -405,7 +405,7 @@ def get_parameter_value(filename, parameter):
if name.strip() == parameter:
fd.close()
return value.strip()
- except Valuerror:
+ except ValueError:
pass # just ignore non-conforming lines
fd.close()
return None
@@ -504,7 +504,7 @@ def get_imgdata(imgfile, indent):
try:
img = gd.image(imgfile)
except IOError as e:
- PrintLog.message(u'unable to open image file: {0:s}'.format(imgfile))
+ PrintLog.message(u'unable to open image file: {0:s} because: {1:s}'.format(imgfile, e))
return (0, 0, r'')
(width, height) = img.size()
@@ -1310,6 +1310,8 @@ def article_index(title):
return result # this returns a tuple of text strings, so beware!
+start_time = 0 # ensure value is initialised
+
def write_article(language_links):
global compress
global verbose
@@ -1385,7 +1387,6 @@ def write_article(language_links):
except KeyError:
PrintLog.message(u'Error in: write_article, Title not found')
PrintLog.message(u'Title: {0:s}'.format(g_this_article_title))
- PrintLog.message(u'Offset: {0:s}'.format(file_offset))
PrintLog.message(u'Count: {0:s}'.format(article_count))
else:
f_out.write(whole_article)
View
6 host-tools/offline-renderer/CountSizes.py
@@ -8,7 +8,6 @@
import sys, os
import struct
import os.path
-import pylzma
import getopt
import PrintLog
import locale
@@ -17,6 +16,11 @@
locale.setlocale(locale.LC_ALL, '')
verbose = False
+sizes = None
+dist_list = None
+distribution = None
+byte_count = None
+total = 0
def usage(message):
View
1  host-tools/offline-renderer/CreatePinyinTable.py
@@ -8,7 +8,6 @@
import os
import sys
-import string
import re
import getopt
import PrintLog
View
2  host-tools/offline-renderer/EscapeBuffer.py
@@ -7,8 +7,6 @@
# AUTHORS: Sean Moss-Pultz <sean@openmoko.com>
# Christopher Hall <hsw@openmoko.com>
-import os
-import sys
import io
import struct
View
1  host-tools/offline-renderer/LanguageTranslation.py
@@ -8,7 +8,6 @@
import os
import sys
-import string
import os.path
import unicodedata
import PinyinTable
View
4 host-tools/offline-renderer/LittleParser.py
@@ -7,11 +7,9 @@
# Christopher Hall <hsw@openmoko.com>
from HTMLParser import HTMLParser
-import unicodedata
import htmlentitydefs
import re
-import codecs
-import sys
+
entities = re.compile(r'&amp;([a-zA-Z]{2,8});', re.IGNORECASE)
lessthan = re.compile(r'<')
View
1  host-tools/offline-renderer/SearchKey.py
@@ -6,7 +6,6 @@
# AUTHORS: Sean Moss-Pultz <sean@openmoko.com>
# Christopher Hall <hsw@openmoko.com>
-import os, sys
import re
import unicodedata
View
2  host-tools/offline-renderer/SegmentedFile.py
@@ -5,7 +5,7 @@
# DESCRIPTION: segmented file handling
# AUTHORS: Christopher Hall <hsw@openmoko.com>
-import sys, os
+import os
import os.path
class SegmentedFileReader(object):
View
1  host-tools/offline-renderer/WordWrap.py
@@ -7,7 +7,6 @@
# Christopher Hall <hsw@openmoko.com>
import sys
-import os
import unicodedata
import PrintLog
View
4 host-tools/offline-renderer/combine_idx.py
@@ -6,7 +6,8 @@
# AUTHORS: Sean Moss-Pultz <sean@openmoko.com>
# Christopher Hall <hsw@openmoko.com>
-import os, sys, re
+import os
+import sys
import os.path
import struct
import getopt
@@ -45,7 +46,6 @@ def main():
verbose = True
elif opt in ('-h', '--help'):
usage(None)
- off_name = arg
elif opt in ('-p', '--prefix'):
in_format = arg + '{0:d}.idx-tmp'
elif opt in ('-o', '--output'):
Please sign in to comment.
Something went wrong with that request. Please try again.