Return the current configuration as a YubiKeyFrame object.
170311
def to_frame(self, slot=1):
        
        data = self.to_string()
        payload = data.ljust(64, yubico_util.chr_byte(0x0))
        if slot is 1:
            if self._update_config:
                command = SLOT.UPDATE1
            else:
                command = SLOT.CONFIG
        elif slot is 2:
            if self._update_config:
                command = SLOT.UPDATE2
            else:
                command = SLOT.CONFIG2
        else:
            assert()

        if self._swap_slots:
            command = SLOT.SWAP

        if self._zap:
            payload = b''

        return yubikey_frame.YubiKeyFrame(command=command, payload=payload)
187158
def info(ctx):
    
    controller = ctx.obj['controller']
    version = controller.version
    click.echo(
        'OATH version: {}.{}.{}'.format(version[0], version[1], version[2]))
    click.echo('Password protection ' +
               ('enabled' if controller.locked else 'disabled'))

    keys = ctx.obj['settings'].get('keys', {})
    if controller.locked and controller.id in keys:
        click.echo('The password for this YubiKey is remembered by ykman.')

    if ctx.obj['dev'].is_fips:
        click.echo('FIPS Approved Mode: {}'.format(
            'Yes' if controller.is_in_fips_mode else 'No'))
1364979
def get(self, key, default):
        """"""
        with self._lock:
            try:
                return self._dict[key].copy()
            except KeyError:
                return default
690876
def pack(self):
        
        # # 22-bytes Yubikey secrets block
        # typedef struct {
        #   uint8_t key[KEY_SIZE];              // AES key
        #   uint8_t uid[UID_SIZE];              // Unique (secret) ID
        # } YUBIKEY_SECRETS;
        return self.key + self.uid.ljust(pyhsm.defines.UID_SIZE, chr(0))
34366
def get(self, key: str) -> Optional[str]:
        
        return get_config(self.full_key(key))
997466
def get_frame():
    """"""
    ret = QFrame()
    ret.setLineWidth(1)
    ret.setMidLineWidth(0)
    ret.setFrameShadow(QFrame.Sunken)
    ret.setFrameShape(QFrame.Box)
    return ret
518667
def have_current_state_entry(self, wid, key):
        ''
        cscoll = self.current_state()
        c_state = cscoll.get(wid, {})
        return key in c_state
1359669
def to_frame(self, slot=SLOT.SCAN_MAP):
        
        payload = self.scanmap.ljust(64, b'\0')
        return yubikey_frame.YubiKeyFrame(command=slot, payload=payload)
927706
def get_config(cls, key, default=None):
        
        return cls._app.config.get(key, default)
339511
def get_property(self, key):
        """"""
        _key = DJANGO_CONF[key]
        return getattr(self, _key, CONF_SPEC[_key])
676857
def tcfg_get(key)
      t_tcfg = tcfg
      unless t_tcfg.key? key
        raise NoSuchConfigurationKeyError, "No configuration defined for '#{key}'"
      end
      t_tcfg[key]
    end
351345
def type(self, url = False, text = False, other = None):
        
        if (url, text, other) == (True, False, None):
            self.ndef_type = _NDEF_URI_TYPE
        elif (url, text, other) == (False, True, None):
            self.ndef_type = _NDEF_TEXT_TYPE
        elif (url, text, type(other)) == (False, False, int):
            self.ndef_type = other
        else:
            raise YubiKeyNEO_USBHIDError("Bad or conflicting NDEF type specified")
        return self
832101
def _write_config(self, cfg, slot):
        
        old_pgm_seq = self._status.pgm_seq
        frame = cfg.to_frame(slot=slot)
        self._debug("Writing %s frame :\n%s\n" % \
                        (yubikey_config.command2str(frame.command), cfg))
        self._write(frame)
        self._waitfor_clear(yubikey_defs.SLOT_WRITE_FLAG)
        # make sure we have a fresh pgm_seq value
        self.status()
        self._debug("Programmed slot %i, sequence %i -> %i\n" % (slot, old_pgm_seq, self._status.pgm_seq))

        cfgs = self._status.valid_configs()
        if not cfgs and self._status.pgm_seq == 0:
            return
        if self._status.pgm_seq == old_pgm_seq + 1:
            return

        raise YubiKeyUSBHIDError('YubiKey programming failed (seq %i not increased (%i))' % \
                                    (old_pgm_seq, self._status.pgm_seq))
1355727
def key(self, frame):
        ""
        def keytuple(primary):
            if frame.frameno is None:
                return (primary, 1)
            return (primary, 0, frame.frameno)

        # Look up frame by exact match
        if type(frame) in self.frame_keys:
            return keytuple(self.frame_keys[type(frame)])

        # Look up parent frame for v2.2 frames
        if frame._in_version(2) and type(frame).__bases__[0] in self.frame_keys:
            return keytuple(self.frame_keys[type(frame).__bases__[0]])

        # Try each pattern
        for (pattern, key) in self.re_keys:
            if re.match(pattern, frame.frameid):
                return keytuple(key)

        return keytuple(self.unknown_key)
618993
def get_keys_to_action(self):
        """"""
        # get the old mapping of keys to actions
        old_keys_to_action = self.env.unwrapped.get_keys_to_action()
        # invert the keys to action mapping to lookup key combos by action
        action_to_keys = {v: k for k, v in old_keys_to_action.items()}
        # create a new mapping of keys to actions
        keys_to_action = {}
        # iterate over the actions and their byte values in this mapper
        for action, byte in self._action_map.items():
            # get the keys to press for the action
            keys = action_to_keys[byte]
            # set the keys value in the dictionary to the current discrete act
            keys_to_action[keys] = action

        return keys_to_action
31856
def custom_conf(self, conf):
        ''''''
        if conf:
            for (key, val) in conf.items():
                self.__conf[key] = val
        return self
763067
def get_config(config_path):
    """"""
    if not os.path.exists(config_path):
        raise ConfigDoesNotExistException

    logger.debug('config_path is {0}'.format(config_path))
    with io.open(config_path, encoding='utf-8') as file_handle:
        try:
            yaml_dict = poyo.parse_string(file_handle.read())
        except poyo.exceptions.PoyoException as e:
            raise InvalidConfiguration(
                'Unable to parse YAML file {}. Error: {}'
                ''.format(config_path, e)
            )

    config_dict = merge_configs(DEFAULT_CONFIG, yaml_dict)

    raw_replay_dir = config_dict['replay_dir']
    config_dict['replay_dir'] = _expand_path(raw_replay_dir)

    raw_cookies_dir = config_dict['cookiecutters_dir']
    config_dict['cookiecutters_dir'] = _expand_path(raw_cookies_dir)

    return config_dict