-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4174d5
commit dd82ec7
Showing
2 changed files
with
24 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import simplejson as json | ||
import sys | ||
from singer import RecordMessage | ||
|
||
|
||
def format_message(message,ensure_ascii=True): | ||
return json.dumps(message.asdict(), use_decimal=True, ensure_ascii=ensure_ascii) | ||
|
||
|
||
def write_message(message, ensure_ascii=True): | ||
sys.stdout.write(format_message(message, ensure_ascii=ensure_ascii) + '\n') | ||
sys.stdout.flush() | ||
|
||
|
||
def write_record(stream_name, record, stream_alias=None, time_extracted=None, ensure_ascii=True): | ||
"""Write a single record for the given stream. | ||
""" | ||
write_message(RecordMessage(stream=(stream_alias or stream_name), | ||
record=record, | ||
time_extracted=time_extracted), ensure_ascii=ensure_ascii) |
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