forked from ros-infrastructure/superflore
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2b928d
commit 307fbb6
Showing
13 changed files
with
334 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "superflore-gen-meta-pkgs", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${env:HOME}/.local/bin/superflore-gen-meta-pkgs", | ||
"stopOnEntry": true, | ||
"console": "none", | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"SUPERFLORE_GITHUB_TOKEN": "", | ||
"ROSDEP_DEBUG": "true" | ||
}, | ||
"args": [ | ||
"--dry-run", | ||
"--ros-distro", | ||
"bouncy", | ||
] | ||
}, | ||
{ | ||
"name": "superflore-check-ebuilds", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${env:HOME}/.local/bin/superflore-check-ebuilds", | ||
"stopOnEntry": true, | ||
"console": "none", | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"SUPERFLORE_GITHUB_TOKEN": "" | ||
}, | ||
"args": [ | ||
] | ||
}, | ||
{ | ||
"name": "superflore-gen-ebuilds", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${env:HOME}/.local/bin/superflore-gen-ebuilds", | ||
"stopOnEntry": true, | ||
"console": "none", | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"SUPERFLORE_GITHUB_TOKEN": "" | ||
}, | ||
"args": [ | ||
"--dry-run", | ||
"--ros-distro", | ||
"crystal" | ||
] | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"python.pythonPath": "env/bin/python", | ||
"python.linting.pylintEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ | |
'docker', | ||
'pyyaml', | ||
'pygithub', | ||
'catkin_pkg >= 0.4.0' | ||
'catkin_pkg >= 0.4.0', | ||
'bs4' | ||
] | ||
|
||
setup( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import urllib | ||
import bs4 | ||
|
||
from collections import OrderedDict | ||
|
||
|
||
class OpenEmbeddedLayersDB(object): | ||
def __init__(self): | ||
# Tells if we could read recipe information | ||
self._exists = False | ||
# Valid layers in priority order to filter when searching for a recipe | ||
self._prio_valid_layers = OrderedDict.fromkeys(['openembedded-core', 'meta-oe', 'meta-python', 'meta-multimedia', | ||
'meta-ros', 'meta-intel-realsense', 'meta-qt5', 'meta-clang', 'meta-sca', 'meta-openstack', 'meta-virtualization']) | ||
# All fields below come straight from OpenEmbedded Layer query table results | ||
self.name = '' | ||
self.version = '' | ||
self.summary = '' | ||
self.description = '' | ||
self.section = '' | ||
self.license = '' | ||
self.homepage = '' | ||
self.recipe = '' | ||
self.layer = '' | ||
self.inherits = '' | ||
self.dependencies = '' | ||
self.packageconfig = '' | ||
|
||
def __str__(self): | ||
if not self._exists: | ||
return '' | ||
return '\n'.join([getattr(self, i) for i in vars(self) if not i.startswith('_')]) | ||
|
||
def _fill_field(self, key, value): | ||
if key: | ||
my_attr = '{}'.format(key.split()[0].lower()) | ||
if hasattr(self, my_attr): | ||
setattr(self, my_attr, value) | ||
return True | ||
return False | ||
|
||
def _get_first_on_multiple_matches(self, bs): | ||
class QueryResult: | ||
def __init__(self): | ||
self.recipe_name = '' | ||
self.link = '' | ||
self.version = '' | ||
self.description = '' | ||
self.layer = '' | ||
|
||
def __str__(self): | ||
return '\n'.join([self.recipe_name, self.link, self.version, self.description, self.layer]) | ||
|
||
if bs.table.find('th', text='Recipe name'): | ||
tr = bs.table.find('tr') | ||
while tr: | ||
td = tr.find('td') | ||
tr = tr.findNext('tr') | ||
if not td: | ||
continue | ||
qr = QueryResult() | ||
for f in ['recipe_name', 'version', 'description', 'layer']: | ||
if f == 'recipe_name': | ||
a = td.find('a') | ||
if a: | ||
setattr(qr, 'link', str( | ||
"https://layers.openembedded.org" + a.get('href', ''))) | ||
setattr(qr, f, str(td.text)) | ||
td = td.find_next_sibling() | ||
if not td: | ||
break | ||
if qr.link: | ||
# Get first valid entry | ||
self._query_url(qr.link) | ||
return | ||
|
||
def _query_url(self, query_url): | ||
try: | ||
req = urllib.request.urlopen(query_url) | ||
read_str = req.read() | ||
bs = bs4.BeautifulSoup(read_str, "html.parser") | ||
th = bs.table.find('th', text='Name') | ||
while th: | ||
td = th.findNext('td') | ||
if td: | ||
self._exists |= self._fill_field( | ||
str(th.text), str(td.text)) | ||
th = th.findNext('th') | ||
except Exception: | ||
self._exists = False | ||
return | ||
if not self._exists and bs: | ||
# Didn't match fully, so search on multi-match table | ||
self._get_first_on_multiple_matches(bs) | ||
else: | ||
# Confirm that the only recipe found is indeed in a valid layer | ||
for layer in self._prio_valid_layers: | ||
if self.layer.startswith(layer): | ||
return | ||
self._exists = False | ||
|
||
def exists(self): | ||
return self._exists | ||
|
||
def query_recipe(self, recipe): | ||
if recipe: | ||
url_prefix = 'https://layers.openembedded.org/layerindex/branch/master/recipes/?q={}' | ||
for layer in self._prio_valid_layers: | ||
query_url = url_prefix.format( | ||
recipe + urllib.parse.quote(' layer:') + layer) | ||
self._query_url(query_url) | ||
if self.exists(): | ||
return | ||
|
||
|
||
def main(): | ||
for recipe in ['', 'clang', 'ament_cmake_core', 'ament-cmake-core', 'libxml2', 'bullet', 'sdl', 'sdl-image', 'qtbase']: | ||
print('Checking ' + recipe + '...') | ||
oe_query = OpenEmbeddedLayersDB() | ||
oe_query.query_recipe(recipe) | ||
if oe_query.exists(): | ||
print(oe_query) | ||
else: | ||
print("Recipe {} doesn't exist!".format(recipe)) | ||
print() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
haha, oops.