<commit_before>using Hyena;

using System;
using System.IO;
using System.Collections.Generic;

using FSpot.Utils;
using Mono.Unix;
using Mono.Unix.Native;
using Gdk;

using GLib;
using TagLib.Image;

using GFileInfo = GLib.FileInfo;

namespace FSpot.Imaging {
	public class ImageFormatException : ApplicationException {
		public ImageFormatException (string msg) : base (msg)
		{
		}
	}

	public static class ImageFile {

#region Factory functionality

		static Dictionary<string, Type> name_table;
		internal static Dictionary<string, Type> NameTable { get { return name_table; } }

        static ImageFile ()
        {
            var base_type = typeof (BaseImageFile);
            var raw_type = typeof (DCRawFile);
            var nef_type = typeof (FSpot.Imaging.Tiff.NefFile);

            name_table = new Dictionary<string, Type> ();

            // Plain image files
            name_table ["image/gif"] = name_table [".gif"] = base_type;
            name_table ["image/x-pcx"] = name_table [".pcx"] = base_type;
            name_table ["image/x-portable-anymap"] = name_table [".pnm"] = base_type;
            name_table ["image/x-portable-bitmap"] = name_table [".pbm"] = base_type;
            name_table ["image/x-portable-graymap"] = name_table [".pgm"] = base_type;
            name_table ["image/x-portable-pixmap"] = name_table [".ppm"] = base_type;
            name_table ["image/x-bmp"] = name_table ["image/x-MS-bmp"] = name_table [".bmp"] = base_type;
            name_table ["image/jpeg"] = name_table [".jfi"] = name_table [".jfif"] = name_table [".jif"] = name_table [".jpe"] = name_table [".jpeg"] = name_table [".jpg"] = base_type;
            name_table ["image/png"] = name_table [".png"] = base_type;
            name_table ["image/tiff"] = name_table [".tif"] = name_table [".tiff"] = base_type;
            name_table ["image/svg+xml"] = name_table [".svg"] = name_table [".svgz"] = base_type;

            // RAW files
            name_table ["image/arw"] = name_table ["image/x-sony-arw"] = name_table [".arw"] = nef_type;
            name_table ["image/cr2"] = name_table ["image/x-canon-cr2"] = name_table [".cr2"] = typeof (FSpot.Imaging.Tiff.Cr2File);
            name_table ["image/dng"] = name_table ["image/x-adobe-dng"] = name_table [".dng"] = typeof (FSpot.Imaging.Tiff.DngFile);
            name_table ["image/nef"] = name_table ["image/x-nikon-nef"] = name_table [".nef"] = nef_type;
            name_table ["image/rw2"] = name_table ["image/x-raw"] = name_table [".rw2"] = raw_type;

            // Other types (FIXME: Currently unsupported by Taglib#, this list should shrink).
            name_table [".pef"] = nef_type;
            name_table [".raw"] = typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".kdc"] = typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".rw2"] = typeof (FSpot.Imaging.DCRawFile);
            name_table [".orf"] =  typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".srf"] = typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".crw"] = typeof (FSpot.Imaging.Ciff.CiffFile);
            name_table [".mrw"] = typeof (FSpot.Imaging.DCRawFile);
            name_table [".raf"] = typeof (FSpot.Imaging.Raf.RafFile);
            name_table [".x3f"] = typeof (FSpot.Imaging.DCRawFile);
            name_table ["image/x-dcraw"] = name_table [".raw"];
            name_table ["image/x-ciff"]  = name_table [".crw"];
            name_table ["image/x-mrw"]   = name_table [".mrw"];
            name_table ["image/x-x3f"]   = name_table [".x3f"];
            name_table ["image/x-orf"]   = name_table [".orf"];
            name_table ["image/x-raf"]   = name_table [".raf"];

            // as xcf pixbufloader is not part of gdk-pixbuf, check if it's there,
            // and enable it if needed.<commit_msg>Add mime mappings for PEF.<commit_after>using Hyena;

using System;
using System.IO;
using System.Collections.Generic;

using FSpot.Utils;
using Mono.Unix;
using Mono.Unix.Native;
using Gdk;

