generated from bomzheg/aiogram_template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature/#106
- Loading branch information
Showing
52 changed files
with
1,686 additions
and
145 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
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 |
---|---|---|
|
@@ -63,6 +63,7 @@ jobs: | |
run: source .venv/bin/activate && pytest --cov-report "xml:coverage.xml" --cov=shvatka tests/ | ||
- name: Coverage comment | ||
id: coverageComment | ||
continue-on-error: true | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-xml-coverage-path: ./coverage.xml | ||
|
@@ -74,20 +75,16 @@ jobs: | |
hide-comment: false | ||
report-only-changed-files: false | ||
remove-link-from-badge: false | ||
coverage-badge: | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: Create the Badge | ||
uses: schneegans/[email protected] | ||
continue-on-error: true | ||
with: | ||
auth: ${{ secrets.BAGE_GIST }} // don't passed from direct push | ||
auth: ${{ secrets.BAGE_GIST }} | ||
gistID: 99469cb5f8a18784c1f03d229a799427 | ||
filename: bage.json | ||
label: Coverage Report | ||
message: ${{ steps.coverageComment.outputs.coverage }} // can't access from another job | ||
color: ${{ steps.coverageComment.outputs.color }} // can't access from another job | ||
message: ${{ steps.coverageComment.outputs.coverage }} | ||
color: ${{ steps.coverageComment.outputs.color }} | ||
namedLogo: python | ||
docs: | ||
needs: [build] | ||
|
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,6 @@ | ||
from base64 import b64encode | ||
from typing import Any | ||
|
||
|
||
def obfuscate_sensitive(information: Any) -> str: | ||
return b64encode(str(information).encode("utf8")).decode("utf8") |
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
Empty file.
Empty file.
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,79 @@ | ||
from shvatka.core.migration_utils import models_0 | ||
from shvatka.core.models.dto import scn, action | ||
|
||
|
||
def bonus_key_0_to_1(bonus_key: models_0.BonusKey) -> action.BonusKey: | ||
return action.BonusKey(text=bonus_key.text, bonus_minutes=bonus_key.bonus_minutes) | ||
|
||
|
||
def hint_0_to_1(hint: models_0.AnyHint) -> scn.AnyHint: | ||
match hint: | ||
case models_0.TextHint(text=text): | ||
return scn.TextHint(text=text) | ||
case models_0.GPSHint(latitude=latitude, longitude=longitude): | ||
return scn.GPSHint(latitude=latitude, longitude=longitude) | ||
case models_0.VenueHint as vh: | ||
return scn.VenueHint( | ||
latitude=vh.latitude, | ||
longitude=vh.longitude, | ||
title=vh.title, | ||
address=vh.address, | ||
foursquare_id=vh.foursquare_id, | ||
foursquare_type=vh.foursquare_type, | ||
) | ||
case models_0.PhotoHint(file_guid=file_guid, caption=caption): | ||
return scn.PhotoHint(file_guid=file_guid, caption=caption) | ||
case models_0.AudioHint(file_guid=file_guid, caption=caption, thumb_guid=thumb_guid): | ||
return scn.AudioHint(file_guid=file_guid, thumb_guid=thumb_guid, caption=caption) | ||
case models_0.VideoHint(file_guid=file_guid, caption=caption, thumb_guid=thumb_guid): | ||
return scn.VideoHint(file_guid=file_guid, thumb_guid=thumb_guid, caption=caption) | ||
case models_0.DocumentHint(file_guid=file_guid, caption=caption, thumb_guid=thumb_guid): | ||
return scn.DocumentHint(file_guid=file_guid, caption=caption, thumb_guid=thumb_guid) | ||
case models_0.AnimationHint(file_guid=file_guid, caption=caption, thumb_guid=thumb_guid): | ||
return scn.AnimationHint(file_guid=file_guid, caption=caption, thumb_guid=thumb_guid) | ||
case models_0.VoiceHint(file_guid=file_guid, caption=caption): | ||
return scn.VoiceHint(file_guid=file_guid, caption=caption) | ||
case models_0.VideoNoteHint(file_guid=guid): | ||
return scn.VideoNoteHint(file_guid=guid) | ||
case models_0.ContactHint as ch: | ||
return scn.ContactHint( | ||
phone_number=ch.phone_number, | ||
first_name=ch.first_name, | ||
last_name=ch.last_name, | ||
vcard=ch.vcard, | ||
) | ||
case models_0.StickerHint(file_guid=guid): | ||
return scn.StickerHint(file_guid=guid) | ||
case _: | ||
raise RuntimeError("unknown hint type") | ||
|
||
|
||
def time_hint_0_to_1(time_hint: models_0.TimeHint) -> scn.TimeHint: | ||
return scn.TimeHint( | ||
time=time_hint.time, | ||
hint=[hint_0_to_1(hint) for hint in time_hint.hint], | ||
) | ||
|
||
|
||
def hints_0_to_1(hints: models_0.HintsList) -> scn.HintsList: | ||
return scn.HintsList([time_hint_0_to_1(hint) for hint in hints]) | ||
|
||
|
||
def level_0_to_1(level: models_0.LevelScenario) -> scn.LevelScenario: | ||
conditions: list[action.AnyCondition] = [action.KeyWinCondition(set(level.keys))] | ||
if level.bonus_keys: | ||
conditions.append( | ||
action.KeyBonusCondition({bonus_key_0_to_1(b) for b in level.bonus_keys}) | ||
) | ||
return scn.LevelScenario( | ||
id=level.id, | ||
time_hints=hints_0_to_1(level.time_hints), | ||
conditions=scn.Conditions(conditions), | ||
__model_version__=1, | ||
) | ||
|
||
|
||
def game_0_to_1(game: models_0.GameScenario) -> scn.GameScenario: | ||
return scn.GameScenario( | ||
name=game.name, levels=[level_0_to_1(lvl) for lvl in game.levels], __model_version__=1 | ||
) |
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,39 @@ | ||
from .file_content import ( | ||
FileMeta, | ||
FileContentLink, | ||
TgLink, | ||
ParsedTgLink, | ||
SavedFileMeta, | ||
StoredFileMeta, | ||
FileMetaLightweight, | ||
UploadedFileMeta, | ||
VerifiableFileMeta, | ||
) | ||
from .game import ( | ||
GameScenario, | ||
FullGameScenario, | ||
ParsedGameScenario, | ||
ParsedCompletedGameScenario, | ||
RawGameScenario, | ||
UploadedGameScenario, | ||
) | ||
from .hint_part import ( | ||
AnyHint, | ||
BaseHint, | ||
FileMixin, | ||
TextHint, | ||
GPSHint, | ||
VenueHint, | ||
AudioHint, | ||
VideoHint, | ||
DocumentHint, | ||
AnimationHint, | ||
VoiceHint, | ||
VideoNoteHint, | ||
StickerHint, | ||
PhotoHint, | ||
ContactHint, | ||
) | ||
from .level import LevelScenario, SHKey, BonusKey, HintsList | ||
from .parsed_zip import ParsedZip | ||
from .time_hint import TimeHint |
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,71 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
|
||
from shvatka.core.models import dto | ||
from shvatka.core.models.enums.hint_type import HintType | ||
|
||
|
||
@dataclass | ||
class TgLink: | ||
file_id: str | ||
"""telegram file_id""" | ||
content_type: HintType | ||
"""type of content""" | ||
|
||
|
||
@dataclass | ||
class FileContentLink: | ||
file_path: str | ||
"""path to file in file system""" | ||
|
||
|
||
@dataclass | ||
class FileMetaLightweight: | ||
guid: str | ||
"""GUID for filename in file storage, DB and in archive""" | ||
original_filename: str | ||
"""Filename from user before renamed to guid""" | ||
extension: str | ||
"""extension with leading dot: ".zip" ".tar.gz" etc""" | ||
content_type: HintType | None = field(kw_only=True, default=None) | ||
"""type of content""" | ||
|
||
@property | ||
def local_file_name(self): | ||
return self.guid + (self.extension or "") | ||
|
||
@property | ||
def public_filename(self): | ||
return self.original_filename + (self.extension or "") | ||
|
||
|
||
@dataclass | ||
class StoredFileMeta(FileMetaLightweight): | ||
file_content_link: FileContentLink | ||
|
||
|
||
@dataclass | ||
class UploadedFileMeta(FileMetaLightweight): | ||
tg_link: TgLink | None = None | ||
|
||
|
||
@dataclass | ||
class FileMeta(StoredFileMeta): | ||
tg_link: TgLink | ||
|
||
|
||
@dataclass | ||
class VerifiableFileMeta(FileMeta): | ||
author_id: int | ||
|
||
|
||
@dataclass | ||
class SavedFileMeta(VerifiableFileMeta): | ||
id: int | ||
author: dto.Player | ||
|
||
|
||
@dataclass | ||
class ParsedTgLink(TgLink): | ||
filename: str | None = None |
Oops, something went wrong.
6840829
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see coverage