Update of /cvsroot/freevo/freevo/lib/pyepg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv544/lib/pyepg
Modified Files:
guide.py
Log Message:
-Add some timer debugging, which will be removed at some later point. I need
this to see where speed improvements can be made.
-Link sql_checkTable method to one in the specific database implimentation.
This could also be totally removed from here.
-Fix some minor grammar errors.
-Add an exact_match (boolean) argument to the search method. Using this avoids
the LIKE clause which will always does a full table scan (takes longer).
Index: guide.py
===================================================================
RCS file: /cvsroot/freevo/freevo/lib/pyepg/guide.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** guide.py 14 Feb 2005 15:12:55 -0000 1.24
--- guide.py 24 Mar 2005 17:58:55 -0000 1.25
***************
*** 51,54 ****
--- 51,64 ----
log = logging.getLogger('pyepg')
+ _timer = 0.00
+
+ def timer_set():
+ global _timer
+ _timer = time.time()
+
+ def timer_report(msg):
+ global _timer
+ log.debug('TIMER: %s took %f' % (msg, time.time()-_timer))
+
class Guide:
***************
*** 123,128 ****
def sql_execute(self, query, close=False):
query = self.__escape_query(query)
! try:
result = self.db.execute(query)
except TypeError:
--- 133,140 ----
def sql_execute(self, query, close=False):
query = self.__escape_query(query)
+ log.debug('QUERY: %s' % query)
+ timer_set()
! try:
result = self.db.execute(query)
except TypeError:
***************
*** 134,139 ****
--- 146,153 ----
self.db.commit()
self.db.close()
+ timer_report('query')
return result
else:
+ timer_report('query')
return result
***************
*** 143,154 ****
! def sql_checkTable(self,table=None):
if not table:
return False
! # verify the table exists
! if not self.db.execute('select name from sqlite_master where ' + \
! 'name="%s" and type="table"' % table):
! return None
! return table
--- 157,164 ----
! def sql_checkTable(self, table=None):
if not table:
return False
! self.db.check_table(table)
***************
*** 275,289 ****
#
if len(title) > 255:
! log.error('title to long %s' % title)
title = title[:255]
if len(subtitle) > 255:
subtitle = subtitle[:255]
! log.error('subtitle to long %s' % subtitle)
if len(episode) > 255:
episode = episode[:255]
! log.error('episode to long %s' % episode)
if len(description) > 4095:
episode = episode[:4095]
! log.error('description to long %s' % description)
query = 'insert into programs (channel_id, title, start, stop, \
--- 285,299 ----
#
if len(title) > 255:
! log.error('title too long %s' % title)
title = title[:255]
if len(subtitle) > 255:
subtitle = subtitle[:255]
! log.error('subtitle too long %s' % subtitle)
if len(episode) > 255:
episode = episode[:255]
! log.error('episode too long %s' % episode)
if len(description) > 4095:
episode = episode[:4095]
! log.error('description too long %s' % description)
query = 'insert into programs (channel_id, title, start, stop, \
***************
*** 488,492 ****
def search(self, searchstr, by_chan=None, search_title=True,
! search_subtitle=True, search_description=True):
"""
Return a list of programs with a title similar to the given parameter.
--- 498,503 ----
def search(self, searchstr, by_chan=None, search_title=True,
! search_subtitle=True, search_description=True,
! exact_match=False):
"""
Return a list of programs with a title similar to the given parameter.
***************
*** 507,519 ****
if search_title:
! clause = '%s title like "%%%s%%"' % (clause, searchstr)
if search_subtitle:
if search_title: clause += ' or'
! clause = '%s subtitle like "%%%s%%"' % (clause, searchstr)
if search_description:
if search_title or se: clause += ' or'
! clause = '%s description like "%%%s%%"' % (clause, searchstr)
clause += ' )'
--- 518,539 ----
if search_title:
! if exact_match:
! clause = '%s title="%s"' % (clause, searchstr)
! else:
! clause = '%s title like "%%%s%%"' % (clause, searchstr)
if search_subtitle:
if search_title: clause += ' or'
! if exact_match:
! clause = '%s subtitle="%s"' % (clause, searchstr)
! else:
! clause = '%s subtitle like "%%%s%%"' % (clause, searchstr)
if search_description:
if search_title or se: clause += ' or'
! if exact_match:
! clause = '%s description="%s"' % (clause, searchstr)
! else:
! clause = '%s description like "%%%s%%"' % (clause, searchstr)
clause += ' )'
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog