Commit efec098a authored by André's avatar André
Browse files

Use absolute imports

parent 10f8fe2b
......@@ -29,12 +29,12 @@
from gi.repository import Gtk
import nbxmpp
from common import gajim
from common import dataforms
from gajim.common import gajim
from gajim.common import dataforms
import gtkgui_helpers
import dialogs
import dataforms_widget
from gajim import gtkgui_helpers
from gajim import dialogs
from gajim import dataforms_widget
class CommandWindow:
"""
......
......@@ -26,11 +26,11 @@
from enum import IntEnum, unique
from gi.repository import Gtk
import gtkgui_helpers
from gajim import gtkgui_helpers
from gi.repository import GLib
from gi.repository import Pango
from common import gajim
from gajim.common import gajim
@unique
class Column(IntEnum):
......
......@@ -18,21 +18,22 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
from common import helpers
from common import gajim
from common.exceptions import GajimGeneralException
from gajim.common import gajim as c_gajim
from gajim.common import helpers
from gajim.common.gajim import interface
from gajim.common.exceptions import GajimGeneralException
from gi.repository import Gtk
import sys
import os
import config
import dialogs
import features_window
import shortcuts_window
import plugins.gui
import history_window
import disco
from history_sync import HistorySyncAssistant
from server_info import ServerInfoDialog
from gajim import config
from gajim import dialogs
from gajim import features_window
from gajim import shortcuts_window
import gajim.plugins.gui
from gajim import history_window
from gajim import disco
from gajim.history_sync import HistorySyncAssistant
from gajim.server_info import ServerInfoDialog
class AppActions():
......@@ -43,23 +44,23 @@ def __init__(self, app: Gtk.Application):
# Application Menu Actions
def on_preferences(self, action, param):
if 'preferences' in gajim.interface.instances:
gajim.interface.instances['preferences'].window.present()
if 'preferences' in interface.instances:
interface.instances['preferences'].window.present()
else:
gajim.interface.instances['preferences'] = \
interface.instances['preferences'] = \
config.PreferencesWindow()
def on_plugins(self, action, param):
if 'plugins' in gajim.interface.instances:
gajim.interface.instances['plugins'].window.present()
if 'plugins' in interface.instances:
interface.instances['plugins'].window.present()
else:
gajim.interface.instances['plugins'] = plugins.gui.PluginsWindow()
interface.instances['plugins'] = gajim.plugins.gui.PluginsWindow()
def on_accounts(self, action, param):
if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].window.present()
if 'accounts' in interface.instances:
interface.instances['accounts'].window.present()
else:
gajim.interface.instances['accounts'] = config.AccountsWindow()
interface.instances['accounts'] = config.AccountsWindow()
def on_history_manager(self, action, param):
config_path = '-c %s' % gajim.gajimpaths.data_root
......@@ -76,12 +77,12 @@ def on_manage_bookmarks(self, action, param):
config.ManageBookmarksWindow()
def on_quit(self, action, param):
gajim.interface.roster.on_quit_request()
interface.roster.on_quit_request()
# Accounts Actions
def on_profile(self, action, param):
gajim.interface.edit_own_details(param.get_string())
interface.edit_own_details(param.get_string())
def on_activate_bookmark(self, action, param):
dict_ = param.unpack()
......@@ -91,19 +92,19 @@ def on_activate_bookmark(self, action, param):
nick = dict_['nick']
if 'password' in dict_:
password = dict_['password']
gajim.interface.join_gc_room(account, jid, nick, password)
interface.join_gc_room(account, jid, nick, password)
def on_send_server_message(self, action, param):
account = param.get_string()
server = gajim.config.get_per('accounts', account, 'hostname')
server = c_gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/online'
dialogs.SingleMessageWindow(account, server, 'send')
def on_service_disco(self, action, param):
account = param.get_string()
server_jid = gajim.config.get_per('accounts', account, 'hostname')
if server_jid in gajim.interface.instances[account]['disco']:
gajim.interface.instances[account]['disco'][server_jid].\
server_jid = c_gajim.config.get_per('accounts', account, 'hostname')
if server_jid in interface.instances[account]['disco']:
interface.instances[account]['disco'][server_jid].\
window.present()
else:
try:
......@@ -114,16 +115,16 @@ def on_service_disco(self, action, param):
def on_join_gc(self, action, param):
account = param.get_string()
invisible_show = gajim.SHOW_LIST.index('invisible')
if gajim.connections[account].connected == invisible_show:
invisible_show = c_gajim.SHOW_LIST.index('invisible')
if c_gajim.connections[account].connected == invisible_show:
dialogs.ErrorDialog(_(
'You cannot join a group chat while you are invisible'))
return
if 'join_gc' in gajim.interface.instances[account]:
gajim.interface.instances[account]['join_gc'].window.present()
if 'join_gc' in interface.instances[account]:
interface.instances[account]['join_gc'].window.present()
else:
try:
gajim.interface.instances[account]['join_gc'] = \
interface.instances[account]['join_gc'] = \
dialogs.JoinGroupchatWindow(account)
except GajimGeneralException:
pass
......@@ -141,64 +142,64 @@ def on_single_message(self, action, param):
def on_archiving_preferences(self, action, param):
account = param.get_string()
if 'archiving_preferences' in gajim.interface.instances[account]:
gajim.interface.instances[account]['archiving_preferences'].window.\
if 'archiving_preferences' in interface.instances[account]:
interface.instances[account]['archiving_preferences'].window.\
present()
else:
gajim.interface.instances[account]['archiving_preferences'] = \
interface.instances[account]['archiving_preferences'] = \
dialogs.Archiving313PreferencesWindow(account)
def on_history_sync(self, action, param):
account = param.get_string()
if 'history_sync' in gajim.interface.instances[account]:
gajim.interface.instances[account]['history_sync'].present()
if 'history_sync' in interface.instances[account]:
interface.instances[account]['history_sync'].present()
else:
gajim.interface.instances[account]['history_sync'] = \
HistorySyncAssistant(account, gajim.interface.roster.window)
interface.instances[account]['history_sync'] = \
HistorySyncAssistant(account, interface.roster.window)
def on_privacy_lists(self, action, param):
account = param.get_string()
if 'privacy_lists' in gajim.interface.instances[account]:
gajim.interface.instances[account]['privacy_lists'].window.present()
if 'privacy_lists' in interface.instances[account]:
interface.instances[account]['privacy_lists'].window.present()
else:
gajim.interface.instances[account]['privacy_lists'] = \
interface.instances[account]['privacy_lists'] = \
dialogs.PrivacyListsWindow(account)
def on_server_info(self, action, param):
account = param.get_string()
if 'server_info' in gajim.interface.instances[account]:
gajim.interface.instances[account]['server_info'].present()
if 'server_info' in interface.instances[account]:
interface.instances[account]['server_info'].present()
else:
gajim.interface.instances[account]['server_info'] = \
interface.instances[account]['server_info'] = \
ServerInfoDialog(account)
def on_xml_console(self, action, param):
account = param.get_string()
if 'xml_console' in gajim.interface.instances[account]:
gajim.interface.instances[account]['xml_console'].present()
if 'xml_console' in interface.instances[account]:
interface.instances[account]['xml_console'].present()
else:
gajim.interface.instances[account]['xml_console'] = \
interface.instances[account]['xml_console'] = \
dialogs.XMLConsoleWindow(account)
# Admin Actions
def on_set_motd(self, action, param):
account = param.get_string()
server = gajim.config.get_per('accounts', account, 'hostname')
server = c_gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/motd'
dialogs.SingleMessageWindow(account, server, 'send')
def on_update_motd(self, action, param):
account = param.get_string()
server = gajim.config.get_per('accounts', account, 'hostname')
server = c_gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/motd/update'
dialogs.SingleMessageWindow(account, server, 'send')
def on_delete_motd(self, action, param):
account = param.get_string()
server = gajim.config.get_per('accounts', account, 'hostname')
server = c_gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/motd/delete'
gajim.connections[account].send_motd(server)
c_gajim.connections[account].send_motd(server)
# Help Actions
......@@ -222,15 +223,15 @@ def on_about(self, action, param):
# View Actions
def on_file_transfers(self, action, param):
if gajim.interface.instances['file_transfers']. \
if interface.instances['file_transfers']. \
window.get_property('visible'):
gajim.interface.instances['file_transfers'].window.present()
interface.instances['file_transfers'].window.present()
else:
gajim.interface.instances['file_transfers'].window.show_all()
interface.instances['file_transfers'].window.show_all()
def on_history(self, action, param):
if 'logs' in gajim.interface.instances:
gajim.interface.instances['logs'].window.present()
if 'logs' in interface.instances:
interface.instances['logs'].window.present()
else:
gajim.interface.instances['logs'] = history_window.\
interface.instances['logs'] = history_window.\
HistoryWindow()
......@@ -25,9 +25,9 @@
from gi.repository import Gdk
from gi.repository import GLib
import gtkgui_helpers
from common import helpers
from common import i18n
from gajim import gtkgui_helpers
from gajim.common import helpers
from gajim.common import i18n
class AtomWindow:
window = None
......
......@@ -34,29 +34,29 @@
from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GLib
import gtkgui_helpers
import gui_menu_builder
import message_control
import dialogs
from common import logger
from common import gajim
from common import helpers
from common import exceptions
from common import ged
from common import i18n
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
from common.contacts import GC_Contact
from common.logger import KindConstant
from gajim import gtkgui_helpers
from gajim import gui_menu_builder
from gajim import message_control
from gajim import dialogs
from gajim.common import logger
from gajim.common import gajim
from gajim.common import helpers
from gajim.common import exceptions
from gajim.common import ged
from gajim.common import i18n
from gajim.common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
from gajim.common.contacts import GC_Contact
from gajim.common.logger import KindConstant
from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
from nbxmpp.protocol import NS_ESESSION
from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER_5
from nbxmpp.protocol import NS_CHATSTATES
from common.connection_handlers_events import MessageOutgoingEvent
from common.exceptions import GajimGeneralException
from gajim.common.connection_handlers_events import MessageOutgoingEvent
from gajim.common.exceptions import GajimGeneralException
from command_system.implementation.hosts import ChatCommands
from gajim.command_system.implementation.hosts import ChatCommands
try:
import gtkspell
......@@ -64,7 +64,7 @@
except (ImportError, ValueError):
HAS_GTK_SPELL = False
from chat_control_base import ChatControlBase
from gajim.chat_control_base import ChatControlBase
################################################################################
class ChatControl(ChatControlBase):
......@@ -1033,7 +1033,7 @@ def print_conversation(self, text, frm='', tim=None, encrypted=None,
name = self.get_our_nick()
if not xhtml and not encrypted and \
gajim.config.get('rst_formatting_outgoing_messages'):
from common.rst_xhtml_generator import create_xhtml
from gajim.common.rst_xhtml_generator import create_xhtml
xhtml = create_xhtml(text)
if xhtml:
xhtml = '<body xmlns="%s">%s</body>' % (NS_XHTML, xhtml)
......
......@@ -35,35 +35,35 @@
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
import gtkgui_helpers
from gtkgui_helpers import Color
import message_control
import dialogs
import history_window
import notify
from gajim import gtkgui_helpers
from gajim.gtkgui_helpers import Color
from gajim import message_control
from gajim import dialogs
from gajim import history_window
from gajim import notify
import re
import emoticons
from scrolled_window import ScrolledWindow
from common import events
from common import gajim
from common import helpers
from common import ged
from message_control import MessageControl
from conversation_textview import ConversationTextview
from message_textview import MessageTextView
from common.contacts import GC_Contact
from common.connection_handlers_events import MessageOutgoingEvent
from command_system.implementation.middleware import ChatCommandProcessor
from command_system.implementation.middleware import CommandTools
from gajim import emoticons
from gajim.scrolled_window import ScrolledWindow
from gajim.common import events
from gajim.common import gajim
from gajim.common import helpers
from gajim.common import ged
from gajim.message_control import MessageControl
from gajim.conversation_textview import ConversationTextview
from gajim.message_textview import MessageTextView
from gajim.common.contacts import GC_Contact
from gajim.common.connection_handlers_events import MessageOutgoingEvent
from gajim.command_system.implementation.middleware import ChatCommandProcessor
from gajim.command_system.implementation.middleware import CommandTools
# The members of these modules are not referenced directly anywhere in this
# module, but still they need to be kept around. Importing them automatically
# registers the contained CommandContainers with the command system, thereby
# populating the list of available commands.
import command_system.implementation.standard
import command_system.implementation.execute
from gajim.command_system.implementation import standard
from gajim.command_system.implementation import execute
try:
import gtkspell
......
......@@ -31,7 +31,7 @@
over the process.
"""
from .tools import remove
from gajim.command_system.tools import remove
COMMANDS = {}
CONTAINERS = {}
......@@ -66,7 +66,7 @@ def traverse_commands(container):
yield attribute
def is_command(attribute):
from .framework import Command
from gajim.command_system.framework import Command
return isinstance(attribute, Command)
def is_root(namespace):
......@@ -115,4 +115,4 @@ def enable(self):
def disable(self):
remove_commands(self)
remove_container(self)
\ No newline at end of file
remove_container(self)
......@@ -22,10 +22,10 @@
from types import FunctionType
from inspect import getargspec, getdoc
from .dispatcher import Host, Container
from .dispatcher import get_command, list_commands
from .mapping import parse_arguments, adapt_arguments
from .errors import DefinitionError, CommandError, NoCommandError
from gajim.command_system.dispatcher import Host, Container
from gajim.command_system.dispatcher import get_command, list_commands
from gajim.command_system.mapping import parse_arguments, adapt_arguments
from gajim.command_system.errors import DefinitionError, CommandError, NoCommandError
class CommandHost(metaclass=Host):
"""
......
......@@ -34,8 +34,8 @@
detected.
"""
from ..framework import CommandContainer, command, doc
from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
from gajim.command_system.framework import CommandContainer, command, doc
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
class CustomCommonCommands(CommandContainer):
"""
......
......@@ -37,8 +37,8 @@
from gi.repository import GLib
from ..framework import CommandContainer, command, doc
from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
from gajim.command_system.framework import CommandContainer, command, doc
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
class Execute(CommandContainer):
AUTOMATIC = True
......
......@@ -18,7 +18,7 @@
different command processors, which are the source of commands.
"""
from ..framework import CommandHost
from gajim.command_system.framework import CommandHost
class ChatCommands(CommandHost):
"""
......
......@@ -34,10 +34,10 @@
from traceback import print_exc
from gi.repository import Pango
from common import gajim
from gajim.common import gajim
from ..framework import CommandProcessor
from ..errors import CommandError, NoCommandError
from gajim.command_system.framework import CommandProcessor
from gajim.command_system.errors import CommandError, NoCommandError
class ChatCommandProcessor(CommandProcessor):
"""
......
......@@ -20,17 +20,17 @@
from time import localtime, strftime
from datetime import date
import dialogs
from common import gajim
from common import helpers
from common.exceptions import GajimGeneralException
from common.logger import KindConstant
from gajim import dialogs
from gajim.common import gajim
from gajim.common import helpers
from gajim.common.exceptions import GajimGeneralException
from gajim.common.logger import KindConstant
from ..errors import CommandError
from ..framework import CommandContainer, command, doc
from ..mapping import generate_usage
from gajim.command_system.errors import CommandError
from gajim.command_system.framework import CommandContainer, command, doc
from gajim.command_system.mapping import generate_usage
from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
class StandardCommonCommands(CommandContainer):
"""
......
......@@ -25,7 +25,7 @@
import re
from operator import itemgetter
from .errors import DefinitionError, CommandError
from gajim.command_system.errors import DefinitionError, CommandError
# Quite complex piece of regular expression logic to parse options and
# arguments. Might need some tweaking along the way.
......
......@@ -9,7 +9,7 @@
raise ImportError
from pyasn1.type import univ, constraint, char, namedtype, tag
from pyasn1.codec.der.decoder import decode
from common.helpers import prep, InvalidFormat
from gajim.common.helpers import prep, InvalidFormat
MAX = 64
oid_xmppaddr = '1.3.6.1.5.5.7.8.5'
......
......@@ -27,8 +27,8 @@
import shutil
import sys
from common import gajim
from common import logger
from gajim.common import gajim
from gajim.common import logger
# DO NOT MOVE ABOVE OF import gajim
import sqlite3 as sqlite
......@@ -179,7 +179,7 @@ def check_and_possibly_move_config():
vars['MY_ICONSETS_PATH'] = gajim.MY_ICONSETS_PATH
vars['MY_MOOD_ICONSETS_PATH'] = gajim.MY_MOOD_ICONSETS_PATH
vars['MY_ACTIVITY_ICONSETS_PATH'] = gajim.MY_ACTIVITY_ICONSETS_PATH
from common import configpaths
from gajim.common import configpaths
MY_DATA = configpaths.gajimpaths['MY_DATA']
MY_CONFIG = configpaths.gajimpaths['MY_CONFIG']
MY_CACHE = configpaths.gajimpaths['MY_CACHE']
......@@ -264,7 +264,7 @@ def check_and_possibly_create_paths():
VCARD_PATH = gajim.VCARD_PATH
AVATAR_PATH = gajim.AVATAR_PATH
from common import configpaths
from gajim.common import configpaths
MY_DATA = configpaths.gajimpaths['MY_DATA']
MY_CONFIG = configpaths.gajimpaths['MY_CONFIG']
MY_CACHE = configpaths.gajimpaths['MY_CACHE']
......
......@@ -23,10 +23,10 @@
##
import nbxmpp
from common import helpers
from common import dataforms
from common import gajim
from common.connection_handlers_events import MessageOutgoingEvent
from gajim.common import helpers
from gajim.common import dataforms
from gajim.common import gajim
from gajim.common.connection_handlers_events import MessageOutgoingEvent
import logging
log = logging.getLogger('gajim.c.commands')
......
......@@ -33,7 +33,7 @@
import re
from common import defs
from gajim.common import defs
from gi.repository import GLib
from enum import IntEnum, unique
......@@ -795,7 +795,7 @@ def _init_options(self):
self.__options[1][opt] = self.__options[0][opt][Option.VAL]
def _really_save(self):
from common import gajim
from gajim.common import gajim
if gajim.interface:
gajim.interface.save_config()
self.save_timeout_id = None
......