We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Base media skill is loaded as a normal skill
At the moment, the load_skills function tries to load the media skill as if it is a normal skill. 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mycroft/skills/core.py`
Content:
```
1 # Copyright 2016 Mycroft AI, Inc.
2 #
3 # This file is part of Mycroft Core.
4 #
5 # Mycroft Core is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Mycroft Core is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.
17 
18 
19 import imp
20 import time
21 
22 import abc
23 import os.path
24 import re
25 from adapt.intent import Intent
26 from os.path import join, dirname, splitext, isdir
27 
28 from mycroft.client.enclosure.api import EnclosureAPI
29 from mycroft.configuration import ConfigurationManager
30 from mycroft.dialog import DialogLoader
31 from mycroft.filesystem import FileSystemAccess
32 from mycroft.messagebus.message import Message
33 from mycroft.util.log import getLogger
34 
35 __author__ = 'seanfitz'
36 
37 PRIMARY_SKILLS = ['intent', 'wake']
38 BLACKLISTED_SKILLS = ["send_sms"]
39 SKILLS_BASEDIR = dirname(__file__)
40 THIRD_PARTY_SKILLS_DIR = "/opt/mycroft/third_party"
41 
42 MainModule = '__init__'
43 
44 logger = getLogger(__name__)
45 
46 
47 def load_vocab_from_file(path, vocab_type, emitter):
48     with open(path, 'r') as voc_file:
49         for line in voc_file.readlines():
50             parts = line.strip().split("|")
51             entity = parts[0]
52 
53             emitter.emit(
54                 Message("register_vocab",
55                         metadata={'start': entity, 'end': vocab_type}))
56             for alias in parts[1:]:
57                 emitter.emit(
58                     Message("register_vocab",
59                             metadata={'start': alias, 'end': vocab_type,
60                                       'alias_of': entity}))
61 
62 
63 def load_regex_from_file(path, emitter):
64     if(path.endswith('.rx')):
65         with open(path, 'r') as reg_file:
66             for line in reg_file.readlines():
67                 re.compile(line.strip())
68                 emitter.emit(
69                     Message("register_vocab",
70                             metadata={'regex': line.strip()}))
71 
72 
73 def load_vocabulary(basedir, emitter):
74     for vocab_type in os.listdir(basedir):
75         load_vocab_from_file(
76             join(basedir, vocab_type), splitext(vocab_type)[0], emitter)
77 
78 
79 def load_regex(basedir, emitter):
80     for regex_type in os.listdir(basedir):
81         if regex_type.endswith(".rx"):
82             load_regex_from_file(
83                 join(basedir, regex_type), emitter)
84 
85 
86 def create_intent_envelope(intent):
87     return Message(None, metadata=intent.__dict__, context={})
88 
89 
90 def open_intent_envelope(message):
91     intent_dict = message.metadata
92     return Intent(intent_dict.get('name'),
93                   intent_dict.get('requires'),
94                   intent_dict.get('at_least_one'),
95                   intent_dict.get('optional'))
96 
97 
98 def load_skill(skill_descriptor, emitter):
99     try:
100         skill_module = imp.load_module(
101             skill_descriptor["name"] + MainModule, *skill_descriptor["info"])
102         if (hasattr(skill_module, 'create_skill') and
103                 callable(skill_module.create_skill)):
104             # v2 skills framework
105             skill = skill_module.create_skill()
106             skill.bind(emitter)
107             skill.initialize()
108             return skill
109         else:
110             logger.warn(
111                 "Module %s does not appear to be skill" % (
112                     skill_descriptor["name"]))
113     except:
114         logger.error(
115             "Failed to load skill: " + skill_descriptor["name"], exc_info=True)
116     return None
117 
118 
119 def get_skills(skills_folder):
120     skills = []
121     possible_skills = os.listdir(skills_folder)
122     for i in possible_skills:
123         location = join(skills_folder, i)
124         if (not isdir(location) or
125                 not MainModule + ".py" in os.listdir(location)):
126             continue
127 
128         skills.append(create_skill_descriptor(location))
129     skills = sorted(skills, key=lambda p: p.get('name'))
130     return skills
131 
132 
133 def create_skill_descriptor(skill_folder):
134     info = imp.find_module(MainModule, [skill_folder])
135     return {"name": os.path.basename(skill_folder), "info": info}
136 
137 
138 def load_skills(emitter, skills_root=SKILLS_BASEDIR):
139     skills = get_skills(skills_root)
140     for skill in skills:
141         if skill['name'] in PRIMARY_SKILLS:
142             load_skill(skill, emitter)
143 
144     for skill in skills:
145         if (skill['name'] not in PRIMARY_SKILLS and
146                 skill['name'] not in BLACKLISTED_SKILLS):
147             load_skill(skill, emitter)
148 
149 
150 class MycroftSkill(object):
151     """
152     Abstract base class which provides common behaviour and parameters to all
153     Skills implementation.
154     """
155 
156     def __init__(self, name, emitter=None):
157         self.name = name
158         self.bind(emitter)
159         config = ConfigurationManager.get()
160         self.config = config.get(name)
161         self.config_core = config.get('core')
162         self.dialog_renderer = None
163         self.file_system = FileSystemAccess(join('skills', name))
164         self.registered_intents = []
165 
166     @property
167     def location(self):
168         return self.config_core.get('location')
169 
170     @property
171     def lang(self):
172         return self.config_core.get('lang')
173 
174     def bind(self, emitter):
175         if emitter:
176             self.emitter = emitter
177             self.enclosure = EnclosureAPI(emitter)
178             self.__register_stop()
179 
180     def __register_stop(self):
181         self.stop_time = time.time()
182         self.stop_threshold = self.config_core.get('stop_threshold')
183         self.emitter.on('mycroft.stop', self.__handle_stop)
184 
185     def detach(self):
186         for name in self.registered_intents:
187             self.emitter.emit(
188                 Message("detach_intent", metadata={"intent_name": name}))
189 
190     def initialize(self):
191         """
192         Initialization function to be implemented by all Skills.
193 
194         Usually used to create intents rules and register them.
195         """
196         raise Exception("Initialize not implemented for skill: " + self.name)
197 
198     def register_intent(self, intent_parser, handler):
199         intent_message = create_intent_envelope(intent_parser)
200         intent_message.message_type = "register_intent"
201         self.emitter.emit(intent_message)
202         self.registered_intents.append(intent_parser.name)
203 
204         def receive_handler(message):
205             try:
206                 handler(message)
207             except:
208                 # TODO: Localize
209                 self.speak(
210                     "An error occurred while processing a request in " +
211                     self.name)
212                 logger.error(
213                     "An error occurred while processing a request in " +
214                     self.name, exc_info=True)
215 
216         self.emitter.on(intent_parser.name, receive_handler)
217 
218     def register_vocabulary(self, entity, entity_type):
219         self.emitter.emit(
220             Message('register_vocab',
221                     metadata={'start': entity, 'end': entity_type}))
222 
223     def register_regex(self, regex_str):
224         re.compile(regex_str)  # validate regex
225         self.emitter.emit(
226             Message('register_vocab', metadata={'regex': regex_str}))
227 
228     def speak(self, utterance):
229         self.emitter.emit(Message("speak", metadata={'utterance': utterance}))
230 
231     def speak_dialog(self, key, data={}):
232         self.speak(self.dialog_renderer.render(key, data))
233 
234     def init_dialog(self, root_directory):
235         self.dialog_renderer = DialogLoader().load(
236             join(root_directory, 'dialog', self.lang))
237 
238     def load_data_files(self, root_directory):
239         self.init_dialog(root_directory)
240         self.load_vocab_files(join(root_directory, 'vocab', self.lang))
241 
242     def load_vocab_files(self, vocab_dir):
243         load_vocabulary(vocab_dir, self.emitter)
244 
245     def load_regex_files(self, regex_dir):
246         load_regex(regex_dir, self.emitter)
247 
248     def __handle_stop(self, event):
249         self.stop_time = time.time()
250         self.stop()
251 
252     @abc.abstractmethod
253     def stop(self):
254         pass
255 
256     def is_stop(self):
257         passed_time = time.time() - self.stop_time
258         return passed_time < self.stop_threshold
259
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mycroft/skills/core.py b/mycroft/skills/core.py
--- a/mycroft/skills/core.py
+++ b/mycroft/skills/core.py
@@ -35,7 +35,7 @@
 __author__ = 'seanfitz'
 
 PRIMARY_SKILLS = ['intent', 'wake']
