diff --git a/scripts/rosdistro_build_cache b/scripts/rosdistro_build_cache index e6607712..a344373d 100755 --- a/scripts/rosdistro_build_cache +++ b/scripts/rosdistro_build_cache @@ -33,8 +33,6 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import argparse import gzip import logging @@ -92,13 +90,7 @@ def main(): if args.dist_names and dist_name not in args.dist_names: continue # write the cache - data = yaml.dump(cache.get_data(), Dumper=CacheYamlDumper) - - # On Python 3, we must encode the unicode yaml str prior to writing it, - # whereas for Python 2, the yaml output is a str which cannot be further - # encoded (compared with a unicode object). - if sys.version_info[0] >= 3: - data = data.encode('utf-8') + data = yaml.dump(cache.get_data(), Dumper=CacheYamlDumper).encode() with open('%s-cache.yaml' % dist_name, 'wb') as f: print('- write cache file "%s-cache.yaml"' % dist_name) diff --git a/scripts/rosdistro_convert b/scripts/rosdistro_convert index c511b52b..bdb0c1c8 100755 --- a/scripts/rosdistro_convert +++ b/scripts/rosdistro_convert @@ -33,16 +33,11 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import os import subprocess import sys import tempfile -try: - from urllib.error import HTTPError -except ImportError: - from urllib2 import HTTPError +from urllib.error import HTTPError from rosdistro.common import rmtree from rosdistro.loader import load_url diff --git a/scripts/rosdistro_freeze_source b/scripts/rosdistro_freeze_source index d698f848..4182cd6e 100755 --- a/scripts/rosdistro_freeze_source +++ b/scripts/rosdistro_freeze_source @@ -33,8 +33,6 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import argparse import os.path import sys diff --git a/scripts/rosdistro_migrate_to_rep_141 b/scripts/rosdistro_migrate_to_rep_141 index 2596b73e..c0f331a9 100755 --- a/scripts/rosdistro_migrate_to_rep_141 +++ b/scripts/rosdistro_migrate_to_rep_141 @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function - import argparse import gzip import os diff --git a/scripts/rosdistro_migrate_to_rep_143 b/scripts/rosdistro_migrate_to_rep_143 index d2d6a778..e3dd3605 100755 --- a/scripts/rosdistro_migrate_to_rep_143 +++ b/scripts/rosdistro_migrate_to_rep_143 @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function - import argparse from rosdistro.verify import _yaml_header_lines diff --git a/src/rosdistro/__init__.py b/src/rosdistro/__init__.py index a7044c8f..41cfa06b 100644 --- a/src/rosdistro/__init__.py +++ b/src/rosdistro/__init__.py @@ -31,8 +31,6 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import gzip import logging import os diff --git a/src/rosdistro/aptdistro.py b/src/rosdistro/aptdistro.py index 2fb77cc4..38199c63 100644 --- a/src/rosdistro/aptdistro.py +++ b/src/rosdistro/aptdistro.py @@ -1,7 +1,4 @@ -try: - from urllib2 import urlopen -except ImportError: - from urllib.request import urlopen +from urllib.request import urlopen class AptDistro: diff --git a/src/rosdistro/common.py b/src/rosdistro/common.py index a7d381a3..4a94a7cc 100644 --- a/src/rosdistro/common.py +++ b/src/rosdistro/common.py @@ -1,5 +1,3 @@ -from __future__ import print_function - from errno import EACCES, EPERM import os import shutil diff --git a/src/rosdistro/develdistro.py b/src/rosdistro/develdistro.py index 4c388eae..442b8716 100644 --- a/src/rosdistro/develdistro.py +++ b/src/rosdistro/develdistro.py @@ -1,7 +1,5 @@ -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen +from urllib.request import urlopen + import yaml diff --git a/src/rosdistro/distribution_cache.py b/src/rosdistro/distribution_cache.py index 90281ffe..42f416a1 100644 --- a/src/rosdistro/distribution_cache.py +++ b/src/rosdistro/distribution_cache.py @@ -31,8 +31,6 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import sys from . import logger @@ -71,11 +69,6 @@ def __init__(self, name, data=None, distribution_file_data=None): self.source_repo_package_xmls[repo_name] = SourceRepositoryCache(repo_data) self.distribution_file.source_packages = self.get_source_packages() - # if Python 2 has converted the xml to unicode, convert it back - for k, v in self.release_package_xmls.items(): - if not isinstance(v, str) and not isinstance(v, bytes): - self.release_package_xmls[k] = v.encode('utf-8') - def get_data(self): data = {} data['type'] = 'cache' diff --git a/src/rosdistro/distribution_cache_generator.py b/src/rosdistro/distribution_cache_generator.py index 3e4e94ea..8646fe55 100644 --- a/src/rosdistro/distribution_cache_generator.py +++ b/src/rosdistro/distribution_cache_generator.py @@ -31,8 +31,6 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import gzip import os import re @@ -155,12 +153,7 @@ def __init__(self, *args, **kwargs): def ignore_aliases(self, content): """ Allow strings that look like package XML to alias to each other in the YAML output. """ - try: - basestring - except NameError: - # Python 3 - basestring = str - return not (isinstance(content, basestring) and 'abc' in sanitize_xml('abc') assert 'ab c' in sanitize_xml(' ab c ') - # This unicode check should be valid on both Python 2 and 3. + # This unicode check should be valid. assert 'français' in sanitize_xml(' français ') # subsequent parse calls will collapse empty tags, therefore sanitize should do the same