summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2020-05-12 17:25:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-12 17:25:11 +0000
commit0ee5b3713cc20dffa6408398d94483bbcd5bb7ad (patch)
treebd95f943d9706bb15092d31f7a1ae59050e60339
parent2ea0ae67ceb742ee81b50d9f719567b20dafbcad (diff)
parenta5213a25ff1a930d18cbfc88e2eca810aa848b92 (diff)
downloadmedia-0ee5b3713cc20dffa6408398d94483bbcd5bb7ad.tar.gz
Merge "Camera: Move metadata generation scripts to python3" into rvc-dev
-rw-r--r--camera/docs/docs.html24
-rwxr-xr-xcamera/docs/metadata-check-dependencies10
-rwxr-xr-xcamera/docs/metadata-generate4
-rwxr-xr-xcamera/docs/metadata-parser-sanity-check4
-rwxr-xr-xcamera/docs/metadata-validate2
-rw-r--r--camera/docs/metadata_definitions.xml1
-rw-r--r--camera/docs/metadata_helpers.py18
-rw-r--r--camera/docs/metadata_helpers_test.py50
-rw-r--r--camera/docs/metadata_model.py59
-rwxr-xr-xcamera/docs/metadata_parser_xml.py20
-rw-r--r--camera/docs/metadata_template.mako2
-rwxr-xr-xcamera/docs/metadata_validate.py12
-rw-r--r--camera/docs/ndk_camera_metadata_tags.mako4
-rw-r--r--camera/docs/plots.py12
14 files changed, 112 insertions, 110 deletions
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index 27178240..c2c64cbc 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -4857,11 +4857,13 @@ crop to achieve aspect ratios different than the native camera sensor.<wbr/></p>
<p>By using this control,<wbr/> the application gains a simpler way to control zoom,<wbr/> which can
be a combination of optical and digital zoom.<wbr/> For example,<wbr/> a multi-camera system may
contain more than one lens with different focal lengths,<wbr/> and the user can use optical
-zoom by switching between lenses.<wbr/> Using zoomRatio has benefits in the scenarios below:
-<em> Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
- better precision compared to an integer value of <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>.<wbr/>
-</em> Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
- <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a> doesn't.<wbr/></p>
+zoom by switching between lenses.<wbr/> Using zoomRatio has benefits in the scenarios below:</p>
+<ul>
+<li>Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
+ better precision compared to an integer value of <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>.<wbr/></li>
+<li>Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
+ <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a> doesn't.<wbr/></li>
+</ul>
<p>To illustrate,<wbr/> here are several scenarios of different zoom ratios,<wbr/> crop regions,<wbr/>
and output streams,<wbr/> for a hypothetical camera device with an active array of size
<code>(2000,<wbr/>1500)</code>.<wbr/></p>
@@ -10492,11 +10494,13 @@ crop to achieve aspect ratios different than the native camera sensor.<wbr/></p>
<p>By using this control,<wbr/> the application gains a simpler way to control zoom,<wbr/> which can
be a combination of optical and digital zoom.<wbr/> For example,<wbr/> a multi-camera system may
contain more than one lens with different focal lengths,<wbr/> and the user can use optical
-zoom by switching between lenses.<wbr/> Using zoomRatio has benefits in the scenarios below:
-<em> Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
- better precision compared to an integer value of <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>.<wbr/>
-</em> Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
- <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a> doesn't.<wbr/></p>
+zoom by switching between lenses.<wbr/> Using zoomRatio has benefits in the scenarios below:</p>
+<ul>
+<li>Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
+ better precision compared to an integer value of <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>.<wbr/></li>
+<li>Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
+ <a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a> doesn't.<wbr/></li>
+</ul>
<p>To illustrate,<wbr/> here are several scenarios of different zoom ratios,<wbr/> crop regions,<wbr/>
and output streams,<wbr/> for a hypothetical camera device with an active array of size
<code>(2000,<wbr/>1500)</code>.<wbr/></p>
diff --git a/camera/docs/metadata-check-dependencies b/camera/docs/metadata-check-dependencies
index 3ad7b1b6..73db4760 100755
--- a/camera/docs/metadata-check-dependencies
+++ b/camera/docs/metadata-check-dependencies
@@ -82,7 +82,7 @@ function python_check()
local pkg=""
- if python -c "import $mod" >& /dev/null
+ if python3 -c "import $mod" >& /dev/null
then
return 0
fi
@@ -106,10 +106,10 @@ function python_check()
binary_check xmllint libxml2 libxml2-utils
binary_check tidy tidy tidy
-binary_check python python27 python2.7
-python_check bs4 py27-beautifulsoup4 python-bs4
-python_check mako py27-mako python-mako
-python_check markdown py27-markdown python-markdown
+binary_check python3
+python_check bs4 python-bs4 python3-bs4
+python_check mako python-mako
+python_check markdown python-markdown python3-markdown
exit $retcode
diff --git a/camera/docs/metadata-generate b/camera/docs/metadata-generate
index 31c7cf5a..b8c6bbfe 100755
--- a/camera/docs/metadata-generate
+++ b/camera/docs/metadata-generate
@@ -47,7 +47,7 @@ device_info_dir="$ANDROID_BUILD_TOP/cts/tools/cts-device-info/"`
out_files=()
function relpath() {
- python -c "import os.path; print os.path.relpath('$1', '$PWD')"
+ python3 -c "import os.path; print(os.path.relpath('$1', '$PWD'))"
}
# Generates a file. Appends to $out_files array as a side effect.
@@ -66,7 +66,7 @@ function gen_file_abs() {
local hal_version="${4:-3.2}"
local spec_file=$thisdir/metadata_definitions.xml
- python $thisdir/metadata_parser_xml.py $spec_file $in $out $hal_version
+ python3 $thisdir/metadata_parser_xml.py $spec_file $in $out $hal_version
local succ=$?
diff --git a/camera/docs/metadata-parser-sanity-check b/camera/docs/metadata-parser-sanity-check
index efc9ce67..fc97b7cb 100755
--- a/camera/docs/metadata-parser-sanity-check
+++ b/camera/docs/metadata-parser-sanity-check
@@ -33,7 +33,7 @@ function check_test
{
local file="$1"
local results
- results="$(python "$file" 2>&1)"
+ results="$(python3 "$file" 2>&1)"
local retval=$?
if [[ $retval -ne 0 ]]
then
@@ -47,7 +47,7 @@ function check_test
check_test "$thisdir/metadata_model_test.py" || exit 1
check_test "$thisdir/metadata_helpers_test.py" || exit 1
-python $thisdir/metadata_parser_xml.py $thisdir/metadata_definitions.xml $thisdir/metadata_template.mako $tmp_out || exit 1
+python3 $thisdir/metadata_parser_xml.py $thisdir/metadata_definitions.xml $thisdir/metadata_template.mako $tmp_out || exit 1
tidy -indent -xml -quiet $thisdir/metadata_definitions.xml > $tmp_tidy1
tidy -indent -xml -quiet $tmp_out > $tmp_tidy2
diff --git a/camera/docs/metadata-validate b/camera/docs/metadata-validate
index 78d6823b..8d60a681 100755
--- a/camera/docs/metadata-validate
+++ b/camera/docs/metadata-validate
@@ -29,5 +29,5 @@ schema=$thisdir/metadata_definitions.xsd
doc=$1
xmllint --noout --schema $schema $doc || exit 1
-python $thisdir/metadata_validate.py $doc || exit 1
+python3 $thisdir/metadata_validate.py $doc || exit 1
diff --git a/camera/docs/metadata_definitions.xml b/camera/docs/metadata_definitions.xml
index cbf74e17..7f22143a 100644
--- a/camera/docs/metadata_definitions.xml
+++ b/camera/docs/metadata_definitions.xml
@@ -3271,6 +3271,7 @@ xsi:schemaLocation="http://schemas.android.com/service/camera/metadata/ metadata
be a combination of optical and digital zoom. For example, a multi-camera system may
contain more than one lens with different focal lengths, and the user can use optical
zoom by switching between lenses. Using zoomRatio has benefits in the scenarios below:
+
* Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
better precision compared to an integer value of android.scaler.cropRegion.
* Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
diff --git a/camera/docs/metadata_helpers.py b/camera/docs/metadata_helpers.py
index a8e3a953..b9aee3fe 100644
--- a/camera/docs/metadata_helpers.py
+++ b/camera/docs/metadata_helpers.py
@@ -103,7 +103,7 @@ def find_unique_entries(node):
for entry in i.entries:
d[entry.name] = entry
- for k,v in d.iteritems():
+ for k,v in d.items():
yield v.merge()
def path_name(node):
@@ -184,9 +184,8 @@ def protobuf_type(entry):
}
if typeName not in typename_to_protobuftype:
- print >> sys.stderr,\
- " ERROR: Could not find protocol buffer type for {%s} type {%s} typedef {%s}" % \
- (entry.name, entry.type, entry.typedef)
+ print(" ERROR: Could not find protocol buffer type for {%s} type {%s} typedef {%s}" % \
+ (entry.name, entry.type, entry.typedef), file=sys.stderr)
proto_type = typename_to_protobuftype[typeName]
@@ -676,7 +675,10 @@ def enumerate_with_last(iterable):
"""
it = (i for i in iterable)
- first = next(it) # OK: raises exception if it is empty
+ try:
+ first = next(it) # OK: raises exception if it is empty
+ except StopIteration:
+ return
second = first # for when we have only 1 element in iterable
@@ -1229,8 +1231,8 @@ def filter_tags(text, metadata, filter_function, summary_function = None):
tag_set.add(node)
return whole_match.replace(candidate,filter_function(node))
else:
- print >> sys.stderr,\
- " WARNING: Could not crossref likely reference {%s}" % (match.group(0))
+ print(" WARNING: Could not crossref likely reference {%s}" % (match.group(0)),
+ file=sys.stderr)
return whole_match
text = re.sub(tag_match, filter_sub, text)
@@ -1294,7 +1296,7 @@ def filter_links(text, filter_function, summary_function = None):
target_ndk = match.group(2)
shortname = match.group(3).strip()
- #print "Found link '%s' ndk '%s' as '%s' -> '%s'" % (target, target_ndk, shortname, filter_function(target, target_ndk, shortname))
+ #print("Found link '%s' ndk '%s' as '%s' -> '%s'" % (target, target_ndk, shortname, filter_function(target, target_ndk, shortname)))
# Replace match with crossref
target_set.add(target)
diff --git a/camera/docs/metadata_helpers_test.py b/camera/docs/metadata_helpers_test.py
index 812a0d76..70ab765c 100644
--- a/camera/docs/metadata_helpers_test.py
+++ b/camera/docs/metadata_helpers_test.py
@@ -71,8 +71,8 @@ class TestHelpers(TestCase):
def test_enum_calculate_value_string(self):
def compare_values_against_list(expected_list, enum):
for (idx, val) in enumerate(expected_list):
- self.assertEquals(val,
- enum_calculate_value_string(list(enum.values)[idx]))
+ self.assertEqual(val,
+ enum_calculate_value_string(list(enum.values)[idx]))
plain_enum = Enum(parent=None, values=['ON', 'OFF'])
@@ -112,8 +112,8 @@ class TestHelpers(TestCase):
single_value = [1]
for (x, last) in enumerate_with_last(single_value):
- self.assertEquals(1, x)
- self.assertEquals(True, last)
+ self.assertEqual(1, x)
+ self.assertEqual(True, last)
multiple_values = [4, 5, 6]
lst = list(enumerate_with_last(multiple_values))
@@ -162,56 +162,56 @@ If the path foo/android.testOuter1.testSection1.control1/bar.txt exists, then oh
wbr_gen = itertools.repeat(wbr_string)
# No special characters, do nothing
- self.assertEquals("no-op", wbr("no-op"))
+ self.assertEqual("no-op", wbr("no-op"))
# Insert WBR after characters in [ '.', '/', '_' ]
- self.assertEquals("word.{0}".format(wbr_string), wbr("word."))
- self.assertEquals("word/{0}".format(wbr_string), wbr("word/"))
- self.assertEquals("word_{0}".format(wbr_string), wbr("word_"))
+ self.assertEqual("word.{0}".format(wbr_string), wbr("word."))
+ self.assertEqual("word/{0}".format(wbr_string), wbr("word/"))
+ self.assertEqual("word_{0}".format(wbr_string), wbr("word_"))
- self.assertEquals("word.{0}break".format(wbr_string), wbr("word.break"))
- self.assertEquals("word/{0}break".format(wbr_string), wbr("word/break"))
- self.assertEquals("word_{0}break".format(wbr_string), wbr("word_break"))
+ self.assertEqual("word.{0}break".format(wbr_string), wbr("word.break"))
+ self.assertEqual("word/{0}break".format(wbr_string), wbr("word/break"))
+ self.assertEqual("word_{0}break".format(wbr_string), wbr("word_break"))
# Test words with more components
- self.assertEquals("word_{0}break_{0}again".format(wbr_string),
+ self.assertEqual("word_{0}break_{0}again".format(wbr_string),
wbr("word_break_again"))
- self.assertEquals("word_{0}break_{0}again_{0}emphasis".format(wbr_string),
+ self.assertEqual("word_{0}break_{0}again_{0}emphasis".format(wbr_string),
wbr("word_break_again_emphasis"))
# Words with 2 or less subcomponents are ignored for the capital letters
- self.assertEquals("word_{0}breakIgnored".format(wbr_string),
+ self.assertEqual("word_{0}breakIgnored".format(wbr_string),
wbr("word_breakIgnored"))
- self.assertEquals("wordIgnored".format(wbr_string),
+ self.assertEqual("wordIgnored".format(wbr_string),
wbr("wordIgnored"))
# Words with at least 3 sub components get word breaks before caps
- self.assertEquals("word_{0}break_{0}again{0}Capitalized".format(wbr_string),
+ self.assertEqual("word_{0}break_{0}again{0}Capitalized".format(wbr_string),
wbr("word_break_againCapitalized"))
- self.assertEquals("word.{0}break.{0}again{0}Capitalized".format(wbr_string),
+ self.assertEqual("word.{0}break.{0}again{0}Capitalized".format(wbr_string),
wbr("word.break.againCapitalized"))
- self.assertEquals("a.{0}b{0}C.{0}d{0}E.{0}f{0}G".format(wbr_string),
+ self.assertEqual("a.{0}b{0}C.{0}d{0}E.{0}f{0}G".format(wbr_string),
wbr("a.bC.dE.fG"))
# Don't be overly aggressive with all caps
- self.assertEquals("TRANSFORM_{0}MATRIX".format(wbr_string),
+ self.assertEqual("TRANSFORM_{0}MATRIX".format(wbr_string),
wbr("TRANSFORM_MATRIX"))
- self.assertEquals("SCENE_{0}MODE_{0}FACE_{0}PRIORITY".format(wbr_string),
+ self.assertEqual("SCENE_{0}MODE_{0}FACE_{0}PRIORITY".format(wbr_string),
wbr("SCENE_MODE_FACE_PRIORITY"))
- self.assertEquals("android.{0}color{0}Correction.{0}mode is TRANSFORM_{0}MATRIX.{0}".format(wbr_string),
+ self.assertEqual("android.{0}color{0}Correction.{0}mode is TRANSFORM_{0}MATRIX.{0}".format(wbr_string),
wbr("android.colorCorrection.mode is TRANSFORM_MATRIX."))
- self.assertEquals("The overrides listed for SCENE_{0}MODE_{0}FACE_{0}PRIORITY are ignored".format(wbr_string),
+ self.assertEqual("The overrides listed for SCENE_{0}MODE_{0}FACE_{0}PRIORITY are ignored".format(wbr_string),
wbr("The overrides listed for SCENE_MODE_FACE_PRIORITY are ignored"));
def test_dedent(self):
# Remove whitespace from 2nd and 3rd line (equal ws)
- self.assertEquals("bar\nline1\nline2", dedent("bar\n line1\n line2"))
+ self.assertEqual("bar\nline1\nline2", dedent("bar\n line1\n line2"))
# Remove whitespace from all lines (1st line ws < 2/3 line ws)
- self.assertEquals("bar\nline1\nline2", dedent(" bar\n line1\n line2"))
+ self.assertEqual("bar\nline1\nline2", dedent(" bar\n line1\n line2"))
# Remove some whitespace from 2nd line, all whitespace from other lines
- self.assertEquals("bar\n line1\nline2", dedent(" bar\n line1\n line2"))
+ self.assertEqual("bar\n line1\nline2", dedent(" bar\n line1\n line2"))
if __name__ == '__main__':
unittest.main()
diff --git a/camera/docs/metadata_model.py b/camera/docs/metadata_model.py
index 1172971e..48c085e0 100644
--- a/camera/docs/metadata_model.py
+++ b/camera/docs/metadata_model.py
@@ -36,6 +36,7 @@ metadata_definitions.xml file.
"""
import sys
+import functools
import itertools
from collections import OrderedDict
@@ -176,9 +177,8 @@ class Node(object):
for child in self._get_children():
if child.parent != self:
- print >> sys.stderr, ("ERROR: Node '%s' doesn't match the parent" + \
- "(expected: %s, actual %s)") \
- %(child, self, child.parent)
+ print("ERROR: Node '%s' doesn't match the parent (expected: %s, actual %s)" \
+ % (child, self, child.parent), file=sys.stderr)
succ = False
succ = child.validate_tree() and succ
@@ -422,9 +422,8 @@ class Metadata(Node):
# should not throw if we pass validation
# but can happen when importing obsolete CSV entries
if target_entry is None:
- print >> sys.stderr, ("WARNING: Clone entry '%s' target kind '%s'" + \
- " has no corresponding entry") \
- %(p.name, p.target_kind)
+ print("WARNING: Clone entry '%s' target kind '%s' has no corresponding entry" \
+ % (p.name, p.target_kind), file=sys.stderr)
def _construct_outer_namespaces(self):
@@ -432,7 +431,7 @@ class Metadata(Node):
self._outer_namespaces = []
root = self._dictionary_by_name(self._outer_namespaces)
- for ons_name, ons in root.iteritems():
+ for ons_name, ons in root.items():
ons._leafs = []
for p in self._entries_ordered:
@@ -443,7 +442,7 @@ class Metadata(Node):
if p not in ons._leafs:
ons._leafs.append(p)
- for ons_name, ons in root.iteritems():
+ for ons_name, ons in root.items():
ons.validate_tree()
@@ -457,7 +456,7 @@ class Metadata(Node):
def _construct_sections(self, outer_namespace):
sections_dict = self._dictionary_by_name(outer_namespace.sections)
- for sec_name, sec in sections_dict.iteritems():
+ for sec_name, sec in sections_dict.items():
sec._leafs = []
sec.validate_tree()
@@ -473,12 +472,11 @@ class Metadata(Node):
if p not in sec._leafs:
sec._leafs.append(p)
- for sec_name, sec in sections_dict.iteritems():
+ for sec_name, sec in sections_dict.items():
if not sec.validate_tree():
- print >> sys.stderr, ("ERROR: Failed to validate tree in " + \
- "construct_sections (start), with section = '%s'")\
- %(sec)
+ print("ERROR: Failed to validate tree in construct_sections (start), with section = '%s'"
+ % (sec), file=sys.stderr)
self._construct_kinds(sec)
@@ -486,9 +484,8 @@ class Metadata(Node):
outer_namespace._sections.append(sec)
if not sec.validate_tree():
- print >> sys.stderr, ("ERROR: Failed to validate tree in " + \
- "construct_sections (end), with section = '%s'") \
- %(sec)
+ print("ERROR: Failed to validate tree in construct_sections (end), with section = '%s'"
+ % (sec), file=sys.stderr)
# 'controls', 'static' 'dynamic'. etc
def _construct_kinds(self, section):
@@ -522,17 +519,17 @@ class Metadata(Node):
kind.validate_tree()
if not section.validate_tree():
- print >> sys.stderr, ("ERROR: Failed to validate tree in " + \
- "construct_kinds, with kind = '%s'") %(kind)
+ print("ERROR: Failed to validate tree in construct_kinds, with kind = '%s'" % (kind),
+ file=sys.stderr)
if not kind.validate_tree():
- print >> sys.stderr, ("ERROR: Failed to validate tree in " + \
- "construct_kinds, with kind = '%s'") %(kind)
+ print("ERROR: Failed to validate tree in construct_kinds, with kind = '%s'" % (kind),
+ file=sys.stderr)
def _construct_inner_namespaces(self, parent, depth=0):
#parent is InnerNamespace or Kind
ins_dict = self._dictionary_by_name(parent.namespaces)
- for name, ins in ins_dict.iteritems():
+ for name, ins in ins_dict.items():
ins._leafs = []
for p in parent._leafs:
@@ -546,7 +543,7 @@ class Metadata(Node):
if p not in ins._leafs:
ins._leafs.append(p)
- for name, ins in ins_dict.iteritems():
+ for name, ins in ins_dict.items():
ins.validate_tree()
# construct children INS
self._construct_inner_namespaces(ins, depth + 1)
@@ -558,9 +555,8 @@ class Metadata(Node):
parent._namespaces.append(ins)
if not ins.validate_tree():
- print >> sys.stderr, ("ERROR: Failed to validate tree in " + \
- "construct_inner_namespaces, with ins = '%s'") \
- %(ins)
+ print("ERROR: Failed to validate tree in construct_inner_namespaces, with ins = '%s'"
+ % (ins), file=sys.stderr)
# doesnt construct the entries, so much as links them
def _construct_entries(self, parent, depth=0):
@@ -573,7 +569,7 @@ class Metadata(Node):
entry = entry_dict.get(p.name, p)
entry_dict[p.name] = entry
- for name, entry in entry_dict.iteritems():
+ for name, entry in entry_dict.items():
old_parent = entry.parent
entry._parent = parent
@@ -582,9 +578,8 @@ class Metadata(Node):
parent._entries.append(entry)
if old_parent is not None and old_parent != parent:
- print >> sys.stderr, ("ERROR: Parent changed from '%s' to '%s' for " + \
- "entry '%s'") \
- %(old_parent.name, parent.name, entry.name)
+ print("ERROR: Parent changed from '%s' to '%s' for entry '%s'"
+ % (old_parent.name, parent.name, entry.name), file = sys.stderr)
def _get_children(self):
if self.outer_namespaces is not None:
@@ -749,7 +744,7 @@ class Section(Node):
return acc
- new_kinds_lst = reduce(aggregate_by_name, self.kinds, [])
+ new_kinds_lst = functools.reduce(aggregate_by_name, self.kinds, [])
for k in new_kinds_lst:
yield k
@@ -1201,8 +1196,8 @@ class Entry(Node):
"""
if kwargs.get('type') is None:
- print >> sys.stderr, "ERROR: Missing type for entry '%s' kind '%s'" \
- %(kwargs.get('name'), kwargs.get('kind'))
+ print("ERROR: Missing type for entry '%s' kind '%s'"
+ % (kwargs.get('name'), kwargs.get('kind')), file=sys.stderr)
# Attributes are Read-Only, but edges may be mutated by
# Metadata, particularly during construct_graph
diff --git a/camera/docs/metadata_parser_xml.py b/camera/docs/metadata_parser_xml.py
index 6d42466f..686073fb 100755
--- a/camera/docs/metadata_parser_xml.py
+++ b/camera/docs/metadata_parser_xml.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Copyright (C) 2012 The Android Open Source Project
@@ -37,11 +37,12 @@ Dependencies:
import sys
import os
-import StringIO
from bs4 import BeautifulSoup
from bs4 import NavigableString
+from io import StringIO
+
from mako.template import Template
from mako.lookup import TemplateLookup
from mako.runtime import Context
@@ -96,7 +97,7 @@ class MetadataParserXml:
Returns:
MetadataParserXml instance representing the XML file.
"""
- return MetadataParserXml(file(file_name).read(), file_name)
+ return MetadataParserXml(open(file_name).read(), file_name)
@property
def soup(self):
@@ -163,7 +164,7 @@ class MetadataParserXml:
d3 = self._parse_entry_optional(entry)
- entry_dict = dict(d.items() + d2.items() + d3.items())
+ entry_dict = {**d, **d2, **d3}
insert(entry_dict)
self.metadata.construct_graph()
@@ -331,7 +332,7 @@ class MetadataParserXml:
hal_version: target HAL version, used when generating HIDL HAL outputs.
Must be a string of form "X.Y" where X and Y are integers.
"""
- buf = StringIO.StringIO()
+ buf = StringIO()
metadata_helpers._context_buf = buf
metadata_helpers._hal_major_version = int(hal_version.partition('.')[0])
metadata_helpers._hal_minor_version = int(hal_version.partition('.')[2])
@@ -351,18 +352,17 @@ class MetadataParserXml:
buf.close()
if output_name is None:
- print tpl_data
+ print(tpl_data)
else:
- file(output_name, "w").write(tpl_data.encode('utf-8'))
+ open(output_name, "w").write(tpl_data)
#####################
#####################
if __name__ == "__main__":
if len(sys.argv) <= 2:
- print >> sys.stderr, \
- "Usage: %s <filename.xml> <template.mako> [<output_file>] [<hal_version>]" \
- % (sys.argv[0])
+ print("Usage: %s <filename.xml> <template.mako> [<output_file>] [<hal_version>]" \
+ % (sys.argv[0]), file=sys.stderr)
sys.exit(0)
file_name = sys.argv[1]
diff --git a/camera/docs/metadata_template.mako b/camera/docs/metadata_template.mako
index 7d9718d9..09922d05 100644
--- a/camera/docs/metadata_template.mako
+++ b/camera/docs/metadata_template.mako
@@ -32,7 +32,7 @@
<types>
% for typedef in metadata.types:
<typedef name="${typedef.name}">
- % for (language, klass) in typedef.languages.iteritems():
+ % for (language, klass) in typedef.languages.items():
<language name="${language}">${klass | h}</language>
% endfor
</typedef>
diff --git a/camera/docs/metadata_validate.py b/camera/docs/metadata_validate.py
index ede14494..31bf563f 100755
--- a/camera/docs/metadata_validate.py
+++ b/camera/docs/metadata_validate.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Copyright (C) 2012 The Android Open Source Project
@@ -183,7 +183,7 @@ def validate_error(msg):
Args:
msg: a string you want to be printed
"""
- print >> sys.stderr, "ERROR: " + msg
+ print("ERROR: %s" % (msg), file=sys.stderr)
def validate_clones(soup):
@@ -347,15 +347,15 @@ def validate_xml(xml):
if __name__ == "__main__":
if len(sys.argv) <= 1:
- print >> sys.stderr, "Usage: %s <filename.xml>" % (sys.argv[0])
+ print("Usage: %s <filename.xml>" % (sys.argv[0]), file=sys.stderr)
sys.exit(0)
file_name = sys.argv[1]
- succ = validate_xml(file(file_name).read()) is not None
+ succ = validate_xml(open(file_name).read()) is not None
if succ:
- print "%s: SUCCESS! Document validated" %(file_name)
+ print("%s: SUCCESS! Document validated" % (file_name))
sys.exit(0)
else:
- print >> sys.stderr, "%s: ERRORS: Document failed to validate" %(file_name)
+ print("%s: ERRORS: Document failed to validate" % (file_name), file=sys.stderr)
sys.exit(1)
diff --git a/camera/docs/ndk_camera_metadata_tags.mako b/camera/docs/ndk_camera_metadata_tags.mako
index dfbe6327..7811f999 100644
--- a/camera/docs/ndk_camera_metadata_tags.mako
+++ b/camera/docs/ndk_camera_metadata_tags.mako
@@ -145,9 +145,9 @@ typedef enum acamera_metadata_enum_${csym(ndk(entry.name)).lower()} {
% for val in entry.enum.values:
% if val.ndk_hidden:
<%
- print " WARNING: {}_{} is marked as hidden".format(csym(ndk(entry.name)), val.name) + \
+ print(" WARNING: {}_{} is marked as hidden".format(csym(ndk(entry.name)), val.name) + \
" enum in NDK. Please double check this value is properly hidden" + \
- " in NDK API implementation"
+ " in NDK API implementation")
%>\
% endif
% if val.hidden or val.ndk_hidden:
diff --git a/camera/docs/plots.py b/camera/docs/plots.py
index fb4e9643..9ec7cda3 100644
--- a/camera/docs/plots.py
+++ b/camera/docs/plots.py
@@ -43,7 +43,7 @@ def doc_coeff(x,y):
coeff_str += "%0.4f ]" % coeffs[-1]
- print coeff_str
+ print(coeff_str)
def doc_map(fig, imgMap, index):
plt.figure(fig.number)
@@ -75,7 +75,7 @@ doc_plot(lin_fig, x_lin, y_lin)
lin_title = 'Linear tonemapping curve'
plt.title(lin_title)
-print lin_title
+print(lin_title)
doc_coeff(x_lin, y_lin)
if args.save_figures:
@@ -91,7 +91,7 @@ doc_plot(inv_fig, x_inv, y_inv)
inv_title = 'Inverting tonemapping curve'
plt.title(inv_title)
-print inv_title
+print(inv_title)
doc_coeff(x_inv, y_inv)
if args.save_figures:
@@ -108,7 +108,7 @@ doc_plot(gamma_fig, x_gamma, y_gamma)
gamma_title = r'$\gamma=1/2.2$ tonemapping curve'
plt.title(gamma_title)
-print gamma_title
+print(gamma_title)
doc_coeff(x_gamma, y_gamma)
if args.save_figures:
@@ -124,7 +124,7 @@ doc_plot(srgb_fig, x_srgb, y_srgb)
srgb_title = 'sRGB tonemapping curve'
plt.title(srgb_title)
-print srgb_title
+print(srgb_title)
doc_coeff(x_srgb, y_srgb)
if args.save_figures:
@@ -199,7 +199,7 @@ doc_plot(rec709_fig, x_rec709, y_rec709)
rec709_title = 'Rec. 709 tonemapping curve'
plt.title(rec709_title)
-print rec709_title
+print(rec709_title)
doc_coeff(x_rec709, y_rec709)
if args.save_figures: