Developer Tips and Tricks

From VisItusers.org

Jump to: navigation, search

Contents

[edit] Adding third_party tarballs

Scenario: You want to add a new third_party lib tarball, however you don't have a full checkout of 'trunk/third_party'. You can use the following to just checkout the root directory w/o any files:

svn checkout  svn+ssh://NERSC_NAME@portal-auth.nersc.gov/project/projectdirs/visit/svn/visit/trunk/third_party/ --depth empty

Than add & commit. This is also useful for adding new data tarballs

[edit] Searching for CLI Commands

[edit] From outside of visit's cli

When franticly writing python code for VisIt, I often need to browse the list of functions available. But, output from 'dir()' from within a VisIt cli session is hard to sort through. The command below lists them in alphabetical order, one per line so it is much easier to find a method.

echo "dir()" | visit -cli -nowin -forceinteractivecli | tr ',' '\n' | tr -d " '" | sort

You can pipe it through grep if you're looking for something specific...

echo "dir()" | visit -cli -nowin -forceinteractivecli | tr ',' '\n' | tr -d " '" | grep Material

DefineMaterialExpression
GetMaterialAttributes
GetMaterials
ListMaterials
MaterialAttributes
SetDefaultMaterialAttributes
SetMaterialAttributes
TurnMaterialsOff
TurnMaterialsOn

Also, if you need help on a specific CLI command but either are not currently running the cli or don't plan to keep it running...

echo "help(TurnMaterialsOff)" | visit -cli -nowin -forceinteractivecli

[edit] lsearch

Place this function in ~/.visit/visitrc

def lsearch(pattern,echo=True,lst=globals()):
    rvals = None
    if not echo:
        rvals = []
    for v in lst:
        if not v.find(pattern) == -1:
            if echo:
                print v
            else:
                rvals.append(v)
    return rvals

And with in VisIt's cli you can simply type:

lsearch("Substring")

And any substring match is printed.

The function also returns a python list of all strings that matched:

for r in lsearch("Substring"):
   # do something
Personal tools