دليل استخدام بندورة - المورد الثقافي/ملحقة عميل بندورة لمؤسسة المورد

من ويكي أضِف
اذهب إلى: تصفح، ابحث
'''
    mawred.py - pandora_client plugin

    custom parse_path for pandora_client to parse mawred archive paths in the form

    YYYY/Event/Day/MVI_2036.MOV

'''
import re
import ox

def example_path(client):
    return '\t' + 'YYYY/Event/Day/MVI_2036.MOV'

def parse_path(client, path):
    '''
        args:
            client - Client instance
            path   - path without volume prefix 
        return:
            return None if file is ignored, dict with parsed item information otherwise
    '''
    m = re.compile('^(?P<year>\d{4})/(?P<event>.+?)/(?P<day>.+?)/.*').match(path)
    if not m:
        return None
    info = m.groupdict()
    date = '%s' % (info['year'])
    for key in info:
        if info[key]:
            info[key] = info[key].replace('_', ' ')

    event = [info['event']]
    title = "%s, %s %s" % ( info['event'],info['day'],info['year'])

    r = {
        'year': date,
        'title': title,
        'topic': event
    }
    _info = ox.movie.parse_path(path)
    for key in ('extension', 'type'):
        r[key] = _info[key]
    return r