示例#1
0
def dev(client, page):
    dirs = [FileTool.abspath('~/Pictures/')]
    print(is_cached('test.jpg', dirs))

    # backup to DB
    db_path = get_db_file(client)
    with SchemaImgur(db_path) as db:
        if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0:
            db.create()
        imgs = client.backup_myfavs(page)
        for img in imgs:
            img_row = db.image.select_single(where='link = ?',
                                             values=[img.link])
            if img_row:
                # update?
                print(
                    "This link is ignored because it exists in current database: %s"
                    % (img.link))
                pass
            else:
                print("Saving: %s" % (img.link))
                db.image.insert(
                    [img.title, img.description, img.datetime, img.link])
        db.ds().commit()
    pass
示例#2
0
文件: imgur.py 项目: dakside/imgurtk
def dev(client, page):
    dirs = [ FileTool.abspath('~/Pictures/') ]
    print(is_cached('test.jpg', dirs))
    
    # backup to DB
    db_path = get_db_file(client)
    with SchemaImgur(db_path) as db:
        if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0:
            db.create()
        imgs = client.backup_myfavs(page)
        for img in imgs:
            img_row = db.image.select_single(where='link = ?', values=[img.link])
            if img_row:
                # update?
                print("This link is ignored because it exists in current database: %s" % (img.link))
                pass
            else:
                print("Saving: %s" % (img.link))
                db.image.insert([img.title, img.description, img.datetime, img.link])
        db.ds().commit()
    pass
示例#3
0
    note here is that this script will be used in the other examples so
    set up a test user with API credentials and set them up in auth.ini.
'''

import os
import argparse
import sys
from igui import AuthForm
from auth import SimpleImgurClient

from chirptext.leutile import FileTool
from puchikarui import *

#------------------------------------------------------------------------------

STORE_DIR = FileTool.abspath('./dirs.txt')

#------------------------------------------------------------------------------


class SchemaImgur(Schema):
    def __init__(self, data_source=None):
        Schema.__init__(self, data_source)
        self.add_table('image', 'title description datetime link'.split())

    def create(self):
        self.ds().executescript('''
        -- DROP TABLE IF EXISTS image; 
        CREATE TABLE IF NOT EXISTS image(title, description, datetime, link PRIMARY KEY);
        ''')
示例#4
0
文件: imgur.py 项目: dakside/imgurtk
    note here is that this script will be used in the other examples so
    set up a test user with API credentials and set them up in auth.ini.
'''

import os
import argparse
import sys
from igui import AuthForm
from auth import SimpleImgurClient

from chirptext.leutile import FileTool
from puchikarui import *

#------------------------------------------------------------------------------

STORE_DIR = FileTool.abspath('./dirs.txt')

#------------------------------------------------------------------------------

class SchemaImgur(Schema):
    def __init__(self, data_source=None):
        Schema.__init__(self, data_source)
        self.add_table('image', 'title description datetime link'.split())
    
    def create(self):
        self.ds().executescript('''
        -- DROP TABLE IF EXISTS image; 
        CREATE TABLE IF NOT EXISTS image(title, description, datetime, link PRIMARY KEY);
        ''')

def is_cached(filename, dirs):