Changeset 231


Ignore:
Timestamp:
07/20/2010 05:16:48 PM (13 years ago)
Author:
marcus
Message:
  • parser work
  • command sdef done (solved #21)
Location:
SHX/trunk/src/SeismicHandler
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/src/SeismicHandler/core/command.py

    r223 r231  
    5454            # first from parser 
    5555            try: 
    56                 self.qualifiers[q] = kwargs["shx_qualifier"][q] 
     56                self.qualifiers[q] = kwargs["shx_qualifiers"][q] 
    5757                continue 
    5858            except KeyError: 
     
    8989            self.parameters = args 
    9090 
     91        # transfer symbol set 
     92        try: 
     93            self.symbols = kwargs["shx_symbols"] 
     94        except: 
     95            self.symbols = None 
     96 
    9197        self.logger.debug("%s: %s, %s" % (self.__class__.__name__, \ 
    9298                                              self.parameters, self.qualifiers)) 
  • SHX/trunk/src/SeismicHandler/core/parser.py

    r230 r231  
    5959    Switches may occur at any position, but are commonly placed following the 
    6060    command name: 
    61     >>> sorted(x["shx_qualifier"].keys()) 
     61    >>> sorted(x["shx_qualifiers"].keys()) 
    6262    ['SWITCH1', 'SWITCH2'] 
    63     >>> x["shx_qualifier"]["SWITCH1"] 
     63    >>> x["shx_qualifiers"]["SWITCH1"] 
    6464    True 
    65     >>> x["shx_qualifier"]["SWITCH2"] 
     65    >>> x["shx_qualifiers"]["SWITCH2"] 
    6666    '4' 
    6767 
     
    7777    >>> x["shx_parameter"] 
    7878    ['BAR', 'FOO'] 
    79     >>> x["shx_qualifier"]["FOO"] 
     79    >>> x["shx_qualifiers"]["FOO"] 
    8080    '1' 
    8181 
    8282    Please note that the "suspected" file name is also present as switch: 
    83     >>> sorted(x["shx_qualifier"].keys()) 
     83    >>> sorted(x["shx_qualifiers"].keys()) 
    8484    ['BLA', 'FOO', 'SW', 'TEST', 'TMP'] 
    8585    >>> x["shx_suspectedFilename"] 
     
    127127            sfile = None 
    128128 
    129         qualifier = {} 
     129        qualifiers = {} 
    130130        # remove cmd and qualifiers from string 
    131131        cmd_par = input.replace(cmd, "") 
     
    136136            i = qq.split("=") 
    137137            if len(i) > 1: 
    138                 qualifier[i[0][1:]] = i[1] 
     138                qualifiers[i[0][1:]] = i[1] 
    139139            else: 
    140                 qualifier[i[0][1:]] = True 
     140                qualifiers[i[0][1:]] = True 
    141141 
    142142        par = cmd_par.split() 
     
    163163                "shx_command": cmd.lower(), # command always in lower case 
    164164                "shx_parameter": parameter, 
    165                 "shx_qualifier": qualifier, 
     165                "shx_qualifiers": qualifiers, 
    166166                "shx_suspectedFilename": sfile, 
    167167        } 
     
    291291                cmd = parse(cmd).parsed 
    292292 
    293                  
    294293                # Execute command... 
    295294                if cmd["shx_command"] in commands.list: 
    296                     commands.list[cmd["shx_command"]](*cmd["shx_parameter"], **cmd["shx_qualifier"]) 
    297                      
     295                    # also supply recent symbolset 
     296                    commands.list[cmd["shx_command"]](shx_symbols=self.symbols, \ 
     297                                 *cmd["shx_parameter"], **cmd["shx_qualifiers"]) 
     298 
    298299                # .. or start script. 
    299300                else: 
     
    441442        raise Exception("Symbol %s not found!" % name) 
    442443 
    443     def __setattr__(self, name, value): 
     444    def __setattr__(self, name, value=None): 
    444445        name = name.upper() 
    445446 
     
    466467        raise Exception("Symbol %s not found!" % name) 
    467468 
    468     def setGlobal(self, name, value): 
     469    def setGlobal(self, name, value=None): 
    469470        name = name.upper() 
    470471 
  • SHX/trunk/src/SeismicHandler/tests/data/SCRIPT1.SHC

    r230 r231  
    1 !switch echo on 
     1switch echo on 
     2!switch capconv off 
     3sdef foo 3 
     4sdel foo 
    25echo test /NO_LF 
    36echo_ch xxx 
Note: See TracChangeset for help on using the changeset viewer.