コード例 #1
0
ファイル: metadata.py プロジェクト: crcollins/pyOS
def move_path(src, dst):
    now = datetime.datetime.now()

    src = convert_many(src)
    dst = convert_many(dst)
    assert len(src) == len(dst)

    data = [(x, now, y) for ((x, ), (y, )) in zip(dst, src)]

    con = sqlite3.connect(METADATAFILE,  detect_types=sqlite3.PARSE_DECLTYPES)
    with con:
        cur = con.cursor()
        cur.executemany("UPDATE metadata SET path = ?, modified = ? WHERE path = ?", data)
コード例 #2
0
ファイル: metadata.py プロジェクト: crcollins/pyOS
def delete_path(path):
    path = convert_many(path)
    delsql = 'DELETE FROM metadata WHERE path = ?'

    con = sqlite3.connect(METADATAFILE,  detect_types=sqlite3.PARSE_DECLTYPES)
    with con:
        cur = con.cursor()
        cur.executemany(delsql, path)
コード例 #3
0
ファイル: userdata.py プロジェクト: crcollins/pyOS
def delete_user(user):
    user = convert_many(user)
    delsql = 'DELETE FROM userdata WHERE username = ?'

    con = sqlite3.connect(USERDATAFILE,  detect_types=sqlite3.PARSE_DECLTYPES)
    with con:
        cur = con.cursor()
        cur.executemany(delsql, user)
コード例 #4
0
ファイル: metadata.py プロジェクト: crcollins/pyOS
def copy_path(src, dst):
    now = datetime.datetime.now()

    src = convert_many(src)
    dst = convert_many(dst)
    assert len(src) == len(dst)

    selsql = 'SELECT owner,permission FROM metadata WHERE path = ?'
    addsql = 'INSERT INTO metadata VALUES (?, ?, ?, ?, ?, ?)'

    con = sqlite3.connect(METADATAFILE,  detect_types=sqlite3.PARSE_DECLTYPES)
    with con:
        cur = con.cursor()
        temp = []
        for x in src:
            cur.execute(selsql, x)
            temp.append(cur.fetchone())

        # fix for ignored files
        zipped = ((x, y) for (x, y) in zip(dst, temp) if y is not None)
        data = [(path, owner, perm, now, now, now) for ((path, ), (owner, perm)) in zipped]
        cur.executemany(addsql, data)
コード例 #5
0
ファイル: metadata.py プロジェクト: crcollins/pyOS
def add_path(path, owner, permission):
    now = datetime.datetime.now()

    validate_permission(permission)
    validate_owner(owner)

    data = convert_many(path, owner, permission, now, now, now)

    addsql = 'INSERT INTO metadata VALUES (?, ?, ?, ?, ?, ?)'

    con = sqlite3.connect(METADATAFILE,  detect_types=sqlite3.PARSE_DECLTYPES)
    with con:
        cur = con.cursor()
        cur.executemany(addsql, data)