Skip to content

Commit

Permalink
Reformat with yapf3
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Oct 8, 2024
1 parent 74ab5d3 commit 39930d7
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions new_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

# Maintainer Inputs ###########################################################

print(
"""Hi there, this is an openPMD maintainer tool to update the source
print("""Hi there, this is an openPMD maintainer tool to update the source
code of openPMD-api to a new version.
For it to work, you need write access on the source directory and
you should be working in a clean git branch without ongoing
rebase/merge/conflict resolves and without unstaged changes."""
)
rebase/merge/conflict resolves and without unstaged changes.""")

# check source dir
# REPO_DIR = Path(__file__).parent.parent.parent.absolute()
Expand Down Expand Up @@ -63,27 +61,28 @@
break

OLD_VERSION_TAG = ""
with open(str(REPO_DIR.joinpath("include/openPMD/version.hpp")), encoding="utf-8") as f:
with open(str(REPO_DIR.joinpath("include/openPMD/version.hpp")),
encoding="utf-8") as f:
for line in f:
match = re.search(r'#define OPENPMDAPI_VERSION_LABEL "([^"]+)"', line)
if match:
OLD_VERSION_TAG = match.group(1)
break

OLD_VERSION_SUFFIX = f"(-{OLD_VERSION_TAG})?" if OLD_VERSION_TAG else ""
OLD_VERSION_STR = f"({re.escape(OLD_VERSION_STR_README)})|({re.escape(OLD_VERSION_STR_CMAKE)}{OLD_VERSION_SUFFIX})"
OLD_VERSION_STR = \
f"({re.escape(OLD_VERSION_STR_README)})" + \
f"|({re.escape(OLD_VERSION_STR_CMAKE)}{OLD_VERSION_SUFFIX})"

print(f"The old version is: {OLD_VERSION_STR}")
print()


REPLY = input("Is this information correct? Will now start updating! [y/N] ")
print()
if REPLY not in ["Y", "y", ""]:
print("You did not confirm with 'y', aborting.")
sys.exit(1)


# Ask for new #################################################################

print("""We will now run a few sed commands on your source directory.\n""")
Expand Down Expand Up @@ -116,8 +115,8 @@ def generic_replace(filename, previous, after):


for file in [
"docs/source/dev/linking.rst",
"README.md",
"docs/source/dev/linking.rst",
"README.md",
]:
generic_replace(file, previous=OLD_VERSION_STR, after=VERSION_STR)

Expand All @@ -136,15 +135,14 @@ def generic_replace(filename, previous, after):
if match:
PREVIOUS_PIP_VERSION = match.group(1)
break
generic_replace(
"setup.py", previous=PREVIOUS_PIP_VERSION, after=VERSION_STR_SUFFIX_WITH_DOT
)
generic_replace("setup.py",
previous=PREVIOUS_PIP_VERSION,
after=VERSION_STR_SUFFIX_WITH_DOT)
generic_replace(
".github/workflows/windows.yml",
previous=f"{PREVIOUS_PIP_VERSION}0?",
after=(
f"{VERSION_STR_SUFFIX_WITH_DOT}0" if SUFFIX else VERSION_STR_SUFFIX_WITH_DOT
),
after=(f"{VERSION_STR_SUFFIX_WITH_DOT}0"
if SUFFIX else VERSION_STR_SUFFIX_WITH_DOT),
)
generic_replace(
"docs/source/conf.py",
Expand Down Expand Up @@ -180,8 +178,6 @@ def replace(key, value):

# Epilogue ####################################################################

print(
"""Done. Please check your source, e.g. via
print("""Done. Please check your source, e.g. via
git diff
now and commit the changes if no errors occurred."""
)
now and commit the changes if no errors occurred.""")

0 comments on commit 39930d7

Please sign in to comment.