NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

Changeset 300

Show
Ignore:
Timestamp:
12/09/09 18:42:25
Author:
cbc
Message:

Fix for Windows .mnd files binary copied to Unix.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sodar/trunk/sodar/scintec/maindata.py

    r296 r300  
    152152        # Divide the data into blocks 
    153153        # across boundaries separated by blank lines. 
    154         blocks = [block.strip() 
    155                   for block 
    156                   in mnd.split('\n\n') 
    157                   if block.strip()] 
     154        EOL = '\r\n' # Windows file binary copied to Unix 
     155        def divide(mnd,eol): 
     156            blocks = [block.strip() 
     157                      for block 
     158                      in mnd.split(eol*2) 
     159                      if block.strip()] 
     160            if len(blocks) < 2: 
     161                eol = '\n' # Windows to Windows or Unix to Unix 
     162                blocks, eol = divide(mnd,eol) 
     163            return (blocks,eol) 
     164        blocks,EOL = divide(mnd,EOL) 
    158165         
    159166        # The first block is the specification of the format header. 
     
    161168        format_header_spec = [line.strip() 
    162169                              for line 
    163                               in blocks[0].split('\n'
     170                              in blocks[0].split(EOL
    164171                              if line.strip()] 
    165172                               
     
    190197        file_header_body = [line.strip() 
    191198                            for line 
    192                             in blocks[1].split('\n'
     199                            in blocks[1].split(EOL
    193200                            if not line.strip().startswith('#')] 
    194201        self.comments = dict([(name.strip(),value.strip()) 
     
    219226        self.extend([Profile([line.strip() 
    220227                              for line 
    221                               in block.split('\n'
     228                              in block.split(EOL
    222229                              if line.strip()]) 
    223230                     for block