GEP 026: replace make

* somewhere along the road, all of plugins dir was added to sys.path, this
   is not ok, we only needed lib on sys.path
 * As due to the GEP we can import from the plugin directory, better just
   import the lib modules needed, and avoid sys.path extension
 * At the same time this fixes a bug due to __init__.py being present, import
   of a file named equal to the plugin directory was importing the __init__.py, 
   not the intended file.
 


svn: r20481
This commit is contained in:
Benny Malengier 2012-10-02 11:31:00 +00:00
parent 0a34aa05b1
commit 149298c52b
35 changed files with 49 additions and 53 deletions

View File

@ -280,8 +280,7 @@ class CLIManager(object):
Register the plugins at initialization time.
"""
self._pmgr.reg_plugins(PLUGINS_DIR, dbstate, uistate)
self._pmgr.reg_plugins(USER_PLUGINS, dbstate, uistate,
append=False, load_on_reg=True)
self._pmgr.reg_plugins(USER_PLUGINS, dbstate, uistate, load_on_reg=True)
def startcli(errors, argparser):
"""

View File

@ -96,7 +96,7 @@ class BasePluginManager(object):
self.__loaded_plugins = {}
def reg_plugins(self, direct, dbstate=None, uistate=None,
append=True, load_on_reg=False):
load_on_reg=False):
"""
Searches the specified directory, and registers python plugin that
are being defined in gpr.py files.
@ -117,9 +117,6 @@ class BasePluginManager(object):
# Skip hidden and system directories:
if dirname.startswith(".") or dirname in ["po", "locale"]:
dirnames.remove(dirname)
# add the directory to the python search path
if append:
sys.path.append(dirpath)
# if the path has not already been loaded, save it in the
# registereddir_list list for use on reloading.
self.__registereddir_set.add(dirpath)

View File

@ -43,7 +43,7 @@ from math import radians
#
#------------------------------------------------------------------------
from gen.plug.docgen import PAPER_PORTRAIT
import libcairodoc
import gramps.plugins.lib.libcairodoc as libcairodoc
from gen.errors import UnavailableError
#import constfunc

View File

@ -49,8 +49,8 @@ from gen.ggettext import gettext as _
from gen.utils.image import resize_to_jpeg
from gen.const import DATA_DIR, WEBSTUFF_IMAGE_DIR, PROGRAM_NAME, URL_HOMEPAGE, VERSION
from gen.plug.docgen import BaseDoc, TextDoc, FONT_SANS_SERIF, URL_PATTERN
from libhtmlbackend import HtmlBackend, process_spaces
from libhtml import Html
from gramps.plugins.lib.libhtmlbackend import HtmlBackend, process_spaces
from gramps.plugins.lib.libhtml import Html
#------------------------------------------------------------------------
#

View File

@ -86,7 +86,7 @@ from gen.plug.docgen import (BaseDoc, TextDoc, DrawDoc, graphicstyle,
INDEX_TYPE_ALP, PARA_ALIGN_RIGHT, URL_PATTERN,
LOCAL_HYPERLINK, LOCAL_TARGET)
from gen.plug.docgen.fontscale import string_width
from libodfbackend import OdfBackend
from gramps.plugins.lib.libodfbackend import OdfBackend
from gen.const import PROGRAM_NAME, VERSION
from gen.plug.report import utils as ReportUtils
from gen.utils.image import image_size, image_dpi, image_actual_size

View File

@ -37,7 +37,7 @@ import sys
# Gramps modules
#
#------------------------------------------------------------------------
import libcairodoc
import gramps.plugins.lib.libcairodoc as libcairodoc
from gen.plug.docgen import INDEX_TYPE_ALP, INDEX_TYPE_TOC
from gen.errors import ReportError

View File

@ -73,7 +73,7 @@ _BORN = _('short for born|b.')
_DIED = _('short for died|d.')
_MARR = _('short for married|m.')
from libtreebase import *
from gramps.plugins.lib.libtreebase import *
#------------------------------------------------------------------------
#

View File

@ -54,8 +54,8 @@ from gen.utils.alive import probably_alive
from gen.datehandler import displayer as _dd, long_days
import gen.lib
import libholiday
from libholiday import g2iso
import gramps.plugins.lib.libholiday as libholiday
from gramps.plugins.lib.libholiday import g2iso
#------------------------------------------------------------------------
#

View File

@ -62,7 +62,7 @@ _MARR = _('short for married|m.')
_RPT_NAME = 'descend_chart'
from libtreebase import *
from gramps.plugins.lib.libtreebase import *
#------------------------------------------------------------------------
#

View File

@ -44,7 +44,7 @@ import time
#-------------------------------------------------------------------------
import gen.lib
from gen.const import VERSION
import libgedcom
import gramps.plugins.lib.libgedcom as libgedcom
from gen.errors import DatabaseError
from gui.plug.export import WriterOptionBox
from gen.updatecallback import UpdateCallback

View File

@ -63,7 +63,7 @@ from gen.db.exceptions import DbWriteFailure
from gen.const import VERSION
from gen.constfunc import win
from gui.plug.export import WriterOptionBox
import libgrampsxml
import gramps.plugins.lib.libgrampsxml as libgrampsxml
#-------------------------------------------------------------------------
#

View File

@ -36,8 +36,8 @@ sys.path.append(os.path.join(os.curdir, 'plugins', 'lib'))
import subprocess
import libxml2
from libgrampsxml import GRAMPS_XML_VERSION
from gen.const import VERSION
from gramps.plugins.lib.libgrampsxml import GRAMPS_XML_VERSION
from gramps.gen.const import VERSION
import exportvcard
class VCardCheck(unittest.TestCase):

View File

@ -56,7 +56,7 @@ from gen.datehandler import parser as _dp
from gen.plug import Gramplet
from libmetadata import MetadataView, format_datetime
from gramps.plugins.lib.libmetadata import MetadataView, format_datetime
from gui.widgets import ValidatableMaskedEntry
from gen.errors import ValidationError
from gui.dialog import QuestionDialog, OptionDialog

View File

@ -22,7 +22,7 @@
# $Id$
#
from libmetadata import MetadataView
from gramps.plugins.lib.libmetadata import MetadataView
from gen.plug import Gramplet
from gen.utils.file import media_path_full

View File

@ -45,8 +45,8 @@ LOG = logging.getLogger(".GedcomImport")
#------------------------------------------------------------------------
from gen.errors import DbError, GedcomError
from gui.glade import Glade
from libmixin import DbMixin
import libgedcom
from gramps.plugins.lib.libmixin import DbMixin
import gramps.plugins.lib.libgedcom as libgedcom
module = __import__("libgedcom")
reload (module)

View File

@ -58,7 +58,7 @@ from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY,
TAG_KEY, CITATION_KEY)
from gen.updatecallback import UpdateCallback
from gen.const import VERSION
import libgrampsxml
import gramps.plugins.lib.libgrampsxml
#-------------------------------------------------------------------------
#

View File

@ -39,7 +39,7 @@ import subprocess
import libxml2
import libxslt
from libgrampsxml import GRAMPS_XML_VERSION
from gramps.plugins.lib.libgrampsxml import GRAMPS_XML_VERSION
from gen.const import ROOT_DIR, VERSION
import importvcard

View File

@ -43,7 +43,7 @@ import os.path
#
#------------------------------------------------------------------------
from gen.plug.docbackend import DocBackend
from libhtml import Html, xml_lang
from gramps.plugins.lib.libhtml import Html, xml_lang
from gen.errors import ReportError

View File

@ -42,7 +42,7 @@ from gen.lib.familyreltype import FamilyRelType
from gen.display.name import displayer as _nd
from gen.utils.alive import probably_alive
from gen.plug.report import utils as ReportUtils
from libtranslate import Translator
from gramps.plugins.lib.libtranslate import Translator
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from gen.plug.report import utils as ReportUtils
from gen.display.name import displayer as name_displayer
from libsubstkeyword import SubstKeywords
from gramps.plugins.lib.libsubstkeyword import SubstKeywords
PT2CM = ReportUtils.pt2cm

View File

@ -38,7 +38,7 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
from libmapservice import MapService
from gramps.plugins.lib.libmapservice import MapService
from gui.dialog import WarningDialog
# Make upper case of translaed country so string search works later

View File

@ -35,7 +35,7 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
from libmapservice import MapService
from gramps.plugins.lib.libmapservice import MapService
class GoogleMapService(MapService):
"""Map service using http://maps.google.com"""

