A mapping of mimetypes to every class for reading data files.
511993
def tfclasses():
    
    # automatically find any subclasses of TraceFile in the same
    # directory as me
    classes = {}
    mydir = op.dirname(op.abspath(inspect.getfile(get_mimetype)))
    tfcls = {"<class 'aston.tracefile.TraceFile'>",
             "<class 'aston.tracefile.ScanListFile'>"}
    for filename in glob(op.join(mydir, '*.py')):
        name = op.splitext(op.basename(filename))[0]
        module = import_module('aston.tracefile.' + name)
        for clsname in dir(module):
            cls = getattr(module, clsname)
            if hasattr(cls, '__base__'):
                if str(cls.__base__) in tfcls:
                    classes[cls.mime] = cls
    return classes
752126
def guess_mimetype_read(read):
    """"""
    mime = None
    try:
        data = read()[:70]
    except Exception:
        pass
    else:
        for cmime, ro in PARSE_CONTENTS.items():
            if ro.search(data):
                mime = cmime
                break
    return mime
302186
private static ImmutableMap<String, AnnotationInfo> buildImmutableClasses(
      List<String> extraKnownImmutables) {
    return new Builder()
        .addStrings(extraKnownImmutables)
        .addClasses(Primitives.allPrimitiveTypes())
        .addClasses(Primitives.allWrapperTypes())
        .add("com.google.protobuf.ByteString")
        .add("com.google.protobuf.Descriptors$Descriptor")
        .add("com.google.protobuf.Descriptors$EnumDescriptor")
        .add("com.google.protobuf.Descriptors$EnumValueDescriptor")
        .add("com.google.protobuf.Descriptors$FieldDescriptor")
        .add("com.google.protobuf.Descriptors$FileDescriptor")
        .add("com.google.protobuf.Descriptors$ServiceDescriptor")
        .add("com.google.protobuf.Extension")
        .add("com.google.protobuf.ExtensionRegistry$ExtensionInfo")
        // NOTE: GeneratedMessage is included here for external tests that use this class for
        // checking whether classes are immutable. Within error prone, protos are verified
        // using isProto2MessageClass from this class.
        .add("com.google.protobuf.GeneratedMessage")
        .add("com.google.re2j.Pattern")
        .add("com.google.inject.TypeLiteral")
        .add("com.google.inject.Key")
        .add(com.google.common.base.CharMatcher.class)
        .add(com.google.common.base.Converter.class)
        .add(com.google.common.base.Joiner.class)
        .add(com.google.common.base.Optional.class, "T")
        .add(com.google.common.base.Splitter.class)
        .add(com.google.common.collect.ContiguousSet.class, "C")
        .add(com.google.common.collect.ImmutableBiMap.class, "K", "V")
        .add(com.google.common.collect.ImmutableCollection.class, "E")
        .add(com.google.common.collect.ImmutableList.class, "E")
        .add(com.google.common.collect.ImmutableListMultimap.class, "K", "V")
        .add(com.google.common.collect.ImmutableMap.class, "K", "V")
        .add(com.google.common.collect.ImmutableMultimap.class, "K", "V")
        .add(com.google.common.collect.ImmutableMultiset.class, "E")
        .add(com.google.common.collect.ImmutableRangeMap.class, "K", "V")
        .add(com.google.common.collect.ImmutableRangeSet.class, "C")
        .add(com.google.common.collect.ImmutableSet.class, "E")
        .add(com.google.common.collect.ImmutableSetMultimap.class, "K", "V")
        .add(com.google.common.collect.ImmutableSortedMap.class, "K", "V")
        .add(com.google.common.collect.ImmutableSortedMultiset.class, "E")
        .add(com.google.common.collect.ImmutableSortedSet.class, "E")
        .add(com.google.common.collect.ImmutableTable.class, "R", "C", "V")
        .add(com.google.common.collect.Range.class, "C")
        .add(com.google.common.graph.ImmutableGraph.class, "N")
        .add(com.google.common.graph.ImmutableNetwork.class, "N", "E")
        .add(com.google.common.graph.ImmutableValueGraph.class, "N", "V")
        .add("com.google.common.hash.AbstractHashFunction") // package-private
        .add(com.google.common.hash.HashCode.class)
        .add(com.google.common.io.BaseEncoding.class)
        .add(com.google.common.net.MediaType.class)
        .add(com.google.common.primitives.UnsignedInteger.class)
        .add(com.google.common.primitives.UnsignedLong.class)
        .add("com.ibm.icu.number.LocalizedNumberFormatter")
        .add("com.ibm.icu.number.LocalizedNumberRangeFormatter")
        .add("com.ibm.icu.number.UnlocalizedNumberFormatter")
        .add("com.ibm.icu.number.UnlocalizedNumberRangeFormatter")
        .add("com.ibm.icu.util.Currency")
        .add("com.ibm.icu.util.ULocale")
        .add(java.lang.Class.class)
        .add(java.lang.String.class)
        .add(java.lang.annotation.Annotation.class)
        .add(java.math.BigDecimal.class)
        .add(java.math.BigInteger.class)
        .add(java.net.InetAddress.class)
        .add(java.net.URI.class)
        .add(java.nio.charset.Charset.class)
        .add(java.nio.file.Path.class)
        .add(java.nio.file.WatchEvent.class)
        .add(java.nio.file.attribute.AclEntry.class)
        .add(java.nio.file.attribute.FileTime.class)
        .add(java.util.UUID.class)
        .add(java.util.Locale.class)
        .add(java.util.regex.Pattern.class)
        .add("android.net.Uri")
        .add("java.util.AbstractMap$SimpleImmutableEntry", "K", "V")
        .add("java.util.Optional", "T")
        .add("java.util.OptionalDouble")
        .add("java.util.OptionalInt")
        .add("java.util.OptionalLong")
        .add("java.time.Duration")
        .add("java.time.Instant")
        .add("java.time.LocalDate")
        .add("java.time.LocalDateTime")
        .add("java.time.LocalTime")
        .add("java.time.MonthDay")
        .add("java.time.OffsetDateTime")
        .add("java.time.OffsetTime")
        .add("java.time.Period")
        .add("java.time.Year")
        .add("java.time.YearMonth")
        .add("java.time.ZoneId")
        .add("java.time.ZoneOffset")
        .add("java.time.ZonedDateTime")
        .add("java.time.chrono.AbstractChronology")
        .add("java.time.chrono.ChronoLocalDate")
        .add("java.time.chrono.ChronoLocalDateTime", "D")
        .add("java.time.chrono.ChronoPeriod")
        .add("java.time.chrono.ChronoZonedDateTime", "D")
        .add("java.time.chrono.Chronology")
        .add("java.time.chrono.Era")
        .add("java.time.chrono.HijrahChronology")
        .add("java.time.chrono.HijrahDate")
        .add("java.time.chrono.IsoChronology")
        .add("java.time.chrono.JapaneseChronology")
        .add("java.time.chrono.JapaneseDate")
        .add("java.time.chrono.JapaneseEra")
        .add("java.time.chrono.MinguoChronology")
        .add("java.time.chrono.MinguoDate")
        .add("java.time.chrono.ThaiBuddhistChronology")
        .add("java.time.chrono.ThaiBuddhistDate")
        .add("java.time.format.DateTimeFormatter")
        .add("java.time.format.DecimalStyle")
        .add("java.time.temporal.TemporalField")
        .add("java.time.temporal.TemporalUnit")
        .add("java.time.temporal.ValueRange")
        .add("java.time.temporal.WeekFields")
        .add("java.time.zone.ZoneOffsetTransition")
        .add("java.time.zone.ZoneOffsetTransitionRule")
        .add("java.time.zone.ZoneRules")
        .add("java.time.zone.ZoneRulesProvider")
        .add("org.threeten.bp.Duration")
        .add("org.threeten.bp.Instant")
        .add("org.threeten.bp.LocalDate")
        .add("org.threeten.bp.LocalDateTime")
        .add("org.threeten.bp.LocalTime")
        .add("org.threeten.bp.MonthDay")
        .add("org.threeten.bp.OffsetDateTime")
        .add("org.threeten.bp.OffsetTime")
        .add("org.threeten.bp.Period")
        .add("org.threeten.bp.Year")
        .add("org.threeten.bp.YearMonth")
        .add("org.threeten.bp.ZoneId")
        .add("org.threeten.bp.ZoneOffset")
        .add("org.threeten.bp.ZonedDateTime")
        .add("org.threeten.bp.chrono.AbstractChronology")
        .add("org.threeten.bp.chrono.ChronoLocalDate")
        .add("org.threeten.bp.chrono.ChronoLocalDateTime", "D")
        .add("org.threeten.bp.chrono.ChronoPeriod")
        .add("org.threeten.bp.chrono.ChronoZonedDateTime", "D")
        .add("org.threeten.bp.chrono.Chronology")
        .add("org.threeten.bp.chrono.Era")
        .add("org.threeten.bp.chrono.HijrahChronology")
        .add("org.threeten.bp.chrono.HijrahDate")
        .add("org.threeten.bp.chrono.IsoChronology")
        .add("org.threeten.bp.chrono.JapaneseChronology")
        .add("org.threeten.bp.chrono.JapaneseDate")
        .add("org.threeten.bp.chrono.JapaneseEra")
        .add("org.threeten.bp.chrono.MinguoChronology")
        .add("org.threeten.bp.chrono.MinguoDate")
        .add("org.threeten.bp.chrono.ThaiBuddhistChronology")
        .add("org.threeten.bp.chrono.ThaiBuddhistDate")
        .add("org.threeten.bp.format.DateTimeFormatter")
        .add("org.threeten.bp.format.DecimalStyle")
        .add("org.threeten.bp.temporal.TemporalField")
        .add("org.threeten.bp.temporal.TemporalUnit")
        .add("org.threeten.bp.temporal.ValueRange")
        .add("org.threeten.bp.temporal.WeekFields")
        .add("org.threeten.bp.zone.ZoneOffsetTransition")
        .add("org.threeten.bp.zone.ZoneOffsetTransitionRule")
        .add("org.threeten.bp.zone.ZoneRules")
        .add("org.threeten.bp.zone.ZoneRulesProvider")
        .add("org.threeten.extra.Interval")
        .add("org.joda.time.DateTime")
        .add("org.joda.time.DateTimeZone")
        .add("org.joda.time.Days")
        .add("org.joda.time.Duration")
        .add("org.joda.time.Instant")
        .add("org.joda.time.Interval")
        .add("org.joda.time.LocalDate")
        .add("org.joda.time.LocalDateTime")
        .add("org.joda.time.Period")
        .add("org.joda.time.format.DateTimeFormatter")
        .add("org.openqa.selenium.Dimension")
        .add("org.openqa.selenium.DeviceRotation")
        .add("org.openqa.selenium.ImmutableCapabilities")
        .build();
  }
