# Path: ugali/utils/logger.py
# class SpecialFormatter(logging.Formatter):
#     FORMATS = {'DEFAULT'       : "%(message)s",
#                logging.WARNING : "WARNING: %(message)s",
#                logging.ERROR   : "ERROR: %(message)s"}
#     def format(self, record):
# def file_found(filename,force):


import os,sys
import pprint
import copy
import glob
import numpy as np
import healpy as hp
import yaml
import ugali.utils.config # To recognize own type
from os.path import join, exists
from collections import OrderedDict as odict
from ugali.utils.logger import logger
from ugali.utils.mlab import isstring
        Provides functionality to merge with a default configuration.

        Parameters:
          config:   filename, dict, or Config object (deep copied)
          default:  default configuration to merge
        
        Returns:
          config
        """
        self.update(self._load(default))
        self.update(self._load(config))

        self._formatFilepaths()

        # For back-compatibility...
        self.params = self

        # Run some basic validation
        # ADW: This should be run after creating filenames
        self._validate()

        # Filenames from this config (masked by existence) 
        # ADW: We should not recreate filenames if they already exist
        # in the input config
        if not hasattr(self,'filenames'):
            try:
                self.filenames = self._createFilenames()
            except:
                exc_type,exc_value,exc_traceback = sys.exc_info()
                logger.warning("%s %s"%(exc_type,exc_value))

# Path: ugali/utils/logger.py
# class SpecialFormatter(logging.Formatter):
#     FORMATS = {'DEFAULT'       : "%(message)s",
#                logging.WARNING : "WARNING: %(message)s",
#                logging.ERROR   : "ERROR: %(message)s"}
#     def format(self, record):
# def file_found(filename,force):


# Path: ugali/utils/config.py
import os,sys
import pprint
import copy
import glob
import numpy as np
import healpy as hp
import yaml
import ugali.utils.config # To recognize own type
from os.path import join, exists
from collections import OrderedDict as odict
from ugali.utils.logger import logger
from ugali.utils.mlab import isstring

        Provides functionality to merge with a default configuration.

        Parameters:
          config:   filename, dict, or Config object (deep copied)
          default:  default configuration to merge
        
        Returns:
          config
        """
        self.update(self._load(default))
        self.update(self._load(config))

        self._formatFilepaths()

        # For back-compatibility...
        self.params = self

        # Run some basic validation
        # ADW: This should be run after creating filenames
        self._validate()

        # Filenames from this config (masked by existence) 
        # ADW: We should not recreate filenames if they already exist
        # in the input config
        if not hasattr(self,'filenames'):
            try:
                self.filenames = self._createFilenames()
            except:
                exc_type,exc_value,exc_traceback = sys.exc_info()
                logger.warning("%s %s"%(exc_type,exc_value))

                logger.warning("Filenames could not be created for config.")