Oleksandr Kravchuk 43e6a43e3d python: Remove unnecessary 'from __future__ import'
All of the removed `from __future__ import` were needed in older
versions of Python (mostly 2.5.x and below) but later became mandatory
in most versions of Python 3 hence are not necessary anymore.

More specifically, according to __future__.py[1]:
- unicode_literals is part of Python since versions 2.6.0 and 3.0.0;
- print_function is part of Python since versions 2.6.0 and 3.0.0;
- absolute_import is part of Python since versions 2.5.0 and 3.0.0;
- division is part of Python since versions 2.2.0 and 3.0.0;

Get rid of those unnecessary imports to slightly clean up the codebase.

[1] https://github.com/python/cpython/blob/master/Lib/__future__.py
2020-08-03 11:40:27 +02:00

53 lines
1.6 KiB
Python

# Copyright 2008-2016 Free Software Foundation, Inc.
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
from .hier_block import HierBlockGenerator, QtHierBlockGenerator
from .top_block import TopBlockGenerator
from .cpp_top_block import CppTopBlockGenerator
from .cpp_hier_block import CppHierBlockGenerator
class Generator(object):
"""Adaptor for various generators (uses generate_options)"""
def __init__(self, flow_graph, file_path):
"""
Initialize the generator object.
Determine the file to generate.
Args:
flow_graph: the flow graph object
file_path: the path to the grc file
"""
self.generate_options = flow_graph.get_option('generate_options')
self.output_language = flow_graph.get_option('output_language')
if self.output_language == 'python':
if self.generate_options == 'hb':
generator_cls = HierBlockGenerator
elif self.generate_options == 'hb_qt_gui':
generator_cls = QtHierBlockGenerator
else:
generator_cls = TopBlockGenerator
elif self.output_language == 'cpp':
if self.generate_options == 'hb':
generator_cls = CppHierBlockGenerator
elif self.generate_options == 'hb_qt_gui':
pass
else:
generator_cls = CppTopBlockGenerator
self._generator = generator_cls(flow_graph, file_path)
def __getattr__(self, item):
"""get all other attrib from actual generator object"""
return getattr(self._generator, item)