Exemplo n.º 1
0
def mack_models(pif, start, end, series):
    mseries = 'MB' if 'RW' not in series else None if 'SF' in series else ''
    amods = {mbdata.get_mack_number(rec['alias.id']): rec for rec in pif.dbh.fetch_aliases(type_id='mack')}
    mmods = {mbdata.get_mack_number(rec['base_id.id']): rec for rec in
	pif.dbh.fetch_casting_list('sf') + pif.dbh.fetch_casting_list('rw')}
    amods.update(mmods)
    return mod_to_mack(pif, amods, start, end, mseries)
Exemplo n.º 2
0
def get_mack_numbers(pif, mod_id):
    def fmt_mack_id(m):
        ostr = ''
        if m[0]:
            ostr += '%s-' % m[0]
        if m[2]:
            ostr += '%03d-%s' % m[1:]
        else:
            ostr += '%03d' % m[1]
        return ostr

    ret = []
    mack = mbdata.get_mack_number(mod_id)
    if mod_id.startswith('RW') or mod_id in ('MI740', 'MI816',
                                             'MI861') or (mack and mack[0]
                                                          and mack[2]):
        ret.append(fmt_mack_id(mack))
    aliases = sorted(pif.dbh.fetch_aliases(mod_id),
                     key=lambda x: (-x['alias.flags'], x['alias.ref_id']))
    ret += [
        fmt_mack_id(mbdata.get_mack_number(x['alias.id'])) for x in aliases
    ]
    if not mack or not mack[2]:
        ret.append(mod_id)
    return ret
Exemplo n.º 3
0
def mack_models(pif, start, end, series):
    mseries = 'MB' if 'RW' not in series else None if 'SF' in series else ''
    amods = [(mbdata.get_mack_number(rec['alias.id']), rec,) for rec in pif.dbh.fetch_aliases(type_id='mack')]
    mmods = [(mbdata.get_mack_number(rec['base_id.id']), rec,) for rec in
	pif.dbh.fetch_casting_list('sf') + pif.dbh.fetch_casting_list('rw')]
    amods = sorted([x for x in mmods + amods
		    if x and x[0] and int(x[0][1]) >= start and int(x[0][1]) <= end and
		       not (mseries is not None and mseries != x[0][0])],
		   key=lambda x: (x[0][1], x[0][0], x[0][2]))
    return amods
Exemplo n.º 4
0
def mack_models(pif, start, end, series):
    mseries = 'MB' if 'RW' not in series else None if 'SF' in series else ''
    amods = [(
        mbdata.get_mack_number(rec['alias.id']),
        rec,
    ) for rec in pif.dbh.fetch_aliases(type_id='mack')]
    mmods = [(
        mbdata.get_mack_number(rec['base_id.id']),
        rec,
    ) for rec in pif.dbh.fetch_casting_list('sf') +
             pif.dbh.fetch_casting_list('rw')]
    amods = sorted([
        x for x in mmods + amods
        if (x and x[0] and int(x[0][1]) >= start and int(x[0][1]) <= end
            and not (mseries is not None and mseries != x[0][0]))
    ],
                   key=lambda x: (x[0][1], x[0][0], x[0][2]))
    return amods
Exemplo n.º 5
0
def get_mack_numbers(pif, cid, mod_type, aliases):  # called from elsewhere
    mack_nums = []
    if mod_type == cid[0:2] and mod_type in ('RW', 'SF'):
        aliases.append(cid)
    for alias in aliases:
        mack_id = mbdata.get_mack_number(alias)
        if mack_id:
            mack_nums.append(mack_id)
    mack_nums.sort(key=lambda x: x[1])
    return ['-'.join([str(y) for y in x]).upper() for x in mack_nums]
Exemplo n.º 6
0
def get_mack_numbers(pif, cid, mod_type, aliases):  # called from elsewhere
    aliases = [(x['alias.flags'], x['alias.id']) for x in aliases if x['alias.type'] == 'mack']
    if mod_type == cid[0:2] and mod_type in ('RW', 'SF'):
        aliases.append((config.FLAG_ALIAS_PRIMARY, cid,))
    mack_nums = []
    for alias in aliases:
	mack_id = mbdata.get_mack_number(alias[1])
	if mack_id:
	    mack_nums.append(((alias[0] & config.FLAG_ALIAS_PRIMARY) != 0,) + mack_id)
    mack_nums.sort(key=lambda x: x[2])
    # if aliases.flags == 2, put it first or bold it or something
    return [('<b>' if x[0] else '') +
	    '-'.join([str(y) for y in x[1:]]).upper() +
	    ('</b>' if x[0] else '')
	for x in mack_nums]
Exemplo n.º 7
0
def get_mack_numbers(pif, cid, mod_type, aliases):  # called from elsewhere
    aliases = [(x['alias.flags'], x['alias.id']) for x in aliases
               if x['alias.type'] == 'mack']
    if mod_type == cid[0:2] and mod_type in ('RW', 'SF'):
        aliases.append((
            config.FLAG_ALIAS_PRIMARY,
            cid,
        ))
    mack_nums = []
    for alias in aliases:
        mack_id = mbdata.get_mack_number(alias[1])
        if mack_id:
            mack_nums.append(((alias[0] & config.FLAG_ALIAS_PRIMARY) != 0, ) +
                             mack_id)
    mack_nums.sort(key=lambda x: x[2])
    # if aliases.flags == 2, put it first or bold it or something
    return [('<b>' if x[0] else '') + '-'.join([str(y)
                                                for y in x[1:]]).upper() +
            ('</b>' if x[0] else '') for x in mack_nums]