877721
public static List<MimeType> parseMimeTypes(String mimeTypes) {
        if (!Strings.isNullOrEmpty(mimeTypes)) {
            return Collections.emptyList();
        }
        String[] tokens = mimeTypes.split(",\\s*");
        List<MimeType> result = new ArrayList<MimeType>(tokens.length);
        for (String token : tokens) {
            result.add(parseMimeType(token));
        }
        return result;
    }
528280
private FileCompressionType mimeTypeToCompressionType(String mimeTypeStr)
  throws MimeTypeParseException
  {
    MimeType mimeType = null;

    if (mimeTypeStr != null)
    {
      mimeType = new MimeType(mimeTypeStr);
    }

    if (mimeType != null && mimeType.getSubType() != null)
    {
      return FileCompressionType.lookupByMimeSubType(
          mimeType.getSubType().toLowerCase());
    }

    return null;
  }
841695
def _generate_base_mimetypes(self):
        
        for t in self.type_instances:
            if t.custom_mime:
                continue

            yield t.mime, (t, None, None)
1135857
def _get_imports_m(self, data_types, default_imports):
        """"""
        if not isinstance(data_types, list):
            data_types = [data_types]

        import_classes = default_imports

        for data_type in data_types:
            import_classes.append(fmt_class_prefix(data_type))

            if data_type.parent_type:
                import_classes.append(fmt_class_prefix(data_type.parent_type))

            if is_struct_type(
                    data_type) and data_type.has_enumerated_subtypes():
                for _, subtype in data_type.get_all_subtypes_with_tags():
                    import_classes.append(fmt_class_prefix(subtype))

            for field in data_type.all_fields:
                data_type, _ = unwrap_nullable(field.data_type)

                # unpack list or map
                while is_list_type(data_type) or is_map_type(data_type):
                    data_type = (data_type.value_data_type if
                        is_map_type(data_type) else data_type.data_type)

                if is_user_defined_type(data_type):
                    import_classes.append(fmt_class_prefix(data_type))

        if import_classes:
            import_classes = list(set(import_classes))
            import_classes.sort()

        return import_classes
