Changeset 0a9fcab in sasmodels for sasmodels/autoc.py


Ignore:
Timestamp:
Dec 4, 2017 8:13:55 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Children:
2db9fe4
Parents:
ef6a512
Message:

simplify handling of gauss.z in py2c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/autoc.py

    ref6a512 r0a9fcab  
    6767    while translate: 
    6868        function_name, function = translate.pop(0) 
    69         source = inspect.getsource(function) 
    70         tree = ast.parse(source) 
    7169        filename = function.__code__.co_filename 
    7270        offset = function.__code__.co_firstlineno 
    7371        refs = function.__code__.co_names 
    74         snippet = codegen.to_source(tree) #, filename, offset) 
    75         code[function_name] = snippet 
    7672        depends[function_name] = set(refs) 
     73        source = inspect.getsource(function) 
    7774        for name in refs: 
    7875            if name in tagged or name in DEFINES: 
     
    9996            elif isinstance(obj, special.Gauss): 
    10097                libs.append('lib/gauss%d.c'%obj.n) 
     98                source = (source.replace(name+'.n', 'GAUSS_N') 
     99                          .replace(name+'.z', 'GAUSS_Z') 
     100                          .replace(name+'.w', 'GAUSS_W')) 
    101101            else: 
    102102                raise TypeError("Could not convert global %s of type %s" 
    103103                                % (name, str(type(obj)))) 
    104104 
     105        tree = ast.parse(source) 
     106        snippet = codegen.to_source(tree) #, filename, offset) 
     107        code[function_name] = snippet 
     108 
    105109    # remove duplicates from the dependecy list 
    106     unique_libs= [] 
     110    unique_libs = [] 
    107111    for filename in libs: 
    108112        if filename not in unique_libs: 
Note: See TracChangeset for help on using the changeset viewer.