Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
forslund committed Aug 22, 2017
1 parent e61b516 commit dea591e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions mycroft/skills/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
import time

import operator
import os.path
import re
import time
from os.path import join, dirname, splitext, isdir

from os.path import join, dirname, splitext, isdir, basename, exists
from os import listdir
from functools import wraps

from adapt.intent import Intent, IntentBuilder
Expand Down Expand Up @@ -89,14 +87,14 @@ def load_regex_from_file(path, emitter):


def load_vocabulary(basedir, emitter):
for vocab_type in os.listdir(basedir):
for vocab_type in listdir(basedir):
if vocab_type.endswith(".voc"):
load_vocab_from_file(
join(basedir, vocab_type), splitext(vocab_type)[0], emitter)


def load_regex(basedir, emitter):
for regex_type in os.listdir(basedir):
for regex_type in listdir(basedir):
if regex_type.endswith(".rx"):
load_regex_from_file(
join(basedir, regex_type), emitter)
Expand Down Expand Up @@ -154,7 +152,7 @@ def load_skill(skill_descriptor, emitter, skill_id):

def create_skill_descriptor(skill_folder):
info = imp.find_module(MainModule, [skill_folder])
return {"name": os.path.basename(skill_folder), "info": info}
return {"name": basename(skill_folder), "info": info}


# Lists used when adding skill handlers using decorators
Expand Down Expand Up @@ -466,7 +464,7 @@ def speak_dialog(self, key, data={}, expect_response=False):

def init_dialog(self, root_directory):
dialog_dir = join(root_directory, 'dialog', self.lang)
if os.path.exists(dialog_dir):
if exists(dialog_dir):
self.dialog_renderer = DialogLoader().load(dialog_dir)
else:
logger.debug('No dialog loaded, ' + dialog_dir + ' does not exist')
Expand All @@ -475,12 +473,12 @@ def load_data_files(self, root_directory):
self.init_dialog(root_directory)
self.load_vocab_files(join(root_directory, 'vocab', self.lang))
regex_path = join(root_directory, 'regex', self.lang)
if os.path.exists(regex_path):
if exists(regex_path):
self.load_regex_files(regex_path)

def load_vocab_files(self, vocab_dir):
self.vocab_dir = vocab_dir
if os.path.exists(vocab_dir):
if exists(vocab_dir):
load_vocabulary(vocab_dir, self.emitter)
else:
logger.debug('No vocab loaded, ' + vocab_dir + ' does not exist')
Expand Down
2 changes: 1 addition & 1 deletion mycroft/skills/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _get_last_modified_date(path):
# get subdirs and remove hidden ones
subdirs = [s for s in subdirs if not s.startswith('.')]
for subdir in subdirs:
for root, _, _ in os.walk(os.path.join(path, subdir)):
for root, _, _ in os.walk(join(path, subdir)):
base = os.path.basename(root)
# checking if is a hidden path
if not base.startswith(".") and not base.startswith("/."):
Expand Down

0 comments on commit dea591e

Please sign in to comment.