295438
function populateMaps (extensions, types) {
  // source preference (least -> most)
  var preference = ['nginx', 'apache', undefined, 'iana']

  Object.keys(db).forEach(function forEachMimeType (type) {
    var mime = db[type]
    var exts = mime.extensions

    if (!exts || !exts.length) {
      return
    }

    // mime -> extensions
    extensions[type] = exts

    // extension -> mime
    for (var i = 0; i < exts.length; i++) {
      var extension = exts[i]

      if (types[extension]) {
        var from = preference.indexOf(db[types[extension]].source)
        var to = preference.indexOf(mime.source)

        if (types[extension] !== 'application/octet-stream' &&
          (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
          // skip the remapping
          continue
        }
      }

      // set the extension -> mime
      types[extension] = type
    }
  })
}
483989
private Iterable<Class<?>> allMessageTypes(final Class<?> concreteMsgClass) {
        ClassTypeExtractor extractor = new ClassTypeExtractor(concreteMsgClass);
        return extractor.allClassesAndInterfaces();
    }
298304
def expand_idx_mimetype(type_):
    """"""
    if isinstance(type_, unicode_type):
        match = __IDX_PATTERN.match(type_)
        return __IDX_MAPPING.get(match.group(1), type_) if match else type_
    else:
        return type_
1313287
def _jar_classfiles(self, jar_file):
    """"""
    for cls in ClasspathUtil.classpath_entries_contents([jar_file]):
      if cls.endswith('.class'):
        yield cls
95314
def guess_mimetype(filename):
    
    m, encoding = mimetypes.guess_type(filename)
    if encoding:
        m = ENCODING_MIMETYPES.get(encoding, None)
    return m or 'application/octet-stream'
979601
def classes(self) -> Iterator[str]:
        """"""
        yield from (
            c[:-6]
            for c in self.path_map.keys() if c.endswith('.class')
        )
1223072
def _get_dtype_maps():
    
    
    # Define pairs
    tmp = [ (np.float32, 'MET_FLOAT'),  (np.float64, 'MET_DOUBLE'),
            (np.uint8, 'MET_UCHAR'),    (np.int8, 'MET_CHAR'),
            (np.uint16, 'MET_USHORT'),  (np.int16, 'MET_SHORT'),
            (np.uint32, 'MET_UINT'),    (np.int32, 'MET_INT'),
            (np.uint64, 'MET_ULONG'),   (np.int64, 'MET_LONG') ]
    
    # Create dictionaries
    map1, map2 = {}, {}
    for np_type, itk_type in tmp:
        map1[np_type.__name__] = itk_type
        map2[itk_type] = np_type.__name__
    
    # Done
    return map1, map2
21242
void readInnerClasses(ClassSymbol c) {
        int n = nextChar();
        for (int i = 0; i < n; i++) {
            nextChar(); // skip inner class symbol
            ClassSymbol outer = readClassSymbol(nextChar());
            Name name = readName(nextChar());
            if (name == null) name = names.empty;
            long flags = adjustClassFlags(nextChar());
            if (outer != null) { // we have a member class
                if (name == names.empty)
                    name = names.one;
                ClassSymbol member = enterClass(name, outer);
                if ((flags & STATIC) == 0) {
                    ((ClassType)member.type).setEnclosingType(outer.type);
                    if (member.erasure_field != null)
                        ((ClassType)member.erasure_field).setEnclosingType(types.erasure(outer.type));
                }
                if (c == outer) {
                    member.flags_field = flags;
                    enterMember(c, member);
                }
            }
        }
    }
1123350
def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, maskMap):
        
        # Assign file extension attribute to file object
        self.fileExtension = extension

        if isinstance(maskMap, RasterMapFile) and maskMap.fileExtension == 'msk':
            # Vars from mask map
            columns = maskMap.columns
            rows = maskMap.rows
            upperLeftX = maskMap.west
            upperLeftY = maskMap.north

            # Derive the cell size (GSSHA cells are square, so it is the same in both directions)
            cellSizeX = int(abs(maskMap.west - maskMap.east) / columns)
            cellSizeY = -1 * cellSizeX

            # Dictionary of keywords/cards and parse function names
            KEYWORDS = {'DATASET': wdc.datasetHeaderChunk,
                        'TS': wdc.datasetScalarTimeStepChunk}

            # Open file and read plain text into text field
            with open(path, 'r') as f:
                chunks = pt.chunk(KEYWORDS, f)

            # Parse header chunk first
            header = wdc.datasetHeaderChunk('DATASET', chunks['DATASET'][0])

            # Parse each time step chunk and aggregate
            timeStepRasters = []

            for chunk in chunks['TS']:
                timeStepRasters.append(wdc.datasetScalarTimeStepChunk(chunk, columns, header['numberCells']))

            # Set WMS dataset file properties
            self.name = header['name']
            self.numberCells = header['numberCells']
            self.numberData = header['numberData']
            self.objectID = header['objectID']

            if header['type'] == 'BEGSCL':
                self.objectType = header['objectType']
                self.type = self.SCALAR_TYPE

            elif header['type'] == 'BEGVEC':
                self.vectorType = header['objectType']
                self.type = self.VECTOR_TYPE

            # Create WMS raster dataset files for each raster
            for timeStep, timeStepRaster in enumerate(timeStepRasters):
                # Create new WMS raster dataset file object
                wmsRasterDatasetFile = WMSDatasetRaster()

                # Set the wms dataset for this WMS raster dataset file
                wmsRasterDatasetFile.wmsDataset = self

                # Set the time step and timestamp and other properties
                wmsRasterDatasetFile.iStatus = timeStepRaster['iStatus']
                wmsRasterDatasetFile.timestamp = timeStepRaster['timestamp']
                wmsRasterDatasetFile.timeStep = timeStep + 1

                # If spatial is enabled create PostGIS rasters
                if spatial:
                    # Process the values/cell array
                    wmsRasterDatasetFile.raster = RasterLoader.makeSingleBandWKBRaster(session,
                                                                                       columns, rows,
                                                                                       upperLeftX, upperLeftY,
                                                                                       cellSizeX, cellSizeY,
                                                                                       0, 0,
                                                                                       spatialReferenceID,
                                                                                       timeStepRaster['cellArray'])

                # Otherwise, set the raster text properties
                else:
                    wmsRasterDatasetFile.rasterText = timeStepRaster['rasterText']

            # Add current file object to the session
            session.add(self)

        else:
            log.warning("Could not read {0}. Mask Map must be supplied "
                     "to read WMS Datasets.".format(filename))
707707
def map_to_precursors_on_fly(seqs, names, loci, args):
    """"""
    precursor = precursor_sequence(loci, args.ref).upper()
    dat = dict()
    for s, n in itertools.izip(seqs, names):
        res = pyMatch.Match(precursor, str(s), 1, 3)
        if res > -1:
            dat[n] = [res, res + len(s)]
    logger.debug("mapped in %s: %s out of %s" % (loci, len(dat), len(seqs)))
    return dat