-BLACKLISTED_SKILLS = ["send_sms"]
+BLACKLISTED_SKILLS = ["send_sms", "media"]
 SKILLS_BASEDIR = dirname(__file__)
 THIRD_PARTY_SKILLS_DIR = "/opt/mycroft/third_party"

{"golden_diff": "diff --git a/mycroft/skills/core.py b/mycroft/skills/core.py\n--- a/mycroft/skills/core.py\n+++ b/mycroft/skills/core.py\n@@ -35,7 +35,7 @@\n __author__ = 'seanfitz'\n \n PRIMARY_SKILLS = ['intent', 'wake']\n-BLACKLISTED_SKILLS = [\"send_sms\"]\n+BLACKLISTED_SKILLS = [\"send_sms\", \"media\"]\n SKILLS_BASEDIR = dirname(__file__)\n THIRD_PARTY_SKILLS_DIR = \"/opt/mycroft/third_party\"\n", "issue": "Base media skill is loaded as a normal skill\nAt the moment, the load_skills function tries to load the media skill as if it is a normal skill. \n\n", "before_files": [{"content": "# Copyright 2016 Mycroft AI, Inc.\n#\n# This file is part of Mycroft Core.\n#\n# Mycroft Core is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Mycroft Core is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.\n\n\nimport imp\nimport time\n\nimport abc\nimport os.path\nimport re\nfrom adapt.intent import Intent\nfrom os.path import join, dirname, splitext, isdir\n\nfrom mycroft.client.enclosure.api import EnclosureAPI\nfrom mycroft.configuration import ConfigurationManager\nfrom mycroft.dialog import DialogLoader\nfrom mycroft.filesystem import FileSystemAccess\nfrom mycroft.messagebus.message import Message\nfrom mycroft.util.log import getLogger\n\n__author__ = 'seanfitz'\n\nPRIMARY_SKILLS = ['intent', 'wake']\nBLACKLISTED_SKILLS = [\"send_sms\"]\nSKILLS_BASEDIR = dirname(__file__)\nTHIRD_PARTY_SKILLS_DIR = \"/opt/mycroft/third_party\"\n\nMainModule = '__init__'\n\nlogger = getLogger(__name__)\n\n\ndef load_vocab_from_file(path, vocab_type, emitter):\n    with open(path, 'r') as voc_file:\n        for line in voc_file.readlines():\n            parts = line.strip().split(\"|\")\n            entity = parts[0]\n\n            emitter.emit(\n                Message(\"register_vocab\",\n                        metadata={'start': entity, 'end': vocab_type}))\n            for alias in parts[1:]:\n                emitter.emit(\n                    Message(\"register_vocab\",\n                            metadata={'start': alias, 'end': vocab_type,\n                                      'alias_of': entity}))\n\n\ndef load_regex_from_file(path, emitter):\n    if(path.endswith('.rx')):\n        with open(path, 'r') as reg_file:\n            for line in reg_file.readlines():\n                re.compile(line.strip())\n                emitter.emit(\n                    Message(\"register_vocab\",\n                            metadata={'regex': line.strip()}))\n\n\ndef load_vocabulary(basedir, emitter):\n    for vocab_type in os.listdir(basedir):\n        load_vocab_from_file(\n            join(basedir, vocab_type), splitext(vocab_type)[0], emitter)\n\n\ndef load_regex(basedir, emitter):\n    for regex_type in os.listdir(basedir):\n        if regex_type.endswith(\".rx\"):\n            load_regex_from_file(\n                join(basedir, regex_type), emitter)\n\n\ndef create_intent_envelope(intent):\n    return Message(None, metadata=intent.__dict__, context={})\n\n\ndef open_intent_envelope(message):\n    intent_dict = message.metadata\n    return Intent(intent_dict.get('name'),\n                  intent_dict.get('requires'),\n                  intent_dict.get('at_least_one'),\n                  intent_dict.get('optional'))\n\n\ndef load_skill(skill_descriptor, emitter):\n    try:\n        skill_module = imp.load_module(\n            skill_descriptor[\"name\"] + MainModule, *skill_descriptor[\"info\"])\n        if (hasattr(skill_module, 'create_skill') and\n                callable(skill_module.create_skill)):\n            # v2 skills framework\n            skill = skill_module.create_skill()\n            skill.bind(emitter)\n            skill.initialize()\n            return skill\n        else:\n            logger.warn(\n                \"Module %s does not appear to be skill\" % (\n                    skill_descriptor[\"name\"]))\n    except:\n        logger.error(\n            \"Failed to load skill: \" + skill_descriptor[\"name\"], exc_info=True)\n    return None\n\n\ndef get_skills(skills_folder):\n    skills = []\n    possible_skills = os.listdir(skills_folder)\n    for i in possible_skills:\n        location = join(skills_folder, i)\n        if (not isdir(location) or\n                not MainModule + \".py\" in os.listdir(location)):\n            continue\n\n        skills.append(create_skill_descriptor(location))\n    skills = sorted(skills, key=lambda p: p.get('name'))\n    return skills\n\n\ndef create_skill_descriptor(skill_folder):\n    info = imp.find_module(MainModule, [skill_folder])\n    return {\"name\": os.path.basename(skill_folder), \"info\": info}\n\n\ndef load_skills(emitter, skills_root=SKILLS_BASEDIR):\n    skills = get_skills(skills_root)\n    for skill in skills:\n        if skill['name'] in PRIMARY_SKILLS:\n            load_skill(skill, emitter)\n\n    for skill in skills:\n        if (skill['name'] not in PRIMARY_SKILLS and\n                skill['name'] not in BLACKLISTED_SKILLS):\n            load_skill(skill, emitter)\n\n\nclass MycroftSkill(object):\n    \"\"\"\n    Abstract base class which provides common behaviour and parameters to all\n    Skills implementation.\n    \"\"\"\n\n    def __init__(self, name, emitter=None):\n        self.name = name\n        self.bind(emitter)\n        config = ConfigurationManager.get()\n        self.config = config.get(name)\n        self.config_core = config.get('core')\n        self.dialog_renderer = None\n        self.file_system = FileSystemAccess(join('skills', name))\n        self.registered_intents = []\n\n    @property\n    def location(self):\n        return self.config_core.get('location')\n\n    @property\n    def lang(self):\n        return self.config_core.get('lang')\n\n    def bind(self, emitter):\n        if emitter:\n            self.emitter = emitter\n            self.enclosure = EnclosureAPI(emitter)\n            self.__register_stop()\n\n    def __register_stop(self):\n        self.stop_time = time.time()\n        self.stop_threshold = self.config_core.get('stop_threshold')\n        self.emitter.on('mycroft.stop', self.__handle_stop)\n\n    def detach(self):\n        for name in self.registered_intents:\n            self.emitter.emit(\n                Message(\"detach_intent\", metadata={\"intent_name\": name}))\n\n    def initialize(self):\n        \"\"\"\n        Initialization function to be implemented by all Skills.\n\n        Usually used to create intents rules and register them.\n        \"\"\"\n        raise Exception(\"Initialize not implemented for skill: \" + self.name)\n\n    def register_intent(self, intent_parser, handler):\n        intent_message = create_intent_envelope(intent_parser)\n        intent_message.message_type = \"register_intent\"\n        self.emitter.emit(intent_message)\n        self.registered_intents.append(intent_parser.name)\n\n        def receive_handler(message):\n            try:\n                handler(message)\n            except:\n                # TODO: Localize\n                self.speak(\n                    \"An error occurred while processing a request in \" +\n                    self.name)\n                logger.error(\n                    \"An error occurred while processing a request in \" +\n                    self.name, exc_info=True)\n\n        self.emitter.on(intent_parser.name, receive_handler)\n\n    def register_vocabulary(self, entity, entity_type):\n        self.emitter.emit(\n            Message('register_vocab',\n                    metadata={'start': entity, 'end': entity_type}))\n\n    def register_regex(self, regex_str):\n        re.compile(regex_str)  # validate regex\n        self.emitter.emit(\n            Message('register_vocab', metadata={'regex': regex_str}))\n\n    def speak(self, utterance):\n        self.emitter.emit(Message(\"speak\", metadata={'utterance': utterance}))\n\n    def speak_dialog(self, key, data={}):\n        self.speak(self.dialog_renderer.render(key, data))\n\n    def init_dialog(self, root_directory):\n        self.dialog_renderer = DialogLoader().load(\n            join(root_directory, 'dialog', self.lang))\n\n    def load_data_files(self, root_directory):\n        self.init_dialog(root_directory)\n        self.load_vocab_files(join(root_directory, 'vocab', self.lang))\n\n    def load_vocab_files(self, vocab_dir):\n        load_vocabulary(vocab_dir, self.emitter)\n\n    def load_regex_files(self, regex_dir):\n        load_regex(regex_dir, self.emitter)\n\n    def __handle_stop(self, event):\n        self.stop_time = time.time()\n        self.stop()\n\n    @abc.abstractmethod\n    def stop(self):\n        pass\n\n    def is_stop(self):\n        passed_time = time.time() - self.stop_time\n        return passed_time < self.stop_threshold\n", "path": "mycroft/skills/core.py"}], "after_files": [{"content": "# Copyright 2016 Mycroft AI, Inc.\n#\n# This file is part of Mycroft Core.\n#\n# Mycroft Core is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Mycroft Core is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.\n\n\nimport imp\nimport time\n\nimport abc\nimport os.path\nimport re\nfrom adapt.intent import Intent\nfrom os.path import join, dirname, splitext, isdir\n\nfrom mycroft.client.enclosure.api import EnclosureAPI\nfrom mycroft.configuration import ConfigurationManager\nfrom mycroft.dialog import DialogLoader\nfrom mycroft.filesystem import FileSystemAccess\nfrom mycroft.messagebus.message import Message\nfrom mycroft.util.log import getLogger\n\n__author__ = 'seanfitz'\n\nPRIMARY_SKILLS = ['intent', 'wake']\nBLACKLISTED_SKILLS = [\"send_sms\", \"media\"]\nSKILLS_BASEDIR = dirname(__file__)\nTHIRD_PARTY_SKILLS_DIR = \"/opt/mycroft/third_party\"\n\nMainModule = '__init__'\n\nlogger = getLogger(__name__)\n\n\ndef load_vocab_from_file(path, vocab_type, emitter):\n    with open(path, 'r') as voc_file:\n        for line in voc_file.readlines():\n            parts = line.strip().split(\"|\")\n            entity = parts[0]\n\n            emitter.emit(\n                Message(\"register_vocab\",\n                        metadata={'start': entity, 'end': vocab_type}))\n            for alias in parts[1:]:\n                emitter.emit(\n                    Message(\"register_vocab\",\n                            metadata={'start': alias, 'end': vocab_type,\n                                      'alias_of': entity}))\n\n\ndef load_regex_from_file(path, emitter):\n    if(path.endswith('.rx')):\n        with open(path, 'r') as reg_file:\n            for line in reg_file.readlines():\n                re.compile(line.strip())\n                emitter.emit(\n                    Message(\"register_vocab\",\n                            metadata={'regex': line.strip()}))\n\n\ndef load_vocabulary(basedir, emitter):\n    for vocab_type in os.listdir(basedir):\n        load_vocab_from_file(\n            join(basedir, vocab_type), splitext(vocab_type)[0], emitter)\n\n\ndef load_regex(basedir, emitter):\n    for regex_type in os.listdir(basedir):\n        if regex_type.endswith(\".rx\"):\n            load_regex_from_file(\n                join(basedir, regex_type), emitter)\n\n\ndef create_intent_envelope(intent):\n    return Message(None, metadata=intent.__dict__, context={})\n\n\ndef open_intent_envelope(message):\n    intent_dict = message.metadata\n    return Intent(intent_dict.get('name'),\n                  intent_dict.get('requires'),\n                  intent_dict.get('at_least_one'),\n                  intent_dict.get('optional'))\n\n\ndef load_skill(skill_descriptor, emitter):\n    try:\n        skill_module = imp.load_module(\n            skill_descriptor[\"name\"] + MainModule, *skill_descriptor[\"info\"])\n        if (hasattr(skill_module, 'create_skill') and\n                callable(skill_module.create_skill)):\n            # v2 skills framework\n            skill = skill_module.create_skill()\n            skill.bind(emitter)\n            skill.initialize()\n            return skill\n        else:\n            logger.warn(\n                \"Module %s does not appear to be skill\" % (\n                    skill_descriptor[\"name\"]))\n    except:\n        logger.error(\n            \"Failed to load skill: \" + skill_descriptor[\"name\"], exc_info=True)\n    return None\n\n\ndef get_skills(skills_folder):\n    skills = []\n    possible_skills = os.listdir(skills_folder)\n    for i in possible_skills:\n        location = join(skills_folder, i)\n        if (not isdir(location) or\n                not MainModule + \".py\" in os.listdir(location)):\n            continue\n\n        skills.append(create_skill_descriptor(location))\n    skills = sorted(skills, key=lambda p: p.get('name'))\n    return skills\n\n\ndef create_skill_descriptor(skill_folder):\n    info = imp.find_module(MainModule, [skill_folder])\n    return {\"name\": os.path.basename(skill_folder), \"info\": info}\n\n\ndef load_skills(emitter, skills_root=SKILLS_BASEDIR):\n    skills = get_skills(skills_root)\n    for skill in skills:\n        if skill['name'] in PRIMARY_SKILLS:\n            load_skill(skill, emitter)\n\n    for skill in skills:\n        if (skill['name'] not in PRIMARY_SKILLS and\n                skill['name'] not in BLACKLISTED_SKILLS):\n            load_skill(skill, emitter)\n\n\nclass MycroftSkill(object):\n    \"\"\"\n    Abstract base class which provides common behaviour and parameters to all\n    Skills implementation.\n    \"\"\"\n\n    def __init__(self, name, emitter=None):\n        self.name = name\n        self.bind(emitter)\n        config = ConfigurationManager.get()\n        self.config = config.get(name)\n        self.config_core = config.get('core')\n        self.dialog_renderer = None\n        self.file_system = FileSystemAccess(join('skills', name))\n        self.registered_intents = []\n\n    @property\n    def location(self):\n        return self.config_core.get('location')\n\n    @property\n    def lang(self):\n        return self.config_core.get('lang')\n\n    def bind(self, emitter):\n        if emitter:\n            self.emitter = emitter\n            self.enclosure = EnclosureAPI(emitter)\n            self.__register_stop()\n\n    def __register_stop(self):\n        self.stop_time = time.time()\n        self.stop_threshold = self.config_core.get('stop_threshold')\n        self.emitter.on('mycroft.stop', self.__handle_stop)\n\n    def detach(self):\n        for name in self.registered_intents:\n            self.emitter.emit(\n                Message(\"detach_intent\", metadata={\"intent_name\": name}))\n\n    def initialize(self):\n        \"\"\"\n        Initialization function to be implemented by all Skills.\n\n        Usually used to create intents rules and register them.\n        \"\"\"\n        raise Exception(\"Initialize not implemented for skill: \" + self.name)\n\n    def register_intent(self, intent_parser, handler):\n        intent_message = create_intent_envelope(intent_parser)\n        intent_message.message_type = \"register_intent\"\n        self.emitter.emit(intent_message)\n        self.registered_intents.append(intent_parser.name)\n\n        def receive_handler(message):\n            try:\n                handler(message)\n            except:\n                # TODO: Localize\n                self.speak(\n                    \"An error occurred while processing a request in \" +\n                    self.name)\n                logger.error(\n                    \"An error occurred while processing a request in \" +\n                    self.name, exc_info=True)\n\n        self.emitter.on(intent_parser.name, receive_handler)\n\n    def register_vocabulary(self, entity, entity_type):\n        self.emitter.emit(\n            Message('register_vocab',\n                    metadata={'start': entity, 'end': entity_type}))\n\n    def register_regex(self, regex_str):\n        re.compile(regex_str)  # validate regex\n        self.emitter.emit(\n            Message('register_vocab', metadata={'regex': regex_str}))\n\n    def speak(self, utterance):\n        self.emitter.emit(Message(\"speak\", metadata={'utterance': utterance}))\n\n    def speak_dialog(self, key, data={}):\n        self.speak(self.dialog_renderer.render(key, data))\n\n    def init_dialog(self, root_directory):\n        self.dialog_renderer = DialogLoader().load(\n            join(root_directory, 'dialog', self.lang))\n\n    def load_data_files(self, root_directory):\n        self.init_dialog(root_directory)\n        self.load_vocab_files(join(root_directory, 'vocab', self.lang))\n\n    def load_vocab_files(self, vocab_dir):\n        load_vocabulary(vocab_dir, self.emitter)\n\n    def load_regex_files(self, regex_dir):\n        load_regex(regex_dir, self.emitter)\n\n    def __handle_stop(self, event):\n        self.stop_time = time.time()\n        self.stop()\n\n    @abc.abstractmethod\n    def stop(self):\n        pass\n\n    def is_stop(self):\n        passed_time = time.time() - self.stop_time\n        return passed_time < self.stop_threshold\n", "path": "mycroft/skills/core.py"}]}