TNO Intern

Commit 0487a41b authored by Arjo Segers's avatar Arjo Segers
Browse files

Read Timestamp object from rcfile settings.

parent 05e7621f
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
#
# Python module 'rc' .
# Changes
# 
# 2022-09, Arjo Segers, Met-Norway
#   Read Timestamp object from rcfile settings.
#

# ------------------------------------------------
@@ -620,25 +623,25 @@ class RcFile( object ) :
    def get( self, key, totype='', default=None, verbose=False ) :
    
        """
        Return element 'key' from the dictionary.
        Return element ``key`` from the dictionary.
        
        If the element is not present but a default is specified, 
        than return this value.
        
        If 'verbose' is set to True, a debug message is send to the logging
        If ``verbose`` is set to True, a debug message is send to the logging
        system on which value is returned for the given key.
        
        The optional argument 'totype' defines the conversion to a Python type.
        The optional argument ``totype`` defines the conversion to a Python type.
        
        * If 'totype' is set to 'bool', the return value is:
        * If ``totype`` is set to ``'bool'``, the return value is:
 
          * True for values 'T', 'True', 'yes', and '1';
          * False for 'F', 'False', 'no', or '0'.
          * True for values ``'T'``, ``'True'``, ``'yes'``, and ``'1'``;
          * False for ``'F'``, ``'False'``, ``'no'``, or ``'0'``.
          
        * If 'totype' is set to 'datetime', the content is read into a
        * If ``totype`` is set to ``'datetime'``, the content is read into a
          :py:class:`datetime.datetime` object.
        
        For other values, an exception will be raised.
        * For ``timestamp``, the result is a :py:class:`pandas.Timestamp` object.
        """
        
        # element found ?
@@ -671,6 +674,12 @@ class RcFile( object ) :
                # define:
                value = datetime.datetime(*tvals)
            #
            elif totype in ['Timestamp','timestamp'] :
                # load:
                import pandas
                # convert:
                value = pandas.Timestamp( value )
            #
            elif len(totype) > 0 :
                # convert to other type ...
                value = eval( '%s(%s)' % (totype,value) )