Mercurial > kallithea
changeset 5998:037efd94e955
cleanup: get rid of dn as shortcut for os.path.dirname
We keep 'dirname' as shortcut despite having removed the 'join' shortcut:
* the name is less ambiguous than 'join'.
* dirname is often applied multiple times - spelling it out would be too
verbose.
author | domruf <dominikruf@gmail.com> |
---|---|
date | Mon, 13 Jun 2016 21:39:47 +0200 |
parents | b313d735d9c8 |
children | 58809814b51d |
files | kallithea/lib/db_manage.py kallithea/lib/indexers/__init__.py kallithea/lib/indexers/daemon.py kallithea/lib/paster_commands/cache_keys.py kallithea/lib/paster_commands/cleanup.py kallithea/lib/paster_commands/install_iis.py kallithea/lib/paster_commands/ishell.py kallithea/lib/paster_commands/make_index.py kallithea/lib/paster_commands/make_rcextensions.py kallithea/lib/paster_commands/repo_scan.py kallithea/lib/paster_commands/setup_db.py kallithea/lib/paster_commands/update_repoinfo.py kallithea/lib/utils.py kallithea/tests/fixture.py kallithea/tests/functional/test_admin.py kallithea/tests/scripts/manual_test_concurrency.py kallithea/tests/scripts/manual_test_crawler.py |
diffstat | 17 files changed, 37 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/db_manage.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/db_manage.py Mon Jun 13 21:39:47 2016 +0200 @@ -31,7 +31,7 @@ import time import uuid import logging -from os.path import dirname as dn +from os.path import dirname from kallithea import __dbversion__, __py_version__, EXTERN_TYPE_INTERNAL, DB_MIGRATIONS from kallithea.model.user import UserModel @@ -138,7 +138,7 @@ print 'No upgrade performed' sys.exit(0) - repository_path = os.path.join(dn(dn(dn(os.path.realpath(__file__)))), + repository_path = os.path.join(dirname(dirname(dirname(os.path.realpath(__file__)))), 'kallithea', 'lib', 'dbmigrate') db_uri = self.dburi
--- a/kallithea/lib/indexers/__init__.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/indexers/__init__.py Mon Jun 13 21:39:47 2016 +0200 @@ -28,10 +28,10 @@ import os import sys import logging -from os.path import dirname as dn +from os.path import dirname # Add location of top level folder to sys.path -sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) +sys.path.append(dirname(dirname(dirname(os.path.realpath(__file__))))) from whoosh.analysis import RegexTokenizer, LowercaseFilter from whoosh.fields import TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME
--- a/kallithea/lib/indexers/daemon.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/indexers/daemon.py Mon Jun 13 21:39:47 2016 +0200 @@ -34,10 +34,10 @@ from shutil import rmtree from time import mktime -from os.path import dirname as dn +from os.path import dirname # Add location of top level folder to sys.path -project_path = dn(dn(dn(dn(os.path.realpath(__file__))))) +project_path = dirname(dirname(dirname(dirname(os.path.realpath(__file__))))) sys.path.append(project_path) from kallithea.config.conf import INDEX_EXTENSIONS, INDEX_FILENAMES
--- a/kallithea/lib/paster_commands/cache_keys.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/cache_keys.py Mon Jun 13 21:39:47 2016 +0200 @@ -35,8 +35,8 @@ from kallithea.model.db import CacheInvalidation # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/paster_commands/cleanup.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/cleanup.py Mon Jun 13 21:39:47 2016 +0200 @@ -38,8 +38,8 @@ from kallithea.model.db import Ui # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/paster_commands/install_iis.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/install_iis.py Mon Jun 13 21:39:47 2016 +0200 @@ -25,8 +25,8 @@ from paste.script.command import BadCommand # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path) class Command(AbstractInstallCommand):
--- a/kallithea/lib/paster_commands/ishell.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/ishell.py Mon Jun 13 21:39:47 2016 +0200 @@ -32,8 +32,8 @@ from kallithea.lib.utils import BasePasterCommand # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/paster_commands/make_index.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/make_index.py Mon Jun 13 21:39:47 2016 +0200 @@ -34,8 +34,8 @@ from kallithea.lib.utils import BasePasterCommand, load_rcextensions # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path) @@ -71,7 +71,7 @@ from kallithea.lib.pidlock import LockHeld, DaemonLock from kallithea.lib.indexers.daemon import WhooshIndexingDaemon try: - l = DaemonLock(file_=os.path.join(dn(dn(index_location)), + l = DaemonLock(file_=os.path.join(dirname(dirname(index_location)), 'make_index.lock')) WhooshIndexingDaemon(index_location=index_location, repo_location=repo_location,
--- a/kallithea/lib/paster_commands/make_rcextensions.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/make_rcextensions.py Mon Jun 13 21:39:47 2016 +0200 @@ -33,8 +33,8 @@ from kallithea.lib.utils import BasePasterCommand, ask_ok # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/paster_commands/repo_scan.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/repo_scan.py Mon Jun 13 21:39:47 2016 +0200 @@ -33,8 +33,8 @@ from kallithea.lib.utils import BasePasterCommand, repo2db_mapper # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/paster_commands/setup_db.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/setup_db.py Mon Jun 13 21:39:47 2016 +0200 @@ -26,8 +26,8 @@ from paste.deploy import appconfig # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/paster_commands/update_repoinfo.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/paster_commands/update_repoinfo.py Mon Jun 13 21:39:47 2016 +0200 @@ -36,8 +36,8 @@ from kallithea.model.meta import Session # Add location of top level folder to sys.path -from os.path import dirname as dn -rc_path = dn(dn(dn(os.path.realpath(__file__)))) +from os.path import dirname +rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) sys.path.append(rc_path)
--- a/kallithea/lib/utils.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/lib/utils.py Mon Jun 13 21:39:47 2016 +0200 @@ -37,7 +37,7 @@ import decorator import warnings from os.path import abspath -from os.path import dirname as dn +from os.path import dirname from paste.script.command import Command, BadCommand @@ -653,7 +653,7 @@ os.makedirs(index_location) try: - l = DaemonLock(file_=os.path.join(dn(index_location), 'make_index.lock')) + l = DaemonLock(file_=os.path.join(dirname(index_location), 'make_index.lock')) WhooshIndexingDaemon(index_location=index_location, repo_location=repo_location) \ .run(full_index=full_index) @@ -705,12 +705,12 @@ shutil.rmtree(data_path) #CREATE DEFAULT TEST REPOS - cur_dir = dn(dn(abspath(__file__))) + cur_dir = dirname(dirname(abspath(__file__))) tar = tarfile.open(os.path.join(cur_dir, 'tests', 'fixtures', "vcs_test_hg.tar.gz")) tar.extractall(os.path.join(TESTS_TMP_PATH, HG_REPO)) tar.close() - cur_dir = dn(dn(abspath(__file__))) + cur_dir = dirname(dirname(abspath(__file__))) tar = tarfile.open(os.path.join(cur_dir, 'tests', 'fixtures', "vcs_test_git.tar.gz")) tar.extractall(os.path.join(TESTS_TMP_PATH, GIT_REPO)) tar.close()
--- a/kallithea/tests/fixture.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/tests/fixture.py Mon Jun 13 21:39:47 2016 +0200 @@ -27,9 +27,9 @@ from kallithea.model.gist import GistModel from kallithea.model.scm import ScmModel from kallithea.lib.vcs.backends.base import EmptyChangeset +from os.path import dirname -dn = os.path.dirname -FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'tests', 'fixtures') +FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'tests', 'fixtures') def error_function(*args, **kwargs):
--- a/kallithea/tests/functional/test_admin.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/tests/functional/test_admin.py Mon Jun 13 21:39:47 2016 +0200 @@ -5,9 +5,9 @@ from kallithea.model.db import UserLog from kallithea.model.meta import Session from kallithea.lib.utils2 import safe_unicode +from os.path import dirname -dn = os.path.dirname -FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures') +FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures') class TestAdminController(TestController):
--- a/kallithea/tests/scripts/manual_test_concurrency.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/tests/scripts/manual_test_concurrency.py Mon Jun 13 21:39:47 2016 +0200 @@ -30,7 +30,7 @@ import sys import shutil import logging -from os.path import dirname as dn +from os.path import dirname from tempfile import _RandomNameSequence from subprocess import Popen, PIPE @@ -47,7 +47,7 @@ from kallithea.tests import HG_REPO from kallithea.config.environment import load_environment -rel_path = dn(dn(dn(dn(os.path.abspath(__file__))))) +rel_path = dirname(dirname(dirname(dirname(os.path.abspath(__file__))))) conf = appconfig('config:development.ini', relative_to=rel_path) load_environment(conf.global_conf, conf.local_conf)
--- a/kallithea/tests/scripts/manual_test_crawler.py Sun Jun 12 21:21:43 2016 +0200 +++ b/kallithea/tests/scripts/manual_test_crawler.py Mon Jun 13 21:39:47 2016 +0200 @@ -38,10 +38,10 @@ import os import sys import tempfile -from os.path import dirname as dn +from os.path import dirname __here__ = os.path.abspath(__file__) -__root__ = dn(dn(dn(__here__))) +__root__ = dirname(dirname(dirname(__here__))) sys.path.append(__root__) from kallithea.lib import vcs