# Path: mediahandler/util/config.py
# def make_config(new_file=None):
#     """Generates default yaml mediahandler configuration file.
# 
#     Optional argument:
#         - new_file
#             Path to a yaml mediahandler configuration file. Will
#             verify that the file exists and is readable.
#     """
# 
#     # Set default path
#     config_file = os.path.join(os.path.expanduser("~"),
#                                '.config', 'mediahandler', 'config.yml')
# 
#     # Validate config
#     if new_file and not isinstance(new_file, str):
#         raise TypeError('argument should be a string file path')
# 
#     # Check for user-provided path
#     if new_file is not None:
#         config_file = new_file
# 
#     # Check that config exists
#     if os.path.isfile(config_file) and not os.access(config_file, os.R_OK):
#         raise Warning('Configuration file cannot be opened')
# 
#     # Copy default config to user file
#     default_config = os.path.join(mh.__mediaextras__, 'config.yml')
# 
#     # Make directories for config file
#     config_path = os.path.dirname(config_file)
#     if not os.path.exists(config_path):
#         os.makedirs(config_path)
#         if not mh.__iswin__:
#             os.chmod(config_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IXOTH)
# 
#     # Copy new configuration file to path
#     shutil.copy(default_config, config_file)
# 
#     # Modify default config values for windows
#     if mh.__iswin__:
#         _modify_config_for_windows(config_file)
# 
#     # Change permissions to current user if sudo
#     if 'SUDO_UID' in os.environ.keys():
#         with os.open(config_file, os.O_RDONLY) as filed:
#             os.fchown(filed, int(os.environ['SUDO_UID']), -1)
# 
#     return config_file
# 
# def parse_config(file_path):
#     """Reads and parses a yaml mediahandler configuration file.
# 
#     Optional argument:
#         - file_path
#             Path to a valid yaml mediahandler configuration file.
# 
#     Uses settings.yml validation structure to build missing and default
#     values. Sends values to the correct _get_valid_<type>() function
#     for validation.
#     """
# 
#     # Read yaml files
#     parsed = _get_yaml(file_path)
#     struct = _get_yaml(os.path.join(mh.__mediaextras__, 'settings.yml'))
# 
#     # Loop through config & validate
#     settings = {}
#     for item in struct['items']:
#         section = item['section']
# 
#         # Populate hash
#         settings[section] = _process_section(
#             section, item['options'], parsed)
# 
#     # Check that appropriate modules are installed
#     _check_modules(settings)
# 
#     return settings


import re
import sys
import logging
import mediahandler as mh
import mediahandler.util.args as args
import mediahandler.util.notify as notify
        import mediahandler.util.extract as extract
from shutil import rmtree
from os import path, listdir, remove
from mediahandler.util.config import make_config, parse_config
    """
    media = None
    name = None
    stype = None
    general = None
    query = None
    notifications = None

    tv = None
    music = None
    movies = None
    audiobooks = None

    def __init__(self, config):
        """Initialize the MHandler class.

        Required argument:

            - config
                Full path to valid mediahandler configuration file.
                A default file available for customization is located here: ::

                  ~/.config/mediahandler/config.yml
        """

        # Set up args via super
        super(MHandler, self).__init__(config)

        # Extract settings from config
        self.config = make_config(config)

# Path: mediahandler/util/config.py
# def make_config(new_file=None):
#     """Generates default yaml mediahandler configuration file.
# 
#     Optional argument:
#         - new_file
#             Path to a yaml mediahandler configuration file. Will
#             verify that the file exists and is readable.
#     """
# 
#     # Set default path
#     config_file = os.path.join(os.path.expanduser("~"),
#                                '.config', 'mediahandler', 'config.yml')
# 
#     # Validate config
#     if new_file and not isinstance(new_file, str):
#         raise TypeError('argument should be a string file path')
# 
#     # Check for user-provided path
#     if new_file is not None:
#         config_file = new_file
# 
#     # Check that config exists
#     if os.path.isfile(config_file) and not os.access(config_file, os.R_OK):
#         raise Warning('Configuration file cannot be opened')
# 
#     # Copy default config to user file
#     default_config = os.path.join(mh.__mediaextras__, 'config.yml')
# 
#     # Make directories for config file
#     config_path = os.path.dirname(config_file)
#     if not os.path.exists(config_path):
#         os.makedirs(config_path)
#         if not mh.__iswin__:
#             os.chmod(config_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IXOTH)
# 
#     # Copy new configuration file to path
#     shutil.copy(default_config, config_file)
# 
#     # Modify default config values for windows
#     if mh.__iswin__:
#         _modify_config_for_windows(config_file)
# 
#     # Change permissions to current user if sudo
#     if 'SUDO_UID' in os.environ.keys():
#         with os.open(config_file, os.O_RDONLY) as filed:
#             os.fchown(filed, int(os.environ['SUDO_UID']), -1)
# 
#     return config_file
# 
# def parse_config(file_path):
#     """Reads and parses a yaml mediahandler configuration file.
# 
#     Optional argument:
#         - file_path
#             Path to a valid yaml mediahandler configuration file.
# 
#     Uses settings.yml validation structure to build missing and default
#     values. Sends values to the correct _get_valid_<type>() function
#     for validation.
#     """
# 
#     # Read yaml files
#     parsed = _get_yaml(file_path)
#     struct = _get_yaml(os.path.join(mh.__mediaextras__, 'settings.yml'))
# 
#     # Loop through config & validate
#     settings = {}
#     for item in struct['items']:
#         section = item['section']
# 
#         # Populate hash
#         settings[section] = _process_section(
#             section, item['options'], parsed)
# 
#     # Check that appropriate modules are installed
#     _check_modules(settings)
# 
#     return settings


# Path: mediahandler/handler.py
import re
import sys
import logging
import mediahandler as mh
import mediahandler.util.args as args
import mediahandler.util.notify as notify
        import mediahandler.util.extract as extract
from shutil import rmtree
from os import path, listdir, remove
from mediahandler.util.config import make_config, parse_config

    """
    media = None
    name = None
    stype = None
    general = None
    query = None
    notifications = None

    tv = None
    music = None
    movies = None
    audiobooks = None

    def __init__(self, config):
        """Initialize the MHandler class.

        Required argument:

            - config
                Full path to valid mediahandler configuration file.
                A default file available for customization is located here: ::

                  ~/.config/mediahandler/config.yml
        """

        # Set up args via super
        super(MHandler, self).__init__(config)

        # Extract settings from config
        self.config = make_config(config)

        self.set_settings(parse_config(self.config))