Return a tuple of (``shell variables``, ``errors``) from collecting top- level variables defined in bash script at ``location``. ``shell variables`` is a mapping of {name: value} ``errors`` a list of error message strings. Optionally ``resolve`` the variables with emulated she
(location, resolve=False, needed_variables=None)
| 80 | |
| 81 | |
| 82 | def collect_shell_variables(location, resolve=False, needed_variables=None): |
| 83 | """ |
| 84 | Return a tuple of (``shell variables``, ``errors``) from collecting top- |
| 85 | level variables defined in bash script at ``location``. |
| 86 | |
| 87 | ``shell variables`` is a mapping of {name: value} |
| 88 | ``errors`` a list of error message strings. |
| 89 | |
| 90 | Optionally ``resolve`` the variables with emulated shell parameter |
| 91 | expansion. If the set ``needed_variables`` is provided, only return |
| 92 | variables with a named present in this set and only report errors for |
| 93 | variables with a name listed in this set. |
| 94 | """ |
| 95 | with open(location) as inp: |
| 96 | text = inp.read() |
| 97 | |
| 98 | return collect_shell_variables_from_text_as_dict( |
| 99 | text=text, |
| 100 | resolve=resolve, |
| 101 | needed_variables=needed_variables, |
| 102 | ) |
| 103 | |
| 104 | # |
| 105 | # Convenience functions on parse tree labels |
no test coverage detected