Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed relative imports. #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OSTranslatorII/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

def classFactory(iface):
"""Load OsTranslatorII class from file OsTranslatorII."""
from .os_translator_ii import OsTranslatorII
from OSTranslatorII.os_translator_ii import OsTranslatorII
return OsTranslatorII(iface)
3 changes: 1 addition & 2 deletions OSTranslatorII/import_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# (at your option) any later version.

from __future__ import absolute_import
from builtins import str
from .import_task import *
from OSTranslatorII.import_task import *
import time

class ImportManager(QObject):
Expand Down
5 changes: 4 additions & 1 deletion OSTranslatorII/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ [email protected]
# Optional items:

# Uncomment the following line and add your changelog:
changelog=3.2.5 Bug fixes:
changelog=3.2.7 Bug fixes:
- fixed postprocessing while running in the CLI mode
- removed relative imports
<p>3.2.5 Bug fixes:
- applying OS styles
- cores number to be used (#54)
<p>3.2.4 Bug fixes:
Expand Down
11 changes: 6 additions & 5 deletions OSTranslatorII/os-translator-ii-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
# Fix ValueError: API 'QDate' has already been set to version 1
from __future__ import print_function
from __future__ import absolute_import
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
try:
import qgis.PyQt
except ImportError:
pass

import traceback
import sys
import argparse
import os
from qgis.PyQt import QtCore
from .import_manager import ImportManager
from .post_processor_thread import PostProcessorThread
from .utils import (
from import_manager import ImportManager
from post_processor_thread import PostProcessorThread
from utils import (
build_args,
get_input_files,
get_pioneer_file,
Expand Down
2 changes: 1 addition & 1 deletion OSTranslatorII/os-translator-ii-standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import sys
from qgis.PyQt import QtGui
from .os_translator_ii_dialog import OsTranslatorIIDialog
from OSTranslatorII.os_translator_ii_dialog import OsTranslatorIIDialog

def main():
app = QtGui.QApplication(sys.argv)
Expand Down
7 changes: 3 additions & 4 deletions OSTranslatorII/os_translator_ii.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
# (at your option) any later version.

from __future__ import absolute_import
from builtins import object
from qgis.PyQt.QtWidgets import QAction
from qgis.PyQt.QtGui import QIcon

from .os_translator_ii_dialog import OsTranslatorIIDialog
from .utils import OSII_icon_path
from OSTranslatorII.os_translator_ii_dialog import OsTranslatorIIDialog
from OSTranslatorII.utils import OSII_icon_path


class OsTranslatorII(object):
class OsTranslatorII:
"""QGIS Plugin Implementation."""

def __init__(self, iface):
Expand Down
8 changes: 4 additions & 4 deletions OSTranslatorII/os_translator_ii_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import xml.etree.ElementTree as ET

from math import floor
from .import_manager import *
from .result_dialog import *
from .post_processor_thread import *
from .utils import *
from OSTranslatorII.import_manager import *
from OSTranslatorII.result_dialog import *
from OSTranslatorII.post_processor_thread import *
from OSTranslatorII.utils import *

try:
from qgis.core import QgsDataSourceURI, QgsSettings
Expand Down
2 changes: 1 addition & 1 deletion OSTranslatorII/post_processor_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import traceback
import sys
from qgis.PyQt.QtCore import *
from .styler import *
from OSTranslatorII.styler import *

class PostProcessorThread(QThread):

Expand Down
2 changes: 1 addition & 1 deletion OSTranslatorII/result_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from __future__ import absolute_import
import os
from .utils import OSII_icon_path
from OSTranslatorII.utils import OSII_icon_path

from qgis.PyQt import QtGui, QtCore, uic
from qgis.PyQt import QtWidgets
Expand Down
5 changes: 2 additions & 3 deletions OSTranslatorII/styler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
# (at your option) any later version.

from __future__ import absolute_import
from builtins import object
import psycopg2
try:
from qgis.core import QgsVectorLayer
except ImportError:
pass # We may be calling the script from the console in which case this import is not used

from qgis.PyQt.Qt import QDomDocument
from . import utils
from OSTranslatorII import utils


class Styler(object):
class Styler:
def __init__(self, cur, uri, schema, osmm_schema, osmm_style_name):
self.cur = cur
self.uri = uri
Expand Down
15 changes: 7 additions & 8 deletions OSTranslatorII/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ def OSII_icon_path():
def download(packageUrl, destinationFileName):
handle = tempfile.NamedTemporaryFile(delete=False, suffix=destinationFileName)
name = handle.name

try:
from qgis.core import QgsNetworkAccessManager
_download_qgis(packageUrl, handle)

import qgis.utils
in_qgis = qgis.utils.iface is not None
if in_qgis:
_download_qgis(packageUrl, handle)
else:
_download_urllib2(packageUrl, handle)
except ImportError:
# in case we are using cli and qgis is not installed
_download_urllib2(packageUrl, handle)
except Exception as err:
# in case we are using cli and qgis is not installed
except Exception:
_download_urllib2(packageUrl, handle)

handle.close()
return name

Expand Down