Skip to content

Commit

Permalink
Merge pull request #20 from sebastienrousseau/feat/pain001
Browse files Browse the repository at this point in the history
fix(pain001): publishes a python package to github
  • Loading branch information
sebastienrousseau authored Mar 19, 2023
2 parents bccb61e + 4cafc40 commit 57b815b
Show file tree
Hide file tree
Showing 28 changed files with 2,231 additions and 347 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:

jobs:

# This job reads the version number from setup.cfg and sets it as an environment variable
# This job reads the version number from setup.cfg and sets it as an
# environment variable
version:
runs-on: ubuntu-latest
outputs:
Expand All @@ -33,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Check out the repository code
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Set up Python and install dependencies
- name: ❯ Set up Python and install dependencies 🐍📦
Expand All @@ -57,7 +58,26 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

# This job builds the distribution packages, and publishes them to PyPI
# This job runs flake8 to check for code style issues
lint:
needs: version
runs-on: ubuntu-latest
steps:
# Check out the repository code
- uses: actions/checkout@v3
# Set up Python and install dependencies
- name: ❯ Set up Python and install dependencies 🐍📦
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: ❯ Install flake8 📦
run: python -m pip install flake8
# Run flake8
- name: ❯ Run flake8 🔍
run: flake8

# This job builds the distribution packages, and publishes them
# to PyPI
build:
needs: [version, pytest]
runs-on: ubuntu-latest
Expand All @@ -68,7 +88,7 @@ jobs:
PKG_NAME: pain001
steps:
# Check out the repository code
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: ❯ Set up Python 🐍
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
id: python
Expand Down Expand Up @@ -146,7 +166,7 @@ jobs:
tag_name: v${{ env.VERSION }}
release_name: Release v${{ env.VERSION }}
body_path: ${{ github.workspace }}/CHANGELOG.md
draft: true
draft: false
prerelease: false

- name: Upload Release Assets 📦
Expand All @@ -161,5 +181,4 @@ jobs:
-H "Content-Type: $(file --mime-type -b $file)" \
--data-binary @$file \
"${upload_url}?name=$(basename $file)"
done
done
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"cSpell.words": [
"bdist",
"configparser",
"cstmr",
"dateutil",
"DEUTDEDBFRA",
"github",
"GITHUB",
"lxml",
"pypa",
"PYPI",
"pytest",
Expand Down
42 changes: 28 additions & 14 deletions TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,34 @@

## Overview 📖

Pain001 is a powerful library that allows you to generate a Customer-to
-Bank Credit Transfer payload in the pain.001.001.03 format from a CSV
file. With Pain001, you can easily create professional-looking payment
data in just a few simple steps.
The pain001 Python package is a CLI tool that makes it easy to automate
the creation of ISO 20022 compliant payment files (XML PAIN.001.03)
directly from a CSV file. With pain001, you can easily create payment
transactions files in just a few simple steps.

## Features ✨

- Pain001 is a command-line interface (CLI) that when called, generates
a Customer-to-Bank Credit Transfer payload in a pain.001.001.03 format
from a CSV file.
- Pain001 uses an XML template file and maps CSV column names to XML
element tags to generate the XML file.
- The CSV file must contain the payment data in the required format, and
the XML template file must exist. Otherwise, the function will raise a
FileNotFoundError.
- Pain001 includes several features, including batch booking, generation
of an end-to-end payment ID, and support for multiple currencies.
- **Simplified file creation:** The library generates payment files in
the PAIN.001.001.03 format quickly and efficiently.
- **Ensuring the Highest Quality and Compliance:** The library
guarantees that all created payment files follow ISO 20022 standards.
- **Enhanced efficiency:** The Pain001 library automates the creation of
PAIN.001.001.03 files, freeing developers to focus on other aspects of
their projects.
- **Improved accuracy:** By providing precise data, the library reduces
errors in payment file creation.
- **Seamless integration:** As a Python package, the pain001 library is
compatible with various Python-based applications and easily
integrates into any existing projects.
- **Cross-border compatibility:** The library supports both Single Euro
Payments Area (SEPA) and non-SEPA credit transfers, making it
versatile for use in different countries and regions.
- **Time-saving:** The automated file creation process reduces the time
spent on manual data entry and file generation, increasing overall
productivity.
- **Scalable solution:** The Pain001 library can handle varying volumes
of payment files, making it suitable for businesses of different sizes
and transaction volumes.
- **Customisable:** The library allows developers to customise the
output, making it adaptable to specific business requirements and
preferences.
7 changes: 4 additions & 3 deletions pain001/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""The Python pain001 module."""
__all__ = ['pain001']
__version__ = '0.0.8'
__all__ = ["pain001"]
__version__ = "0.0.9"
49 changes: 33 additions & 16 deletions pain001/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=invalid-name
"""Enables use of Python Pain001 as a "main" function (i.e. "python -m pain001").
"""
Enables use of Python Pain001 as a "main" function (i.e.
"python3 -m pain001 <xml_file_path> <xsd_file_path> <csv_file_path>").
This allows using Pain001 with third-party libraries without modifying their code.
This allows using Pain001 with third-party libraries without modifying
their code.
"""

from . import core
Expand All @@ -26,7 +30,8 @@

cli_string = """
usage: python3 -m pain001 <xml_file_path> <xsd_file_path> <csv_file_path>
usage:
python3 -m pain001 <xml_file_path> <xsd_file_path> <csv_file_path>
Python Pain001 is a Python package that generates a Customer-to-Bank
Credit Transfer payload in the pain.001.001.03 format from a CSV file.
Expand All @@ -40,34 +45,46 @@
python3 -m pain001 <xml_file_path> <xsd_file_path> <csv_file_path>
The first argument is the path of the XML template file. The second
argument is the path of the XSD template file. The third argument is the
path of the CSV file containing the payment data."""
argument is the path of the XSD template file. The third argument is
the path of the CSV file containing the payment data."""


def main():
"""Entrypoint for pain001 when invoked as a module with python -m pain001."""
"""
Entrypoint for pain001 when invoked as a module with
python3 -m pain001 <xml_file_path> <xsd_file_path> <csv_file_path>.
"""

parser = argparse.ArgumentParser(
description='Generate Pain.001 file from CSV data')
parser.add_argument('xml_file_path', help='Path to XML template file')
parser.add_argument('xsd_file_path', help='Path to XSD template file')
parser.add_argument('csv_file_path', help='Path to CSV data file')
description="Generate Pain.001 file from CSV data"
)
parser.add_argument(
"xml_file_path", help="Path to XML template file"
)
parser.add_argument(
"xsd_file_path", help="Path to XSD template file"
)
parser.add_argument(
"csv_file_path", help="Path to CSV data file"
)
args = parser.parse_args()

if not os.path.isfile(args.xml_file_path):
print('The XML template file does not exist.')
print("The XML template file does not exist.")
sys.exit(1)

if not os.path.isfile(args.xsd_file_path):
print('The XSD template file does not exist.')
print("The XSD template file does not exist.")
sys.exit(1)

if not os.path.isfile(args.csv_file_path):
print('The CSV file does not exist.')
print("The CSV file does not exist.")
sys.exit(1)

core.main(args.xml_file_path, args.xsd_file_path, args.csv_file_path)
core.main(
args.xml_file_path, args.xsd_file_path, args.csv_file_path
)


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit 57b815b

Please sign in to comment.