Next / Previous / Contents / Shipman's homepage

21.2. Heading.__getModTime(): Find the file's modification time

listext2
# - - -   H e a d i n g . _ _ g e t M o d T i m e

    def __getModTime(self):
        '''Set up self.__timestamp.
        '''
        #-- 1
        # [ status  :=  the posix status tuple for Args().inFileName ]
        status = os.stat(Args().inFileName)

        #-- 2
        # [ modEpoch  :=  the modification timestamp from status as an
        #                 epoch time ]
        modEpoch = status[stat.ST_MTIME]

        #-- 3
        # [ local  :=  modEpoch as a local time tuple ]
        local = time.localtime(modEpoch)

        #-- 4
        # [ self.__timestamp  :=  local is YYYY-MM-DD HH:MM:SS ]
        self.__timestamp = time.strftime("%Y-%m-%d %H:%M:%S", local)