How to use the construct.Flag function in construct

To help you get started, we’ve selected a few construct examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PythEch / pymobiledevice / libs / python / construct / formats / filesystem / fat16.py View on Github external
def DirEntry(name):
    return Struct(name,
            Bytes("name", 8),
            Bytes("extension", 3),
            BitStruct("attributes",
                Flag("unused"),
                Flag("device"),
                Flag("archive"),
                Flag("subDirectory"),
                Flag("volumeLabel"),
                Flag("system"),
                Flag("hidden"),
                Flag("readonly")),
            # reserved
            Padding(10),
            ULInt16("timeRecorded"),
            ULInt16("dateRecorded"),
            ULInt16("firstCluster"),
            ULInt32("fileSize"))
github PythEch / pymobiledevice / libs / python / construct / formats / filesystem / fat16.py View on Github external
def DirEntry(name):
    return Struct(name,
            Bytes("name", 8),
            Bytes("extension", 3),
            BitStruct("attributes",
                Flag("unused"),
                Flag("device"),
                Flag("archive"),
                Flag("subDirectory"),
                Flag("volumeLabel"),
                Flag("system"),
                Flag("hidden"),
                Flag("readonly")),
            # reserved
            Padding(10),
            ULInt16("timeRecorded"),
            ULInt16("dateRecorded"),
            ULInt16("firstCluster"),
            ULInt32("fileSize"))
github PIC-IRIS / PH5 / ph5 / core / rt_130_h.py View on Github external
def data_packet():
    DT = construct.BitStruct("DT",
                             construct.BitField("PacketHeader", 128),
                             construct.BitField("EventNumber", 16),
                             construct.BitField("DataStream", 8),
                             construct.BitField("Channel", 8),
                             construct.BitField("Samples", 16),
                             # construct.BitField ("Flags", 8),
                             construct.Flag("Calibration"),
                             construct.Flag("Overscaled"),
                             construct.Flag("StackedData"),
                             construct.BitField("Unused", 2),
                             construct.Flag("Second_EH_ET"),
                             construct.Flag("LastDataPacket"),
                             construct.Flag("FirstDataPacket"),
                             construct.BitField("DataFormat", 8),
                             construct.BitField("Data", 8000))
    return DT
github veekun / pokedex / pokedex / struct / _pokemon_struct.py View on Github external
Flag('record_ribbon'),
        Flag('footprint_ribbon'),
        Flag('gorgeous_royal_ribbon'),
        Flag('royal_ribbon'),
        Flag('gorgeous_ribbon'),
        Flag('smile_ribbon'),
        Flag('snooze_ribbon'),
        Flag('relax_ribbon'),
        Flag('careless_ribbon'),
        Flag('downcast_ribbon'),
        Flag('shock_ribbon'),
        Flag('alert_ribbon'),
        Flag('world_ability_ribbon'),
        Flag('pair_ability_ribbon'),
        Flag('multi_ability_ribbon'),
        Flag('double_ability_ribbon'),
        Flag('great_ability_ribbon'),
        Flag('ability_ribbon'),
        Flag('sinnoh_champ_ribbon'),
    ),

    # Block B
    ULInt16('move1_id'),
    ULInt16('move2_id'),
    ULInt16('move3_id'),
    ULInt16('move4_id'),
    ULInt8('move1_pp'),
    ULInt8('move2_pp'),
    ULInt8('move3_pp'),
    ULInt8('move4_pp'),
    ULInt8('move1_pp_ups'),
    ULInt8('move2_pp_ups'),
