Coding Guidelines: relative import of gen in gen submodule

svn: r20479
This commit is contained in:
Benny Malengier 2012-10-02 08:28:08 +00:00
parent 47a612c36a
commit 9832e6712e
41 changed files with 107 additions and 111 deletions

View File

@ -62,7 +62,7 @@ except:
# Initialize global displayer
try:
from gen.config import config
from ..config import config
val = config.get('preferences.date-format')
except:
val = 0

View File

@ -188,7 +188,7 @@ class BSDDBTxn(object):
# test code
if __name__ == "__main__":
print "1"
from gen.config import config
from ..config import config
if config.get('preferences.use-bsddb3'):
from bsddb3 import db, dbshelve
else:

View File

@ -21,10 +21,10 @@
# gen/db/test/db_test.py
# $Id$
from gen.db import (DbReadBase, DbWriteBase,
from ..db import (DbReadBase, DbWriteBase,
DbBsddbRead, DbBsddb)
from gen.proxy.proxybase import ProxyDbBase
from gen.proxy import LivingProxyDb
from ...proxy.proxybase import ProxyDbBase
from ...proxy import LivingProxyDb
class DbTest(object):
READ_METHODS = [
@ -263,20 +263,20 @@ db1._verify_readonly()
db2 = DbTest(DbWriteBase())
db2._verify_readwrite()
from gen.db import DbBsddbRead
from .. import DbBsddbRead
db3 = DbTest(DbBsddbRead())
db3._verify_readonly()
from gen.db import DbBsddb
from .. import DbBsddb
db4 = DbTest(DbBsddb())
db4._verify_readwrite()
from gen.proxy.proxybase import ProxyDbBase
from ...proxy.proxybase import ProxyDbBase
gdb = DbBsddb()
db5 = DbTest(ProxyDbBase(gdb))
db5._verify_readonly()
from gen.proxy import LivingProxyDb
from ...proxy import LivingProxyDb
gdb = DbBsddb()
db6 = DbTest(LivingProxyDb(gdb, LivingProxyDb.MODE_EXCLUDE_ALL))
db6._verify_readonly()

View File

@ -29,7 +29,7 @@ import time
import logging
LOG = logging.getLogger(".citation")
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
"""
methods to upgrade a database from version 13 to current version

View File

@ -25,10 +25,10 @@
Provide the database state class
"""
from gen.db import DbBsddbRead
from gen.proxy.proxybase import ProxyDbBase
from gen.utils.callback import Callback
from gen.config import config
from db import DbBsddbRead
from proxy.proxybase import ProxyDbBase
from utils.callback import Callback
from config import config
class DbState(Callback):
"""

View File

@ -26,7 +26,7 @@
import unittest as U
from test.test_util import msg
from gen.lib.grampstype import GrampsType, _init_map
from ..grampstype import GrampsType, _init_map
# some simple map items to test with
vals = "zz ab cd ef".split()

View File

@ -25,11 +25,11 @@ This package implements an object difference engine.
"""
import os
import cli.user
from gen.dbstate import DbState
from cli.grampscli import CLIManager
from gen.plug import BasePluginManager
from gen.db.dictionary import DictionaryDb
import gramps.cli.user
from ..dbstate import DbState
from gramps.cli.grampscli import CLIManager
from ..plug import BasePluginManager
from ..db.dictionary import DictionaryDb
def import_as_dict(filename):
"""

View File

@ -30,10 +30,10 @@ Provide merge capabilities for citations.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import (Person, Family, Event, Place, MediaObject, Repository)
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import (Person, Family, Event, Place, MediaObject, Repository)
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -29,10 +29,10 @@ Provide merge capabilities for events.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import Person, Family
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import Person, Family
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -29,10 +29,10 @@ Provide merge capabilities for families.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from gen.merge import MergePersonQuery
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
from . import MergePersonQuery
#-------------------------------------------------------------------------
#

View File

@ -29,10 +29,10 @@ Provide merge capabilities for media objects.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import Person, Family, Event, Source, Citation, Place
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import Person, Family, Event, Source, Citation, Place
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -29,11 +29,11 @@ Provide merge capabilities for notes.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import (Person, Family, Event, Place, Source, Citation, Repository,
MediaObject)
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import (Person, Family, Event, Place, Source, Citation, Repository,
MediaObject)
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -31,9 +31,9 @@ Provide merge capabilities for persons.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -30,10 +30,10 @@ Provide merge capabilities for places.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import Person, Family, Event
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import Person, Family, Event
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -29,10 +29,10 @@ Provide merge capabilities for repositories.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import Source
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import Source
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -31,11 +31,11 @@ Provide merge capabilities for sources.
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.lib import (Person, Family, Event, Place, Source, Repository,
MediaObject, Citation)
from gen.db import DbTxn
from gen.ggettext import sgettext as _
from gen.errors import MergeError
from ..lib import (Person, Family, Event, Place, Source, Repository,
MediaObject, Citation)
from ..db import DbTxn
from ..ggettext import sgettext as _
from ..errors import MergeError
#-------------------------------------------------------------------------
#

View File

@ -36,7 +36,7 @@ import libxml2
import libxslt
from libgrampsxml import GRAMPS_XML_VERSION
from gen.const import ROOT_DIR, VERSION, USER_PLUGINS
from ...const import ROOT_DIR, VERSION, USER_PLUGINS
from ...lib import Name, Surname
from ...ggettext import sgettext as _

View File

@ -29,7 +29,7 @@ except:
from gnome.vfs import mime_get_short_list_applications, \
mime_get_description, get_mime_type, mime_get_default_application
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
def get_description(type):
"""Return the description of the specified mime type."""

View File

@ -22,7 +22,7 @@
#
import mimetypes
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
_type_map = {
'application/x-gramps' : 'Gramps database',

View File

@ -38,7 +38,7 @@ from _winreg import *
#
#-------------------------------------------------------------------------
import _pythonmime
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
def get_description(mime_type):
"""Return the description of the specfied mime type"""

View File

@ -28,7 +28,7 @@
# Python modules
#
#------------------------------------------------------------------------
from gen.ggettext import gettext as _
from ...ggettext import gettext as _
#-------------------------------------------------------------------------
#

View File

@ -29,7 +29,7 @@
# standard python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
from ...ggettext import gettext as _
import os
#-------------------------------------------------------------------------
@ -39,8 +39,8 @@ import os
#-------------------------------------------------------------------------
# Report categories
from gen.plug import CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_CODE, CATEGORY_WEB,\
CATEGORY_BOOK, CATEGORY_GRAPHVIZ
from .. import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_CODE, CATEGORY_WEB,
CATEGORY_BOOK, CATEGORY_GRAPHVIZ)
standalone_categories = {
CATEGORY_TEXT : _("Text Reports"),
@ -55,4 +55,3 @@ book_categories = {
CATEGORY_TEXT : _("Text"),
CATEGORY_DRAW : _("Graphics"),
}

View File

@ -57,11 +57,11 @@ except:
# (do not import anything from 'gui' as this is in 'gen')
#
#-------------------------------------------------------------------------
from gen.const import HOME_DIR, REPORT_OPTIONS
from gen.config import config
from gen.plug.docgen import PAPER_PORTRAIT
from gen.plug import _options
from gen.plug import MenuOptions
from ...const import HOME_DIR, REPORT_OPTIONS
from ...config import config
from ..docgen import PAPER_PORTRAIT
from .. import _options
from .. import MenuOptions
#-------------------------------------------------------------------------
#

View File

@ -26,16 +26,16 @@
# Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import sgettext as _
from ...ggettext import sgettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.plug.utils import gfloat
from gen.plug.docgen import PaperSize
from gen.const import PAPERSIZE
from ..utils import gfloat
from ..docgen import PaperSize
from ...const import PAPERSIZE
#-------------------------------------------------------------------------
#

View File

@ -26,11 +26,11 @@
"""
Provide utilities for printing endnotes in text reports.
"""
from gen.plug.docgen import FontStyle, ParagraphStyle, FONT_SANS_SERIF
from gen.lib import NoteType, Citation
from gen.ggettext import gettext as _
from gen.utils.string import confidence
from gen.datehandler import displayer
from ..docgen import FontStyle, ParagraphStyle, FONT_SANS_SERIF
from ...lib import NoteType, Citation
from ...ggettext import gettext as _
from ...utils.string import confidence
from ....datehandler import displayer
def add_endnote_styles(style_sheet):
"""

View File

@ -34,7 +34,7 @@ A collection of utilities to aid in the generation of reports.
#
#-------------------------------------------------------------------------
import os
from gen.ggettext import gettext as _
from ...ggettext import gettext as _
#------------------------------------------------------------------------
#

View File

@ -39,7 +39,6 @@ from itertools import imap
# GRAMPS libraries
#
#-------------------------------------------------------------------------
#from gen.lib import *
from proxybase import ProxyDbBase
class FilterProxyDb(ProxyDbBase):

View File

@ -37,9 +37,9 @@ from itertools import ifilter
#
#-------------------------------------------------------------------------
from proxybase import ProxyDbBase
from gen.lib import Date, Person, Name, Surname, NameOriginType
from gen.utils.alive import probably_alive
from gen.config import config
from ..lib import Date, Person, Name, Surname, NameOriginType
from ..utils.alive import probably_alive
from ..config import config
#-------------------------------------------------------------------------
#

View File

@ -31,7 +31,7 @@ Proxy class for the GRAMPS databases. Filter out all data marked private.
# Python libraries
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
import logging
LOG = logging.getLogger(".citation")
@ -40,9 +40,9 @@ LOG = logging.getLogger(".citation")
# GRAMPS libraries
#
#-------------------------------------------------------------------------
from gen.lib import (MediaRef, Attribute, Address, EventRef,
Person, Name, Source, RepoRef, MediaObject, Place, Event,
Family, ChildRef, Repository, LdsOrd, Surname, Citation)
from ..lib import (MediaRef, Attribute, Address, EventRef,
Person, Name, Source, RepoRef, MediaObject, Place, Event,
Family, ChildRef, Repository, LdsOrd, Surname, Citation)
from proxybase import ProxyDbBase
class PrivateProxyDb(ProxyDbBase):

View File

@ -38,7 +38,7 @@ import types
# GRAMPS libraries
#
#-------------------------------------------------------------------------
from gen.db.base import DbReadBase, DbWriteBase
from ..db.base import DbReadBase, DbWriteBase
class ProxyCursor(object):
"""

View File

@ -37,7 +37,7 @@ try:
except:
use_lock = False
from gen.const import HOME_DIR
from const import HOME_DIR
#-------------------------------------------------------------------------
#

View File

@ -401,7 +401,7 @@ class RelationshipCalculator(object):
self.__db_connected = False
self.depth = 15
try:
from gen.config import config
from config import config
self.set_depth(config.get('behavior.generation-depth'))
except ImportError:
pass

View File

@ -23,7 +23,7 @@
"""
Provide a simplified database access interface to the GRAMPS database.
"""
from gen.plug.docgen import StyleSheet, ParagraphStyle, TableStyle,\
from ..plug.docgen import StyleSheet, ParagraphStyle, TableStyle,\
TableCellStyle, FONT_SANS_SERIF, PARA_ALIGN_LEFT
class SimpleDoc(object):

View File

@ -27,7 +27,7 @@ Provide a simplified table creation interface
"""
import cgi
from gen.ggettext import sgettext as _
from ..ggettext import sgettext as _
from ..lib import (Person, Family, Event, Source, Place, Citation,
Repository, MediaObject, Note, Date, Span)
from ..config import config

View File

@ -39,9 +39,9 @@ import locale
# GRAMPS Modules
#
#-------------------------------------------------------------------------
from gen.lib import Date
from gen.utils.db import get_birth_or_fallback
from gen.display.name import displayer as _nd
from lib import Date
from utils.db import get_birth_or_fallback
from display.name import displayer as _nd
#-------------------------------------------------------------------------
#

View File

@ -52,7 +52,7 @@ from ..ggettext import sgettext as _
#-------------------------------------------------------------------------
# cache values; use refresh_constants() if they change
try:
from gen.config import config
from ..config import config
_MAX_AGE_PROB_ALIVE = config.get('behavior.max-age-prob-alive')
_MAX_SIB_AGE_DIFF = config.get('behavior.max-sib-age-diff')
_AVG_GENERATION_GAP = config.get('behavior.avg-generation-gap')
@ -499,7 +499,7 @@ def probably_alive_range(person, db,
"""
# First, find the real database to use all people
# for determining alive status:
from gen.proxy.proxybase import ProxyDbBase
from ..proxy.proxybase import ProxyDbBase
basedb = db
while isinstance(basedb, ProxyDbBase):
basedb = basedb.db
@ -512,7 +512,7 @@ def update_constants():
"""
Used to update the constants that are cached in this module.
"""
from gen.config import config
from ..config import config
global _MAX_AGE_PROB_ALIVE, _MAX_SIB_AGE_DIFF, _AVG_GENERATION_GAP
_MAX_AGE_PROB_ALIVE = config.get('behavior.max-age-prob-alive')
_MAX_SIB_AGE_DIFF = config.get('behavior.max-sib-age-diff')

View File

@ -28,7 +28,7 @@
import os
import tempfile
import zipfile
from gen.ggettext import gettext as _
from ...ggettext import gettext as _
#-------------------------------------------------------------------------
#
@ -36,10 +36,8 @@ from gen.ggettext import gettext as _
#
#-------------------------------------------------------------------------
from TabbedDoc import *
from gen.const import PROGRAM_NAME, VERSION
from gen.errors import ReportError
from ...const import PROGRAM_NAME, VERSION
from ...errors import ReportError
#-------------------------------------------------------------------------
#

View File

@ -44,7 +44,7 @@ import tempfile
# Gramps modules
#
#-------------------------------------------------------------------------
from gen.utils.file import get_unicode_path_from_env_var
from file import get_unicode_path_from_env_var
#-------------------------------------------------------------------------
#

View File

@ -24,12 +24,12 @@
Parses the lds.xml file to build the temple/code maps
"""
from gen.const import DATA_DIR
from ..const import DATA_DIR
import os
import logging
from xml.parsers.expat import ParserCreate
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
LOG = logging.getLogger(".")

View File

@ -26,7 +26,7 @@ import unittest
from test import test_util as tu
tu.path_append_parent()
from gen.utils.callback import Callback
from ..callback import Callback
try:
log

View File

@ -265,7 +265,7 @@ def get_addon_translator(filename=None, domain="addon", languages=None):
# Check if path is of type str. Do import and conversion if so.
# The import cannot be done at the top as that will conflict with the translation system.
if type(path) == str:
from gen.utils.file import get_unicode_path_from_env_var
from file import get_unicode_path_from_env_var
path = get_unicode_path_from_env_var(path)
if languages:
addon_translator = gettext.translation(domain, os.path.join(path,"locale"),
@ -305,7 +305,7 @@ def trans_objclass(objclass_str):
Translates objclass_str into "... %s", where objclass_str
is 'Person', 'person', 'Family', 'family', etc.
"""
from gen.ggettext import gettext as _
from ..ggettext import gettext as _
objclass = objclass_str.lower()
if objclass == "person":
return _("the person")