def __eq__(self, item):
     if isinstance(item, MasterEntry):
         result = []
         if nmdurl.equal_uri(self.masteruri, item.masteruri):
             result = set(self.entry()).intersection(set(item.entry()))
         return len(result) > 0
     return False
示例#2
0
 def _add_history(self):
     for hitem in nm.settings().launch_history:
         if not hitem.startswith(os.path.sep):
             hitem_uri, _ = nmdurl.split(hitem, with_scheme=True)
             current_uri = nmdurl.nmduri(self._current_path)
             if nmdurl.equal_uri(hitem_uri, current_uri):
                 self._add_path(hitem, PathItem.RECENT_FILE, 0, 0,
                                os.path.basename(hitem))
示例#3
0
 def set_current_master(self, masteruri, mastername):
     self._current_master = masteruri.rstrip(os.path.sep)
     self._current_master_name = mastername
     if self._is_root(self._current_path):
         nm.nmd().file.list_path_threaded(self._current_path)
         if nmdurl.equal_uri(self._current_path, masteruri_from_master()):
             self._add_path(nmdurl.nmduri(self._current_master),
                            PathItem.REMOTE_DAEMON, 0, 0,
                            get_hostname(self._current_master_name))
示例#4
0
 def _listed_path(self, url, path, result):
     if not self.is_current_nmd(url):
         return
     root = self.invisibleRootItem()
     while root.rowCount():
         root.removeRow(0)
     self.pyqt_workaround.clear()
     # test for ROS root paths and add these if it is in ROS_PACKAGE_PATH
     isroot = path in ['', os.path.sep]
     if isroot:
         self.ros_root_paths[url] = []
     # append path items to the list model
     result_list = []
     for path_item in result:
         if isroot and path_item.type in [FileItem.DIR, FileItem.PACKAGE]:
             self.ros_root_paths[url].append(path_item.path)
         item = os.path.normpath(os.path.join(path, path_item.path))
         gpath = nmdurl.join(url, item)
         path_id = PathItem.NOT_FOUND
         if FileItem.FILE == path_item.type:
             _, ext = os.path.splitext(path_item.path)
             if ext in nm.settings(
             ).launch_view_file_ext or path_item.path.find('.launch.') > 0:
                 path_id = PathItem.FILE
         elif FileItem.DIR == path_item.type:
             path_id = PathItem.FOLDER
         elif FileItem.SYMLINK == path_item.type:
             pass
         elif FileItem.PACKAGE == path_item.type:
             path_id = PathItem.PACKAGE
         if path_id != PathItem.NOT_FOUND and not os.path.basename(
                 path_item.path).startswith('.'):
             # TODO: create filter for files
             result_list.append(
                 (gpath, path_id, path_item.mtime, path_item.size,
                  os.path.basename(path_item.path)))
     root_path = nmdurl.join(url, path)
     self._set_new_list(root_path, result_list)
     isroot = self._is_root(self._current_path)
     if isroot and not nmdurl.equal_uri(self._current_master,
                                        masteruri_from_master()):
         self._add_path(nmdurl.nmduri(self._current_master),
                        PathItem.REMOTE_DAEMON, 0, 0,
                        get_hostname(self._current_master_name))
     self.pathlist_handled.emit(root_path)
示例#5
0
 def is_current_nmd(self, url):
     return nmdurl.equal_uri(nmdurl.masteruri(url),
                             nmdurl.masteruri(self._current_path))