From 760bfd2ab2e76016e4ddfeec725d87138966ded1 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Tue, 13 Feb 2024 14:55:06 -0300 Subject: [PATCH 1/6] build package pypi workflow --- .github/workflows/build.yaml | 57 ++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 47e5958..6290837 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,39 +1,34 @@ -name: PyCaseStyle Package Build +name: Publish Python 🐍 distributions 📦 to PyPI on: push: - branches: - - main - pull_request: - branches: - - main + tags: + - '*' jobs: - build: - runs-on: ubuntu-latest + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-18.04 steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - uses: actions/checkout@master + - name: Set up Python 3.10 + uses: actions/setup-python@v3 with: - python-version: 3.8 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Test with pytest - run: | - pytest - - - name: Build and Publish to PyPI - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | + python-version: '3.10' + - name: Install pypa/setuptools + run: >- + python -m + pip install wheel + - name: Extract tag name + id: tag + run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3) + - name: Update version in setup.py + run: >- + sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py + - name: Build a binary wheel + run: >- python setup.py sdist bdist_wheel - pip install twine - twine upload dist/* \ No newline at end of file + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file From 3484d6f584af827e15c1ba7357f0c0a86b8cda0a Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Tue, 13 Feb 2024 14:55:15 -0300 Subject: [PATCH 2/6] dynamic version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6809a78..0905662 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='pycasestyle', - version='0.0.1', + version='{{VERSION_PLACEHOLDER}}', keywords=['pycasestyle', 'camelcase', 'snakecase', 'pascal case', 'kebab case', 'dict key case', 'string case'], description='A simple python lib to convert string and dict keys to camelcase, pascal case, kebab case and snake case.', long_description=readme, From 0f47a6c5553a2f5b5ce4121f9b7c0d65e40fb9d8 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Tue, 13 Feb 2024 15:02:32 -0300 Subject: [PATCH 3/6] fixed workflow github ubuntu version bug --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6290837..63e2090 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,7 +8,8 @@ on: jobs: build-n-publish: name: Build and publish Python 🐍 distributions 📦 to PyPI - runs-on: ubuntu-18.04 + runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} + steps: - uses: actions/checkout@master - name: Set up Python 3.10 From 3032940ef4fa57a1038d37b26005dd8b39f81e3f Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Tue, 13 Feb 2024 15:05:24 -0300 Subject: [PATCH 4/6] setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 0905662..6d1dc28 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ keywords=['pycasestyle', 'camelcase', 'snakecase', 'pascal case', 'kebab case', 'dict key case', 'string case'], description='A simple python lib to convert string and dict keys to camelcase, pascal case, kebab case and snake case.', long_description=readme, + long_description_content_type="text/markdown", author='Pedro Rodrigues', author_email='pedrota.rodrigues@gmail.com', url='https://github.com/preduus/pycasestyle', From 9efa32e28f043d2138a47a787f114494559fb995 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Tue, 13 Feb 2024 15:10:52 -0300 Subject: [PATCH 5/6] fixed readme --- README.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.rst b/README.rst index 1d1cfc7..5bd3164 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,6 @@ Installation To install pycasestyle, you can use pip: .. code-block:: bash - pip install pycasestyle Usage @@ -24,7 +23,6 @@ Usage You can import the text formatting styles directly from the pycasestyle module and use them in your code. Here's an example of how to use the text formatting styles: .. code-block:: python - import pycasestyle # Converting to camelcase from text @@ -68,7 +66,6 @@ You need to migrate information from Postgres to Elasticsearch, however, the map .. code-block:: python - import pycasestyle postgres_contract = { From 344c028937da1ac0fe1e62e5be264e4134a68bc4 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Tue, 13 Feb 2024 15:14:44 -0300 Subject: [PATCH 6/6] implemented from_dict recursively until first level only --- pycasestyle/camelcase.py | 2 ++ pycasestyle/kebabcase.py | 2 ++ pycasestyle/pascalcase.py | 2 ++ pycasestyle/snakecase.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/pycasestyle/camelcase.py b/pycasestyle/camelcase.py index d1c9920..461cce3 100644 --- a/pycasestyle/camelcase.py +++ b/pycasestyle/camelcase.py @@ -39,5 +39,7 @@ def from_dict(self, __dict: dict) -> dict: camel_case_dict = {} for key, value in __dict.items(): camel_case_key = self.from_string(key) + if isinstance(value, dict): + value = self.from_dict(value) camel_case_dict[camel_case_key] = value return camel_case_dict diff --git a/pycasestyle/kebabcase.py b/pycasestyle/kebabcase.py index cd98248..867c2a9 100644 --- a/pycasestyle/kebabcase.py +++ b/pycasestyle/kebabcase.py @@ -38,5 +38,7 @@ def from_dict(self, __dict: dict) -> dict: kebab_case_dict = {} for key, value in __dict.items(): kebab_case_key = self.from_string(key) + if isinstance(value, dict): + value = self.from_dict(value) kebab_case_dict[kebab_case_key] = value return kebab_case_dict diff --git a/pycasestyle/pascalcase.py b/pycasestyle/pascalcase.py index 65e95a3..6b834b9 100644 --- a/pycasestyle/pascalcase.py +++ b/pycasestyle/pascalcase.py @@ -39,5 +39,7 @@ def from_dict(self, __dict: dict) -> dict: pascal_case_dict = {} for key, value in __dict.items(): pascal_case_key = self.from_string(key) + if isinstance(value, dict): + value = self.from_dict(value) pascal_case_dict[pascal_case_key] = value return pascal_case_dict diff --git a/pycasestyle/snakecase.py b/pycasestyle/snakecase.py index 701536f..c4b4492 100644 --- a/pycasestyle/snakecase.py +++ b/pycasestyle/snakecase.py @@ -38,5 +38,7 @@ def from_dict(self, __dict: dict) -> dict: snake_case_dict = {} for key, value in __dict.items(): snake_case_key = self.from_string(key) + if isinstance(value, dict): + value = self.from_dict(value) snake_case_dict[snake_case_key] = value return snake_case_dict