From: Michael Orlitzky Date: Wed, 11 Nov 2009 04:35:07 +0000 (-0500) Subject: Removed rows length checks in two places, and replaced them with first-column-not... X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=73a63cfdfdc7ea6db01572d5f76f1e0e7a16e37f;p=dead%2Fcensus-tools.git Removed rows length checks in two places, and replaced them with first-column-not-None checks. Removed an unnecessary conditional from get_block_geometry_as_wkt(). --- diff --git a/src/Census.py b/src/Census.py index 63f69aa..0f8d234 100644 --- a/src/Census.py +++ b/src/Census.py @@ -46,11 +46,12 @@ class Database: cursor.execute(query, sql_params) rows = cursor.fetchall() cursor.close() - - if len(rows) > 0: + + # SQL queries that return no results get returned as [[None]]. + if rows[0][0] != None: return rows[0][0] else: - return None + return 0 def find_contained_population(self, well_known_text): @@ -112,10 +113,11 @@ class Database: rows = cursor.fetchall() cursor.close() - if (len(rows) > 0): + # SQL queries that return no results get returned as [[None]]. + if rows[0][0] != None: return rows[0][0] else: - return None + return 0 @@ -137,8 +139,7 @@ class Database: rows = cursor.fetchall() cursor.close() - if len(rows) > 0: - return rows[0][0] - else: - return None + # Just pass on the None if that's what we got from the + # database. + return rows[0][0]