Opening An Understand Project
Let’s start by taking a look at a very simple Python script that will open an Understand Project and print out all of the file names for that project:
sample.py
import understand db = understand.open("C:/projects/test.und") for file in db.ents("file"): print(file.longname())
Lets break down each component of this script:
import understand
You must include this line at the top of each script when you want to use the understand library
db = understand.open("c:\projects\test.und")
The db variable stores all the data related to your project. Use understand.open to specify the project you want the script to run on. Every uPython script should start by specifying your Understand project, Understand projects always end with .und
for file in db.ents("file"):
print(file.longname())
For every file in the project, print out the full path name. "ents" is short for entities, we'll learn more about that in tutorial 3. "file" searches through every entity in your project and filters out just the entities labeled as a file.