View File

@ -35,7 +35,7 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
from libmapservice import MapService
from gramps.plugins.lib.libmapservice import MapService
class OpensStreetMapService(MapService):

View File

@ -51,8 +51,8 @@ from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions
from gen.utils.trans import get_available_translations
from libnarrate import Narrator
from libtranslate import Translator, get_language_string
from gramps.plugins.lib.libnarrate import Narrator
from gramps.plugins.lib.libtranslate import Translator, get_language_string
#------------------------------------------------------------------------
#

View File

@ -53,7 +53,7 @@ from gen.plug.report import MenuReportOptions
from gen.utils.alive import probably_alive
from gen.datehandler import displayer as _dd, long_days
import libholiday
import gramps.plugins.lib.libholiday as libholiday
#------------------------------------------------------------------------
#

View File

@ -56,9 +56,9 @@ from gen.plug.report import MenuReportOptions
import gen.datehandler
from libnarrate import Narrator
from gramps.plugins.lib.libnarrate import Narrator
from gen.utils.trans import get_available_translations
from libtranslate import Translator, get_language_string
from gramps.plugins.lib.libtranslate import Translator, get_language_string
#------------------------------------------------------------------------
#

View File

@ -60,9 +60,9 @@ from gen.plug.report import MenuReportOptions
import gen.datehandler
from libnarrate import Narrator
from gramps.plugins.lib.libnarrate import Narrator
from gen.utils.trans import get_available_translations
from libtranslate import Translator, get_language_string
from gramps.plugins.lib.libtranslate import Translator, get_language_string
#------------------------------------------------------------------------
#

