# Path: canary/dtuple.py
# class TupleDescriptor:
# class DatabaseTuple:
#   def __init__(self, desc):
#   def __len__(self):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, desc, data):
#   def __str__(self):
#   def __repr__(self):
#   def __cmp__(self, other):
#   def __getattr__(self, name):
#   def __setattr__(self, name, value):
#   def __getitem__(self, key):
#   def __setitem__(self, key, value):
#   def __len__(self):
#   def __getslice__(self, i, j):
#   def __setslice__(self, i, j, list):
#   def _keys_(self):
#   def _has_key_(self, key):
#   def _items_(self):
#   def _count_(self, item):
#   def _index_(self, item):
#   def _getvalue_(self,name):
#   def asMapping(self):
#   def asTuple(self):
#   def asList(self):


from cStringIO import StringIO
from elementtree.ElementTree import Element, SubElement
from unidecode import unidecode
from canary import dtuple
    from string import capwords
import Image, ImageDraw
import os
import re
import time
import traceback
import urllib
import elementtree.ElementTree as etree
import feedparser
    import smtplib
            setattr(self, str(field), value)
       
    #def append (self, field, value):
    #    list_attr = getattr(self, str(field))
    #    if not value in list_attr:
    #        list_attr.append(value)
    
       
    def get_new_uid (self, context):
        cursor = context.get_cursor()
        try:
            cursor.execute('SELECT LAST_INSERT_ID() AS new_uid')
            row = cursor.fetchone()
            new_uid = int(row[0])
        except:
            new_uid = -1
        return new_uid
    

    def load (self, context):
        cursor = context.get_cursor()
        if self.uid:
            cursor.execute("""SELECT * FROM """ + self.TABLE_NAME +
                """
                WHERE uid LIKE %s
                """, (self.uid))
            fields = [d[0] for d in cursor.description]
            desc = dtuple.TupleDescriptor([[f] for f in fields])
            row = cursor.fetchone()
            if row:

# Path: canary/dtuple.py
# class TupleDescriptor:
# class DatabaseTuple:
#   def __init__(self, desc):
#   def __len__(self):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, desc, data):
#   def __str__(self):
#   def __repr__(self):
#   def __cmp__(self, other):
#   def __getattr__(self, name):
#   def __setattr__(self, name, value):
#   def __getitem__(self, key):
#   def __setitem__(self, key, value):
#   def __len__(self):
#   def __getslice__(self, i, j):
#   def __setslice__(self, i, j, list):
#   def _keys_(self):
#   def _has_key_(self, key):
#   def _items_(self):
#   def _count_(self, item):
#   def _index_(self, item):
#   def _getvalue_(self,name):
#   def asMapping(self):
#   def asTuple(self):
#   def asList(self):


# Path: canary/utils.py
from cStringIO import StringIO
from elementtree.ElementTree import Element, SubElement
from unidecode import unidecode
from canary import dtuple
    from string import capwords
import Image, ImageDraw
import os
import re
import time
import traceback
import urllib
import elementtree.ElementTree as etree
import feedparser
    import smtplib

            setattr(self, str(field), value)
       
    #def append (self, field, value):
    #    list_attr = getattr(self, str(field))
    #    if not value in list_attr:
    #        list_attr.append(value)
    
       
    def get_new_uid (self, context):
        cursor = context.get_cursor()
        try:
            cursor.execute('SELECT LAST_INSERT_ID() AS new_uid')
            row = cursor.fetchone()
            new_uid = int(row[0])
        except:
            new_uid = -1
        return new_uid
    

    def load (self, context):
        cursor = context.get_cursor()
        if self.uid:
            cursor.execute("""SELECT * FROM """ + self.TABLE_NAME +
                """
                WHERE uid LIKE %s
                """, (self.uid))
            fields = [d[0] for d in cursor.description]
            desc = dtuple.TupleDescriptor([[f] for f in fields])
            row = cursor.fetchone()
            if row:

                row = dtuple.DatabaseTuple(desc, row)