Skip to content

Commit

Permalink
Add backwards compatible dict.get() fallback value (singer-io#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
luandy64 authored and Judah Rand committed Oct 27, 2020
1 parent aea7b22 commit d209713
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions singer/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def reset_stream(state, tap_stream_id):
state['bookmarks'][tap_stream_id] = {}
return state

def get_bookmark(state, tap_stream_id, key):
return state.get('bookmarks', {}).get(tap_stream_id, {}).get(key)
def get_bookmark(state, tap_stream_id, key, default=None):
return state.get('bookmarks', {}).get(tap_stream_id, {}).get(key, default)

def set_offset(state, tap_stream_id, offset_key, offset_value):
state = ensure_bookmark_path(state, ['bookmarks', tap_stream_id, "offset", offset_key])
Expand All @@ -35,12 +35,12 @@ def clear_offset(state, tap_stream_id):
state['bookmarks'][tap_stream_id]["offset"] = {}
return state

def get_offset(state, tap_stream_id):
return state.get('bookmarks', {}).get(tap_stream_id, {}).get("offset")
def get_offset(state, tap_stream_id, default=None):
return state.get('bookmarks', {}).get(tap_stream_id, {}).get("offset", default)

def set_currently_syncing(state, tap_stream_id):
state['currently_syncing'] = tap_stream_id
return state

def get_currently_syncing(state):
return state.get('currently_syncing')
def get_currently_syncing(state, default=None):
return state.get('currently_syncing', default)

0 comments on commit d209713

Please sign in to comment.