Return the format attribute of the BFD file being processed.
354845
def format(self):
        """"""
        if not self._ptr:
            raise BfdException("BFD not initialized")

        return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.FORMAT)
1220399
def from_format(self, attr):
        
        if attr.name_format:
            if self.name_format == attr.name_format:
                try:
                    return self._fro[attr.name.lower()]
                except KeyError:
                    pass
        else:  # don't know the name format so try all I have
            try:
                return self._fro[attr.name.lower()]
            except KeyError:
                pass

        return ""
1308676
def get_wbfmt(self, data_nt=None):
        """"""
        if data_nt is None or self.b_plain:
            return self.fmtname2wbfmtobj.get('plain')
        # User namedtuple field/value for color
        if self.ntfld_wbfmt is not None:
            return self.__get_wbfmt_usrfld(data_nt)
        # namedtuple format_txt for color/bold/border
        if self.b_format_txt:
            wbfmt = self.__get_wbfmt_format_txt(data_nt)
            if wbfmt is not None:
                return wbfmt
        # 'ntfld_wbfmt': namedtuple field which contains a value used as a key for a xlsx format
        # 'ntval2wbfmtdict': namedtuple value and corresponding xlsx format dict.
        return self.fmtname2wbfmtobj.get('plain')
825298
def detect_format(filename):
    
    filename = Path(filename)

    if filename.is_dir():
        if list(filename.glob('*.stc')) and list(filename.glob('*.erd')):
            return Ktlx
        elif (filename / 'patient.info').exists():
            return Moberg
        elif (filename / 'info.xml').exists():
            return EgiMff
        elif list(filename.glob('*.openephys')):
            return OpenEphys
        elif list(filename.glob('*.txt')):
            return Text
        else:
            raise UnrecognizedFormat('Unrecognized format for directory ' +
                                     str(filename))
    else:
        if filename.suffix == '.won':
            return Wonambi

        if filename.suffix.lower() == '.trc':
            return Micromed

        if filename.suffix == '.set':
            return EEGLAB

        if filename.suffix == '.edf':
            return Edf

        if filename.suffix == '.abf':
            return Abf

        if filename.suffix == '.vhdr' or filename.suffix == '.eeg':
            return BrainVision

        if filename.suffix == '.dat':  # very general
            try:
                _read_header_length(filename)

            except (AttributeError, ValueError):  # there is no HeaderLen
                pass

            else:
                return BCI2000

        with filename.open('rb') as f:
            file_header = f.read(8)
            if file_header in (b'NEURALCD', b'NEURALSG', b'NEURALEV'):
                return BlackRock
            elif file_header[:6] == b'MATLAB':  # we might need to read more
                return FieldTrip
        
        if filename.suffix.lower() == '.txt':
            with filename.open('rt') as f:
                first_line = f.readline()
                if '.rr' in first_line[-4:]:
                    return LyonRRI
        
        else:
            raise UnrecognizedFormat('Unrecognized format for file ' +
                                     str(filename))
955804
def extract_format(format, extra_types):
    '''
    '''
    fill = align = None
    if format[0] in '<>=^':
        align = format[0]
        format = format[1:]
    elif len(format) > 1 and format[1] in '<>=^':
        fill = format[0]
        align = format[1]
        format = format[2:]

    zero = False
    if format and format[0] == '0':
        zero = True
        format = format[1:]

    width = ''
    while format:
        if not format[0].isdigit():
            break
        width += format[0]
        format = format[1:]

    if format.startswith('.'):
        # Precision isn't needed but we need to capture it so that
        # the ValueError isn't raised.
        format = format[1:]  # drop the '.'
        precision = ''
        while format:
            if not format[0].isdigit():
                break
            precision += format[0]
            format = format[1:]

    # the rest is the type, if present
    type = format
    if type and type not in ALLOWED_TYPES and type not in extra_types:
        raise ValueError('format spec %r not recognised' % type)

    return locals()
