Skip to content

Instantly share code, notes, and snippets.

@k-okada

k-okada/dep.py

Created Sep 10, 2018
Embed
What would you like to do?
#!/usr/bin/env python
from __future__ import print_function
import sys
import urllib
import yaml
import xml.etree.ElementTree as ET
f = open("distribution.yaml", "r+")
distribution = yaml.load(f)
# [[http://wiki.ros.org/axis_camera|axis_camera|target="_blank"]] ([[https://github.com/ros-drivers/axis_camera/tree/master|axis_camera|target="_blank"]])
for repo_keys in distribution['repositories'].keys():
repo = distribution['repositories'][repo_keys]
# check only for unmtaintained packages
if repo.has_key('status') and repo['status'] == 'unmaintained':
# get package name
if repo['release'].has_key('packages'):
packages = repo['release']['packages']
else:
packages = [repo_keys]
# get release information
version = repo['release']['version']
release_url = repo['release']['url']
tag = repo['release']['tags']['release']
# check maintainer name
manifest_url = release_url
manifest_url = manifest_url.replace('.git', '/{}/package.xml'.format(tag.format(package=packages[0],version=version)))
manifest_url = manifest_url.replace('github.com', 'raw.githubusercontent.com')
#print("Loading from ... {}".format(manifest_url), file=sys.stderr)
tree = ET.parse(urllib.urlopen(manifest_url))
# get soruce information
if repo.has_key('source'):
source_url = repo['source']['url']
version = repo['source']['version']
elif repo.has_key('doc'):
source_url = repo['doc']['url']
version = repo['doc']['version']
#print( "maintainer ... ", [maintainer.attrib['email'] for maintainer in tree.iter('maintainer')],file=sys.stderr)
if any(maintainer.attrib['email'] in ['ros-orphaned-packages@googlegroups.com', 'Sammy.Pfeiffer@student.uts.edu.au', 'dave@cse.unr.edu'] for maintainer in tree.iter('maintainer')):
#if any(maintainer.attrib['email'] in ['ros-orphaned-packages@googlegroups.com'] for maintainer in tree.iter('maintainer')):
print(" * [[http://wiki.ros.org/{repo}|{repo}|target=\"_black\"]] (".format(repo=repo_keys), end='')
print(" | ".join(list(map(lambda package : "[[http://wiki.ros.org/{package}|{package}|target=\"_blank\"]]".format(package=package), packages))), end='')
print(")")
print(" * source repository : [[{source_url}|{source_url}|target=\"_blank\"]]".format(source_url=source_url))
print(" * release repository : [[{release_url}|{release_url}|target=\"_blank\"]]".format(release_url=release_url))
print("")
else:
print("{} is unmaintained but not orphaned".format(source_url), file=sys.stderr)
print(" maintainer ... ", [maintainer.attrib['email'] for maintainer in tree.iter('maintainer')],file=sys.stderr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment