Skip to content

Commit

Permalink
docs(devs): clean code and fix some docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsanima committed Feb 18, 2022
1 parent 4a10533 commit 27fcd3c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
54 changes: 28 additions & 26 deletions make_release.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
#!/usr/bin/python3

# Copyritht © 2022 Marcin Różewski MDSANIMA


"""
Help Developmend Release Workflow.
Python package release. Help devs workflow.
.. important::
This file is not a part of `mdsanima-dev` python pacage.
Run in `package.json` script.
This file is not a part of ``mdsanima-dev`` python package.
Embedded in the ``package.json`` script.
Bumping version in `package.json` file.
Bumping version in '__init__.py` file.
Autogenerate 'CHANGELOG.md` based on commits.
Committing `package.json`, `__init__py` and `CHANGELOG.md` with signed GPG keys.
Bumping version in ``package.json`` file.
Bumping version in ``__init__.py`` file.
Autogenerate ``CHANGELOG.md`` based on commits.
Committing ``package.json``, ``__init__py`` and ``CHANGELOG.md`` files.
Creating tagging release and signed commit with GPG keys.
Check version in `package.json` and then replece this version in `__init__.py`
file on `src` folder `mdsanima_dev` python package.
Check version in ``package.json`` then replece this version in ``__init__.py``
file on ``src`` folder ``mdsanima_dev`` python package.
:usage: ./make_release.py
:usage: ``./make_release.py``
"""


import os
import json
import pathlib


HERE = pathlib.Path(__file__).parent


def go_check():
"""
Load data from ``package.json``file.
``postbump`` executex after the version is bumped.
Loading data from ``package.json`` file.
Execute after the version is bumped by ``postbump`` options.
:return: new version to replece
:rtype: str
Expand All @@ -43,41 +46,40 @@ def go_check():
return new_version


def go_read_write(old_version, new_version):
def go_read_write(old_version: str, new_version: str):
"""
This function replecing old version with new version file ``__init__.py``
Replace old version with new version ``__init__.py`` file.
:param old_version: lines with old version
:param old_version: line number with old version
:type old_version: str
:param new_version: lines with new version
:param new_version: line number with new version
:type new_version: str
"""
path_to_file = HERE / "src/mdsanima_dev/__init__.py"
with open(path_to_file, 'r', encoding='utf-8') as r:
with open(path_to_file, "r", encoding="utf-8") as r:
replace_version = r.read().replace(old_version, new_version)
with open(path_to_file, 'w', encoding='utf-8') as w:
with open(path_to_file, "w", encoding="utf-8") as w:
w.write(replace_version)


def go_bump():
"""
Reading file ``__init__.py`` and splits lines. Searching matching lines
Reading file ``__init__.py`` and then split lines. Searching matching lines
and replacing this line with new version. Printing info in the console.
"""
path_to_file = HERE / "src/mdsanima_dev/__init__.py"
with open(path_to_file, 'r', encoding='utf-8') as r:
with open(path_to_file, "r", encoding="utf-8") as r:
lines = r.read().splitlines()
lines_len = len(lines)

for line in range(lines_len):
if str("__version__") in str(lines[line]):
print('[MDSANIMA-DEV] -> bumping __init__.py')
print('[MDSANIMA-DEV] => matching line', line + 1, lines[line])
print("[MDSANIMA-DEV] -> bumping __init__.py")
print("[MDSANIMA-DEV] => matching line", line + 1, lines[line])
new_version = go_check()
print('[MDSANIMA-DEV] => checking new version =>', new_version)
print("[MDSANIMA-DEV] => checking new version =>", new_version)
new_line_version = '__version__ = "' + new_version + '"'
go_read_write(str(lines[line]), str(new_line_version))
print('[MDSANIMA-DEV] => replace line', line + 1, new_line_version)
print("[MDSANIMA-DEV] => replace line", line + 1, new_line_version)


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions src/mdsanima_dev/utils/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def frames_to_time_code(frames: int, fps: float) -> str:
Function converts number of frames to time code ``00:00:00:00`` formats.
:param frames: number of total frames
:type frames: integer
:type frames: int
:param fps: frames per second
:type fps: integer or float
:type fps: int or float
:return: time code format
:rtype: string
:rtype: str
:usage:
assigning function calling to a variable
Expand Down

0 comments on commit 27fcd3c

Please sign in to comment.