github veekun / pokedex / pokedex / struct / _pokemon_struct.py View on Github external
Flag('royal_ribbon'),
        Flag('gorgeous_ribbon'),
        Flag('smile_ribbon'),
        Flag('snooze_ribbon'),
        Flag('relax_ribbon'),
        Flag('careless_ribbon'),
        Flag('downcast_ribbon'),
        Flag('shock_ribbon'),
        Flag('alert_ribbon'),
        Flag('world_ability_ribbon'),
        Flag('pair_ability_ribbon'),
        Flag('multi_ability_ribbon'),
        Flag('double_ability_ribbon'),
        Flag('great_ability_ribbon'),
        Flag('ability_ribbon'),
        Flag('sinnoh_champ_ribbon'),
    ),

    # Block B
    ULInt16('move1_id'),
    ULInt16('move2_id'),
    ULInt16('move3_id'),
    ULInt16('move4_id'),
    ULInt8('move1_pp'),
    ULInt8('move2_pp'),
    ULInt8('move3_pp'),
    ULInt8('move4_pp'),
    ULInt8('move1_pp_ups'),
    ULInt8('move2_pp_ups'),
    ULInt8('move3_pp_ups'),
    ULInt8('move4_pp_ups'),
github lukleh / TwistedBot / twistedbot / packets.py View on Github external
def Bool(*args, **kwargs):
    return Flag(*args, default=True, **kwargs)
github pmrowla / pylivemaker / livemaker / lsb / command.py View on Github external
def _struct(cls):
        """Return a construct Struct for this command type."""
        return construct.Struct(
            "type" / construct.Const(cls.type.name, construct.Enum(construct.Byte, CommandType)),
            "Indent" / construct.Int32ul,
            "Mute" / construct.Flag,
            "NotUpdate" / construct.Flag,
            "LineNo" / construct.Int32ul,
            # construct.Probe(),
            construct.Embedded(cls._struct_fields),
            # construct.Probe(),
github PythEch / pymobiledevice / libs / python / construct / formats / filesystem / fat16.py View on Github external
def DirEntry(name):
    return Struct(name,
            Bytes("name", 8),
            Bytes("extension", 3),
            BitStruct("attributes",
                Flag("unused"),
                Flag("device"),
                Flag("archive"),
                Flag("subDirectory"),
                Flag("volumeLabel"),
                Flag("system"),
                Flag("hidden"),
                Flag("readonly")),
            # reserved
            Padding(10),
            ULInt16("timeRecorded"),
            ULInt16("dateRecorded"),
            ULInt16("firstCluster"),
            ULInt32("fileSize"))
github PythEch / pymobiledevice / libs / python / construct / formats / filesystem / fat16.py View on Github external
def DirEntry(name):
    return Struct(name,
            Bytes("name", 8),
            Bytes("extension", 3),
            BitStruct("attributes",
                Flag("unused"),
                Flag("device"),
                Flag("archive"),
                Flag("subDirectory"),
                Flag("volumeLabel"),
                Flag("system"),
                Flag("hidden"),
                Flag("readonly")),
            # reserved
            Padding(10),
            ULInt16("timeRecorded"),
            ULInt16("dateRecorded"),
            ULInt16("firstCluster"),
            ULInt32("fileSize"))
github veekun / pokedex / pokedex / struct / _pokemon_struct.py View on Github external
Flag('beauty_ribbon_hyper'),
        Flag('beauty_ribbon_super'),
        Flag('beauty_ribbon'),
        Flag('cool_ribbon_master'),
        Flag('cool_ribbon_hyper'),
        Flag('cool_ribbon_super'),
        Flag('cool_ribbon'),
    ),
    EmbeddedBitStruct(
        PokemonFormAdapter(BitField('alternate_form', 5)),
        Enum(BitField('gender', 2),
            genderless = 2,
            male = 0,
            female = 1,
        ),
        Flag('fateful_encounter'),
    ),
    BitStruct('shining_leaves',
        Padding(2),
        Flag('crown'),
        Flag('leaf5'),
        Flag('leaf4'),
        Flag('leaf3'),
        Flag('leaf2'),
        Flag('leaf1'),
    ),
    Padding(2),
    ULInt16('pt_egg_location_id'),
    ULInt16('pt_met_location_id'),

    # Block C
    PokemonStringAdapter(String('nickname', 22)),