-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from kozalosev/release/2.3.0
Release/2.3.0
- Loading branch information
Showing
20 changed files
with
648 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
app/data | ||
venv* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Publish to GitHub Registry | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
jobs: | ||
Publish-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
|
||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
# output 0.1.2 | ||
type=semver,pattern={{version}} | ||
# output 0.1 | ||
type=semver,pattern={{major}}.{{minor}} | ||
# disabled if major zero | ||
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- run: echo "🍏 This job's status is ${{ job.status }}." | ||
|
||
Create-release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
generateReleaseNotes: true | ||
token: ${{ secrets.GH_KEY_2_RELEASE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Simplified variant of `.calc.Calculator` working with only one expression.""" | ||
|
||
import re | ||
|
||
from txtproc.abc import TextProcessor | ||
from . import currates | ||
from .calc import Calculator | ||
|
||
_subst_re = re.compile(r"^(?P<expr>[0-9+\-*/%^., ()]+?)? *?" | ||
r"((?P<from_curr>[A-Za-zа-я]{3,}|[$€₽£¥]) *?" | ||
r"(to|>|в)? *?" | ||
r"(?P<to_curr>[A-Za-zа-я]{3,}|[$€₽£¥])?)??$") | ||
|
||
|
||
class SingleExpressionCalculator(TextProcessor): | ||
_calc = Calculator() | ||
|
||
@classmethod | ||
def can_process(cls, query: str, lang_code: str = "") -> bool: | ||
if len(query) == 0: | ||
return False | ||
match = _subst_re.search(query) | ||
if not match: | ||
return False | ||
from_curr = match.group("from_curr") | ||
to_curr = match.group("to_curr") | ||
if from_curr is None: | ||
return True | ||
return currates.currency_exists(from_curr, lang_code) and \ | ||
(to_curr is None or currates.currency_exists(to_curr, lang_code)) | ||
|
||
def process(self, query: str, lang_code: str = "") -> str: | ||
expr = _subst_re.search(query).group("expr") | ||
if not expr: | ||
query = "1 " + query | ||
return self._calc.process("{{" + query + "}}", lang_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.