Skip to content

Commit

Permalink
links.py: eliminated star imports - basher package layout notes:
Browse files Browse the repository at this point in the history
Under #163, #174.
Seems we are going towards a package per panel rather than a links package -
 the specific link init methods and the links belong together as is shown by
 the ugly `__all__` directives.
`import *` is _evil_ and in combination with our loader _chaotic_ evil.

Mopy/bash/basher/app_buttons.py
Renamed Oblivion_Button to more accurate Game_Button. Note pickle cruft.
  • Loading branch information
Utumno committed Jan 28, 2015
1 parent a5dcde6 commit 6a2e4a9
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 78 deletions.
51 changes: 28 additions & 23 deletions Mopy/bash/basher/app_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@
from ..bolt import GPath
# TODO(ut): GetBitmapButton factor out duplicate code

__all__ = ['Obse_Button', 'LAA_Button', 'AutoQuit_Button', 'Game_Button',
'TESCS_Button', 'App_Button', 'Tooldir_Button', 'App_Tes4View',
'App_BOSS', 'App_DocBrowser', 'App_ModChecker', 'App_Settings',
'App_Help', 'App_Restart', 'App_GenPickle']

modList = None

#------------------------------------------------------------------------------
# StatusBar Links--------------------------------------------------------------
# StatusBar Links--------------------------------------------------------------
#------------------------------------------------------------------------------
class StatusBar_Hide(ItemLink):
"""The (single) link on the button's menu - hides the button."""
Expand Down Expand Up @@ -349,27 +354,6 @@ class Tooldir_Button(App_Button):
def __init__(self,toolKey,images,tip,obseTip=None,obseArg=None,workingDir=None,canHide=True):
App_Button.__init__(self,bosh.tooldirs[toolKey],images,tip,obseTip,obseArg,workingDir,toolKey,canHide)

#------------------------------------------------------------------------------
class App_Tes4Gecko(App_Button): # CRUFT
"""Left in for unpickling compatibility reasons."""
def __setstate__(self, state):
self.__dict__.update(state)
self.__class__ = App_Button

#------------------------------------------------------------------------------
class App_Tes5Gecko(App_Button): # CRUFT
"""Left in for unpickling compatibility reasons."""
def __setstate__(self, state):
self.__dict__.update(state)
self.__class__ = App_Button

#------------------------------------------------------------------------------
class App_OblivionBookCreator(App_Button): # CRUFT
"""Left in for unpickling compatibility reasons."""
def __setstate__(self, state):
self.__dict__.update(state)
self.__class__ = App_Button

#------------------------------------------------------------------------------
class _Mods_Tes4ViewExpert(BoolLink):
"""Toggle Tes4Edit expert mode (when launched via Bash)."""
Expand Down Expand Up @@ -493,7 +477,7 @@ def Execute(self,event,extraArgs=None):
modList.RefreshUI('ALL')

#------------------------------------------------------------------------------
class Oblivion_Button(App_Button):
class Game_Button(App_Button):
"""Will close app on execute if autoquit is on."""
@property
def tip(self):
Expand Down Expand Up @@ -799,3 +783,24 @@ def Execute(self,event):
ModChecker().Show()
#balt.ensureDisplayed(modChecker)
Link.Frame.modChecker.Raise()

#------------------------------------------------------------------------------
class App_Tes4Gecko(App_Button): # CRUFT
"""Left in for unpickling compatibility reasons."""
def __setstate__(self, state):
self.__dict__.update(state)
self.__class__ = App_Button

#------------------------------------------------------------------------------
class App_Tes5Gecko(App_Button): # CRUFT
"""Left in for unpickling compatibility reasons."""
def __setstate__(self, state):
self.__dict__.update(state)
self.__class__ = App_Button

#------------------------------------------------------------------------------
class App_OblivionBookCreator(App_Button): # CRUFT
"""Left in for unpickling compatibility reasons."""
def __setstate__(self, state):
self.__dict__.update(state)
self.__class__ = App_Button
5 changes: 5 additions & 0 deletions Mopy/bash/basher/files_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
from ..bolt import CancelError, SkipError, GPath, BoltError
from ..bosh import formatDate

__all__ = ['Files_SortBy', 'Files_Unhide', 'Files_Open', 'File_Backup',
'File_Duplicate', 'File_Snapshot', 'File_Delete', 'File_Hide',
'File_Redate', 'File_Sort', 'File_RevertToBackup',
'File_RevertToSnapshot', 'File_ListMasters', 'File_Open']

#------------------------------------------------------------------------------
# Files Links -----------------------------------------------------------------
#------------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion Mopy/bash/basher/ini_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
# https://github.com/wrye-bash
#
# =============================================================================

from . import Resources
from .dialogs import ListBoxes
from ..balt import ItemLink, Link, BoolLink, EnabledLink, OneItemLink
from .. import bosh, balt, bush

