Skip to content

Commit

Permalink
removed deprecated metadata calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Caha committed Dec 9, 2023
1 parent fa64ffb commit fe907a3
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions dbsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,7 @@ def _print_mergin_changes(
cached_mergin_project_objects = {}


def _get_mergin_project(
work_path,
):
def _get_mergin_project(work_path) -> MerginProject:
"""
Returns a cached MerginProject object or creates one if it does not exist yet.
This is to avoid creating many of these objects (e.g. every pull/push) because it does
Expand All @@ -542,20 +540,16 @@ def _get_mergin_project(
return cached_mergin_project_objects[work_path]


def _get_project_version(
work_path,
):
def _get_project_version(work_path) -> str:
"""Returns the current version of the project"""
mp = _get_mergin_project(work_path)
return mp.metadata["version"]
return mp.version()


def _get_project_id(
mp,
):
def _get_project_id(mp: MerginProject):
"""Returns the project ID"""
try:
project_id = uuid.UUID(mp.metadata["project_id"])
project_id = uuid.UUID(mp.project_id())
except (
KeyError,
ValueError,
Expand Down Expand Up @@ -637,10 +631,9 @@ def _validate_local_project_id(
local_project_id = _get_project_id(mp)
if local_project_id is None:
return
project_path = mp.metadata["name"]
if server_info is None:
try:
server_info = mc.project_info(project_path)
server_info = mc.project_info(mp.project_full_name())
except ClientError as e:
raise DbSyncError("Mergin Maps client error: " + str(e))

Expand Down Expand Up @@ -719,7 +712,7 @@ def revert_local_changes(
mp.dir,
update_delete_file,
update_delete_filepath,
mp.metadata["version"],
mp.version(),
)
except ClientError as e:
raise DbSyncError("Mergin Maps client error: " + str(e))
Expand Down

0 comments on commit fe907a3

Please sign in to comment.