summaryrefslogtreecommitdiff
path: root/virtconv
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2014-09-12 15:59:22 -0400
committerCole Robinson <crobinso@redhat.com>2014-09-12 16:28:38 -0400
commiteb7612356efd746ec142b6fca5e3df17bd80b2e0 (patch)
tree211c3f553c9b1b7512538588f83ac73a3239114a /virtconv
parentf512c0538128a5e6114b04afced2563ccba0479e (diff)
downloadvirt-manager-eb7612356efd746ec142b6fca5e3df17bd80b2e0.tar.gz
virtinst: Switch to relative imports, fix cyclic import warnings
Diffstat (limited to 'virtconv')
-rw-r--r--virtconv/formats.py18
-rw-r--r--virtconv/ovf.py2
-rw-r--r--virtconv/vmx.py2
3 files changed, 9 insertions, 13 deletions
diff --git a/virtconv/formats.py b/virtconv/formats.py
index ccdaa9cf..fed5e1c5 100644
--- a/virtconv/formats.py
+++ b/virtconv/formats.py
@@ -53,14 +53,10 @@ class parser_class(object):
raise NotImplementedError
-from virtconv.vmx import vmx_parser as _vmx_parser
-from virtconv.ovf import ovf_parser as _ovf_parser
-
-
-_parsers = [
- _vmx_parser,
- _ovf_parser,
-]
+def _get_parsers():
+ from .vmx import vmx_parser
+ from .ovf import ovf_parser
+ return [vmx_parser, ovf_parser]
def _is_test():
@@ -71,7 +67,7 @@ def _find_parser_by_name(input_name):
"""
Return the parser of the given name.
"""
- parsers = [p for p in _parsers if p.name == input_name]
+ parsers = [p for p in _get_parsers() if p.name == input_name]
if len(parsers):
return parsers[0]
raise RuntimeError(_("No parser found for type '%s'") % input_name)
@@ -81,7 +77,7 @@ def _find_parser_by_file(input_file):
"""
Return the parser that is capable of comprehending the given file.
"""
- for p in _parsers:
+ for p in _get_parsers():
if p.identify_file(input_file):
return p
raise RuntimeError(_("Don't know how to parse file %s") % input_file)
@@ -155,7 +151,7 @@ def _find_input(input_file, parser, print_cb):
parser = _find_parser_by_file(input_file)
return input_file, parser, force_clean
- parsers = parser and [parser] or _parsers
+ parsers = parser and [parser] or _get_parsers()
for root, ignore, files in os.walk(input_file):
for p in parsers:
for f in [f for f in files if f.endswith(p.suffix)]:
diff --git a/virtconv/ovf.py b/virtconv/ovf.py
index 90fcf16c..51ed1d47 100644
--- a/virtconv/ovf.py
+++ b/virtconv/ovf.py
@@ -25,7 +25,7 @@ import libxml2
import virtinst
-from virtconv.formats import parser_class
+from .formats import parser_class
# Mapping of ResourceType value to device type
diff --git a/virtconv/vmx.py b/virtconv/vmx.py
index 2c6db892..2234e6bd 100644
--- a/virtconv/vmx.py
+++ b/virtconv/vmx.py
@@ -27,7 +27,7 @@ import shlex
import virtinst
from virtinst import util
-from virtconv.formats import parser_class
+from .formats import parser_class
class _VMXLine(object):