View File

@ -30,7 +30,7 @@ import os
from tempfile import mkstemp
from gen.ggettext import gettext as _
from gui.glade import Glade
import libgedcom
import gramps.plugins.lib.libgedcom as libgedcom
#
# Interface to phpGedView

View File

@ -48,7 +48,7 @@ from gi.repository import Gtk
from gen.display.name import displayer as name_displayer
from gui.managedwindow import ManagedWindow
from gui.views.treemodels import PeopleBaseModel, PersonTreeModel
from libpersonview import BasePersonView
from gramps.plugins.lib.libpersonview import BasePersonView
from gen.relationship import get_relationship_calculator
from gui.dialog import ErrorDialog

View File

@ -32,7 +32,7 @@ Person list View
#
#-------------------------------------------------------------------------
from gui.views.listview import LISTTREE
from libpersonview import BasePersonView
from gramps.plugins.lib.libpersonview import BasePersonView
from gui.views.treemodels.peoplemodel import PersonListModel
import gen.lib

View File

@ -39,7 +39,7 @@ from gi.repository import Gtk
#
#-------------------------------------------------------------------------
from gui.views.listview import LISTTREE
from libpersonview import BasePersonView
from gramps.plugins.lib.libpersonview import BasePersonView
from gui.views.treemodels.peoplemodel import PersonTreeModel
import gen.lib
from gen.errors import WindowActiveError

View File

@ -28,7 +28,7 @@ Place List View
# Gramps modules
#
#-------------------------------------------------------------------------
from libplaceview import PlaceBaseView
from gramps.plugins.lib.libplaceview import PlaceBaseView
from gui.views.treemodels.placemodel import PlaceListModel
#-------------------------------------------------------------------------

View File

@ -29,7 +29,7 @@ Place Tree View
#
#-------------------------------------------------------------------------
from gui.views.listview import LISTTREE
from libplaceview import PlaceBaseView
from gramps.plugins.lib.libplaceview import PlaceBaseView
from gui.views.treemodels.placemodel import PlaceTreeModel, COUNTRYLEVELS
import gen.lib
from gen.errors import WindowActiveError

View File

@ -99,16 +99,16 @@ import gen.mime
from gen.display.name import displayer as _nd
from gen.datehandler import displayer as _dd
from gen.proxy import PrivateProxyDb, LivingProxyDb
from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
# import HTML Class from src/plugins/lib/libhtml.py
from libhtml import Html, xml_lang
from gramps.plugins.lib.libhtml import Html, xml_lang
# import styled notes from src/plugins/lib/libhtmlbackend.py
from libhtmlbackend import HtmlBackend, process_spaces
from gramps.plugins.lib.libhtmlbackend import HtmlBackend, process_spaces
from libgedcom import make_gedcom_date
from gen.utils.alive import probably_alive
from gramps.plugins.lib.libgedcom import make_gedcom_date
from gramps.gen.utils.alive import probably_alive
from gen.utils.place import conv_lat_lon
from gui.pluginmanager import GuiPluginManager

View File

@ -64,14 +64,14 @@ from gen.datehandler import displayer as _dd, long_days
from gen.display.name import displayer as _nd
import libholiday
from libhtml import Html, xml_lang
from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
import gramps.plugins.lib.libholiday as libholiday
from gramps.plugins.lib.libhtml import Html, xml_lang
from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
from gui.pluginmanager import GuiPluginManager
# import styled notes from
# src/plugins/lib/libhtmlbackend.py
from libhtmlbackend import HtmlBackend
from gramps.plugins.lib.libhtmlbackend import HtmlBackend
#------------------------------------------------------------------------
# constants
#------------------------------------------------------------------------