summaryrefslogtreecommitdiff
path: root/buildscripts/generate_compile_expansions_shared_cache.py
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2018-03-27 14:30:46 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2018-04-05 14:41:58 -0400
commitc50c68fef179d9306f1a3432f48985bf20555e38 (patch)
treea1c208329a090c54a8a1f02558b2be87b830a8ab /buildscripts/generate_compile_expansions_shared_cache.py
parenta5dacf7092f51055dd774a1911a48815bb9a1e0e (diff)
downloadmongo-c50c68fef179d9306f1a3432f48985bf20555e38.tar.gz
SERVER-23312 Python linting - Lint using pylint, pydocstyle & mypy
Diffstat (limited to 'buildscripts/generate_compile_expansions_shared_cache.py')
-rwxr-xr-xbuildscripts/generate_compile_expansions_shared_cache.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/buildscripts/generate_compile_expansions_shared_cache.py b/buildscripts/generate_compile_expansions_shared_cache.py
index 57115e30038..64528e0d1d8 100755
--- a/buildscripts/generate_compile_expansions_shared_cache.py
+++ b/buildscripts/generate_compile_expansions_shared_cache.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python
"""
-This script generates the compile expansions file used by Evergreen as part of the push/release
-process.
+Generate the compile expansions file used by Evergreen as part of the push/release process.
Invoke by specifying an output file.
$ python generate_compile_expansions.py --out compile_expansions.yml
"""
+from __future__ import print_function
+
import argparse
import json
import os
@@ -14,7 +15,7 @@ import re
import sys
import yaml
-version_json = "version.json"
+VERSION_JSON = "version.json"
def generate_expansions():
@@ -25,7 +26,7 @@ def generate_expansions():
"""
args = parse_args()
expansions = {}
- expansions.update(generate_version_expansions(args))
+ expansions.update(generate_version_expansions())
expansions.update(generate_scons_cache_expansions())
with open(args.out, "w") as out:
@@ -34,18 +35,19 @@ def generate_expansions():
def parse_args():
+ """Parse program arguments."""
parser = argparse.ArgumentParser()
parser.add_argument("--out", required=True)
return parser.parse_args()
-def generate_version_expansions(args):
+def generate_version_expansions():
"""Generate expansions from a version.json file if given, or $MONGO_VERSION."""
expansions = {}
- if os.path.exists(version_json):
- with open(version_json, "r") as f:
- data = f.read()
+ if os.path.exists(VERSION_JSON):
+ with open(VERSION_JSON, "r") as fh:
+ data = fh.read()
version_data = json.loads(data)
version_line = version_data['version']
version_parts = match_verstr(version_line)
@@ -84,8 +86,8 @@ def generate_scons_cache_expansions():
system_id_path = "/etc/mongodb-build-system-id"
if os.path.isfile(system_id_path):
- with open(system_id_path, "r") as f:
- system_uuid = f.readline().strip()
+ with open(system_id_path, "r") as fh:
+ system_uuid = fh.readline().strip()
# Set the scons shared cache setting
@@ -124,8 +126,7 @@ def generate_scons_cache_expansions():
def match_verstr(verstr):
- """
- This function matches a version string and captures the "extra" part.
+ """Match a version string and capture the "extra" part.
If the version is a release like "2.3.4" or "2.3.4-rc0", this will return
None. If the version is a pre-release like "2.3.4-325-githash" or