コード例 #1
0
ファイル: library.py プロジェクト: xchewtoyx/swtagger
 def add_tag_photoid(self, tag, photoid):
     tagentry = self.get_tag(tag)
     if tagentry[1] is None:
         photos = []
     else:
         photos = tagentry[1].split(",")
     assert id_to_thumb(photoid) not in photos
     photos.append(id_to_thumb(photoid))
     self.db.execute("UPDATE TagTable SET photo_id_list=? WHERE id=?",
                     [",".join(photos),tagentry[0]])
     self.db.commit()
コード例 #2
0
 def add_tag_photoid(self, tag, photoid):
     tagentry = self.get_tag(tag)
     if tagentry[1] is None:
         photos = []
     else:
         photos = tagentry[1].split(",")
     assert id_to_thumb(photoid) not in photos
     photos.append(id_to_thumb(photoid))
     self.db.execute("UPDATE TagTable SET photo_id_list=? WHERE id=?",
                     [",".join(photos), tagentry[0]])
     self.db.commit()
コード例 #3
0
ファイル: library.py プロジェクト: xchewtoyx/swtagger
 def add_tag(self, tag, photoids):
     c = self.db.cursor()
     c.execute("""
         INSERT INTO TagTable (name, photo_id_list) VALUES (?,?)""", 
               [tag, ",".join([id_to_thumb(photoid) 
                               for photoid in photoids])])
     self.db.commit()
     return c.lastrowid
コード例 #4
0
ファイル: library.py プロジェクト: xchewtoyx/swtagger
 def photo_hastags(self, photoid):
     """
     Check tags for specified photo
     """
     c = self.db.cursor()
     c.execute("SELECT id,name FROM TagTable WHERE name LIKE ? ",
               ["%%%s%%" % id_to_thumb(photoid)])
     return c.fetchall()
コード例 #5
0
 def add_tag(self, tag, photoids):
     c = self.db.cursor()
     c.execute(
         """
         INSERT INTO TagTable (name, photo_id_list) VALUES (?,?)""",
         [tag, ",".join([id_to_thumb(photoid) for photoid in photoids])])
     self.db.commit()
     return c.lastrowid
コード例 #6
0
 def photo_hastags(self, photoid):
     """
     Check tags for specified photo
     """
     c = self.db.cursor()
     c.execute("SELECT id,name FROM TagTable WHERE name LIKE ? ",
               ["%%%s%%" % id_to_thumb(photoid)])
     return c.fetchall()
コード例 #7
0
ファイル: library.py プロジェクト: xchewtoyx/swtagger
 def tag_hasphoto(self, tag, photoid):
     """
     Check if photo is already marked with specified tag
     """
     if not self.tag_exists(tag):
         return False
     photos = self.get_tag(tag)[1]
     if photos is None:
         return False
     return id_to_thumb(photoid) in photos.split(",")
コード例 #8
0
 def tag_hasphoto(self, tag, photoid):
     """
     Check if photo is already marked with specified tag
     """
     if not self.tag_exists(tag):
         return False
     photos = self.get_tag(tag)[1]
     if photos is None:
         return False
     return id_to_thumb(photoid) in photos.split(",")
コード例 #9
0
ファイル: library.py プロジェクト: xchewtoyx/swtagger
    def add_tag_photolist(self, tag, photoids):
        tagentry = self.get_tag(tag)
        if tagentry[1] is None:
            photos = []
        else:
            photos = tagentry[1].split(",")
        for photo in [id_to_thumb(photoid) for photoid in photoids]:
            if photo not in photos:
                photos.append(photo)

        self.db.execute("UPDATE TagTable SET photo_id_list=? WHERE id=?",
                        [",".join(photos),tagentry[0]])
        self.db.commit()
コード例 #10
0
    def add_tag_photolist(self, tag, photoids):
        tagentry = self.get_tag(tag)
        if tagentry[1] is None:
            photos = []
        else:
            photos = tagentry[1].split(",")
        for photo in [id_to_thumb(photoid) for photoid in photoids]:
            if photo not in photos:
                photos.append(photo)

        self.db.execute("UPDATE TagTable SET photo_id_list=? WHERE id=?",
                        [",".join(photos), tagentry[0]])
        self.db.commit()