using GLib;
using TagLib.Image;

using GFileInfo = GLib.FileInfo;

namespace FSpot.Imaging {
	public class ImageFormatException : ApplicationException {
		public ImageFormatException (string msg) : base (msg)
		{
		}
	}

	public static class ImageFile {

#region Factory functionality

		static Dictionary<string, Type> name_table;
		internal static Dictionary<string, Type> NameTable { get { return name_table; } }

        static ImageFile ()
        {
            var base_type = typeof (BaseImageFile);
            var raw_type = typeof (DCRawFile);
            var nef_type = typeof (FSpot.Imaging.Tiff.NefFile);

            name_table = new Dictionary<string, Type> ();

            // Plain image files
            name_table ["image/gif"] = name_table [".gif"] = base_type;
            name_table ["image/x-pcx"] = name_table [".pcx"] = base_type;
            name_table ["image/x-portable-anymap"] = name_table [".pnm"] = base_type;
            name_table ["image/x-portable-bitmap"] = name_table [".pbm"] = base_type;
            name_table ["image/x-portable-graymap"] = name_table [".pgm"] = base_type;
            name_table ["image/x-portable-pixmap"] = name_table [".ppm"] = base_type;
            name_table ["image/x-bmp"] = name_table ["image/x-MS-bmp"] = name_table [".bmp"] = base_type;
            name_table ["image/jpeg"] = name_table [".jfi"] = name_table [".jfif"] = name_table [".jif"] = name_table [".jpe"] = name_table [".jpeg"] = name_table [".jpg"] = base_type;
            name_table ["image/png"] = name_table [".png"] = base_type;
            name_table ["image/tiff"] = name_table [".tif"] = name_table [".tiff"] = base_type;
            name_table ["image/svg+xml"] = name_table [".svg"] = name_table [".svgz"] = base_type;

            // RAW files
            name_table ["image/arw"] = name_table ["image/x-sony-arw"] = name_table [".arw"] = nef_type;
            name_table ["image/cr2"] = name_table ["image/x-canon-cr2"] = name_table [".cr2"] = typeof (FSpot.Imaging.Tiff.Cr2File);
            name_table ["image/dng"] = name_table ["image/x-adobe-dng"] = name_table [".dng"] = typeof (FSpot.Imaging.Tiff.DngFile);
            name_table ["image/nef"] = name_table ["image/x-nikon-nef"] = name_table [".nef"] = nef_type;
            name_table ["image/rw2"] = name_table ["image/x-raw"] = name_table [".rw2"] = raw_type;
            name_table ["image/pef"] = name_table ["image/x-pentax-pef"] = name_table [".pef"] = nef_type;

            // Other types (FIXME: Currently unsupported by Taglib#, this list should shrink).
            name_table [".raw"] = typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".kdc"] = typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".rw2"] = typeof (FSpot.Imaging.DCRawFile);
            name_table [".orf"] =  typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".srf"] = typeof (FSpot.Imaging.Tiff.NefFile);
            name_table [".crw"] = typeof (FSpot.Imaging.Ciff.CiffFile);
            name_table [".mrw"] = typeof (FSpot.Imaging.DCRawFile);
            name_table [".raf"] = typeof (FSpot.Imaging.Raf.RafFile);
            name_table [".x3f"] = typeof (FSpot.Imaging.DCRawFile);
            name_table ["image/x-dcraw"] = name_table [".raw"];
            name_table ["image/x-ciff"]  = name_table [".crw"];
            name_table ["image/x-mrw"]   = name_table [".mrw"];
            name_table ["image/x-x3f"]   = name_table [".x3f"];
            name_table ["image/x-orf"]   = name_table [".orf"];
            name_table ["image/x-raf"]   = name_table [".raf"];

            // as xcf pixbufloader is not part of gdk-pixbuf, check if it's there,
            // and enable it if needed.
{'fraction_non_alphanumeric': 0.15850181441161224, 'fraction_numerical': 0.002592016588906169, 'mean_word_length': 2.62640977443609, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2816961', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2598, 'n_words': 559}