| 127 | |
| 128 | |
| 129 | class ScopedWS(object): |
| 130 | def __init__(self, ws_name, is_reset, is_cleanup=False): |
| 131 | self.ws_name = ws_name |
| 132 | self.is_reset = is_reset |
| 133 | self.is_cleanup = is_cleanup |
| 134 | self.org_ws = "" |
| 135 | |
| 136 | def __enter__(self): |
| 137 | self.org_ws = workspace.CurrentWorkspace() |
| 138 | if self.ws_name is not None: |
| 139 | workspace.SwitchWorkspace(self.ws_name, True) |
| 140 | if self.is_reset: |
| 141 | workspace.ResetWorkspace() |
| 142 | |
| 143 | return workspace |
| 144 | |
| 145 | def __exit__(self, *args): |
| 146 | if self.is_cleanup: |
| 147 | workspace.ResetWorkspace() |
| 148 | if self.ws_name is not None: |
| 149 | workspace.SwitchWorkspace(self.org_ws) |
| 150 | |
| 151 | |
| 152 | def fetch_any_blob(name): |
no outgoing calls
no test coverage detected