Annotation of qemu/roms/seabios/tools/acpi_extract_preprocess.py, revision 1.1.1.1

1.1       root        1: #!/usr/bin/python
                      2: # Copyright (C) 2011 Red Hat, Inc., Michael S. Tsirkin <[email protected]>
                      3: #
                      4: # This file may be distributed under the terms of the GNU GPLv3 license.
                      5: 
                      6: # Read a preprocessed ASL listing and put each ACPI_EXTRACT
                      7: # directive in a comment, to make iasl skip it.
                      8: # We also put each directive on a new line, the machinery
                      9: # in tools/acpi_extract.py requires this.
                     10: 
                     11: import re;
                     12: import sys;
                     13: import fileinput;
                     14: 
                     15: def die(diag):
                     16:     sys.stderr.write("Error: %s\n" % (diag))
                     17:     sys.exit(1)
                     18: 
                     19: # Note: () around pattern make split return matched string as part of list
                     20: psplit = re.compile(r''' (
                     21:                           \b # At word boundary
                     22:                           ACPI_EXTRACT_\w+ # directive
                     23:                           \s+ # some whitespace
                     24:                           \w+ # array name
                     25:                          )''', re.VERBOSE);
                     26: 
                     27: lineno = 0
                     28: for line in fileinput.input():
                     29:     # line number and debug string to output in case of errors
                     30:     lineno = lineno + 1
                     31:     debug = "input line %d: %s" % (lineno, line.rstrip())
                     32: 
                     33:     s = psplit.split(line);
                     34:     # The way split works, each odd item is the matching ACPI_EXTRACT directive.
                     35:     # Put each in a comment, and on a line by itself.
                     36:     for i in range(len(s)):
                     37:         if (i % 2):
                     38:             sys.stdout.write("\n/* %s */\n" % s[i])
                     39:         else:
                     40:             sys.stdout.write(s[i])
                     41: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.