glob_path¶
Finds all the pathnames matching the pattern.
Function Arguments¶
Name |
Type |
Description |
---|---|---|
pathname |
str |
The file path of target file. |
key |
str |
(optional; default: |
filename_only |
bool |
(optional; default: |
Description¶
The output of this function is a dictionary with only one entry, whose key
is specified by the argument key
and the value is the matched path name
(or the file name if filename_only=true
).
Examples¶
Let’s assume that there are files:
/tmp/aa/00.txt
/tmp/aa/01.txt
/tmp/aa/02.tgz
/tmp/aa/03.tgz
Then the probe statement
{
"eval": "glob_path:/tmp/aa/*.txt"
}
will have the corresponding probed results
[
{
"path": "/tmp/aa/00.txt"
},
{
"path": "/tmp/aa/01.txt"
}
]
And the probe statement
{
"eval": {
"glob_path": {
"pathname": "/tmp/aa/00.txt",
"filename_only": true,
"key": "filename"
}
}
}
will have the corresponding probed results
[
{
"filename": "00.txt"
}
]
And the probe statement
{
"eval": "glob_path:/tmp/aa/no_such_file.txt"
}
will have the corresponding probed results
[
]