catkinize_this.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 import rospy
4 from xml.dom import minidom
5 import subprocess
6 import os.path
7 
8 found = {}
9 
10 def get_root(package):
11  p = subprocess.Popen(['rospack', 'find', package], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
12  out, err = p.communicate()
13  return out.strip()
14 
15 def is_catkinized(package, root=None):
16  if package in found:
17  return found[package]
18 
19  if root is None:
20  root = get_root(package)
21  if root=='':
22  found[package] = None
23  return None
24  if os.path.exists('%s/package.xml'%root):
25  found[package] = True
26  return True
27  elif os.path.exists('%s/manifest.xml'%root):
28  found[package] = False
29  return False
30  else:
31  found[package] = None
32  return None
33 
34 def get_links(name):
35  if not os.path.exists(name):
36  return []
37  xmldoc = minidom.parse(name)
38  if 'package.xml' in name:
39  builds = xmldoc.getElementsByTagName('build_depend')
40  runs = xmldoc.getElementsByTagName('run_depend')
41  return [item.firstChild.nodeValue for item in builds+runs]
42  elif 'manifest.xml' in name:
43  itemlist = xmldoc.getElementsByTagName('depend')
44  return [item.attributes['package'].value for item in itemlist]
45  else:
46  None
47 
48 def check_status(package, depth=0, dlimit=0):
49  root = get_root(package)
50  is_cat = is_catkinized(package, root)
51  if is_cat:
52  links = get_links('%s/package.xml'%root)
53  elif is_cat==False:
54  links = get_links('%s/manifest.xml'%root)
55  else:
56  return
57 
58  s = "%s%s"%(" "*depth, package)
59  print s, " "*(50-len(s)), "CATKIN" if is_cat else "ROSPACK"
60 
61  if depth < dlimit:
62  for p2 in links:
63  if p2 not in found:
64  check_status(p2, depth+1, dlimit)
65 
66 
67 import sys
68 limit = 0
69 for arg in sys.argv[1:]:
70  if '--n' in arg:
71  limit = int(arg[3:])
72 for arg in sys.argv[1:]:
73  check_status(arg, dlimit=limit)
74 
def is_catkinized(package, root=None)
def get_links(name)
def get_root(package)
def check_status(package, depth=0, dlimit=0)


catkinize_this
Author(s): David V. Lu!!
autogenerated on Mon Jun 10 2019 15:48:44