# Path: ciao_contrib/logger_wrapper.py
# def initialize_module_logger(name):
#     """Create a logger for the module with an id of name.
# 
#     Returns the logger. Unlike initialize_logger, no handler
#     is set up.
# 
#     """
# 
#     return get_module_logger(name)


import os
import sys
import time
import numpy as np
import cxcdm as dm
from collections import namedtuple
from ciao_contrib.logger_wrapper import initialize_module_logger


def open_block_from_file(filename):
    """Open the file, returning the block"""

    v5("Opening file {0}".format(filename))
    try:
        bl = tableOpen(filename)

    except IOError:
        v5("  -- not a table, try an image")

        try:
            bl = imageOpen(filename)

        except IOError as ie:
            v5("  -- not an image")
            raise IOError("Unable to open infile='{0}'\n  {1}".format(filename, str(ie)))

    return bl


def close_block(bl):
    """This used to work around a bug in the S-Lang module; should
    not be needed in Python but left in for old code."""

    v5("Closing block '{0}'".format(blockGetName(bl)))
    blockClose(bl)



# Path: ciao_contrib/logger_wrapper.py
# def initialize_module_logger(name):
#     """Create a logger for the module with an id of name.
# 
#     Returns the logger. Unlike initialize_logger, no handler
#     is set up.
# 
#     """
# 
#     return get_module_logger(name)


# Path: ciao_contrib/cxcdm_wrapper.py
import os
import sys
import time
import numpy as np
import cxcdm as dm
from collections import namedtuple
from ciao_contrib.logger_wrapper import initialize_module_logger



def open_block_from_file(filename):
    """Open the file, returning the block"""

    v5("Opening file {0}".format(filename))
    try:
        bl = tableOpen(filename)

    except IOError:
        v5("  -- not a table, try an image")

        try:
            bl = imageOpen(filename)

        except IOError as ie:
            v5("  -- not an image")
            raise IOError("Unable to open infile='{0}'\n  {1}".format(filename, str(ie)))

    return bl


def close_block(bl):
    """This used to work around a bug in the S-Lang module; should
    not be needed in Python but left in for old code."""

    v5("Closing block '{0}'".format(blockGetName(bl)))
    blockClose(bl)



def get_block_info(bl):