I have couple of puzzles in my code.

def load_headers( group_info ):

    if os.path.isfile( group_info.pointer_file ):
        ptr_file = open( group_info.pointer_file, "r" )
    else:
        print group_info.mess_list
        return
    linecount = 0
    ptr_file.seek( 512 )
    print ptr_file.tell()
    line = ptr_file.readline()
    while line != "" :
        if line[0:1] == "<":
            print linecount
            print len(line), line
            print line.split( " ", 3 )
    
            group_info.mess_list.append( line.split( " ", 3 ) )
        line = ptr_file.readline()
    ptr_file.close()

when reading the following line from file:  
<[EMAIL PROTECTED]>                             2338 *            Re: PCB Pad 
Size for TQFP Package??                                             

the split command returns
 ['<[EMAIL PROTECTED]>                            ','','','2338 *            
Re: PCB Pad Size for TQFP Package??']
   
instead of
 ['<[EMAIL PROTECTED]>, '2338',                            '*','Re: PCB Pad 
Size for TQFP Package??']



I have just (finally) realized that it is splitting and removing on single 
space but that seams useless, and split items 1 and 2 are empty strings not 
spaces?? regex somewhere it shouldn't be?



The other problem 
is in this piece of code which is trying to pad the first 512 bytes:

    line = group_info.group_name+" sf"+ group_info.first + " sl"+ \             
        group_info.last + " sc" + group_info.count + "dt" + \           
group_info.date_checked + group_info.time_checked
    line = line + "\n"
    line = string.ljust( line, 512 - len(os.linesep) )
    print len( os.linesep )
    line += "\n"
    print len( line )
    ptr_file.write( line )
    print "**** "+repr(ptr_file.tell())+ " ****"
    print "message list\n"

the ljust function returns string 511 bytes long, besides the fact that the 
logic is not exactly correct what is going on here. Is ljust trying to be smart 
about the EOL inside the string already?

I have tried the following, which should be about right ( account for the 1 
bytes added after justification and two added by file write.)

    line = string.ljust( line, 512 - len(os.linesep) - len(os.linesep) - 1 )

But, in this case I end up 2 bytes short of 512.

Thanks for any help.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to