Permalink
Browse files

fix obvious borkage in encoding check tool

  • Loading branch information...
1 parent f5eb6f3 commit b30ea269aa62272cbe0c3b1c25ad199ca2069df8 @bcampbell committed Mar 27, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 jl/hacks/check-article-encoding
@@ -81,7 +81,7 @@ def iterq(conn,base_query,conds,params):
-def check_row(row,fields,pk,encoding='utf-8'):
+def check_row(table,row,fields,pk,encoding='utf-8'):
""" check fields in row are valid encoding """
errs = 0
@@ -93,11 +93,11 @@ def check_row(row,fields,pk,encoding='utf-8'):
val = u.encode( encoding )
except UnicodeDecodeError:
errs += 1
- logging.error("BAD decode: %s (%s=%s)" %(table,f,pk,row[pk]))
+ logging.error("BAD decode: %s.%s (%s=%s)" %(table,f,pk,row[pk]))
continue
except UnicodeEncodeError:
errs += 1
- logging.error("BAD encode: %s (%s=%s)" %(table,f,pk,row[pk]))
+ logging.error("BAD encode: %s.%s (%s=%s)" %(table,f,pk,row[pk]))
continue
return errs
@@ -143,7 +143,7 @@ def main():
params.append(options.todate)
for row in iterq(DB.conn(),base_query,conds,params):
- check_row(row,fields,'id')
+ check_row('article',row,fields,'id')
# article_url table
@@ -155,12 +155,12 @@ def main():
params = []
if options.fromdate or options.todate:
assert options.fromdate and options.todate
- conds.append("""article_id in (SELECT id FROM article WHERE pubdate>=%s AND pubdate>=%s)""")
+ conds.append("""article_id in (SELECT id FROM article WHERE pubdate>=%s AND pubdate<=%s)""")
params.append(options.fromdate)
params.append(options.todate)
for row in iterq(DB.conn(),base_query,conds,params):
- check_row(row,fields,'id')
+ check_row('article_url',row,fields,'id')

0 comments on commit b30ea26

Please sign in to comment.