Exemple #1
0
def upload(args):
    """
    Uploads documents.
    """
    print 'Uploading documents...'
    keymap = get_keymap()
    keyfields = get_keyfields()
    for root, dirs, files in walk(getcwd()):
        if 'env' in dirs:
            dirs.remove('env') # don't walk into environment
        
        for name in files:
            if name.endswith('.md'):
                path = os.path.join(root,name)
                if is_modified(path):
                    print 'Uploading',name
                    key = find_key(path,keymap,keyfields)
                    key, created = upload_document(path,key=key)
                    write_hash(path)
                    if created:
                        print 'Created new content item',key
                        keymap[path] = key
                        keyfield = extract_keyfield(path)
                        print 'assigning key',key,'to keyfields',keyfields,'under keyfield',keyfield
                        keyfields[keyfield] = key
                else:
                    print name, 'not modified. Skipping.'
    
    write_keyfields(keyfields)
    write_keymap(keymap)
Exemple #2
0
def upload(args):
    """
    Uploads documents.
    """
    print('Uploading documents...')
    keymap = get_keymap()
    keyfields = get_keyfields()
    for root, dirs, files in walk(getcwd()):
        if 'env' in dirs:
            dirs.remove('env')  # don't walk into environment

        for name in files:
            if name.endswith('.md'):
                path = os.path.join(root, name)
                if is_modified(path):
                    print('Uploading', name)
                    key = find_key(path, keymap, keyfields)
                    key, created = upload_document(path, key=key)
                    write_hash(path)
                    if created:
                        print('Created new content item', key)
                        keymap[path] = key
                        keyfield = extract_keyfield(path)
                        print('assigning key', key, 'to keyfields', keyfields,
                              'under keyfield', keyfield)
                        keyfields[keyfield] = key
                else:
                    print(name, 'not modified. Skipping.')

    write_keyfields(keyfields)
    write_keymap(keymap)
Exemple #3
0
def keyfields(args):
    """
    Synchronizes the local cache of keyfield / key data.
    """
    print 'Synchronizing keyfield cache.'
    cfg = get_cfg()
    keyfield_name = cfg.get('Connection','key_field')
    keyfield_data = {}
    keys = get_content_keys()
    for key in keys:
        content_item = get_content_item(key)
        keyfield_data[content_item['data'][keyfield_name]] = key
        print 'Mapping',content_item['data'][keyfield_name],'to',key
    write_keyfields(keyfield_data)
    print 'Keyfield cache synchronized.'
Exemple #4
0
def keyfields(args):
    """
    Synchronizes the local cache of keyfield / key data.
    """
    print('Synchronizing keyfield cache.')
    cfg = get_cfg()
    keyfield_name = cfg.get('Connection', 'key_field')
    keyfield_data = {}
    keys = get_content_keys()
    for key in keys:
        content_item = get_content_item(key)
        keyfield_data[content_item['data'][keyfield_name]] = key
        print('Mapping', content_item['data'][keyfield_name], 'to', key)
    write_keyfields(keyfield_data)
    print('Keyfield cache synchronized.')