# Path: python/tHome/util/Error.py
# class Error ( Exception ):
#    """: Stack based error message exception class.
#    """
#    
#    #-----------------------------------------------------------------------
#    @staticmethod
#    def raiseException( exception, msg ):
#       excType, excValue, trace = sys.exc_info()
# 
#       if not isinstance( exception, Error ):
#          exception = Error( str( exception ) )
# 
#       exception.add( msg )
#       
#       raise exception, None, trace
# 
#    #-----------------------------------------------------------------------
#    @staticmethod
#    def fromException( exception, msg ):
#       excType, excValue, trace = sys.exc_info()
# 
#       newError = Error( str( exception ) )
#       newError.add( msg )
#       
#       raise newError, None, trace
#       
#    #-----------------------------------------------------------------------
#    def __init__( self, msg ):
#       """: Constructor
#       """
#       self._msg = [ msg ]
#       
#       Exception.__init__( self )
# 
#    #-----------------------------------------------------------------------
#    def add( self, msg ):
#       self._msg.append( msg )
#       
#    #-----------------------------------------------------------------------
#    def __str__( self ):
#       s = "\n"
#       for msg in reversed( self._msg ):
#          s += "- %s\n" % msg
# 
#       return s
#       
#    #-----------------------------------------------------------------------


import os
import os.path
from .Error import Error
#===========================================================================
#
# File and directory utilities.
#
#===========================================================================


#===========================================================================
def makeDirs( fileName ):
   """TODO: docs
   """
   try:
      d = os.path.dirname( fileName )
      if d and not os.path.exists( d ):
         os.makedirs( d )

   except ( IOError, OSError ) as e:
      msg = "Error trying to create intermediate directories for the file: " \
            "'%s'" % ( fileName )

# Path: python/tHome/util/Error.py
# class Error ( Exception ):
#    """: Stack based error message exception class.
#    """
#    
#    #-----------------------------------------------------------------------
#    @staticmethod
#    def raiseException( exception, msg ):
#       excType, excValue, trace = sys.exc_info()
# 
#       if not isinstance( exception, Error ):
#          exception = Error( str( exception ) )
# 
#       exception.add( msg )
#       
#       raise exception, None, trace
# 
#    #-----------------------------------------------------------------------
#    @staticmethod
#    def fromException( exception, msg ):
#       excType, excValue, trace = sys.exc_info()
# 
#       newError = Error( str( exception ) )
#       newError.add( msg )
#       
#       raise newError, None, trace
#       
#    #-----------------------------------------------------------------------
#    def __init__( self, msg ):
#       """: Constructor
#       """
#       self._msg = [ msg ]
#       
#       Exception.__init__( self )
# 
#    #-----------------------------------------------------------------------
#    def add( self, msg ):
#       self._msg.append( msg )
#       
#    #-----------------------------------------------------------------------
#    def __str__( self ):
#       s = "\n"
#       for msg in reversed( self._msg ):
#          s += "- %s\n" % msg
# 
#       return s
#       
#    #-----------------------------------------------------------------------


# Path: python/tHome/util/path.py
import os
import os.path
from .Error import Error

#===========================================================================
#
# File and directory utilities.
#
#===========================================================================


#===========================================================================
def makeDirs( fileName ):
   """TODO: docs
   """
   try:
      d = os.path.dirname( fileName )
      if d and not os.path.exists( d ):
         os.makedirs( d )

   except ( IOError, OSError ) as e:
      msg = "Error trying to create intermediate directories for the file: " \
            "'%s'" % ( fileName )

      Error.raiseException( e, msg )