Skip to content

Commit

Permalink
Move config location definitions to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
forslund committed Oct 9, 2018
1 parent f262bd6 commit 260f54a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions mycroft/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .config import Configuration, LocalConf, RemoteConf, \
SYSTEM_CONFIG, USER_CONFIG
from .config import Configuration, LocalConf, RemoteConf
from .locations import SYSTEM_CONFIG, USER_CONFIG


# Compatibility
Expand Down
10 changes: 3 additions & 7 deletions mycroft/configuration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import re
import json
import inflection
from os.path import exists, isfile, join, dirname, expanduser
from os.path import exists, isfile
from requests import RequestException

from mycroft.util.json_helper import load_commented_json, merge_dict
from mycroft.util.log import LOG

from .locations import DEFAULT_CONFIG, SYSTEM_CONFIG, USER_CONFIG


def is_remote_list(values):
''' check if this list corresponds to a backend formatted collection of
Expand Down Expand Up @@ -172,12 +174,6 @@ def __init__(self, cache=None):
self.load_local(cache)


DEFAULT_CONFIG = join(dirname(__file__), 'mycroft.conf')
SYSTEM_CONFIG = '/etc/mycroft/mycroft.conf'
USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
REMOTE_CONFIG = "mycroft.ai"


class Configuration(object):
__config = {} # Cached config
__patch = {} # Patch config that skills can update to override config
Expand Down
19 changes: 19 additions & 0 deletions mycroft/configuration/locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2018 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from os.path import join, dirname, expanduser

DEFAULT_CONFIG = join(dirname(__file__), 'mycroft.conf')
SYSTEM_CONFIG = '/etc/mycroft/mycroft.conf'
USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
REMOTE_CONFIG = "mycroft.ai"
7 changes: 2 additions & 5 deletions mycroft/util/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
import logging
import sys

from os.path import isfile, join, expanduser
from os.path import isfile

from mycroft.util.json_helper import load_commented_json, merge_dict
# from mycroft.configuration import SYSTEM_CONFIG, USER_CONFIG
# TODO avoid circular imports, do not redefine these constants here
SYSTEM_CONFIG = '/etc/mycroft/mycroft.conf'
USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
from mycroft.configuration.locations import SYSTEM_CONFIG, USER_CONFIG


def getLogger(name="MYCROFT"):
Expand Down

0 comments on commit 260f54a

Please sign in to comment.