Gets the file name for the active frame, saving it if necessary. Returns None if it cant be found, or raises KeyboardInterrupt.
(bAutoSave = 1)
| 149 | return (None, None) |
| 150 | |
| 151 | def GetActiveFileName(bAutoSave = 1): |
| 152 | """Gets the file name for the active frame, saving it if necessary. |
| 153 | |
| 154 | Returns None if it cant be found, or raises KeyboardInterrupt. |
| 155 | """ |
| 156 | pathName = None |
| 157 | active = GetActiveView() |
| 158 | if active is None: |
| 159 | return None |
| 160 | try: |
| 161 | doc = active.GetDocument() |
| 162 | pathName = doc.GetPathName() |
| 163 | |
| 164 | if bAutoSave and \ |
| 165 | (len(pathName)>0 or \ |
| 166 | doc.GetTitle()[:8]=="Untitled" or \ |
| 167 | doc.GetTitle()[:6]=="Script"): # if not a special purpose window |
| 168 | if doc.IsModified(): |
| 169 | try: |
| 170 | doc.OnSaveDocument(pathName) |
| 171 | pathName = doc.GetPathName() |
| 172 | |
| 173 | # clear the linecache buffer |
| 174 | linecache.clearcache() |
| 175 | |
| 176 | except win32ui.error: |
| 177 | raise KeyboardInterrupt |
| 178 | |
| 179 | except (win32ui.error, AttributeError): |
| 180 | pass |
| 181 | if not pathName: |
| 182 | return None |
| 183 | return pathName |
| 184 | |
| 185 | lastScript = '' |
| 186 | lastArgs = '' |
no test coverage detected