예제 #1
0
파일: cli.py 프로젝트: pombredanne/box
def checkin(url, files, message=None):
    """Check in files to a repository"""
    from box import Box
    b = Box(url)

    if b.type != 'local':
        raise BoxError('Not a box: %s' % url)

    if not files:
        raise BoxError('No files')

    def _write(path):
        log.debug('writing: %s' % path)
        item = Item.from_path(repo=b, path=path)
        v.addItem(item=item)

    v = b.addVersion()
    count = 1
    total = len(files) 
    while count <= total:
        print '[%s/%s] %0.2f%%' %(count, total, (float(count) / total) * 100), '*'*count, '\r',
        _write(os.path.abspath(files[count-1]))
        count += 1
        sys.stdout.flush()
    v.save(message=message)
    print
예제 #2
0
파일: test.py 프로젝트: pombredanne/box
#!/usr/bin/env python

from box import Box, Item

# create new box

# create new version
b = Box('/tmp/foo')
v = b.addVersion()

# add new item to version and save
i = Item.from_path(b, '/Users/rsgalloway/Desktop/snow.jpg')
v.addItems([i])
print v.items()
print v.tree
v.save('teesting add version, adding snow.jpg')
print v.tree
print b.items()
print v.versions(-1).tree

# inherit items from parents