mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-27 21:26:36 +00:00
graph-depends: fix code style
Fix these warnings: E122 continuation line missing indentation or outdented E127 continuation line over-indented for visual indent E128 continuation line under-indented for visual indent E202 whitespace before ']' E221 multiple spaces before operator E225 missing whitespace around operator E231 missing whitespace after ',' E302 expected 2 blank lines, found 1 E305 expected 2 blank lines after class or function definition, found 1 E502 the backslash is redundant between brackets E713 test for membership should be 'not in' Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
ceec22f569
commit
9ff44852c4
@ -3,6 +3,7 @@
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
# Execute the "make <pkg>-show-version" command to get the version of a given
|
||||
# list of packages, and return the version formatted as a Python dictionary.
|
||||
def get_version(pkgs):
|
||||
@ -25,6 +26,7 @@ def get_version(pkgs):
|
||||
version[pkg] = output[i]
|
||||
return version
|
||||
|
||||
|
||||
def _get_depends(pkgs, rule):
|
||||
sys.stderr.write("Getting dependencies for %s\n" % pkgs)
|
||||
cmd = ["make", "-s", "--no-print-directory"]
|
||||
@ -49,12 +51,14 @@ def _get_depends(pkgs, rule):
|
||||
deps[pkg] = pkg_deps
|
||||
return deps
|
||||
|
||||
|
||||
# Execute the "make <pkg>-show-depends" command to get the list of
|
||||
# dependencies of a given list of packages, and return the list of
|
||||
# dependencies formatted as a Python dictionary.
|
||||
def get_depends(pkgs):
|
||||
return _get_depends(pkgs, 'show-depends')
|
||||
|
||||
|
||||
# Execute the "make <pkg>-show-rdepends" command to get the list of
|
||||
# reverse dependencies of a given list of packages, and return the
|
||||
# list of dependencies formatted as a Python dictionary.
|
||||
|
@ -49,18 +49,18 @@ parser.add_argument("--package", '-p', metavar="PACKAGE",
|
||||
parser.add_argument("--depth", '-d', metavar="DEPTH", dest="depth", type=int, default=0,
|
||||
help="Limit the dependency graph to DEPTH levels; 0 means no limit.")
|
||||
parser.add_argument("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append",
|
||||
help="Do not graph past this package (can be given multiple times)." \
|
||||
+ " Can be a package name or a glob, " \
|
||||
+ " 'virtual' to stop on virtual packages, or " \
|
||||
+ "'host' to stop on host packages.")
|
||||
help="Do not graph past this package (can be given multiple times)." +
|
||||
" Can be a package name or a glob, " +
|
||||
" 'virtual' to stop on virtual packages, or " +
|
||||
"'host' to stop on host packages.")
|
||||
parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append",
|
||||
help="Like --stop-on, but do not add PACKAGE to the graph.")
|
||||
parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours",
|
||||
default="lightblue,grey,gainsboro",
|
||||
help="Comma-separated list of the three colours to use" \
|
||||
+ " to draw the top-level package, the target" \
|
||||
+ " packages, and the host packages, in this order." \
|
||||
+ " Defaults to: 'lightblue,grey,gainsboro'")
|
||||
help="Comma-separated list of the three colours to use" +
|
||||
" to draw the top-level package, the target" +
|
||||
" packages, and the host packages, in this order." +
|
||||
" Defaults to: 'lightblue,grey,gainsboro'")
|
||||
parser.add_argument("--transitive", dest="transitive", action='store_true',
|
||||
default=False)
|
||||
parser.add_argument("--no-transitive", dest="transitive", action='store_false',
|
||||
@ -124,6 +124,7 @@ host_colour = colours[2]
|
||||
|
||||
allpkgs = []
|
||||
|
||||
|
||||
# Execute the "make show-targets" command to get the list of the main
|
||||
# Buildroot PACKAGES and return it formatted as a Python list. This
|
||||
# list is used as the starting point for full dependency graphs
|
||||
@ -138,6 +139,7 @@ def get_targets():
|
||||
return []
|
||||
return output.split(' ')
|
||||
|
||||
|
||||
# Recursive function that builds the tree of dependencies for a given
|
||||
# list of packages. The dependencies are built in a list called
|
||||
# 'dependencies', which contains tuples of the form (pkg1 ->
|
||||
@ -179,11 +181,13 @@ def get_all_depends(pkgs):
|
||||
|
||||
return dependencies
|
||||
|
||||
|
||||
# The Graphviz "dot" utility doesn't like dashes in node names. So for
|
||||
# node names, we strip all dashes.
|
||||
def pkg_node_name(pkg):
|
||||
return pkg.replace("-", "")
|
||||
|
||||
|
||||
TARGET_EXCEPTIONS = [
|
||||
"target-finalize",
|
||||
"target-post-image",
|
||||
@ -225,18 +229,21 @@ for dep in dependencies:
|
||||
# sub-dicts is "pkg2".
|
||||
is_dep_cache = {}
|
||||
|
||||
|
||||
def is_dep_cache_insert(pkg, pkg2, val):
|
||||
try:
|
||||
is_dep_cache[pkg].update({pkg2: val})
|
||||
except KeyError:
|
||||
is_dep_cache[pkg] = {pkg2: val}
|
||||
|
||||
|
||||
# Retrieves from the cache whether pkg2 is a transitive dependency
|
||||
# of pkg.
|
||||
# Note: raises a KeyError exception if the dependency is not known.
|
||||
def is_dep_cache_lookup(pkg, pkg2):
|
||||
return is_dep_cache[pkg][pkg2]
|
||||
|
||||
|
||||
# This function return True if pkg is a dependency (direct or
|
||||
# transitive) of pkg2, dependencies being listed in the deps
|
||||
# dictionary. Returns False otherwise.
|
||||
@ -252,6 +259,7 @@ def is_dep_uncached(pkg,pkg2,deps):
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
# See is_dep_uncached() above; this is the cached version.
|
||||
def is_dep(pkg, pkg2, deps):
|
||||
try:
|
||||
@ -261,6 +269,7 @@ def is_dep(pkg,pkg2,deps):
|
||||
is_dep_cache_insert(pkg, pkg2, val)
|
||||
return val
|
||||
|
||||
|
||||
# This function eliminates transitive dependencies; for example, given
|
||||
# these dependency chain: A->{B,C} and B->{C}, the A->{C} dependency is
|
||||
# already covered by B->{C}, so C is a transitive dependency of A, via B.
|
||||
@ -283,16 +292,18 @@ def remove_transitive_deps(pkg,deps):
|
||||
new_d.append(d[i])
|
||||
return new_d
|
||||
|
||||
|
||||
# This function removes the dependency on some 'mandatory' package, like the
|
||||
# 'toolchain' package, or the 'skeleton' package
|
||||
def remove_mandatory_deps(pkg, deps):
|
||||
return [p for p in deps[pkg] if p not in ['toolchain', 'skeleton']]
|
||||
|
||||
|
||||
# This function will check that there is no loop in the dependency chain
|
||||
# As a side effect, it builds up the dependency cache.
|
||||
def check_circular_deps(deps):
|
||||
def recurse(pkg):
|
||||
if not pkg in list(deps.keys()):
|
||||
if pkg not in list(deps.keys()):
|
||||
return
|
||||
if pkg in not_loop:
|
||||
return
|
||||
@ -314,6 +325,7 @@ def check_circular_deps(deps):
|
||||
for pkg in list(deps.keys()):
|
||||
recurse(pkg)
|
||||
|
||||
|
||||
# This functions trims down the dependency list of all packages.
|
||||
# It applies in sequence all the dependency-elimination methods.
|
||||
def remove_extra_deps(deps):
|
||||
@ -325,6 +337,7 @@ def remove_extra_deps(deps):
|
||||
deps[pkg] = remove_transitive_deps(pkg, deps)
|
||||
return deps
|
||||
|
||||
|
||||
check_circular_deps(dict_deps)
|
||||
if check_only:
|
||||
sys.exit(0)
|
||||
@ -333,6 +346,7 @@ dict_deps = remove_extra_deps(dict_deps)
|
||||
dict_version = brpkgutil.get_version([pkg for pkg in allpkgs
|
||||
if pkg != "all" and not pkg.startswith("root")])
|
||||
|
||||
|
||||
# Print the attributes of a node: label and fill-color
|
||||
def print_attrs(pkg):
|
||||
name = pkg_node_name(pkg)
|
||||
@ -356,6 +370,7 @@ def print_attrs(pkg):
|
||||
outfile.write("%s [label = \"%s\"]\n" % (name, label))
|
||||
outfile.write("%s [color=%s,style=filled]\n" % (name, color))
|
||||
|
||||
|
||||
# Print the dependency graph of a package
|
||||
def print_pkg_deps(depth, pkg):
|
||||
if pkg in done_deps:
|
||||
@ -388,6 +403,7 @@ def print_pkg_deps(depth, pkg):
|
||||
outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir))
|
||||
print_pkg_deps(depth + 1, d)
|
||||
|
||||
|
||||
# Start printing the graph data
|
||||
outfile.write("digraph G {\n")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user