Remove redundant unicode conversion of __file__ variable
This commit is contained in:
parent
d770c8a236
commit
452fbfac80
@ -40,7 +40,7 @@ import uuid
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from .git_revision import get_git_revision
|
from .git_revision import get_git_revision
|
||||||
from .constfunc import get_env_var, conv_to_unicode
|
from .constfunc import get_env_var
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gramps Version
|
# Gramps Version
|
||||||
@ -126,8 +126,7 @@ USER_DIRLIST = (USER_HOME, HOME_DIR, VERSION_DIR, ENV_DIR, TEMP_DIR, THUMB_DIR,
|
|||||||
# above this one, and that the plugins directory is below the root directory.
|
# above this one, and that the plugins directory is below the root directory.
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(
|
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
conv_to_unicode(__file__)), os.pardir))
|
|
||||||
|
|
||||||
sys.path.insert(0, ROOT_DIR)
|
sys.path.insert(0, ROOT_DIR)
|
||||||
git_revision = get_git_revision(ROOT_DIR)
|
git_revision = get_git_revision(ROOT_DIR)
|
||||||
|
@ -25,7 +25,7 @@ _hdlr = logging.StreamHandler()
|
|||||||
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
||||||
LOG.addHandler(_hdlr)
|
LOG.addHandler(_hdlr)
|
||||||
|
|
||||||
from ..constfunc import get_env_var, conv_to_unicode
|
from ..constfunc import get_env_var
|
||||||
|
|
||||||
class ResourcePath(object):
|
class ResourcePath(object):
|
||||||
"""
|
"""
|
||||||
@ -48,7 +48,7 @@ class ResourcePath(object):
|
|||||||
if self.initialized:
|
if self.initialized:
|
||||||
return
|
return
|
||||||
resource_file = os.path.join(os.path.abspath(os.path.dirname(
|
resource_file = os.path.join(os.path.abspath(os.path.dirname(
|
||||||
conv_to_unicode(__file__))), 'resource-path')
|
__file__)), 'resource-path')
|
||||||
installed = os.path.exists(resource_file)
|
installed = os.path.exists(resource_file)
|
||||||
if installed:
|
if installed:
|
||||||
test_path = os.path.join("gramps", "authors.xml")
|
test_path = os.path.join("gramps", "authors.xml")
|
||||||
@ -62,7 +62,7 @@ class ResourcePath(object):
|
|||||||
try:
|
try:
|
||||||
with open(resource_file, encoding='utf-8',
|
with open(resource_file, encoding='utf-8',
|
||||||
errors='strict') as fp:
|
errors='strict') as fp:
|
||||||
resource_path = conv_to_unicode(fp.readline())
|
resource_path = fp.readline()
|
||||||
except UnicodeError as err:
|
except UnicodeError as err:
|
||||||
LOG.exception("Encoding error while parsing resource path", err)
|
LOG.exception("Encoding error while parsing resource path", err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -75,7 +75,7 @@ class ResourcePath(object):
|
|||||||
else:
|
else:
|
||||||
# Let's try to run from source without env['GRAMPS_RESOURCES']:
|
# Let's try to run from source without env['GRAMPS_RESOURCES']:
|
||||||
resource_path = os.path.join(os.path.abspath(os.path.dirname(
|
resource_path = os.path.join(os.path.abspath(os.path.dirname(
|
||||||
conv_to_unicode(__file__))), '..', "..", "..")
|
__file__)), '..', "..", "..")
|
||||||
test_path = os.path.join("data", "authors.xml")
|
test_path = os.path.join("data", "authors.xml")
|
||||||
if (not os.path.exists(os.path.join(resource_path, test_path))):
|
if (not os.path.exists(os.path.join(resource_path, test_path))):
|
||||||
LOG.error("Unable to determine resource path")
|
LOG.error("Unable to determine resource path")
|
||||||
|
Loading…
Reference in New Issue
Block a user