def write_part(self, part_filename):
        '''
        put log file fragment from saved position to cyurrent state 
        into separate file
        '''
        if not self.init_ok:
            log.error('not properly initialized')
            return 0
        if self.stream.closed:
            if os.path.isfile(self.basename):
                part_size=os.path.getsize()
            else:
                log.error('log file (%s) not found on disk' % (self.basename))
                return 0
        else:
            part_size=self.stream.tell() - self.start_pos

        # put fragment
        f_log=open(self.basename, 'rb')
        f_part=open(part_filename, 'wb')
        try:
            f_log.seek(self.start_pos)
            left_size=part_size
            while left_size > 0:
                s=min(left_size, BUF_SIZE)
                buf=f_log.read(s)
                if len(buf) > 0:
                    f_part.write(buf)
                    left_size-=s
                else:
                    break
            return 1
        finally:
            f_part.close()
            f_log.close()

        return 0

        put log file fragment from saved position to cyurrent state 
        into separate file
        
recipes/Python/519624_Saving_logging_disk_log_fragment_inseparated/recipe-519624.py