Skip to content

Commit 2e4000b

Browse files
committed
Moving PROJECT_ROOT into script_utils and using in all scripts/.
1 parent 4a299fe commit 2e4000b

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

scripts/generate_json_docs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from parinx.errors import MethodParsingException
2727
import six
2828

29+
from script_utils import PROJECT_ROOT
2930
from verify_included_modules import get_public_modules
3031

3132

@@ -601,7 +602,7 @@ def main():
601602
parser.add_argument('--tag', help='The version of the documentation.',
602603
default='master')
603604
parser.add_argument('--basepath', help='Path to the library.',
604-
default=os.path.join(os.path.dirname(__file__), '..'))
605+
default=PROJECT_ROOT)
605606
parser.add_argument('--show-toc', help='Prints partial table of contents',
606607
default=False)
607608
args = parser.parse_args()
@@ -635,18 +636,17 @@ def main():
635636
}
636637
}
637638

638-
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
639-
BASE_JSON_DOCS_DIR = os.path.join(BASE_DIR, 'docs', 'json')
639+
BASE_JSON_DOCS_DIR = os.path.join(PROJECT_ROOT, 'docs', 'json')
640640

641-
DOCS_BUILD_DIR = os.path.join(BASE_DIR, 'docs', '_build')
641+
DOCS_BUILD_DIR = os.path.join(PROJECT_ROOT, 'docs', '_build')
642642
JSON_DOCS_DIR = os.path.join(DOCS_BUILD_DIR, 'json', args.tag)
643643
LIB_DIR = os.path.abspath(args.basepath)
644644

645645
library_dir = os.path.join(LIB_DIR, 'google', 'cloud')
646646
public_mods = get_public_modules(library_dir,
647647
base_package='google.cloud')
648648

649-
generate_module_docs(public_mods, JSON_DOCS_DIR, BASE_DIR, toc)
649+
generate_module_docs(public_mods, JSON_DOCS_DIR, PROJECT_ROOT, toc)
650650
generate_doc_types_json(public_mods,
651651
os.path.join(JSON_DOCS_DIR, 'types.json'))
652652
package_files(JSON_DOCS_DIR, DOCS_BUILD_DIR, BASE_JSON_DOCS_DIR)

scripts/make_datastore_grpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import sys
2121
import tempfile
2222

23+
from script_utils import PROJECT_ROOT
2324

24-
ROOT_DIR = os.path.abspath(
25-
os.path.join(os.path.dirname(__file__), '..'))
26-
PROTOS_DIR = os.path.join(ROOT_DIR, 'googleapis-pb')
25+
26+
PROTOS_DIR = os.path.join(PROJECT_ROOT, 'googleapis-pb')
2727
PROTO_PATH = os.path.join(PROTOS_DIR, 'google', 'datastore',
2828
'v1', 'datastore.proto')
29-
GRPC_ONLY_FILE = os.path.join(ROOT_DIR, 'datastore',
29+
GRPC_ONLY_FILE = os.path.join(PROJECT_ROOT, 'datastore',
3030
'google', 'cloud', 'datastore',
3131
'_generated', 'datastore_grpc_pb2.py')
3232
GRPCIO_VIRTUALENV = os.getenv('GRPCIO_VIRTUALENV')

scripts/run_pylint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import sys
3131

3232
from script_utils import get_affected_files
33+
from script_utils import PROJECT_ROOT
3334

3435

3536
IGNORED_DIRECTORIES = [
@@ -44,7 +45,7 @@
4445
os.path.join('google', 'cloud', '__init__.py'),
4546
'setup.py',
4647
]
47-
SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__))
48+
SCRIPTS_DIR = os.path.join(PROJECT_ROOT, 'scripts')
4849
PRODUCTION_RC = os.path.join(SCRIPTS_DIR, 'pylintrc_default')
4950
TEST_RC = os.path.join(SCRIPTS_DIR, 'pylintrc_reduced')
5051
TEST_DISABLED_MESSAGES = [

scripts/run_unit_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
from script_utils import in_travis
3232
from script_utils import in_travis_pr
3333
from script_utils import local_diff_branch
34+
from script_utils import PROJECT_ROOT
3435
from script_utils import travis_branch
3536

3637

37-
PROJECT_ROOT = os.path.abspath(
38-
os.path.join(os.path.dirname(__file__), '..'))
3938
IGNORED_DIRECTORIES = (
4039
'appveyor',
4140
'docs',

scripts/script_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import subprocess
2121

2222

23+
PROJECT_ROOT = os.path.abspath(
24+
os.path.join(os.path.dirname(__file__), '..'))
2325
LOCAL_REMOTE_ENV = 'GOOGLE_CLOUD_TESTING_REMOTE'
2426
LOCAL_BRANCH_ENV = 'GOOGLE_CLOUD_TESTING_BRANCH'
2527
IN_TRAVIS_ENV = 'TRAVIS'

scripts/verify_included_modules.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
from sphinx.ext.intersphinx import fetch_inventory
2626

27+
from script_utils import PROJECT_ROOT
2728

28-
BASE_DIR = os.path.abspath(
29-
os.path.join(os.path.dirname(__file__), '..'))
30-
DOCS_DIR = os.path.join(BASE_DIR, 'docs')
29+
30+
DOCS_DIR = os.path.join(PROJECT_ROOT, 'docs')
3131
IGNORED_PREFIXES = ('test_', '_')
3232
IGNORED_MODULES = frozenset([
3333
'google.cloud.__init__',
@@ -153,7 +153,7 @@ def verify_modules(build_root='_build'):
153153

154154
public_mods = set()
155155
for package in PACKAGES:
156-
library_dir = os.path.join(BASE_DIR, package, 'google', 'cloud')
156+
library_dir = os.path.join(PROJECT_ROOT, package, 'google', 'cloud')
157157
package_mods = get_public_modules(library_dir,
158158
base_package='google.cloud')
159159
public_mods.update(package_mods)

0 commit comments

Comments
 (0)