#------------------------------------------------------------------------------
__all__ = ['INI_SortValid', 'INI_AllowNewLines', 'INI_ListINIs', 'INI_Apply',
'INI_CreateNew', 'INI_ListErrors', 'INI_FileOpenOrCopy',
'INI_Delete']

iniList = None # FIXME(ut): globals should be non None

class INI_SortValid(BoolLink):
Expand Down
20 changes: 20 additions & 0 deletions Mopy/bash/basher/installer_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
from ..bolt import CancelError, SkipError, GPath, StateError, deprint, \
SubProgress, LogFile
from ..bosh import formatInteger

__all__ = ['Installer_Open', 'Installer_Duplicate', 'Installer_Delete',
'InstallerOpenAt_MainMenu', 'Installer_OpenSearch',
'Installer_OpenTESA', 'Installer_OpenPES', 'Installer_Hide',
'Installer_Rename', 'Installer_Refresh', 'Installer_Move',
'Installer_HasExtraData', 'Installer_OverrideSkips',
'Installer_SkipVoices', 'Installer_SkipRefresh', 'Installer_Wizard',
'Installer_EditWizard', 'Installer_OpenReadme', 'Installer_Anneal',
'Installer_Install', 'Installer_Uninstall',
'InstallerConverter_MainMenu', 'InstallerConverter_Create',
'InstallerConverter_ConvertMenu', 'InstallerProject_Pack',
'InstallerArchive_Unpack', 'InstallerProject_ReleasePack',
'InstallerProject_Sync', 'Installer_CopyConflicts',
'InstallerProject_OmodConfig', 'Installer_ListStructure',
'Installer_Espm_SelectAll', 'Installer_Espm_DeselectAll',
'Installer_Espm_List', 'Installer_Espm_Rename',
'Installer_Espm_Reset', 'Installer_Espm_ResetAll',
'Installer_Subs_SelectAll', 'Installer_Subs_DeselectAll',
'Installer_Subs_ToggleSelection', 'Installer_Subs_ListSubPackages',
'Installer_OpenNexus']
# FIXME(ut): globals
iniList = None
gInstallers = None
Expand Down
22 changes: 22 additions & 0 deletions Mopy/bash/basher/installers_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,35 @@
# https://github.com/wrye-bash
#
# =============================================================================

import copy
from .. import bosh, balt, bush
from ..balt import fill, BoolLink, AppendableLink, Link
from . import Resources, Installers_Link
from .dialogs import ListBoxes, CreateNewProject
from ..bolt import GPath, SubProgress

__all__ = ['Installers_SortActive', 'Installers_SortProjects',
'Installers_Refresh', 'Installers_AddMarker',
'Installers_CreateNewProject', 'Installers_MonitorInstall',
'Installers_ListPackages', 'Installers_AnnealAll',
'Installers_UninstallAllPackages',
'Installers_UninstallAllUnknownFiles', 'Installers_AvoidOnStart',
'Installers_Enabled', 'Installers_AutoAnneal',
'Installers_AutoWizard', 'Installers_AutoRefreshProjects',
'Installers_AutoRefreshBethsoft',
'Installers_AutoApplyEmbeddedBCFs', 'Installers_BsaRedirection',
'Installers_RemoveEmptyDirs',
'Installers_ConflictsReportShowsInactive',
'Installers_ConflictsReportShowsLower',
'Installers_ConflictsReportShowBSAConflicts',
'Installers_WizardOverlay', 'Installers_SkipOBSEPlugins',
'Installers_SkipScreenshots', 'Installers_SkipImages',
'Installers_SkipDocs', 'Installers_SkipDistantLOD',
'Installers_SkipLandscapeLODMeshes',
'Installers_SkipLandscapeLODTextures',
'Installers_SkipLandscapeLODNormals', 'Installers_RenameStrings']

gInstallers = None

#------------------------------------------------------------------------------
Expand Down
73 changes: 20 additions & 53 deletions Mopy/bash/basher/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,34 @@
# https://github.com/wrye-bash
#
# =============================================================================

"""Links initialization functions. Each panel (tab) has some Links list
attributes which are populated here. Therefore the order of menu items is
also defined in these functions."""
# TODO(ut): maybe consider a links package - or a package per panel ?
# TODO(ut): remove star imports

import os
import win32gui
from . import InstallersPanel, InstallersList, INIList, ModList, SaveList, \
BSAList, ScreensList, MessageList, MasterList, bEnableWizard, PeopleList,\
BashStatusBar
from .constants import PNG, BMP, TIF, ICO
from .installer_links import *
from .mod_links import *
from .saves_links import *
BashStatusBar, Tab_Link
from .constants import PNG, BMP, TIF, ICO, JPEG
from .. import balt, bosh, bush
from ..cint import CBash
from ..balt import Image, MenuLink, SeparatorLink
from ..bolt import deprint, GPath
# modules below define the __all__ directive
from .app_buttons import *
from .mods_links import *
from .files_links import *
from .misc_links import List_Columns
from ..balt import Image, MenuLink
from .installers_links import *
from .installer_links import *
from .saves_links import *
from .settings_links import *
from .misc_links import *
from .ini_links import *
from .mod_links import *

