def SaveAsDocument(self,doc): old_file_path = doc.GetFilename() if not doc.SaveAs(): return new_file_path = doc.GetFilename() #if save as file is the same file as before,don't remove the old file watcher if doc.IsWatched and not parserutils.ComparePath(new_file_path,old_file_path): doc.FileWatcher.RemoveFile(old_file_path)
def CheckPathExist(self, path): items = [] root_item = self.tree_ctrl.GetRootItem() (item, cookie) = self.tree_ctrl.GetFirstChild(root_item) while item: items.append(item) (item, cookie) = self.tree_ctrl.GetNextChild(root_item, cookie) for item in items: if parserutils.ComparePath(self.tree_ctrl.GetItemText(item), path): return True return False
def GetCurdirImports(self): cur_project = wx.GetApp().GetService(project.ProjectEditor.ProjectService).GetView().GetDocument() if cur_project is None: return [] file_path_name = wx.GetApp().GetDocumentManager().GetCurrentView().GetDocument().GetFilename() cur_file_name = os.path.basename(file_path_name) dir_path = os.path.dirname(file_path_name) imports = [] for file_name in os.listdir(dir_path): if parserutils.ComparePath(cur_file_name,file_name) or not fileutils.is_python_file(file_name) \ or file_name.find(" ") != -1: continue file_path_name = os.path.join(dir_path,file_name) if os.path.isdir(file_path_name) and not parser.is_package_dir(file_path_name): continue imports.append(os.path.splitext(file_name)[0]) return imports