From c3c4896f3ce4d89516e46991aed5ad4977e4ea9c Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Mon, 28 May 2018 17:34:49 +0200 Subject: find_packages.py: Fix python style issues. --- scripts/find_packages.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/find_packages.py b/scripts/find_packages.py index 50453c1..970a25a 100755 --- a/scripts/find_packages.py +++ b/scripts/find_packages.py @@ -14,7 +14,7 @@ import bb.tinfoil def print_deps(tinfoil, abcd_file, rn): try: info = tinfoil.get_recipe_info(rn) - except: + except Exception: # fails on hostperl-runtime-native, virtual/libintl-native, grep-native, virtual/libiconv-native print('Failed to get recipe info for: %s' % rn) return [] @@ -50,10 +50,9 @@ def print_deps(tinfoil, abcd_file, rn): for src in src_uri: # Strip options. # TODO: ignore files with apply=false? - semi_pos = src.find(';') - if semi_pos > 0: - src = src[:semi_pos] - if src[0:7] == 'file://': + src = src.split(';', maxsplit=1)[0] + src_type = src.split('://', maxsplit=1)[0] + if src_type == 'file': # TODO: Get full path of patches and other files within the source # repo, not just the filesystem? fetch = bb.fetch2.Fetch([], data) @@ -61,18 +60,17 @@ def print_deps(tinfoil, abcd_file, rn): abcd_file.write(' - "%s"\n' % local) else: abcd_file.write(' - "%s"\n' % src) - if src[0:7] != 'http://' and src[0:8] != 'https://' and src[0:6] != 'ftp://' and src[0:6] != 'ssh://': + if src_type != 'http' and src_type != 'https' and src_type != 'ftp' and src_type != 'ssh': repos.append(src) if len(repos) > 1: print('Multiple repos not fully supported yet. Pacakge: %s' % info.pn) for repo in repos: - colon_pos = repo.find(':') + vcs_type, url = repo.split('://', maxsplit=1) abcd_file.write(' vcs:\n') - vcs_type = repo[:colon_pos] if vcs_type == 'gitsm': vcs_type = 'git' abcd_file.write(' type: "%s"\n' % vcs_type) - abcd_file.write(' url: "%s"\n' % repo[colon_pos + 3:]) + abcd_file.write(' url: "%s"\n' % url) # TODO: Actually support multiple repos here: abcd_file.write(' revision: "%s"\n' % srcrev) abcd_file.write(' branch: "%s"\n' % branch) -- cgit v1.2.3-54-g00ecf