#------------------------------------------------------------------------------
from .app_buttons import Obse_Button, LAA_Button, AutoQuit_Button, \
Oblivion_Button, TESCS_Button, App_Button, Tooldir_Button, App_Tes4View, \
App_BOSS, App_DocBrowser, App_ModChecker, App_Settings, App_Help, \
App_Restart, App_GenPickle

def InitStatusBar():
"""Initialize status bar links."""
dirImages = bosh.dirs['images']
Expand All @@ -57,7 +61,7 @@ def imageList(template):
BashStatusBar.buttons.append(laaButton)
BashStatusBar.buttons.append(AutoQuit_Button(uid=u'AutoQuit'))
BashStatusBar.buttons.append( # Game
Oblivion_Button(
Game_Button(
bosh.dirs['app'].join(bush.game.exe),
imageList(u'%s%%s.png' % bush.game.fsName.lower()),
u' '.join((_(u"Launch"),bush.game.displayName)),
Expand Down Expand Up @@ -169,7 +173,7 @@ def imageList(template):
try:
win32gui.ExtractIcon(0, target.s, 0)
icon = target
except Exception as e:
except:
icon = u'' # Icon will be set to a red x further down.
else:
# Use the default icon for that file type
Expand Down Expand Up @@ -247,8 +251,6 @@ def imageList(template):
BashStatusBar.buttons.append(App_GenPickle(uid=u'Generate PKL File'))

#------------------------------------------------------------------------------
from .misc_links import Master_ChangeTo, Master_Disable

def InitMasterLinks():
"""Initialize master list menus."""
#--MasterList: Column Links
Expand All @@ -271,22 +273,6 @@ def InitMasterLinks():
MasterList.itemMenu.append(Master_Disable())

#------------------------------------------------------------------------------
from .installers_links import Installers_SortActive,Installers_SortProjects, \
Installers_Refresh, Installers_AddMarker, Installers_CreateNewProject, \
Installers_MonitorInstall, Installers_ListPackages, Installers_AnnealAll, \
Installers_UninstallAllPackages, Installers_UninstallAllUnknownFiles, \
Installers_AvoidOnStart, Installers_Enabled, Installers_AutoAnneal, \
Installers_AutoWizard, Installers_AutoRefreshProjects, \
Installers_AutoRefreshBethsoft, Installers_AutoApplyEmbeddedBCFs, \
Installers_BsaRedirection, Installers_RemoveEmptyDirs, \
Installers_ConflictsReportShowsInactive, \
Installers_ConflictsReportShowsLower, \
Installers_ConflictsReportShowBSAConflicts, Installers_WizardOverlay, \
Installers_SkipOBSEPlugins, Installers_SkipScreenshots, \
Installers_SkipImages, Installers_SkipDocs, Installers_SkipDistantLOD, \
Installers_SkipLandscapeLODMeshes, Installers_SkipLandscapeLODTextures, \
Installers_SkipLandscapeLODNormals, Installers_RenameStrings

def InitInstallerLinks():
"""Initialize Installers tab menus."""
#--Column links
Expand Down Expand Up @@ -419,9 +405,6 @@ def InitInstallerLinks():
InstallersPanel.subsMenu.append(Installer_Subs_ListSubPackages())

#------------------------------------------------------------------------------
from .ini_links import INI_SortValid, INI_AllowNewLines, INI_ListINIs, \
INI_Apply, INI_CreateNew, INI_ListErrors, INI_FileOpenOrCopy, INI_Delete

def InitINILinks():
"""Initialize INI Edits tab menus."""
#--Column Links
Expand Down Expand Up @@ -760,9 +743,6 @@ def InitBSALinks():
BSAList.itemMenu.append(Save_RepairHair())

#------------------------------------------------------------------------------
from .misc_links import Screens_NextScreenShot, Screen_JpgQuality, \
Screen_JpgQualityCustom, Screen_Rename, Screen_ConvertTo

def InitScreenLinks():
"""Initialize screens tab menus."""
#--SaveList: Column Links
Expand Down Expand Up @@ -794,8 +774,6 @@ def InitScreenLinks():
ScreensList.itemMenu.append(convertMenu)

#------------------------------------------------------------------------------
from .misc_links import Messages_Archive_Import, Message_Delete

def InitMessageLinks():
"""Initialize messages tab menus."""
#--SaveList: Column Links
Expand All @@ -807,9 +785,6 @@ def InitMessageLinks():
MessageList.itemMenu.append(Message_Delete())

#------------------------------------------------------------------------------
from .misc_links import People_AddNew, People_Import, People_Karma, \
People_Export

def InitPeopleLinks():
"""Initialize people tab menus."""
#--Header links
Expand All @@ -825,14 +800,6 @@ def InitPeopleLinks():
PeopleList.itemMenu.append(People_Export())

#------------------------------------------------------------------------------
from .settings_links import Settings_BackupSettings, Settings_RestoreSettings, \
Settings_SaveSettings, Settings_ExportDllInfo, Settings_ImportDllInfo, \
Settings_Colors, Settings_IconSize, Settings_UnHideButtons, \
Settings_StatusBar_ShowVersions, Settings_Languages, \
Settings_PluginEncodings, Settings_Games, Settings_UseAltName, \
Settings_Deprint, Settings_DumpTranslator, Settings_UAC
from . import Tab_Link

def InitSettingsLinks():
"""Initialize settings menu."""
SettingsMenu = BashStatusBar.SettingsMenu
Expand Down
7 changes: 7 additions & 0 deletions Mopy/bash/basher/misc_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# https://github.com/wrye-bash
#
# =============================================================================

import re
import time
from ..balt import EnabledLink, AppendableLink, ItemLink, Link, RadioLink, \
Expand All @@ -30,6 +31,12 @@
from .constants import ID_GROUPS, settingDefaults
from ..bolt import GPath, LString

__all__ = ['List_Columns', 'Master_ChangeTo', 'Master_Disable',
'Screens_NextScreenShot', 'Screen_JpgQuality',
'Screen_JpgQualityCustom', 'Screen_Rename', 'Screen_ConvertTo',
'Messages_Archive_Import', 'Message_Delete', 'People_AddNew',
'People_Import', 'People_Karma', 'People_Export']

# Screen Links ----------------------------------------------------------------
#------------------------------------------------------------------------------
class Screens_NextScreenShot(ItemLink):
Expand Down
22 changes: 22 additions & 0 deletions Mopy/bash/basher/mod_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@
from ..patcher.patchers import base
from ..patcher.patchers import special

__all__ = ['Mod_FullLoad', 'Mod_CreateDummyMasters', 'Mod_Groups',
'Mod_Ratings', 'Mod_Details', 'Mod_ShowReadme', 'Mod_ListBashTags',
'Mod_CreateBOSSReport', 'Mod_CopyModInfo', 'Mod_AllowGhosting',
'Mod_Ghost', 'Mod_MarkMergeable', 'Mod_Patch_Update',
'Mod_ListPatchConfig', 'Mod_ExportPatchConfig',
'CBash_Mod_CellBlockInfo_Export', 'Mod_EditorIds_Export',
'Mod_FullNames_Export', 'Mod_Prices_Export', 'Mod_Stats_Export',
'Mod_Factions_Export', 'Mod_ActorLevels_Export',
'CBash_Mod_MapMarkers_Export', 'Mod_FactionRelations_Export',
'Mod_IngredientDetails_Export', 'Mod_Scripts_Export',
'Mod_SigilStoneDetails_Export', 'Mod_SpellRecords_Export',
'Mod_EditorIds_Import', 'Mod_FullNames_Import', 'Mod_Prices_Import',
'Mod_Stats_Import', 'Mod_Factions_Import', 'Mod_ActorLevels_Import',
'CBash_Mod_MapMarkers_Import', 'Mod_FactionRelations_Import',
'Mod_IngredientDetails_Import', 'Mod_Scripts_Import',
'Mod_SigilStoneDetails_Import', 'Mod_SpellRecords_Import',
'Mod_Face_Import', 'Mod_Fids_Replace', 'Mod_SkipDirtyCheck',
'Mod_ScanDirty', 'Mod_RemoveWorldOrphans', 'Mod_CleanMod',
'Mod_UndeleteRefs', 'Mod_AddMaster', 'Mod_CopyToEsmp',
'Mod_DecompileAll', 'Mod_FlipSelf', 'Mod_FlipMasters',
'Mod_SetVersion']

modList = None

#------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions Mopy/bash/basher/mods_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
SeparatorLink, Link
from ..bolt import GPath

__all__ = ['Mods_EsmsFirst', 'Mods_LoadList', 'Mods_SelectedFirst',
'Mods_OblivionVersion', 'Mods_CreateBlankBashedPatch',
'Mods_CreateBlank', 'Mods_ListMods', 'Mods_ListBashTags',
'Mods_CleanDummyMasters', 'Mods_AutoGhost', 'Mods_LockTimes',
'Mods_ScanDirty']

modList = None

# "Load" submenu --------------------------------------------------------------
Expand Down
Loading

0 comments on commit 6a2e4a9

Please sign in to comment.