<commit_before>#
# rgb_cms.py -- RGB color management handling.
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#

import os
import glob
import hashlib
import numpy as np

from ginga.misc import Bunch

from . import paths

# How about color management (ICC profile) support?
try:
    import PIL.ImageCms as ImageCms
    from PIL import Image
    have_cms = True
except ImportError:
    have_cms = False

basedir = paths.ginga_home

# Holds profiles
profile = {}
rendering_intent = 'perceptual'
intents = dict(perceptual=0)

# The working profile, if there is one
working_profile = None

# Holds transforms
icc_transform = {}


class ColorManagerError(Exception):
    pass


class ColorManager(object):

    def __init__(self, logger):
        self.logger = logger

    def can_profile(self):
        return have_cms

    def profile_to_working_pil(self, image_pil, kwds, intent=None):

        image = image_pil

        # If we have a working color profile then handle any embedded
        # profile or color space information, if possible
        if not have_cms:
            self.logger.warning(
                "No CMS is installed; leaving image unprofiled.")
            return image

        if not have_profile(working_profile):
            self.logger.warning(
                "No working profile defined; leaving image unprofiled.")
            return image

        out_profile = profile[working_profile].name

        if not os.path.exists(profile[out_profile].path):
            self.logger.warning(
                "Working profile '%s' (%s) not found; leaving image "
                "unprofiled." % (out_profile, profile[out_profile].path))
            return image<commit_msg>Downgrade rgb_cms warnings to info<commit_after>#
# rgb_cms.py -- RGB color management handling.
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#

import os
import glob
import hashlib
import numpy as np

from ginga.misc import Bunch

from . import paths

# How about color management (ICC profile) support?
try:
    import PIL.ImageCms as ImageCms
    from PIL import Image
    have_cms = True
except ImportError:
    have_cms = False

basedir = paths.ginga_home

# Holds profiles
profile = {}
rendering_intent = 'perceptual'
intents = dict(perceptual=0)

# The working profile, if there is one
working_profile = None

# Holds transforms
icc_transform = {}


class ColorManagerError(Exception):
    pass


class ColorManager(object):

    def __init__(self, logger):
        self.logger = logger

    def can_profile(self):
        return have_cms

    def profile_to_working_pil(self, image_pil, kwds, intent=None):

        image = image_pil

        # If we have a working color profile then handle any embedded
        # profile or color space information, if possible
        if not have_cms:
            self.logger.info(
                "No CMS is installed; leaving image unprofiled.")
            return image

        if not have_profile(working_profile):
            self.logger.info(
                "No working profile defined; leaving image unprofiled.")
            return image

        out_profile = profile[working_profile].name

        if not os.path.exists(profile[out_profile].path):
            self.logger.info(
                "Working profile '%s' (%s) not found; leaving image "
                "unprofiled." % (out_profile, profile[out_profile].path))
            return image
{'fraction_non_alphanumeric': 0.07325383304940375, 'fraction_numerical': 0.0005678591709256105, 'mean_word_length': 2.650777202072539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4586699', 'n_tokens_mistral': 1020, 'n_tokens_neox': 957, 'n_words': 335}