Ignore:
Timestamp:
08/13/10 16:07:29 (14 years ago)
Author:
Malte Marquarding
Message:

Added srctype enum handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/selector.py

    r1826 r1875  
    1 from asap._asap import selector as _selector
     1import re
     2from asap._asap import selector as _selector, srctype
    23from asap.utils import unique, _to_list
    34
     
    148149        Example:
    149150            # select all off scans with integration times over 60 seconds.
    150             selection.set_query("SRCTYPE == 1 AND INTERVAL > 60.0")
    151         """
     151            selection.set_query("SRCTYPE == PSOFF AND INTERVAL > 60.0")
     152        """
     153        rx = re.compile("((SRCTYPE *[!=][=] *)([a-zA-Z.]+))", re.I)
     154        for r in rx.findall(query):
     155            sval = None
     156            stype = r[-1].lower()
     157            if stype.find('srctype.') == -1:
     158                stype = ".".join(["srctype", stype])
     159            try:
     160                sval = eval(stype)
     161                sval = "%s%d" % (r[1], sval)
     162            except:
     163                continue
     164            query = query.replace(r[0], sval)
    152165        taql = "SELECT FROM $1 WHERE " + query
    153166        self._settaql(taql)
Note: See TracChangeset for help on using the changeset viewer.