-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added a receive method to Communicator receive a Query * Added recipient.receive(self) to the send method of Query, to make the recipient receive the Query. Indeed, not forcing him to do so would require a completely different coding mechanism (using triggers, timeouts, etc, with the recipient periodically checking for any pending query) * Used the \_\_getattr\_\_ attribute to pass unknown methods to communicator. This way, a sender or recipient can handle queries in a transparent way (while in practice it passes them to its communicator, exactly as a person woul process a query through its brain) * Added recipient, owner attributes whenever needed, more to come; indeed the most important thing when handling question/answers is to know who speaks and to whom * changed a few method names * added arguments to the check_sender and check_recipient methods in Query so we can check the names against a list passed as an argument (useful to test if a Query is indeed addressed to you)
- Loading branch information
Showing
4 changed files
with
170 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,14 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
from responder import Responder | ||
from modes import ResponseMode | ||
from music_sheet_maker import MusicSheetMaker | ||
from communicator import Communicator | ||
#from modes import ResponseMode | ||
#song_responder = Responder() | ||
#song_responder.set_response_mode(ResponseMode.COMMAND_LINE) | ||
#song_responder.create_song_command_line() | ||
me = 'bot' | ||
|
||
song_responder = Responder() | ||
song_responder.set_response_mode(ResponseMode.COMMAND_LINE) | ||
song_responder.create_song_command_line() | ||
|
||
comm = Communicator(owner=me) | ||
|
||
maker = MusicSheetMaker() | ||
|
||
q = comm.formulate('song_creation') | ||
comm.store(q) | ||
q.send(recipient=maker) | ||
|
||
#maker.ask | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,10 +1,53 @@ | ||
from communicator import Communicator | ||
from parsers import SongParser | ||
from communicator import Communicator, CommunicatorError | ||
#from parsers import SongParser | ||
|
||
|
||
class MusicSheetMaker: | ||
|
||
def __init__(self): | ||
self.communicator = Communicator() | ||
self.parser = SongParser() | ||
self.song = None | ||
self.song = None #Song object | ||
self.name = 'music-sheet-maker' | ||
self.communicator = Communicator(owner=self.name) | ||
#self.parser = SongParser() | ||
#self.receive = self.communicator.receive | ||
|
||
def __getattr__(self, name): | ||
''' | ||
Default function to call in case no one else is found. | ||
''' | ||
return getattr(self.communicator, name) | ||
|
||
def create_song(self, client_listening=True, recipient=None): | ||
|
||
if not self.listening: | ||
raise CommunicatorError(self.name+' is not listening') | ||
|
||
self.communicator.create_song_messages(recipient=recipient) | ||
|
||
#self.set_parser(SongParser(self)) | ||
|
||
#os.chdir(self.get_directory_base()) | ||
|
||
#communicator.output_instructions() | ||
|
||
#communicator.ask_first_line() | ||
#fp = self.load_file(self.get_song_dir_in(), first_line) # loads file or asks for next line | ||
#song_lines = self.read_lines(first_line, fp) | ||
|
||
# Parse song | ||
# TODO: refactor song_lines, song_keys, parse_song to be in Song class | ||
#communicator.ask_input_mode(song_lines) | ||
#song_key = self.ask_song_key(self.get_parser().get_input_mode(), song_lines) | ||
#note_shift = communicator.ask_note_shift() | ||
#self.set_song(self.parse_song(song_lines, song_key, note_shift)) | ||
|
||
#self.calculate_error_ratio() | ||
|
||
# Song information | ||
#communicator.ask_song_title() | ||
#communicator.ask_song_headers(song_key) | ||
|
||
# Output | ||
#communicator.send_song(RenderMode.PNG) | ||
|
||
|
2d3743f
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.
I forgot to say:
2d3743f
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.
Sorry this commit is silly: I have looked again at the Music Cog and it opened my eyes.
Hopefully the changes were minimal so there is no need to undo the commit.