diff options
author | Ross Burton <ross.burton@intel.com> | 2017-10-04 14:12:41 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-10-07 23:20:40 +0100 |
commit | 6172b0131fbfc3a43b7b6d98819058f1e2ce2a92 (patch) | |
tree | 08f44366de63af0c4efe20e86c79a63847bf1f0b | |
parent | 777015d7a3c45d6b10e1acd6bb1d0e60a111eb06 (diff) | |
download | poky-6172b0131fbfc3a43b7b6d98819058f1e2ce2a92.tar.gz |
oe-pkgdata-util: add unescape option to read-value
Some fields are multiline values which have been escaped, so add an option to
unescape the \n and \t.
(From OE-Core rev: 4165ec0057c6bbb24de681572034262351d9b34f)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | scripts/oe-pkgdata-util | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util index a690870b1c..c6fba56c89 100755 --- a/scripts/oe-pkgdata-util +++ b/scripts/oe-pkgdata-util | |||
@@ -197,6 +197,10 @@ def read_value(args): | |||
197 | # PKGSIZE is now in bytes, but we we want it in KB | 197 | # PKGSIZE is now in bytes, but we we want it in KB |
198 | pkgsize = (int(value) + 1024 // 2) // 1024 | 198 | pkgsize = (int(value) + 1024 // 2) // 1024 |
199 | value = "%d" % pkgsize | 199 | value = "%d" % pkgsize |
200 | if args.unescape: | ||
201 | import codecs | ||
202 | # escape_decode() unescapes backslash encodings in byte streams | ||
203 | value = codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8") | ||
200 | if args.prefix_name: | 204 | if args.prefix_name: |
201 | print('%s %s' % (pkg_name, value)) | 205 | print('%s %s' % (pkg_name, value)) |
202 | else: | 206 | else: |
@@ -552,6 +556,7 @@ def main(): | |||
552 | parser_read_value.add_argument('pkg', nargs='*', help='Runtime package name to look up') | 556 | parser_read_value.add_argument('pkg', nargs='*', help='Runtime package name to look up') |
553 | parser_read_value.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)') | 557 | parser_read_value.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)') |
554 | parser_read_value.add_argument('-n', '--prefix-name', help='Prefix output with package name', action='store_true') | 558 | parser_read_value.add_argument('-n', '--prefix-name', help='Prefix output with package name', action='store_true') |
559 | parser_read_value.add_argument('-u', '--unescape', help='Expand escapes such as \\n', action='store_true') | ||
555 | parser_read_value.set_defaults(func=read_value) | 560 | parser_read_value.set_defaults(func=read_value) |
556 | 561 | ||
557 | parser_glob = subparsers.add_parser('glob', | 562 | parser_glob = subparsers.add_parser('glob', |