forked from betwixt-labs/bebop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: betwixt-labs#56 Python support
- added Python generator - added Python runtime
- Loading branch information
1 parent
cf3ac79
commit 43d9bd1
Showing
28 changed files
with
2,886 additions
and
170 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ schema.ts | |
bebop.hpp | ||
*.enc | ||
Rust/src/schema.rs | ||
Python/src/schema.py | ||
target |
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,21 @@ | ||
from schema import Library | ||
from lib import make_lib | ||
import sys | ||
import json | ||
|
||
with open(sys.argv[1], "rb") as buffer_file: | ||
buffer = buffer_file.read() | ||
|
||
de = Library.decode(buffer) | ||
ex = make_lib() | ||
|
||
eq = json.loads(repr(de)) == json.loads(repr(ex)) | ||
|
||
if not eq: | ||
print("decoded:") | ||
print(repr(de)) | ||
print() | ||
print("expected:") | ||
print(repr(ex)) | ||
|
||
sys.exit(0 if eq else 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,6 @@ | ||
from lib import make_lib | ||
from schema import Library | ||
import sys | ||
|
||
with open("py.enc", "wb+") as enc_file: | ||
enc_file.write(bytearray(Library.encode(make_lib()))) |
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,48 @@ | ||
from schema import Library, Instrument, Album, StudioAlbum, LiveAlbum, Song, Musician | ||
from datetime import datetime | ||
|
||
def make_lib(): | ||
giant_steps_song = Song() | ||
giant_steps_song.title = "Giant Steps" | ||
giant_steps_song.year = 1959 | ||
giant_steps_song.performers = [ | ||
Musician(name="John Coltrane", plays=Instrument.PIANO) | ||
] | ||
|
||
a_night_in_tunisia_song = Song() | ||
a_night_in_tunisia_song.title = "A Night in Tunisia" | ||
a_night_in_tunisia_song.year = 1942 | ||
a_night_in_tunisia_song.performers = [ | ||
Musician(name="Dizzy Gillespie", plays=Instrument.TRUMPET), | ||
Musician(name="Count Basie", plays=Instrument.PIANO), | ||
] | ||
|
||
groovin_high_song = Song() | ||
groovin_high_song.title = "Groovin' High" | ||
|
||
adams_apple_album = LiveAlbum() | ||
adams_apple_album.venueName = "Tunisia" | ||
adams_apple_album.concertDate = datetime.fromtimestamp(528205479) | ||
|
||
unnamed_song = Song() | ||
unnamed_song.year = 1965 | ||
unnamed_song.performers = [ | ||
Musician(name="Carmell Jones", plays=Instrument.TRUMPET), | ||
Musician(name="Joe Henderson", plays=Instrument.SAX), | ||
Musician(name="Teddy Smith", plays=Instrument.CLARINET) | ||
] | ||
|
||
brilliant_corners_album = LiveAlbum() | ||
brilliant_corners_album.venueName = "Night's Palace" | ||
brilliant_corners_album.tracks = [ | ||
unnamed_song | ||
] | ||
|
||
return Library(albums={ | ||
"Giant Steps": Album.fromStudioAlbum(StudioAlbum(tracks=[ | ||
giant_steps_song, a_night_in_tunisia_song, groovin_high_song | ||
])), | ||
"Adam's Apple": Album.fromLiveAlbum(adams_apple_album), | ||
"Milestones": Album.fromStudioAlbum(StudioAlbum(tracks=[])), | ||
"Brilliant Corners": Album.fromLiveAlbum(brilliant_corners_album) | ||
}) |
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.