コード例 #1
0
def _register_evos(cards):
    """Register `mon.evos`.
    """
    buckets = bucketize(values(cards), aget('preevo'), ignores={0})
    for mon_id, evos in items(buckets):
        mon = cards[mon_id]
        mon.evos = evos
コード例 #2
0
def _register_families(cards):
    """Register `mon.family`.
    """
    buckets = bucketize(values(cards), aget('base'))
    for base_id, members in items(buckets):
        # fam = CardFamily(base_id, members)
        # for member in fam:
        # member.family = fam
        for member in members:
            member.family = members
コード例 #3
0
def loadjson(j):
    """Load from JSON dict.
    """
    raws = j[jsonkey]
    v = j.get('v', 1)
    if v in {1, 1220}:  # Original version or array version.
        skills = Index((i, Skill(i, raw)) for i, raw in items(raws))
    else:
        # raise ValueError("%r has unknown skills version %s." % (fpath, v))
        raise ValueError("Skill data has unknown skills version %s." % (v,))
    return skills
コード例 #4
0
ファイル: cli.py プロジェクト: harababurel/google-apis-rs
def to_cli_schema(c, schema):
    res = deepcopy(schema)
    fd = dict()
    res['fields'] = fd

    # util.nested_type_name
    properties = schema.get('properties', dict())
    if not properties and 'variant' in schema and 'map' in schema.variant:
        for e in schema.variant.map:
            assert util.TREF in e
            properties[e.type_value] = e
    # end handle enumerations

    for pn, p in util.items(properties):

        def set_nested_schema(ns):
            if ns.fields:
                fd[pn] = ns

        # end utility

        def dup_property():
            pc = deepcopy(p)
            if 'type' in pc and pc.type == 'string' and 'Count' in pn:
                pc.type = 'int64'
            return pc

        # end

        if util.TREF in p:
            if p[util.
                 TREF] != schema.id:  # prevent recursion (in case of self-referential schemas)
                set_nested_schema(to_cli_schema(c, c.schemas[p[util.TREF]]))
        elif p.type == 'array' and 'items' in p and 'type' in p.get(
                'items') and p.get('items').type in POD_TYPES:
            pc = dup_property()
            fd[pn] = SchemaEntry(CTYPE_ARRAY, pc.get('items'), pc)
        elif p.type == 'object':
            if util.is_map_prop(p):
                if 'type' in p.additionalProperties and p.additionalProperties.type in POD_TYPES:
                    pc = dup_property()
                    fd[pn] = SchemaEntry(CTYPE_MAP, pc.additionalProperties,
                                         pc)
            else:
                set_nested_schema(
                    to_cli_schema(
                        c, c.schemas[util.nested_type_name(schema.id, pn)]))
        elif p.type in POD_TYPES:
            pc = dup_property()
            fd[pn] = SchemaEntry(CTYPE_POD, pc, pc)
        # end handle property type
    # end

    return res
コード例 #5
0
def loadjson(j, limit=INSANE_CARD_LIMIT):
    """Load from JSON dict.
    """
    raws = j['card']
    v = j['v']
    #^ We can use version to determine what the fields are.
    if v < 810:
        raise NotImplementedError(v)
    raws = [card[:] for card in raws]
    if v < 900:  # Collab and inherits.
        for card in raws:
            card.extend((0, 0))
    if v < 920:  # Index.
        for i, card in items(raws):
            card.insert(0, i)
    if v < 1220:  # Weird furigana thing.
        for card in raws:
            card.append('')
    if v < 1230:  # Limit break.
        for card in raws:
            card.append(0)
    if v < 1240:  # Super awakening (prep).
        for card in raws:
            card.insert(-9, '')
    if v < 1520:  # Voice.
        for card in raws:
            card.append(0)
    if v < 1600:  # Orbskin.
        for card in raws:
            card.append(0)
    # 1800: HT 2019-10-11
    # 1800: NA 2019-10-~20
    if v < 1800:  # Only used so far for Fagan Rai?
        for card in raws:
            card.append('')
    if v > 1800:
        # Should raise a warning here.
        warnings.warn("Unknown card_data version: %s" % v)
    # else:
    # raise ValueError("%r has unknown card version %s." % (fpath, v))
    cards = Index((raw[0], BookCard(raw)) for raw in values(raws)
                  if not limit or raw[0] < limit)

    _register_evos(cards)
    _register_families(cards)

    return cards
コード例 #6
0
def loadjson(j, limit=INSANE_CARD_LIMIT):
    """Load from JSON dict.
    """
    raws = j['card']
    v = j['v']
    #^ We can use version to determine what the fields are.
    if v == 810:
        raise NotImplementedError('BookCard810')
    elif v == 900:
        cards = [BookCard900(i, raw) for i, raw in items(raws)]
        # cards = util.Bag(cards)
    elif v == 920:
        cards = Index((raw[0], BookCard920(raw)) for raw in values(raws)
                      if not limit or raw[0] < limit)
    else:
        fpath = "FORGOT TO ADD FPATH"
        raise ValueError("%r has unknown card version %s." % (fpath, v))

    _register_evos(cards)
    _register_families(cards)

    return cards
コード例 #7
0
ファイル: card_data.py プロジェクト: bitwalk/pypaddata
def loadjson(j):
    """Load from JSON dict.
    """
    raws = j['card']
    v = j['v']
    #^ We can use version to determine what the fields are.
    if v < 810:
        raise NotImplementedError(v)
    raws = [card[:] for card in raws]
    if v < 900:  # Collab and inherits.
        for card in raws:
            card.extend((0, 0))
    if v < 920:  # Index.
        for i, card in items(raws):
            card.insert(0, i)
    if v < 1220:  # Weird furigana thing.
        for card in raws:
            card.append('')
    if v < 1230:  # Limit break.
        for card in raws:
            card.append(0)
    if v < 1240:  # Super awakening (prep).
        for card in raws:
            card.insert(-9, '')
    if v > 1250:
        # Should raise a warning here.
        warnings.warn("Unknown card_data version: %s" % v)
    # else:
    # raise ValueError("%r has unknown card version %s." % (fpath, v))
    cards = OrderedDict((raw[0], BookCard(raw)) for raw in values(raws)
                        if raw[0] < INSANE_CARD_LIMIT)

    _register_evos(cards)
    _register_families(cards)

    return cards
コード例 #8
0
ファイル: paddb.py プロジェクト: bitwalk/pypaddata
 def items(self):
     return items(self.db)