# Path: subuserlib/classes/userOwnedObject.py
# class UserOwnedObject(object):
#   def __init__(self,user):
# 
# Path: subuserlib/loadMultiFallbackJsonConfigFile.py
# def filterOutNonExistantPaths(paths):
# def expandPathInDict(homeDir,pathAttribute,dictionary):
# def expandPathsInDict(homeDir,pathAttributes,dictionary):
# def getConfig(configFileHierarchy):
# 
# Path: subuserlib/paths.py
# def upNDirsInPath(path,n):
# def getSubuserDir():
# def getSubuserExecutable():
# def getSubuserDataFile(filename):


import os
from subuserlib.classes import userOwnedObject
from subuserlib import loadMultiFallbackJsonConfigFile
from subuserlib import paths
    self._loadConfig()

  def _getSubuserConfigPaths(self):
    """ Returns a list of paths to config.json files in order that they should be looked in. """
    configFileInHomeDir = os.path.join(self.user.homeDir,".subuser","config.json")
    configFileInEtc = "/etc/subuser/config.json"
    configFileInSubuserDir = paths.getSubuserDataFile("config.json")
    return [configFileInHomeDir,configFileInEtc,configFileInSubuserDir]

  def _expandPathsInConfig(self,config):
    """
    Go through a freshly loaded config file and expand any environment variables in the paths.
    """
    pathsToExpand = [
      "bin-dir"
      ,"registry-dir"
      ,"installed-images-list"
      ,"locked-subusers-path"
      ,"subuser-home-dirs-dir"
      ,"repositories-dir"
      ,"runtime-cache"
      ,"lock-dir"
      ,"volumes-dir"]
    loadMultiFallbackJsonConfigFile.expandPathsInDict(self.user.homeDir,pathsToExpand,config)

  def _loadConfig(self):
    """
    Loads the subuser config: a dictionary of settings used by subuser.
    """
    configFileHierarchy = self._getSubuserConfigPaths()

# Path: subuserlib/classes/userOwnedObject.py
# class UserOwnedObject(object):
#   def __init__(self,user):
# 
# Path: subuserlib/loadMultiFallbackJsonConfigFile.py
# def filterOutNonExistantPaths(paths):
# def expandPathInDict(homeDir,pathAttribute,dictionary):
# def expandPathsInDict(homeDir,pathAttributes,dictionary):
# def getConfig(configFileHierarchy):
# 
# Path: subuserlib/paths.py
# def upNDirsInPath(path,n):
# def getSubuserDir():
# def getSubuserExecutable():
# def getSubuserDataFile(filename):


# Path: subuserlib/classes/config.py
import os
from subuserlib.classes import userOwnedObject
from subuserlib import loadMultiFallbackJsonConfigFile
from subuserlib import paths

    self._loadConfig()

  def _getSubuserConfigPaths(self):
    """ Returns a list of paths to config.json files in order that they should be looked in. """
    configFileInHomeDir = os.path.join(self.user.homeDir,".subuser","config.json")
    configFileInEtc = "/etc/subuser/config.json"
    configFileInSubuserDir = paths.getSubuserDataFile("config.json")
    return [configFileInHomeDir,configFileInEtc,configFileInSubuserDir]

  def _expandPathsInConfig(self,config):
    """
    Go through a freshly loaded config file and expand any environment variables in the paths.
    """
    pathsToExpand = [
      "bin-dir"
      ,"registry-dir"
      ,"installed-images-list"
      ,"locked-subusers-path"
      ,"subuser-home-dirs-dir"
      ,"repositories-dir"
      ,"runtime-cache"
      ,"lock-dir"
      ,"volumes-dir"]
    loadMultiFallbackJsonConfigFile.expandPathsInDict(self.user.homeDir,pathsToExpand,config)

  def _loadConfig(self):
    """
    Loads the subuser config: a dictionary of settings used by subuser.
    """
    configFileHierarchy = self._getSubuserConfigPaths()

    config = loadMultiFallbackJsonConfigFile.getConfig(configFileHierarchy)