885221
def _format_attrs(self):
        
        attrs = [
            ('levels', ibase.default_pprint(self._levels,
                                            max_seq_items=False)),
            ('codes', ibase.default_pprint(self._codes,
                                           max_seq_items=False))]
        if com._any_not_none(*self.names):
            attrs.append(('names', ibase.default_pprint(self.names)))
        if self.sortorder is not None:
            attrs.append(('sortorder', ibase.default_pprint(self.sortorder)))
        return attrs
963492
def file_flags(self, _file_flags):
        """"""
        if not self._ptr:
            raise BfdException("BFD not initialized")

        return _bfd.set_file_flags(self._ptr, _file_flags)
732364
def my_archieve(self):
        """"""
        if not self._ptr:
            raise BfdException("BFD not initialized")

        return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.MY_ARCHIEVE)
101102
def do_filesizeformat(value, binary=False):
    
    bytes = float(value)
    base = binary and 1024 or 1000
    prefixes = [
        (binary and 'KiB' or 'kB'),
        (binary and 'MiB' or 'MB'),
        (binary and 'GiB' or 'GB'),
        (binary and 'TiB' or 'TB'),
        (binary and 'PiB' or 'PB'),
        (binary and 'EiB' or 'EB'),
        (binary and 'ZiB' or 'ZB'),
        (binary and 'YiB' or 'YB')
    ]
    if bytes == 1:
        return '1 Byte'
    elif bytes < base:
        return '%d Bytes' % bytes
    else:
        for i, prefix in enumerate(prefixes):
            unit = base ** (i + 2)
            if bytes < unit:
                return '%.1f %s' % ((base * bytes / unit), prefix)
        return '%.1f %s' % ((base * bytes / unit), prefix)
670013
def get_comic_format(filename):
    """"""
    image_format = None
    filename_ext = os.path.splitext(filename)[-1].lower()
    if filename_ext in _COMIC_EXTS:
        if zipfile.is_zipfile(filename):
            image_format = _CBZ_FORMAT
        elif rarfile.is_rarfile(filename):
            image_format = _CBR_FORMAT
    return image_format
481928
function getCharacteristicFormatsKey(format) {
  // coerce 'int32' to 'int'
  if (format == 'int32') format = 'int';

  // look up the key in our known-formats dict
  for (var key in Characteristic.Formats)
    if (Characteristic.Formats[key] == format)
      return key;

  throw new Error("Unknown characteristic format '" + format + "'");
}
725755
def get_fmt_section(self):
        """"""
        if self.b_format_txt:
            return self.fmtname2wbfmtobj.get("light grey")
        return self.fmtname2wbfmtobj.get("plain bold")
96786
def input_format(self, content_type):
        """"""
        return getattr(self, '_input_format', {}).get(content_type, hug.defaults.input_format.get(content_type, None))
1048635
def GetFormatSpecification(cls):
    
    format_specification = specification.FormatSpecification(cls.NAME)
    format_specification.AddNewSignature(b'ElfFile\x00', offset=0)
    return format_specification
672267
def get_jid(jid):
    '''
    
    '''
    conn, mdb = _get_conn(ret=None)
    ret = {}
    rdata = mdb.saltReturns.find({'jid': jid}, {'_id': 0})
    if rdata:
        for data in rdata:
            minion = data['minion']
            # return data in the format {<minion>: { <unformatted full return data>}}
            ret[minion] = data['full_ret']
    return ret
1068828
def format_file_params(files):
        '''
            
        '''
        files_payload = {}
        if files:
            for idx, filename in enumerate(files):
                files_payload["file[" + str(idx) + "]"] = open(filename, 'rb')
        return files_payload
749936
def valid_reloction_types(self):
        """"""
        if not self._ptr:
            raise BfdException("BFD not initialized")

        return _bfd.get_bfd_attribute(
            self._ptr, BfdAttributes.VALID_RELOC_TYPES)