Skip to content
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

Add backwards compatible dict.get() fallback value #95

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)