2 Copyright (C) 1997-2017 JDERobot Developers Team 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU Library General Public License for more details. 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, see <http://www.gnu.org/licenses/>. 17 Authors : Okan Asik (asik.okan@gmail.com) 22 from xml.dom
import minidom
23 from PyQt5.QtCore
import QCoreApplication, QSettings
32 QCoreApplication.setOrganizationName(
'JdeRobot')
33 QCoreApplication.setOrganizationDomain(
'jderobot.org')
34 QCoreApplication.setApplicationName(
'VisualStates')
41 count = settings.beginReadArray(
'workspaces')
42 for i
in range(count):
43 settings.setArrayIndex(i)
44 workspaces.append(settings.value(
'dir'))
53 settings.beginWriteArray(
'workspaces')
54 for i
in range(len(workspaces)):
55 settings.setArrayIndex(i)
56 settings.setValue(
'dir', workspaces[i])
64 if 'ROS_DISTRO' in os.environ:
65 rosDir =
'/opt/ros/' + os.environ[
'ROS_DISTRO']
67 rosDir =
'/opt/ros/kinetic' 69 messageDir = rosDir +
'/include' 70 if os.path.exists(messageDir):
71 allContents = os.listdir(messageDir)
73 for entry
in allContents:
74 if os.path.isdir(messageDir +
'/' + entry):
75 if entry.find(
'_msgs') >= 0:
76 messages.append(entry)
81 for entry
in os.listdir(messageDir +
'/' + msg):
82 if os.path.isfile(messageDir +
'/' + msg +
'/' + entry):
83 if entry.find(
'.h') >= 0
and entry[0].isupper():
85 type[
'typeDir'] = typeDir
86 type[
'type'] = entry[:entry.find(
'.h')]
95 if rospackmodule
is None:
96 rospackmodule = rospkg.RosPack()
97 return rospackmodule.get_path(
'visualstates')
103 if rosPackages
is None:
104 if rospackmodule
is None:
105 rospackmodule = rospkg.RosPack()
106 rosPackages = rospackmodule.list()
109 for dir
in workspaces:
111 rosPackages += packages
122 for dir
in workspaces:
126 for type
in messageTypes:
127 concatType = type[
'typeDir'] +
'/' + type[
'type']
128 concatTypes.append(concatType)
130 rosTypes = sorted(concatTypes)
138 for root, dirs, files
in os.walk(workspaceDir +
'/src'):
141 if not dir.startswith(
'.'):
142 visibleDirs.append(dir)
143 dirs[:] = visibleDirs
145 if file ==
'package.xml':
146 packageFiles.append(root +
'/' + file)
148 for pkgFile
in packageFiles:
149 doc = minidom.parse(pkgFile)
150 nameElement = doc.getElementsByTagName(
'package')[0].getElementsByTagName(
'name')[0]
151 if len(nameElement.childNodes) > 0:
152 packageNames.append(nameElement.childNodes[0].nodeValue)
156 if __name__ ==
'__main__':
159 print(
getPackages(
'/media/okan/depo/jderobot/catkin_ws'))
def getRosMessageTypes(rosDir=None)
def getPackages(workspaceDir)
def writeWorkspaces(workspaces)