Esempio n. 1
0
def make_plants(pif, mod_id, plants):
    columns = []
    headers = {}
    entry = {}

    for plant in plants:
        if plant['manufacture'] == 'no origin':
            flag = (
                'none',
                pif.render.find_image_path('no', art=True),
            )
        elif plant['manufacture'] == '':
            flag = ('unset', '')
        else:
            flag = pif.render.show_flag(mbdata.plant_d[plant['manufacture']])
        url = "/cgi-bin/vars.cgi?manufacture=%s&mod=%s" % (
            plant['manufacture'].replace(' ', '+')
            if plant['manufacture'] else 'unset', mod_id)
        columns.append(plant['manufacture'])
        headers[plant['manufacture']] = pif.render.format_link(
            url,
            useful.img_src(flag[1], also={'title': plant['manufacture']})
            if flag[1] else flag[0])
        entry[plant['manufacture']] = pif.render.format_link(
            url, str(plant['count']))

    llineup = {
        'id':
        'lplants',
        'name':
        '',
        'shown':
        len(plants) > 0,
        'section': [{
            'id': 'la',
            'name': '',
            'columns': columns,
            'headers': headers,
            'range': [{
                'entry': [entry]
            }],
        }],
    }
    return llineup
Esempio n. 2
0
def format_entry(pif, ent):
    dictFlag = {
        '':
        ('o', pif.render.format_image_art('wheel.gif', also={'class': 'dlm'})),
        'Reciprocal': ('Reciprocal', '<i class="fas fa-refresh dlm"></i>'),
        'PayPal': ('Accepts PayPal', '<i class="fab fa-paypal dlm"></i>'),
    }
    is_large = ent['flags'] & pif.dbh.FLAG_LINK_LINE_FORMAT_LARGE
    url = ent['url']
    tag = ent['name']
    dlms = []
    if ent['country']:
        dlms.append(ent['country'])
    cmt = ent['description']
    if ent['flags'] & pif.dbh.FLAG_LINK_LINE_RECIPROCAL:
        dlms.append('Reciprocal')
    if ent['flags'] & pif.dbh.FLAG_LINK_LINE_PAYPAL:
        dlms.append('PayPal')

    ostr = pif.render.format_link(url, tag) + ' '

    if not dlms and not cmt:
        pass
    elif not dlms:
        # add name
        if not is_large:
            ostr += format_delimiter(pif, dictFlag[''])
    else:
        also = {'class': 'dlm'}
        for dlm in dlms:
            flag = pif.render.show_flag(dlm)
            if flag:
                ostr += useful.img_src(flag[1], also={'class': 'dlm'})
            else:
                ostr += format_delimiter(pif, dictFlag[dlm])


#    if cmt and is_large:
#       ostr += '<br>' + '<br>'.join(cmt.split('|'))
#    else:
#       ostr += cmt
    return ostr, cmt.split('|')
Esempio n. 3
0
def format_entry(pif, ent):
    dictFlag = {
            '': ('o', pif.render.format_image_art('wheel.gif', also={'class': 'dlm'})),
            'Reciprocal': ('Reciprocal', '<i class="fas fa-refresh dlm"></i>'),
            'PayPal': ('Accepts PayPal', '<i class="fab fa-paypal dlm"></i>'),
    }
    is_large = ent['flags'] & config.FLAG_LINK_LINE_FORMAT_LARGE
    url = ent['url']
    tag = ent['name']
    dlms = []
    if ent['country']:
        dlms.append(ent['country'])
    cmt = ent['description']
    if ent['flags'] & config.FLAG_LINK_LINE_RECIPROCAL:
        dlms.append('Reciprocal')
    if ent['flags'] & config.FLAG_LINK_LINE_PAYPAL:
        dlms.append('PayPal')

    ostr = pif.render.format_link(url, tag) + ' '

    if not dlms and not cmt:
        pass
    elif not dlms:
        # add name
        if not is_large:
            ostr += format_delimiter(pif, dictFlag[''])
    else:
        also = {'class': 'dlm'}
        for dlm in dlms:
            flag = pif.render.show_flag(dlm)
            if flag:
                ostr += useful.img_src(flag[1], also={'class': 'dlm'})
            else:
                ostr += format_delimiter(pif, dictFlag[dlm])
#    if cmt and is_large:
#       ostr += '<br>' + '<br>'.join(cmt.split('|'))
#    else:
#       ostr += cmt
    return ostr, cmt.split('|')
Esempio n. 4
0
def make_plants(pif, mod_id, plants):
    columns = []
    headers = {}
    entry = {}

    for plant in plants:
	if plant['manufacture'] == 'no origin':
	    flag = ('none', pif.render.find_image_path('no', art=True),)
	elif plant['manufacture'] == '':
	    flag = ('unset', '')
	else:
	    flag = pif.render.show_flag(mbdata.plant_d[plant['manufacture']])
	url = "/cgi-bin/vars.cgi?manufacture=%s&mod=%s" % (plant['manufacture'] if plant['manufacture'] else 'unset', mod_id)
	columns.append(plant['manufacture'])
	headers[plant['manufacture']] = pif.render.format_link(url, useful.img_src(flag[1], also={'title': plant['manufacture']}) if flag[1] else flag[0])
	entry[plant['manufacture']] = pif.render.format_link(url, str(plant['count']))

    llineup = {'id': 'lplants', 'name': '', 'shown': len(plants) > 0,
	'section': [{'id': 'la', 'name': '', 'columns': columns, 'headers': headers,
	    'range': [{'entry': [entry]}],
	}],
    }
    return llineup
Esempio n. 5
0
def format_delimiter(pif, dlm):
    return dlm[1] + ' '
    also = {'class': 'dlm', 'alt': '[' + dlm[0] + ']'}
    pif.render.comment('format_delimiter', dlm)
    return useful.img_src(dlm[1], also=also) + ' '
Esempio n. 6
0
def format_delimiter(pif, dlm):
    return dlm[1] + ' '
    also = {'class': 'dlm', 'alt': '[' + dlm[0] + ']'}
    pif.render.comment('format_delimiter', dlm)
    return useful.img_src(dlm[1], also=also) + ' '