From 59bbb580e34bbc5dce76dacaad9ff94f21fa396f Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 17 May 2013 10:49:33 +0900 Subject: Move Python version checking to a separate module Add a new module with methods for checking the Python version. Instead of handling Python3 imports with try...except blocks, first check the python version and then import the relevant modules. This makes the code a bit cleaner and will result in less diff when/if we remove support for Python < 3 later. Use the same mechanism to handle `input` vs. `raw_input` and add suppression of pylint warnings caused by redefinition of the built-in method `input`. Change-Id: Ia403e525b88d77640a741ac50382146e7d635924 Also-by: Chirayu Desai Signed-off-by: Chirayu Desai --- manifest_xml.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'manifest_xml.py') diff --git a/manifest_xml.py b/manifest_xml.py index cc441dc8..16476aa5 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -18,16 +18,16 @@ import itertools import os import re import sys -try: - # For python3 +import xml.dom.minidom + +from pyversion import is_python3 +if is_python3(): import urllib.parse -except ImportError: - # For python2 +else: import imp import urlparse urllib = imp.new_module('urllib') urllib.parse = urlparse -import xml.dom.minidom from git_config import GitConfig from git_refs import R_HEADS, HEAD -- cgit v1.2.3-54-g00ecf