Skip to content

Commit 430e58b

Browse files
Daniel NunesInfernio
authored andcommitted
Move all local absolute imports to relative
There were circular imports between bosh, parsers and record_groups that did not happen with the absolute imports but had to be fixed with relative imports. Everything else was pretty straightforward. Infernio: Updated for 15, 461 and 480. Also moved all __author__s below the imports to avoid syntax errors with __future__ imports. Infernio: Updated for inf-wx-begone, and reorganized belt imports.
1 parent 080625a commit 430e58b

23 files changed

Lines changed: 122 additions & 118 deletions

Mopy/bash/_games_lo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@
2929
# several older files in a directory would be useful (maybe limit to some
3030
# number, e.g. 5 older versions)
3131

32-
__author__ = 'Utumno'
33-
3432
import errno
3533
import re
3634
import time
3735
from collections import defaultdict
3836
# Local
39-
import bass
40-
import bolt
41-
import env
42-
import exception
43-
from localize import format_date
37+
from . import bass
38+
from . import bolt
39+
from . import env
40+
from . import exception
41+
from .localize import format_date
42+
43+
__author__ = 'Utumno'
4444

4545
def _write_plugins_txt_(path, lord, active, _star):
4646
try:

Mopy/bash/archives.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import re
2626
import subprocess
2727

28-
import bass
29-
from bolt import startupinfo, GPath, deprint, walkdir
30-
from exception import StateError
28+
from . import bass
29+
from .bolt import startupinfo, GPath, deprint, walkdir
30+
from .exception import StateError
3131

3232
exe7z = u'7z.exe' if os.name == u'nt' else u'7z'
3333
# TODO(inf) stuck it here for now - should probably go somewhere else

Mopy/bash/balt.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
# Imports ---------------------------------------------------------------------
2626
from __future__ import division
2727
import re
28-
import bass # for dirs - try to avoid
28+
29+
from . import bass # for dirs - try to avoid
2930
#--Localization
3031
#..Handled by bolt, so import that.
31-
import bolt
32-
from bolt import GPath, deprint
33-
from exception import AbstractError, AccessDeniedError, ArgumentError, \
32+
from . import bolt
33+
from .bolt import GPath, deprint
34+
from .exception import AbstractError, AccessDeniedError, ArgumentError, \
3435
BoltError, CancelError, SkipError, StateError
3536
#--Python
3637
import cPickle
@@ -556,7 +557,7 @@ def askNumber(parent,message,prompt=u'',title=u'',value=0,min=0,max=10000):
556557

557558
# Message Dialogs -------------------------------------------------------------
558559
try:
559-
import windows as _win # only import here !
560+
from . import windows as _win # only import here !
560561
canVista = _win.TASK_DIALOG_AVAILABLE
561562
except ImportError: # bare linux (in wine it's imported but malfunctions)
562563
deprint('Importing windows.py failed', traceback=True)

Mopy/bash/barb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
import os
4242
from os.path import join as jo
4343

44-
import archives
45-
import bass # for settings (duh!)
46-
import bolt
47-
import initialization
48-
from bass import dirs, AppVersion
49-
from bolt import GPath, deprint
50-
from exception import BoltError, StateError, raise_bolt_error
44+
from . import archives
45+
from . import bass # for settings (duh!)
46+
from . import bolt
47+
from . import initialization
48+
from .bass import dirs, AppVersion
49+
from .bolt import GPath, deprint
50+
from .exception import BoltError, StateError, raise_bolt_error
5151

5252
def _init_settings_files(fsName_):
5353
"""Construct a dict mapping directory paths to setting files. Keys are

Mopy/bash/bash.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
import traceback
3737
from ConfigParser import ConfigParser
3838
# Local
39-
import bass
40-
import bolt
41-
import env
42-
import exception
43-
import localize
39+
from . import bass
40+
from . import bolt
41+
from . import env
42+
from . import exception
43+
from . import localize
4444
# NO OTHER LOCAL IMPORTS HERE (apart from the ones above) !
4545
basher = balt = initialization = None
4646
_wx = None
@@ -226,7 +226,7 @@ def _main(opts, wx_locale):
226226
227227
:param opts: command line arguments
228228
:param wx_locale: The wx.Locale object that we ended up using."""
229-
import barg
229+
from . import barg
230230
bass.sys_argv = barg.convert_to_long_options(sys.argv)
231231

232232
if opts.debug:
@@ -237,7 +237,7 @@ def _main(opts, wx_locale):
237237
assure_single_instance(instance)
238238

239239
global initialization
240-
import initialization
240+
from . import initialization
241241
#--Bash installation directories, set on boot, not likely to change
242242
initialization.init_dirs_mopy()
243243

