mirror of
https://github.com/docker/compose.git
synced 2025-04-08 17:05:13 +02:00
Closes: #6890 Some remarks, - `# coding ... utf-8` statements are not needed - isdigit on strings instead of a try-catch. - Default opening mode is read, so we can do `open()` without the `'r'` everywhere - Removed inheritinng from `object` class, it isn't necessary in python3. - `super(ClassName, self)` can now be replaced with `super()` - Use of itertools and `chain` on a couple places dealing with sets. - Used the operator module instead of lambdas when warranted `itemgetter(0)` instead of `lambda x: x[0]` `attrgetter('name')` instead of `lambda x: x.name` - `sorted` returns a list, so no need to use `list(sorted(...))` - Removed `dict()` using dictionary comprehensions whenever possible - Attempted to remove python3.2 support Signed-off-by: alexrecuenco <alejandrogonzalezrecuenco@gmail.com>
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
import os
|
|
import re
|
|
|
|
from const import REPO_ROOT
|
|
|
|
|
|
def update_init_py_version(version):
|
|
path = os.path.join(REPO_ROOT, 'compose', '__init__.py')
|
|
with open(path) as f:
|
|
contents = f.read()
|
|
contents = re.sub(r"__version__ = '[0-9a-z.-]+'", "__version__ = '{}'".format(version), contents)
|
|
with open(path, 'w') as f:
|
|
f.write(contents)
|
|
|
|
|
|
def update_run_sh_version(version):
|
|
path = os.path.join(REPO_ROOT, 'script', 'run', 'run.sh')
|
|
with open(path) as f:
|
|
contents = f.read()
|
|
contents = re.sub(r'VERSION="[0-9a-z.-]+"', 'VERSION="{}"'.format(version), contents)
|
|
with open(path, 'w') as f:
|
|
f.write(contents)
|
|
|
|
|
|
def yesno(prompt, default=None):
|
|
"""
|
|
Prompt the user for a yes or no.
|
|
|
|
Can optionally specify a default value, which will only be
|
|
used if they enter a blank line.
|
|
|
|
Unrecognised input (anything other than "y", "n", "yes",
|
|
"no" or "") will return None.
|
|
"""
|
|
answer = input(prompt).strip().lower()
|
|
|
|
if answer == "y" or answer == "yes":
|
|
return True
|
|
elif answer == "n" or answer == "no":
|
|
return False
|
|
elif answer == "":
|
|
return default
|
|
else:
|
|
return None
|