![]() execute ( "drop index if exists idx_path" ) 80 self. execute ( "drop table if exists pictures" ) 79 self. debug ( "Creating picture cache tables." ) 78 self. warning ( "DatabaseError while setting value for key %r : %s ", path_str, str (e )) 74 75 def _create_con (self, second_try = False ): 76 def create_tables (): 77 logging. warning ( "Picture cache could not set value for key %r ", path_str ) 72 except sqlite. stat (path_str ).st_mtime ) 62 else : 63 mtime = 0 64 if path_str in self : 65 sql = "update pictures set blocks = ?, mtime = ? where path = ?" 66 else : 67 sql = "insert into pictures(blocks,mtime,path) values(?,?,?)" 68 try : 69 self. fetchall () 56 return result 57 58 def _setitem_ (self, path_str, blocks ): 59 blocks = colors_to_string (blocks ) 60 if op. execute (sql ) 51 return (row for row in result ) 52 53 def _len_ (self ): 54 sql = "select count(*) from pictures" 55 result = self. fetchone () 42 if result : 43 result = string_to_colors (result ) 44 return result 45 else : 46 raise KeyError (key ) 47 48 def _iter_ (self ): 49 sql = "select path from pictures" 50 result = self. execute (sql, ) 34 35 # Optimized 36 def _getitem_ (self, key ): 37 if isinstance (key, int ): 38 sql = "select blocks from pictures where rowid = ?" 39 else : 40 sql = "select blocks from pictures where path = ?" 41 result = self. fetchall () 27 return result > 0 28 29 def _delitem_ (self, key ): 30 if key not in self : 31 raise KeyError (key ) 32 sql = "delete from pictures where path = ?" 33 self. ![]() _create _con () 23 24 def _contains_ (self, key ): 25 sql = "select count(*) from pictures where path = ?" 26 result = self. cache import string_to_colors, colors_to_string 13 14 15 class SqliteCache : 16 """A class to cache picture blocks in a sqlite backend.""" 17 18 def _init_ (self, db = ":memory:", readonly = False ): 19 # readonly is not used in the sqlite version of the cache 20 self. path as op 9 import logging 10 import sqlite3 as sqlite 11 12 from core. The terms are also available at 5 # 6 7 import os 8 import os. As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers.Īlternatively you can here view or download the uninterpreted source code file.įor more information about "cache_sqlite.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 4.2.1_vs_4.3.0.ġ # Copyright 2016 Virgil Dupras 2 # 3 # This software is licensed under the "GPLv3" License as described in the "LICENSE" file, 4 # which should be included with this package.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |