Convert some imports from absolute to relative

This commit is contained in:
Nick Hall 2017-02-20 18:15:25 +00:00
parent e46321a7c6
commit 3e5a956454
42 changed files with 108 additions and 124 deletions

View File

@ -41,9 +41,9 @@ import uuid
#-------------------------------------------------------------------------
from .git_revision import get_git_revision
from .constfunc import get_env_var
from gramps.version import VERSION, VERSION_TUPLE, major_version
from gramps.gen.utils.resourcepath import ResourcePath
from gramps.gen.utils.grampslocale import GrampsLocale
from ..version import VERSION, VERSION_TUPLE, major_version
from .utils.resourcepath import ResourcePath
from .utils.grampslocale import GrampsLocale
#-------------------------------------------------------------------------
#

View File

@ -46,7 +46,7 @@ from ._dateparser import DateParser
from ._datedisplay import DateDisplay, DateDisplayEn
from ..constfunc import win
from ..const import GRAMPS_LOCALE as glocale
from gramps.gen.utils.grampslocale import GrampsLocale
from ..utils.grampslocale import GrampsLocale
#-------------------------------------------------------------------------
#

View File

@ -251,7 +251,7 @@ class DateStrings:
if __name__ == '__main__':
import sys
from ..utils.grampslocale import GrampsLocale
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ..const import GRAMPS_LOCALE as glocale
from ._grampslocale import (_deprecated_long_months as old_long,
_deprecated_short_months as old_short,
_deprecated_long_days as old_days)

View File

@ -21,7 +21,7 @@
#
import locale
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ..const import GRAMPS_LOCALE as glocale
"""
Some OS environments do not support the locale.nl_langinfo() method

View File

@ -63,10 +63,10 @@ from functools import wraps
# Gramps libraries
#
#-------------------------------------------------------------------------
from gramps.gen.db.base import DbReadBase
from gramps.gen.db.dbconst import DBLOGNAME
from gramps.gen.errors import HandleError
from gramps.gen.utils.callback import Callback
from .base import DbReadBase
from .dbconst import DBLOGNAME
from ..errors import HandleError
from ..utils.callback import Callback
LOG = logging.getLogger(DBLOGNAME)

View File

@ -25,8 +25,8 @@
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ..const import URL_WIKISTRING, URL_MANUAL_PAGE
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------

View File

@ -41,24 +41,23 @@ import glob
# Gramps Modules
#
#------------------------------------------------------------------------
from gramps.gen.db import (DbReadBase, DbWriteBase, DbUndo, DBLOGNAME,
DBUNDOFN, KEY_TO_CLASS_MAP, REFERENCE_KEY,
PERSON_KEY, FAMILY_KEY, CITATION_KEY,
SOURCE_KEY, EVENT_KEY, MEDIA_KEY,
PLACE_KEY, REPOSITORY_KEY, NOTE_KEY, TAG_KEY)
from gramps.gen.errors import HandleError
from gramps.gen.utils.callback import Callback
from gramps.gen.updatecallback import UpdateCallback
from gramps.gen.db.bookmarks import DbBookmarks
from gramps.gen.db import exceptions
from . import (DbReadBase, DbWriteBase, DbUndo, DBLOGNAME, DBUNDOFN,
KEY_TO_CLASS_MAP, REFERENCE_KEY, PERSON_KEY, FAMILY_KEY,
CITATION_KEY, SOURCE_KEY, EVENT_KEY, MEDIA_KEY, PLACE_KEY,
REPOSITORY_KEY, NOTE_KEY, TAG_KEY)
from ..errors import HandleError
from ..utils.callback import Callback
from ..updatecallback import UpdateCallback
from .bookmarks import DbBookmarks
from . import exceptions
from gramps.gen.utils.id import create_id
from gramps.gen.lib.researcher import Researcher
from gramps.gen.lib import (Tag, Media, Person, Family, Source, Citation, Event,
Place, Repository, Note, NameOriginType)
from gramps.gen.lib.genderstats import GenderStats
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ..utils.id import create_id
from ..lib.researcher import Researcher
from ..lib import (Tag, Media, Person, Family, Source, Citation, Event,
Place, Repository, Note, NameOriginType)
from ..lib.genderstats import GenderStats
from ..config import config
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
LOG = logging.getLogger(DBLOGNAME)

View File

@ -172,7 +172,7 @@ def __index_surname(surn_list):
pa/matronymic not as they change for every generation!
returns a byte string
"""
from gramps.gen.lib import NameOriginType
from ..lib import NameOriginType
if surn_list:
surn = " ".join([x[0] for x in surn_list if not (x[3][0] in [
NameOriginType.PATRONYMIC, NameOriginType.MATRONYMIC])])

View File

@ -42,8 +42,8 @@ from .db import DbReadBase
from .proxy.proxybase import ProxyDbBase
from .utils.callback import Callback
from .config import config
from gramps.gen.db.dbconst import DBLOGNAME
from gramps.gen.db.dummydb import DummyDb
from .db.dbconst import DBLOGNAME
from .db.dummydb import DummyDb
#-------------------------------------------------------------------------
#

View File

@ -22,8 +22,6 @@
Package providing filtering framework for GRAMPS.
"""
from gramps.gen.constfunc import win
class SearchFilter:
def __init__(self, func, text, invert):
self.func = func

View File

@ -33,10 +33,10 @@ import time
# Gramps modules
#
#-------------------------------------------------------------------------
from . import Rule
from ...errors import FilterError
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from . import Rule
from gramps.gen.errors import FilterError
#-------------------------------------------------------------------------
#

View File

@ -24,9 +24,9 @@
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from . import Rule
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
# "People marked public"

View File

@ -33,10 +33,10 @@ LOG = logging.getLogger(".filter")
#-------------------------------------------------------------------------
# we need global variableCustomFilters, so we need to query gramps.gen.filters
# when we need this variable, not import it at the start!
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import gramps.gen.filters
from . import Rule
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#

View File

@ -18,20 +18,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from .. import Rule
from ....const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#

View File

@ -30,9 +30,9 @@
#
#-------------------------------------------------------------------------
from .. import Rule
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from ....lib.childreftype import ChildRefType
from ....const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#

View File

@ -31,7 +31,7 @@
#-------------------------------------------------------------------------
from ....lib.notetype import NoteType
from .. import Rule
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ....const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------

View File

@ -18,14 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from ....const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------
#
# Gramps modules
@ -33,7 +25,9 @@ _ = glocale.translation.sgettext
#-------------------------------------------------------------------------
from .. import Rule
from ....lib.nameorigintype import NameOriginType
from gramps.gen.soundex import soundex
from ....soundex import soundex
from ....const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------

View File

@ -24,12 +24,12 @@ Unittest that tests event-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilterFactory
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.event import (
from ..event import (
AllEvents, HasType, HasIdOf, HasGallery, RegExpIdOf, HasCitation, HasNote,
HasNoteRegexp, HasReferenceCountOf, HasSourceCount, EventPrivate,
MatchesSourceConfidence, HasAttribute, HasData, ChangedSince, HasTag,

View File

@ -24,12 +24,12 @@ Unittest that tests family-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilterFactory
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.family import (
from ..family import (
AllFamilies, HasRelType, HasGallery, HasIdOf, HasLDS, HasNote, RegExpIdOf,
HasNoteRegexp, HasReferenceCountOf, HasSourceCount, HasSourceOf,
HasCitation, FamilyPrivate, HasEvent, HasAttribute, IsBookmarked,

View File

@ -24,12 +24,12 @@ Unittest that tests media-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilterFactory
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.media import (
from ..media import (
AllMedia, HasIdOf, RegExpIdOf, HasCitation, HasNoteRegexp,
HasNoteMatchingSubstringOf, HasReferenceCountOf, HasSourceCount,
HasSourceOf, MediaPrivate, MatchesSourceConfidence, HasMedia,

View File

@ -24,12 +24,12 @@ Unittest that tests note-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilterFactory
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.note import (
from ..note import (
AllNotes, HasIdOf, RegExpIdOf, HasNote, MatchesRegexpOf,
HasReferenceCountOf, NotePrivate, ChangedSince, HasTag, HasType)

View File

@ -24,12 +24,12 @@ Unittest that tests person-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilter
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilter
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.person import (
from ..person import (
Disconnected, Everyone, FamilyWithIncompleteEvent, HasAlternateName,
HasCommonAncestorWith, HasNickname, HasUnknownGender, HasSourceOf,
HaveAltFamilies, HaveChildren, IncompleteNames, IsBookmarked,

View File

@ -24,12 +24,12 @@ Unittest that tests place-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilterFactory
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.place import (
from ..place import (
AllPlaces, HasCitation, HasGallery, HasIdOf, RegExpIdOf, HasNote,
HasNoteRegexp, HasReferenceCountOf, HasSourceCount, HasSourceOf,
PlacePrivate, MatchesSourceConfidence, HasData, HasNoLatOrLon,

View File

@ -24,12 +24,12 @@ Unittest that tests repository-specific filter rules
import unittest
import os
from gramps.gen.db.utils import import_as_dict
from ....db.utils import import_as_dict
from ....filters import GenericFilterFactory
from ....const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.repository import (
from ..repository import (
AllRepos, HasIdOf, RegExpIdOf, HasNoteRegexp, HasReferenceCountOf,
RepoPrivate, ChangedSince, MatchesNameSubstringOf, HasTag)

View File

@ -27,8 +27,8 @@ class HandleClass(str):
@classmethod
def get_schema(cls):
from gramps.gen.lib import (Person, Family, Event, Place, Source,
Media, Repository, Note, Citation, Tag)
from . import (Person, Family, Event, Place, Source, Media, Repository,
Note, Citation, Tag)
tables = {
"Person": Person,
"Family": Family,

View File

@ -37,7 +37,7 @@ import time
#
#-------------------------------------------------------------------------
from .baseobj import BaseObject
from gramps.gen.errors import HandleError
from ..errors import HandleError
#-------------------------------------------------------------------------
#

View File

@ -26,9 +26,9 @@ import os
from .. import (Person, Family, Event, Source, Place, Citation,
Repository, Media, Note, Tag)
from ..serialize import to_json, from_json
from gramps.gen.db.utils import import_as_dict
from ...db.utils import import_as_dict
from ...const import DATA_DIR
from gramps.cli.user import User
from gramps.gen.const import DATA_DIR
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")

View File

@ -31,12 +31,12 @@ import copy
import lxml.etree as ET
from gramps.plugins.lib.libgrampsxml import GRAMPS_XML_VERSION
from gramps.gen.const import DATA_DIR, USER_PLUGINS, TEMP_DIR
from gramps.version import VERSION
from gramps.gen.lib import Name, Surname
from gramps.test.test_util import Gramps
from gramps.cli.user import User
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ...const import DATA_DIR, USER_PLUGINS, TEMP_DIR
from ....version import VERSION
from ...lib import Name, Surname
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
HAS_CLIMERGE = os.path.isdir(os.path.join(USER_PLUGINS, 'CliMerge'))

View File

@ -39,7 +39,7 @@ import traceback
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.version import VERSION as GRAMPSVERSION, VERSION_TUPLE
from ...version import VERSION as GRAMPSVERSION, VERSION_TUPLE
from ..const import IMAGE_DIR
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext

View File

@ -34,7 +34,7 @@
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------

View File

@ -29,7 +29,7 @@ Option class representing an enumerated list of possible values.
#
#-------------------------------------------------------------------------
from . import Option
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------

View File

@ -64,7 +64,7 @@ from ...config import config
from ..docgen import PAPER_PORTRAIT
from .. import _options
from .. import MenuOptions
from gramps.gen.utils.cast import get_type_converter
from ...utils.cast import get_type_converter
def escxml(word):
return escape(word, {'"' : '"'})

View File

@ -26,9 +26,9 @@
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.utils.grampslocale import GrampsLocale
from gramps.gen.display.name import NameDisplay
from gramps.gen.config import config
from ...utils.grampslocale import GrampsLocale
from ...display.name import NameDisplay
from ...config import config
#-------------------------------------------------------------------------
#

View File

@ -28,13 +28,12 @@ Commonly used report options. Call the function, don't copy the code!
# gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ...config import config
from ...display.name import displayer as global_name_display
from ..menu import EnumeratedListOption, BooleanOption, NumberOption
from ...proxy import PrivateProxyDb, LivingProxyDb
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.config import config
from gramps.gen.display.name import displayer as global_name_display
from gramps.gen.plug.menu import (EnumeratedListOption, BooleanOption,
NumberOption)
from gramps.gen.proxy import PrivateProxyDb, LivingProxyDb
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)

View File

@ -47,13 +47,13 @@ LOG = logging.getLogger(".gen.plug")
#-------------------------------------------------------------------------
from ._pluginreg import make_environment
from ..const import USER_PLUGINS
from gramps.version import VERSION_TUPLE
from ...version import VERSION_TUPLE
from . import BasePluginManager
from ..utils.configmanager import safe_eval
from ..config import config
from ..constfunc import mac
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from ..constfunc import mac
#-------------------------------------------------------------------------
#

View File

@ -22,7 +22,7 @@
Proxy class for the Gramps databases. Caches lookups from handles.
"""
from gramps.gen.utils.lru import LRU
from ..utils.lru import LRU
class CacheProxyDb:
"""

View File

@ -33,7 +33,7 @@ from ..lib import (Date, Person, Name, Surname, NameOriginType, Family, Source,
Citation, Event, Media, Place, Repository, Note, Tag)
from ..utils.alive import probably_alive
from ..config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ..const import GRAMPS_LOCALE as glocale
#-------------------------------------------------------------------------
#

View File

@ -37,7 +37,7 @@ try:
except ImportError:
USE_LOCK = False
from gramps.gen.const import HOME_DIR, GRAMPS_LOCALE as glocale
from .const import HOME_DIR, GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------

View File

@ -654,13 +654,13 @@ class GrampsLocale:
if self._dd:
return self._dd
from gramps.gen.config import config
from ..config import config
try:
val = config.get('preferences.date-format')
except AttributeError:
val = 0;
from gramps.gen.datehandler import LANG_TO_DISPLAY as displayers
from ..datehandler import LANG_TO_DISPLAY as displayers
_first = self._GrampsLocale__first_instance
if self.calendar in displayers:
self._dd = displayers[self.calendar](val)
@ -688,7 +688,7 @@ class GrampsLocale:
if self._dp:
return self._dp
from gramps.gen.datehandler import LANG_TO_PARSER as parsers
from ..datehandler import LANG_TO_PARSER as parsers
_first = self._GrampsLocale__first_instance
if self.calendar in parsers:
self._dp = parsers[self.calendar]()
@ -904,7 +904,7 @@ class GrampsLocale:
:returns: The name as text in the proper language.
:rtype: unicode
"""
from gramps.gen.lib.grampstype import GrampsType
from ..lib.grampstype import GrampsType
return GrampsType.xml_str(name)
def format(self, format, val, grouping=False, monetary=False):

View File

@ -48,7 +48,7 @@ Keyword translation interface
# 'n' : nickname = nick name
# 'g' : familynick = family nick name
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
KEYWORDS = [("title", "t", _("Person|Title"), _("Person|TITLE")),

View File

@ -38,9 +38,9 @@ import unittest
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import TEMP_DIR, USER_HOME, USER_PLUGINS, VERSION
from gramps.gen.utils.file import media_path, get_empty_tempdir
from gramps.gen.db.utils import make_database
from ...const import TEMP_DIR, USER_HOME, USER_PLUGINS, VERSION
from ...utils.file import media_path, get_empty_tempdir
from ...db.utils import make_database
#-------------------------------------------------------------------------
#

View File

@ -34,7 +34,7 @@ import math
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.utils.place import conv_lat_lon
from ..place import conv_lat_lon
#-------------------------------------------------------------------------
#