# Path: epymc/ini.py
# def read_from_files(files):
# def write_to_file(file):
# def setup_defaults():
# def add_section(section):
# def has_section(section):
# def has_option(section, option):
# def has_options(options):
# def get_options(section):
# def get(section, option, default_value=None):
# def get_string_list(section, option, separator=' '):
# def get_int(section, option):
# def get_float(section, option):
# def get_bool(section, option):
# def get_string(section, option):
# def set(section, option, value):
# def set_string_list(section, option, values, separator=' '):
# def remove_option(section, option):
# 
# Path: epymc/utils.py
#     XDG_CONFIG_HOME = ''
#     XDG_CACHE_HOME = ''
# def LOG(*args):
# def DBG(msg):
# def iso639_1_to_3(iso1):
# def iso639_1_to_5(iso1):
# def is_py3():
# def is_py2():
# def get_resource_file(res_type, res_name, default=None):
# def get_available_themes():
# def in_use_theme_file_set(theme_file):
# def url2path(url):
# def hum_size(bites):
# def seconds_to_duration(seconds, hours=False):
# def splitpath(path):
# def ensure_file_not_exists(fullpath):
# def md5(txt):
# def user_name():
# def natural_sort(li):
# def natural_cmp(a, b):
# def grab_files(folders, show_hidden=False, recursive=True):
# def download_url_async(url, dest='tmp', min_size=0,
#                        complete_cb=None, progress_cb=None,
#                        urlencode=True, *args, **kargs):
#     def _cb_download_complete(dest, status, dwl_data, *args, **kargs):
#     def _cb_download_progress(dest, dltotal, dlnow, uptotal, upnow, dwl_data, *args, **kargs):
# def download_abort(dwl_handler):
# def http_error_code_to_str(code):
# def distance_between_point_and_segment(point, segment_p1, segment_p2, real=False):
#     def __new__(cls, *args, **kwargs):
#     def __init__(self, cmd, grab_output=False, done_cb=None, *args, **kargs):
#     def data_cb(self, exe, event):
#     def del_cb(self, exe, event):
#     def __init__(self, url, done_cb=None, prog_cb=None, headers=None, **kargs):
#     def _complete_cb(self, event):
#     def _data_cb(self, event):
# class Singleton(object):
# class EmcExec(object):
# class EmcUrl(ecore_con.Url):


import sys
import os
import traceback
from epymc import ini
from epymc import utils

def is_enabled(name):
    return name in _instances


def init_by_name(name):
    for mod in EmcModule.__subclasses__():
        if mod.name == name:
            if name not in _instances:
                try:
                    _instances[name] = mod()
                except:
                    traceback.print_exc()


def init_all():
    for mod in EmcModule.__subclasses__():
        if mod.name not in _instances:
            _instances[mod.name] = mod()


def init_all_by_config():
    if not ini.has_option('general', 'modules'):
        ini.set('general', 'modules', DEFAULT_MODS)

    for modname in ini.get_string_list('general', 'modules'):
        init_by_name(modname)


def save_enabled():

# Path: epymc/ini.py
# def read_from_files(files):
# def write_to_file(file):
# def setup_defaults():
# def add_section(section):
# def has_section(section):
# def has_option(section, option):
# def has_options(options):
# def get_options(section):
# def get(section, option, default_value=None):
# def get_string_list(section, option, separator=' '):
# def get_int(section, option):
# def get_float(section, option):
# def get_bool(section, option):
# def get_string(section, option):
# def set(section, option, value):
# def set_string_list(section, option, values, separator=' '):
# def remove_option(section, option):
# 
# Path: epymc/utils.py
#     XDG_CONFIG_HOME = ''
#     XDG_CACHE_HOME = ''
# def LOG(*args):
# def DBG(msg):
# def iso639_1_to_3(iso1):
# def iso639_1_to_5(iso1):
# def is_py3():
# def is_py2():
# def get_resource_file(res_type, res_name, default=None):
# def get_available_themes():
# def in_use_theme_file_set(theme_file):
# def url2path(url):
# def hum_size(bites):
# def seconds_to_duration(seconds, hours=False):
# def splitpath(path):
# def ensure_file_not_exists(fullpath):
# def md5(txt):
# def user_name():
# def natural_sort(li):
# def natural_cmp(a, b):
# def grab_files(folders, show_hidden=False, recursive=True):
# def download_url_async(url, dest='tmp', min_size=0,
#                        complete_cb=None, progress_cb=None,
#                        urlencode=True, *args, **kargs):
#     def _cb_download_complete(dest, status, dwl_data, *args, **kargs):
#     def _cb_download_progress(dest, dltotal, dlnow, uptotal, upnow, dwl_data, *args, **kargs):
# def download_abort(dwl_handler):
# def http_error_code_to_str(code):
# def distance_between_point_and_segment(point, segment_p1, segment_p2, real=False):
#     def __new__(cls, *args, **kwargs):
#     def __init__(self, cmd, grab_output=False, done_cb=None, *args, **kargs):
#     def data_cb(self, exe, event):
#     def del_cb(self, exe, event):
#     def __init__(self, url, done_cb=None, prog_cb=None, headers=None, **kargs):
#     def _complete_cb(self, event):
#     def _data_cb(self, event):
# class Singleton(object):
# class EmcExec(object):
# class EmcUrl(ecore_con.Url):


# Path: epymc/modules.py
import sys
import os
import traceback
from epymc import ini
from epymc import utils


def is_enabled(name):
    return name in _instances


def init_by_name(name):
    for mod in EmcModule.__subclasses__():
        if mod.name == name:
            if name not in _instances:
                try:
                    _instances[name] = mod()
                except:
                    traceback.print_exc()


def init_all():
    for mod in EmcModule.__subclasses__():
        if mod.name not in _instances:
            _instances[mod.name] = mod()


def init_all_by_config():
    if not ini.has_option('general', 'modules'):
        ini.set('general', 'modules', DEFAULT_MODS)

    for modname in ini.get_string_list('general', 'modules'):
        init_by_name(modname)


def save_enabled():

    ini.set('general', 'modules', ' '.join(_instances.keys()))