-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
エンジンのマニフェストを追加 #387
Merged
Merged
エンジンのマニフェストを追加 #387
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,9 @@ | ||
{ | ||
"manifest_version": "0.12.0", | ||
"name": "dummy name", | ||
"icon": "", | ||
"default_sampling_rate": 24000, | ||
"terms_of_service": "", | ||
"update_infos": [], | ||
"dependency_licenses": [] | ||
} |
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,8 @@ | ||
[ | ||
{ | ||
"name": "dummy library", | ||
"version": "0.0.1", | ||
"license": "dummy license", | ||
"text": "dummy license text" | ||
} | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
dummy teams of service |
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,7 @@ | ||
[ | ||
{ | ||
"version": "0.0.1", | ||
"descriptions": "dummpy descriptions", | ||
"contributors": ["dummy contributor"] | ||
} | ||
] |
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,41 @@ | ||
from typing import List, Optional | ||
Hiroshiba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class UpdateInfo(BaseModel): | ||
""" | ||
エンジンのアップデート情報 | ||
""" | ||
|
||
version: str = Field(title="エンジンのバージョン名") | ||
descriptions: str = Field(title="アップデートの詳細についての説明") | ||
contributors: Optional[List[str]] = Field(title="貢献者名") | ||
|
||
|
||
class LicenseInfo(BaseModel): | ||
""" | ||
依存ライブラリのライセンス情報 | ||
""" | ||
|
||
name: str = Field(title="依存ライブラリ名") | ||
version: Optional[str] = Field(title="依存ライブラリのバージョン") | ||
license: Optional[str] = Field(title="依存ライブラリのライセンス名") | ||
text: str = Field(title="依存ライブラリのライセンス本文") | ||
|
||
|
||
class EngineManifest(BaseModel): | ||
""" | ||
エンジン自体に関する情報 | ||
""" | ||
|
||
manifest_version: str = Field(title="マニフェストのバージョン") | ||
name: str = Field(title="エンジン名") | ||
icon: str = Field(title="エンジンのアイコンをBASE64エンコードしたもの") | ||
default_sampling_rate: int = Field(title="デフォルトのサンプリング周波数") | ||
terms_of_service: str = Field(title="エンジンの利用規約") | ||
update_infos: List[UpdateInfo] = Field(title="エンジンのアップデート情報") | ||
dependency_licenses: List[LicenseInfo] = Field(title="依存関係のライセンス情報") | ||
|
||
class Config: | ||
validate_assignment = True |
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,34 @@ | ||
import json | ||
from base64 import b64encode | ||
from pathlib import Path | ||
|
||
from .EngineManifest import EngineManifest, LicenseInfo, UpdateInfo | ||
|
||
|
||
class EngineManifestLoader: | ||
def __init__(self, assets_dir: Path): | ||
self.assets_dir = assets_dir | ||
|
||
def load_manifest(self) -> EngineManifest: | ||
manifest = EngineManifest( | ||
**json.load((self.assets_dir / "base_info.json").open(encoding="utf-8")) | ||
) | ||
manifest.icon = b64encode((self.assets_dir / "icon.png").read_bytes()).decode( | ||
"utf-8" | ||
) | ||
manifest.terms_of_service = (self.assets_dir / "terms_of_service.md").read_text( | ||
encoding="utf-8" | ||
) | ||
manifest.update_infos = [ | ||
UpdateInfo(**update_info) | ||
for update_info in json.load( | ||
(self.assets_dir / "update_infos.json").open(encoding="utf-8") | ||
) | ||
] | ||
manifest.dependency_licenses = [ | ||
LicenseInfo(**license_info) | ||
for license_info in json.load( | ||
(self.assets_dir / "dependency_licenses.json").open(encoding="utf-8") | ||
) | ||
] | ||
return manifest |
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,7 @@ | ||
from .EngineManifest import EngineManifest | ||
from .EngineManifestLoader import EngineManifestLoader | ||
|
||
__all__ = [ | ||
"EngineManifest", | ||
"EngineManifestLoader", | ||
] |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
他のクラスはついてないので、短くするために
Engine
なくても良いかも?(あまり強い意見じゃないです)