# Path: lib/io.py
# def load_python_file(path):
#     return SourceFileLoader("", path).load_module()
# 
# Path: lib/helpers.py
# def mergedicts(a, b, path=None):
#     "merges b into a"
#     if path is None:
#         path = []
# 
#     for key in b:
#         if key in a:
#             if isinstance(a[key], dict) and isinstance(b[key], dict):
#                 mergedicts(a[key], b[key], path + [str(key)])
#             elif a[key] == b[key]:
#                 pass  # same leaf value
#             else:
#                 a[key] = b[key]
#         else:
#             a[key] = b[key]
#     return a


import itertools
import os
import shutil
import zipfile
from .io import load_python_file
from .helpers import mergedicts
    collected_config = {}
    user_config = {}
    is_zip = False
    zip_file = None

    def __init__(self, sublimious_dir, user_dir=None):
        self.layers = []
        self.commands = []
        self.collected_config = {}
        self.user_config = {}
        self.is_zip = False
        self.zip_file = None

        if "sublime-package" in sublimious_dir:
            self.is_zip = True
            self.zip_file = zipfile.ZipFile(sublimious_dir)

        config_path = os.path.expanduser("~/.sublimious")
        if not os.path.exists(config_path):
            if self.is_zip:
                templ = self.zip_file.open("templates/.sublimious")
                target = open(config_path, "wb")
                shutil.copyfileobj(templ, target)
                target.close()
            else:
                template_path = "%s/%s" % (sublimious_dir, "templates/.sublimious")
                shutil.copyfile(template_path, config_path)

            print("[sublimious] no config found. Copied template.")


# Path: lib/io.py
# def load_python_file(path):
#     return SourceFileLoader("", path).load_module()
# 
# Path: lib/helpers.py
# def mergedicts(a, b, path=None):
#     "merges b into a"
#     if path is None:
#         path = []
# 
#     for key in b:
#         if key in a:
#             if isinstance(a[key], dict) and isinstance(b[key], dict):
#                 mergedicts(a[key], b[key], path + [str(key)])
#             elif a[key] == b[key]:
#                 pass  # same leaf value
#             else:
#                 a[key] = b[key]
#         else:
#             a[key] = b[key]
#     return a


# Path: lib/collector.py
import itertools
import os
import shutil
import zipfile
from .io import load_python_file
from .helpers import mergedicts

    collected_config = {}
    user_config = {}
    is_zip = False
    zip_file = None

    def __init__(self, sublimious_dir, user_dir=None):
        self.layers = []
        self.commands = []
        self.collected_config = {}
        self.user_config = {}
        self.is_zip = False
        self.zip_file = None

        if "sublime-package" in sublimious_dir:
            self.is_zip = True
            self.zip_file = zipfile.ZipFile(sublimious_dir)

        config_path = os.path.expanduser("~/.sublimious")
        if not os.path.exists(config_path):
            if self.is_zip:
                templ = self.zip_file.open("templates/.sublimious")
                target = open(config_path, "wb")
                shutil.copyfileobj(templ, target)
                target.close()
            else:
                template_path = "%s/%s" % (sublimious_dir, "templates/.sublimious")
                shutil.copyfile(template_path, config_path)

            print("[sublimious] no config found. Copied template.")


        config_file = load_python_file(config_path)