@@ -247,7 +247,7 @@ def _main(opts, wx_locale):
247247
msg2 = _(u'done')
248248
try: print msg1
249249
except UnicodeError: print msg1.encode(bolt.Path.sys_fs_enc)
250-
import belt # this imports bosh which imports wx (DUH)
250+
from . import belt # this imports bosh which imports wx (DUH)
251251
bolt.WryeText.genHtml(opts.genHtml)
252252
try: print msg2
253253
except UnicodeError: print msg2.encode(bolt.Path.sys_fs_enc)
@@ -256,7 +256,7 @@ def _main(opts, wx_locale):
256256
# We need the Mopy dirs to initialize restore settings instance
257257
bash_ini_path, restore_ = u'bash.ini', None
258258
# import barb that does not import from bosh/balt/bush
259-
import barb
259+
from . import barb
260260
if opts.restore:
261261
try:
262262
restore_ = barb.RestoreSettings(opts.filename)
@@ -279,14 +279,14 @@ def _main(opts, wx_locale):
279279
bolt.deprint(u'Failed to restore backup', traceback=True)
280280
restore_.restore_ini()
281281
# reset the game and ini
282-
import bush
282+
from . import bush
283283
bush.reset_bush_globals()
284284
bashIni, bush_game, game_ini_path = _detect_game(opts, u'bash.ini')
285-
import bosh # this imports balt (DUH) which imports wx
285+
from . import bosh # this imports balt (DUH) which imports wx
286286
bosh.initBosh(bashIni, game_ini_path)
287287
env.isUAC = env.testUAC(bush_game.gamePath.join(u'Data'))
288288
global basher, balt
289-
import basher, balt
289+
from . import basher, balt
290290
except (exception.BoltError, ImportError, OSError, IOError) as e:
291291
msg = u'\n'.join([_(u'Error! Unable to start Wrye Bash.'), u'\n', _(
292292
u'Please ensure Wrye Bash is correctly installed.'), u'\n',
@@ -393,7 +393,7 @@ def _detect_game(opts, backup_bash_ini):
393393
return bashIni, bush_game, game_ini_path
394394

395395
def _import_bush_and_set_game(opts, bashIni):
396-
import bush
396+
from . import bush
397397
bolt.deprint(u'Searching for game to manage:')
398398
ret, game_icons = bush.detect_and_set_game(opts.oblivionPath, bashIni)
399399
if ret is not None: # None == success

Mopy/bash/basher/gui_fomod.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#
2323
# =============================================================================
2424

25-
__author__ = "Ganda"
26-
2725
from collections import defaultdict
2826
import wx
2927
import wx.wizard as wiz
@@ -34,6 +32,8 @@
3432
LayoutOptions, TextArea, VLayout
3533
from ..fomod import FailedCondition, FomodInstaller
3634

35+
__author__ = "Ganda"
36+
3737
class WizardReturn(object):
3838
__slots__ = ("cancelled", "install_files", "install", "page_size", "pos")
3939

Mopy/bash/bass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ def rmTempDir():
7676
try:
7777
_tempDir.rmtree(safety=_tempDir.stail)
7878
except OSError:
79-
from bolt import deprint
79+
from .bolt import deprint
8080
deprint(u'Failed to remove %s' % _tempDir, traceback=True)
8181
_tempDir = None
8282

8383
def newTempDir():
8484
"""Generate a new temporary directory name, set it as the current Temp
8585
Dir."""
8686
global _tempDir
87-
from bolt import Path
87+
from .bolt import Path
8888
_tempDir = Path.tempDir()
8989
return _tempDir
9090

Mopy/bash/belt.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,21 @@
2727
from collections import OrderedDict
2828
from functools import partial
2929
import os
30-
31-
import ScriptParser # generic parser class
32-
import bass
33-
import load_order
34-
from ScriptParser import error
30+
import StringIO
31+
import traceback
3532
import wx
3633
import wx.wizard as wiz # wxPython wizard class
37-
import bosh, balt, bolt, bush
38-
from balt import Image, set_event_hook, Events
34+
35+
from . import ScriptParser # generic parser class
36+
from . import balt, bass, bolt, bosh, bush, load_order
37+
from .balt import Image, set_event_hook, Events
3938
from .gui import BOTTOM, CENTER, CheckBox, GridLayout, HBoxedLayout, HLayout, \
4039
Label, LayoutOptions, RIGHT, Stretch, TextArea, VLayout, HyperlinkLabel
41-
from env import get_file_version
42-
import StringIO
43-
import traceback
40+
from .env import get_file_version
41+
from .ScriptParser import error
4442

4543
#Translateable strings
46-
from bosh import OBSEIniFile
44+
from .bosh import OBSEIniFile
4745

4846
EXTRA_ARGS = _(u"Extra arguments to '%s'.")
4947
MISSING_ARGS = _(u"Missing arguments to '%s'.")

Mopy/bash/bolt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from __future__ import division
2828
import StringIO
2929
import cPickle
30+
import chardet
3031
import codecs
3132
import collections
3233
import copy
@@ -47,8 +48,7 @@
4748
from functools import partial
4849
from itertools import chain
4950
# Internal
50-
import chardet
51-
import exception
51+
from . import exception
5252

5353
# structure aliases, mainly introduced to reduce uses of 'pack' and 'unpack'
5454
struct_pack = struct.pack
@@ -598,7 +598,7 @@ def stat(self):
598598
@property
599599
def version(self):
600600
"""File version (exe/dll) embedded in the file properties."""
601-
from env import get_file_version
601+
from .env import get_file_version
602602
return get_file_version(self._s)
603603

604604
@property

Mopy/bash/bosh/bsa_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
http://www.uesp.net/wiki/Tes5Mod:Archive_File_Format
3030
"""
3131

32-
__author__ = 'Utumno'
33-
3432
import collections
3533
import errno
3634
import os
@@ -45,6 +43,8 @@
4543
from ..exception import BSAError, BSADecodingError, BSAFlagError, \
4644
BSANotImplemented
4745

46+
__author__ = 'Utumno'
47+
4848
_bsa_encoding = 'cp1252' # rumor has it that's the files/folders names encoding
4949
path_sep = u'\\'
5050

0 commit comments

Comments
 (0)