Changeset 606


Ignore:
Timestamp:
04/12/2012 11:29:23 AM (9 years ago)
Author:
marcus
Message:
  • WRITEA command
  • new qualifier /REPLACE for overwriting existing files (closes #3)
Location:
SHX/trunk/SeismicHandler
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/SeismicHandler/commands/calc.py

    r536 r606  
    1919from SeismicHandler.basics.command import BaseCommand 
    2020from SeismicHandler.basics.error import ShxError 
     21from SeismicHandler.utils import formatstring 
    2122from obspy.core import UTCDateTime 
    2223from obspy.sh.core import toUTCDateTime, fromUTCDateTime 
     
    240241 
    241242        if self.qualifiers["FMT"]: 
    242             # handle @ sign for lower case format character (e.g. E vs. e) 
    243             fmt = self.qualifiers["FMT"][1:-1] 
    244             try: 
    245                 at = fmt.index("@") 
    246                 fmt = fmt[:at] + fmt[at+1].lower() + fmt[at+2:] 
    247             except ValueError: 
    248                 pass 
    249  
     243            fmt = formatstring(self.qualifiers["FMT"]) 
    250244        else: 
    251245            fmt = formats[mode] 
  • SHX/trunk/SeismicHandler/commands/write.py

    r605 r606  
    6060 
    6161        try: 
    62             stream.write(filename, format="Q", byteorder="<", append=True, 
     62            stream.write(filename, format="Q", byteorder="<", append=append, 
    6363                                                 data_directory=data_directory) 
    6464        except: 
  • SHX/trunk/SeismicHandler/utils/__init__.py

    r603 r606  
    2222    return i 
    2323 
     24 
     25def formatstring(fstr): 
     26    """ 
     27    Get number format from format string, e.g. <%8.3@f_> to "%8.3f ". 
     28    """ 
     29    # handle @ sign for lower case format character (e.g. E vs. e) 
     30    fmt = fstr[1:-1] 
     31    try: 
     32        at = fmt.index("@") 
     33        fmt = fmt[:at] + fmt[at+1].lower() + fmt[at+2:] 
     34    except ValueError: 
     35        pass 
     36 
     37    return fmt.replace("_", " ") 
Note: See TracChangeset for help on using the changeset viewer.