BaseTools: Fix old python2 idioms
authorGary Lin <glin@suse.com>
Mon, 25 Jun 2018 10:31:35 +0000 (18:31 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 27 Jun 2018 08:33:27 +0000 (16:33 +0800)
commit0d1f5b2b5dc3c1cf381be0a1ec8f960dc6029a93
tree370c6121707d6141988e1795f061e93abc112cbb
parent2617a73c3628473bacea887d885bdd1e7808ccc6
BaseTools: Fix old python2 idioms

Based on "futurize -f lib2to3.fixes.fix_idioms"

* Change some type comparisons to isinstance() calls:
    type(x) == T -> isinstance(x, T)
    type(x) is T -> isinstance(x, T)
    type(x) != T -> not isinstance(x, T)
    type(x) is not T -> not isinstance(x, T)

* Change "while 1:" into "while True:".

* Change both

    v = list(EXPR)
    v.sort()
    foo(v)

and the more general

    v = EXPR
    v.sort()
    foo(v)

into

    v = sorted(EXPR)
    foo(v)

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
31 files changed:
BaseTools/Scripts/MemoryProfileSymbolGen.py
BaseTools/Scripts/UpdateBuildVersions.py
BaseTools/Source/Python/AutoGen/BuildEngine.py
BaseTools/Source/Python/AutoGen/GenDepex.py
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Common/RangeExpression.py
BaseTools/Source/Python/Common/StringUtils.py
BaseTools/Source/Python/Common/ToolDefClassObject.py
BaseTools/Source/Python/Common/VpdInfoFile.py
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
BaseTools/Source/Python/Eot/Parser.py
BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py
BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
BaseTools/Source/Python/UPT/Library/Misc.py
BaseTools/Source/Python/UPT/Library/ParserValidate.py
BaseTools/Source/Python/UPT/Library/StringUtils.py
BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py
BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py
BaseTools/Source/Python/Workspace/BuildClassObject.py
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/build/BuildReport.py
BaseTools/Source/Python/build/build.py
BaseTools/gcc/mingw-gcc-build.py