Changeset 531


Ignore:
Timestamp:
02/02/2012 05:51:18 PM (12 years ago)
Author:
marcus
Message:
  • ...
  • method for expanding trace lists
Location:
SHX/trunk/SeismicHandler
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/SeismicHandler/basics/error.py

    r529 r531  
    3535        # log message 
    3636        msgs.sendMessage("log.error", message=str(self)) 
     37        setStatus(getattr(self, "status", "unset")) 
    3738 
    3839    def __str__(self): 
     
    4647    """ 
    4748 
    48     def __init__(self, value): 
     49    def __init__(self, value, status=1): 
    4950        self.value = value 
    50         setStatus(1) 
     51        self.status = status 
    5152        Error.__init__(self) 
    5253 
  • SHX/trunk/SeismicHandler/basics/tools.py

    r258 r531  
    99def Property(func): 
    1010    return property(**func()) 
     11 
    1112 
    1213class Singleton(type): 
     
    2425 
    2526        return cls.instance 
     27 
     28 
     29def expandTraceList(trcs, selection): 
     30    """ 
     31    Expand comma separated list of traces into sorted internal trace numbers 
     32    (reverse order). 
     33    """ 
     34 
     35    if not len(trcs): 
     36        return None 
     37 
     38    selection = [i.lower() for i in selection.split(",")] 
     39 
     40    if "all" in selection: 
     41        selected = range(0, len(trcs)) 
     42        selected.reverse() 
     43        return selected 
     44 
     45    selected = [] 
     46    for s in selection: 
     47        # range 
     48        if "-" in s: 
     49            try: 
     50                start, stop = map(int, s.split("-")) 
     51            except: 
     52                print "  skipping '%s'" % s 
     53                continue 
     54 
     55            if stop < start: 
     56                start, stop = stop, start 
     57 
     58            selected.extend(range(start - 1, stop)) 
     59 
     60        else: 
     61            if s.isdigit(): 
     62                selected.append(int(s) - 1) 
     63            else: 
     64                print "  skipping '%s'" % s 
     65 
     66    # unique 
     67    selected = list(set(selected)) 
     68    selected.sort() 
     69    selected.reverse() 
     70 
     71    return selected 
  • SHX/trunk/SeismicHandler/modules/parse.py

    r530 r531  
    509509            quit() 
    510510 
    511     def commandIf(self, cmd): 
     511    def commandIf(self, *args, **kwargs): 
     512        print args, kwargs 
    512513        pass 
    513514 
     
    695696        except NotImplementedError: 
    696697            raise NotImplementedError 
     698        except ShxError, e: 
     699            raise ShxError("'%s' could not be translated!" % value, e.status) 
    697700        except: 
    698             raise ShxError("'%s' could not be translated!" % value) 
     701            raise ShxError("'%s' could not be translated!" % value, 1716) 
    699702 
    700703    def __handleSystem(self, name): 
  • SHX/trunk/SeismicHandler/patches/ObsPy.py

    r529 r531  
    3333from obspy.sh.core import fromUTCDateTime 
    3434from SeismicHandler.basics.messages import logMessage, setStatus 
     35from SeismicHandler.basics.error import ShxError 
    3536 
    3637__all__ = [] 
     
    242243        return self.shx[name] 
    243244 
    244     raise NameError 
     245    raise ShxError("Info entry not found", 1703) 
    245246 
    246247# monkey patching obspy stream class: traces are merge automatically if stream 
Note: See TracChangeset for help on using the changeset viewer.