-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing function parse_dtbo and function dtbo_is_compatible with py…
…thon scripts
- Loading branch information
Showing
5 changed files
with
63 additions
and
60 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
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,57 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: UTF-8 -*- | ||
|
||
from sys import argv, stdin, stderr | ||
import yaml, re, os, argparse | ||
|
||
def status(file): | ||
if ".disabled" in os.path.splitext(file)[-1]: | ||
print("OFF") | ||
else: | ||
print("ON") | ||
def basename(file): | ||
print(re.match(r'(.+\.dtbo)',os.path.basename(file)).group(1)) | ||
|
||
def short_print(metadata): | ||
print(metadata[args.keyword][0].replace("\0", "\n")) | ||
|
||
def short_error_print(file): | ||
if args.e == "file": | ||
basename(file) | ||
else: | ||
print(args.e) | ||
|
||
def long_print(metadata,file): | ||
short_print(metadata) | ||
status(file) | ||
basename(file) | ||
|
||
def long_error_print(file): | ||
if args.e == "file":basename(file) | ||
else: | ||
print(args.e) | ||
status(file) | ||
basename(file) | ||
parser = argparse.ArgumentParser(description='Parse dtbo metadata data') | ||
parser.add_argument('-F', action='store_true', default=False, help='Control print DTBO title,enable status and DTBO filename') | ||
parser.add_argument('-e', metavar='string', default="null", help='error default string') | ||
parser.add_argument('keyword', metavar='string', help='Keyword') | ||
parser.add_argument('filename', nargs='+', metavar='filename', help='DTBO filename list') | ||
|
||
args = parser.parse_args() | ||
|
||
yaml.CLoader.add_constructor('!u8', yaml.constructor.FullConstructor.construct_yaml_seq) | ||
if args.F: | ||
for file in args.filename: | ||
try: | ||
metadata=yaml.load(os.popen("dtc -I dtb -O dts " + file + " 2>/dev/null | dtc -I dts -O yaml 2>/dev/null").read(), Loader=yaml.CLoader)[0]["metadata"] | ||
long_print(metadata,file) | ||
except Exception as e: | ||
long_error_print(file) | ||
else: | ||
for file in args.filename: | ||
try: | ||
metadata=yaml.load(os.popen("dtc -I dtb -O dts " + file + " 2>/dev/null | dtc -I dts -O yaml 2>/dev/null").read(), Loader=yaml.CLoader)[0]["metadata"] | ||
short_print(metadata) | ||
except Exception as e: | ||
short_error_print(file) |
This file was deleted.
Oops, something went wrong.
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