Skip to content

Commit

Permalink
Update release_autoversioning.py
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Hunter <ianfhunter@gmail.com>
  • Loading branch information
ianfhunter authored May 9, 2024
1 parent 438b45a commit 95ed543
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions scripts/release_autoversioning.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@

import configparser

def update_version_in_files(gnoll_ini_path, setup_cfg_path, project_toml_path):
# Read version from GNOLL.ini
config = configparser.ConfigParser()
config.read(gnoll_ini_path)
version = config['Meta Information']['version']

# Update version in setup.cfg
with open(setup_cfg_path, 'r') as f:
def update_version(path, find, replace):
with open(path, 'r') as f:
# Get every line
lines = f.readlines()

with open(setup_cfg_path, 'w') as f:
with open(path, 'w', encoding='utf_8') as f:
for line in lines:
if line.startswith('version ='):
f.write(f'version = {version}\n')
if find in line:
f.write(replace)
else:
f.write(line)

# Update version in Project.toml
with open(project_toml_path, 'r') as f:
lines = f.readlines()

with open(project_toml_path, 'w', encoding='utf_8') as f:
for line in lines:
if line.startswith('version ='):
f.write(f'version = "{version}"\n')
else:
f.write(line)
def update_version_in_files(gnoll_ini_path, setup_cfg_path, project_toml_path):
# Read version from GNOLL.ini
config = configparser.ConfigParser()
config.read(gnoll_ini_path)
version = config['Meta Information']['version']

update_version(setup_cfg_path, 'version =', f'version = "{version}"\n')

Check notice on line 22 in scripts/release_autoversioning.py

View check run for this annotation

codefactor.io / CodeFactor

scripts/release_autoversioning.py#L22

multiple spaces after ',' (E241)
update_version(project_toml_path, 'version =', f'version = "{version}"\n')

Check notice on line 23 in scripts/release_autoversioning.py

View check run for this annotation

codefactor.io / CodeFactor

scripts/release_autoversioning.py#L23

multiple spaces after ',' (E241)
update_version("src/grammar/dice.yacc", 'printf("GNOLL', f'printf("GNOLL {version}")\n')


gnoll_ini_path = 'GNOLL.ini'
setup_cfg_path = 'src/python/setup.cfg'
project_toml_path = 'GNOLL/src/julia/GNOLL/Project.toml'
Expand Down

0 comments on commit 95ed543

Please sign in to comment.