# Path: pergola/_version.py

# 
# Path: pergola/mapping.py
# def check_path(path):
#     """ 
#     Check whether the input file exists and is accessible and if OK returns path
#     
#     :param path: path to the intervals file
#     
#     :returns: the path assessed
#     
#     """
# 
#     assert isinstance(path, str), "Expected string or unicode, found %s." % type(path)
#     try:
#         f = open(path, "r")
#     except IOError:
#         raise IOError('File does not exist: %s' % path)
#     finally:
#         f.close()
#     return path      


from ._version  import __version__
from sys       import stderr
from argparse  import ArgumentParser, ArgumentTypeError
from re        import match
from os.path   import abspath, split, realpath
from .mapping   import check_path
    
    tracks2merge = ""
    
    if track_action == "join_all":
        tracks2merge = tracks
    elif track_action == 'join_odd':
        tracks2merge = set([t for t in tracks if int(t) % 2])
    elif track_action == 'join_even':
        tracks2merge = set([t for t in tracks if not int(t) % 2])
    else:
        tracks2merge = ""
        
    print("Tracks to merge are: ", ",".join("'{0}'".format(t) for t in tracks2merge), file=stderr)
       
    if not tracks2merge:
        print(("No track action applied as track actions \'%s\' can not be applied to list of tracks provided \'%s\'"%(track_action, " ".join(tracks))), file=stderr)
        
    return (tracks2merge)


def read_colors (path_color_file):
    """     
    Reads user colors for each data_type  
    
    :param None path_color_file: :py:func:`str` path to read user color for data_types     
       
    :returns: d_user_color dictionary {'data_type_1': 'orange', 'data_type_2':'blue'}
    
    """


# Path: pergola/_version.py

# 
# Path: pergola/mapping.py
# def check_path(path):
#     """ 
#     Check whether the input file exists and is accessible and if OK returns path
#     
#     :param path: path to the intervals file
#     
#     :returns: the path assessed
#     
#     """
# 
#     assert isinstance(path, str), "Expected string or unicode, found %s." % type(path)
#     try:
#         f = open(path, "r")
#     except IOError:
#         raise IOError('File does not exist: %s' % path)
#     finally:
#         f.close()
#     return path      


# Path: pergola/parsers.py
from ._version  import __version__
from sys       import stderr
from argparse  import ArgumentParser, ArgumentTypeError
from re        import match
from os.path   import abspath, split, realpath
from .mapping   import check_path

    
    tracks2merge = ""
    
    if track_action == "join_all":
        tracks2merge = tracks
    elif track_action == 'join_odd':
        tracks2merge = set([t for t in tracks if int(t) % 2])
    elif track_action == 'join_even':
        tracks2merge = set([t for t in tracks if not int(t) % 2])
    else:
        tracks2merge = ""
        
    print("Tracks to merge are: ", ",".join("'{0}'".format(t) for t in tracks2merge), file=stderr)
       
    if not tracks2merge:
        print(("No track action applied as track actions \'%s\' can not be applied to list of tracks provided \'%s\'"%(track_action, " ".join(tracks))), file=stderr)
        
    return (tracks2merge)


def read_colors (path_color_file):
    """     
    Reads user colors for each data_type  
    
    :param None path_color_file: :py:func:`str` path to read user color for data_types     
       
    :returns: d_user_color dictionary {'data_type_1': 'orange', 'data_type_2':'blue'}
    
    """


    check_path(path_color_file)