diff options
Diffstat (limited to 'scripts/contrib/bbvars.py')
| -rwxr-xr-x | scripts/contrib/bbvars.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/scripts/contrib/bbvars.py b/scripts/contrib/bbvars.py index 0896d64445..04f5023969 100755 --- a/scripts/contrib/bbvars.py +++ b/scripts/contrib/bbvars.py | |||
| @@ -24,12 +24,12 @@ import os.path | |||
| 24 | import re | 24 | import re |
| 25 | 25 | ||
| 26 | def usage(): | 26 | def usage(): |
| 27 | print 'Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0]) | 27 | print('Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0])) |
| 28 | print ' -d FILENAME documentation file to search' | 28 | print(' -d FILENAME documentation file to search') |
| 29 | print ' -h, --help display this help and exit' | 29 | print(' -h, --help display this help and exit') |
| 30 | print ' -m METADIR meta directory to search for recipes' | 30 | print(' -m METADIR meta directory to search for recipes') |
| 31 | print ' -t FILENAME documentation config file (for doc tags)' | 31 | print(' -t FILENAME documentation config file (for doc tags)') |
| 32 | print ' -T Only display variables with doc tags (requires -t)' | 32 | print(' -T Only display variables with doc tags (requires -t)') |
| 33 | 33 | ||
| 34 | def recipe_bbvars(recipe): | 34 | def recipe_bbvars(recipe): |
| 35 | ''' Return a unique set of every bbvar encountered in the recipe ''' | 35 | ''' Return a unique set of every bbvar encountered in the recipe ''' |
| @@ -38,8 +38,8 @@ def recipe_bbvars(recipe): | |||
| 38 | try: | 38 | try: |
| 39 | r = open(recipe) | 39 | r = open(recipe) |
| 40 | except IOError as (errno, strerror): | 40 | except IOError as (errno, strerror): |
| 41 | print 'WARNING: Failed to open recipe ', recipe | 41 | print('WARNING: Failed to open recipe ', recipe) |
| 42 | print strerror | 42 | print(strerror) |
| 43 | 43 | ||
| 44 | for line in r: | 44 | for line in r: |
| 45 | # Strip any comments from the line | 45 | # Strip any comments from the line |
| @@ -72,8 +72,8 @@ def bbvar_is_documented(var, docfiles): | |||
| 72 | try: | 72 | try: |
| 73 | f = open(doc) | 73 | f = open(doc) |
| 74 | except IOError as (errno, strerror): | 74 | except IOError as (errno, strerror): |
| 75 | print 'WARNING: Failed to open doc ', doc | 75 | print('WARNING: Failed to open doc ', doc) |
| 76 | print strerror | 76 | print(strerror) |
| 77 | for line in f: | 77 | for line in f: |
| 78 | if prog.match(line): | 78 | if prog.match(line): |
| 79 | return True | 79 | return True |
| @@ -110,7 +110,7 @@ def main(): | |||
| 110 | try: | 110 | try: |
| 111 | opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"]) | 111 | opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"]) |
| 112 | except getopt.GetoptError, err: | 112 | except getopt.GetoptError, err: |
| 113 | print '%s' % str(err) | 113 | print('%s' % str(err)) |
| 114 | usage() | 114 | usage() |
| 115 | sys.exit(2) | 115 | sys.exit(2) |
| 116 | 116 | ||
| @@ -122,13 +122,13 @@ def main(): | |||
| 122 | if os.path.isfile(a): | 122 | if os.path.isfile(a): |
| 123 | docfiles.append(a) | 123 | docfiles.append(a) |
| 124 | else: | 124 | else: |
| 125 | print 'ERROR: documentation file %s is not a regular file' % (a) | 125 | print('ERROR: documentation file %s is not a regular file' % a) |
| 126 | sys.exit(3) | 126 | sys.exit(3) |
| 127 | elif o == '-m': | 127 | elif o == '-m': |
| 128 | if os.path.isdir(a): | 128 | if os.path.isdir(a): |
| 129 | metadirs.append(a) | 129 | metadirs.append(a) |
| 130 | else: | 130 | else: |
| 131 | print 'ERROR: meta directory %s is not a directory' % (a) | 131 | print('ERROR: meta directory %s is not a directory' % a) |
| 132 | sys.exit(4) | 132 | sys.exit(4) |
| 133 | elif o == "-t": | 133 | elif o == "-t": |
| 134 | if os.path.isfile(a): | 134 | if os.path.isfile(a): |
| @@ -139,17 +139,17 @@ def main(): | |||
| 139 | assert False, "unhandled option" | 139 | assert False, "unhandled option" |
| 140 | 140 | ||
| 141 | if len(docfiles) == 0: | 141 | if len(docfiles) == 0: |
| 142 | print 'ERROR: no docfile specified' | 142 | print('ERROR: no docfile specified') |
| 143 | usage() | 143 | usage() |
| 144 | sys.exit(5) | 144 | sys.exit(5) |
| 145 | 145 | ||
| 146 | if len(metadirs) == 0: | 146 | if len(metadirs) == 0: |
| 147 | print 'ERROR: no metadir specified' | 147 | print('ERROR: no metadir specified') |
| 148 | usage() | 148 | usage() |
| 149 | sys.exit(6) | 149 | sys.exit(6) |
| 150 | 150 | ||
| 151 | if onlydoctags and docconf == "": | 151 | if onlydoctags and docconf == "": |
| 152 | print 'ERROR: no docconf specified' | 152 | print('ERROR: no docconf specified') |
| 153 | usage() | 153 | usage() |
| 154 | sys.exit(7) | 154 | sys.exit(7) |
| 155 | 155 | ||
| @@ -172,14 +172,14 @@ def main(): | |||
| 172 | varlen = varlen + 1 | 172 | varlen = varlen + 1 |
| 173 | 173 | ||
| 174 | # Report all undocumented variables | 174 | # Report all undocumented variables |
| 175 | print 'Found %d undocumented bb variables (out of %d):' % (len(undocumented), len(bbvars)) | 175 | print('Found %d undocumented bb variables (out of %d):' % (len(undocumented), len(bbvars))) |
| 176 | header = '%s%s%s' % (str("VARIABLE").ljust(varlen), str("COUNT").ljust(6), str("DOCTAG").ljust(7)) | 176 | header = '%s%s%s' % (str("VARIABLE").ljust(varlen), str("COUNT").ljust(6), str("DOCTAG").ljust(7)) |
| 177 | print header | 177 | print(header) |
| 178 | print str("").ljust(len(header), '=') | 178 | print(str("").ljust(len(header), '=')) |
| 179 | for v in undocumented: | 179 | for v in undocumented: |
| 180 | doctag = bbvar_doctag(v, docconf) | 180 | doctag = bbvar_doctag(v, docconf) |
| 181 | if not onlydoctags or not doctag == "": | 181 | if not onlydoctags or not doctag == "": |
| 182 | print '%s%s%s' % (v.ljust(varlen), str(bbvars[v]).ljust(6), doctag) | 182 | print('%s%s%s' % (v.ljust(varlen), str(bbvars[v]).ljust(6), doctag)) |
| 183 | 183 | ||
| 184 | 184 | ||
| 185 | if __name__ == "__main__": | 185 | if __name__ == "__main__": |
