1212from .common import UPLOAD_CHUNK_SIZE , InvalidProject , ClientError
1313from .utils import (
1414 generate_checksum ,
15- move_file ,
15+ is_versioned_file ,
1616 int_version ,
17- find ,
1817 do_sqlite_checkpoint ,
1918 unique_path_name ,
2019 conflicted_copy_file_name ,
@@ -138,8 +137,7 @@ def fpath_cache(self, file, version=None):
138137
139138 def project_full_name (self ) -> str :
140139 """Returns fully qualified project name: <workspace>/<name>"""
141- if self ._metadata is None :
142- self ._read_metadata ()
140+ self ._read_metadata ()
143141 if self .is_old_metadata :
144142 return self ._metadata ["name" ]
145143 else :
@@ -164,8 +162,7 @@ def project_id(self) -> str:
164162 only happen with projects downloaded with old client, before February 2023,
165163 see https://github.com/MerginMaps/mergin-py-client/pull/154
166164 """
167- if self ._metadata is None :
168- self ._read_metadata ()
165+ self ._read_metadata ()
169166
170167 # "id" or "project_id" may not exist in projects downloaded with old client version
171168 if self .is_old_metadata :
@@ -182,8 +179,7 @@ def workspace_id(self) -> int:
182179 """Returns ID of the workspace where the project belongs"""
183180 # unfortunately we currently do not have information about workspace ID
184181 # in project's metadata...
185- if self ._metadata is None :
186- self ._read_metadata ()
182+ self ._read_metadata ()
187183
188184 # "workspace_id" does not exist in projects downloaded with old client version
189185 if self .is_old_metadata :
@@ -195,14 +191,12 @@ def workspace_id(self) -> int:
195191
196192 def version (self ) -> str :
197193 """Returns project version (e.g. "v123")"""
198- if self ._metadata is None :
199- self ._read_metadata ()
194+ self ._read_metadata ()
200195 return self ._metadata ["version" ]
201196
202197 def files (self ) -> list :
203198 """Returns project's list of files (each file being a dictionary)"""
204- if self ._metadata is None :
205- self ._read_metadata ()
199+ self ._read_metadata ()
206200 return self ._metadata ["files" ]
207201
208202 @property
@@ -213,12 +207,13 @@ def metadata(self) -> dict:
213207 from warnings import warn
214208
215209 warn ("MerginProject.metadata getter should not be used anymore" , DeprecationWarning )
216- if self ._metadata is None :
217- self ._read_metadata ()
210+ self ._read_metadata ()
218211 return self ._metadata
219212
220- def _read_metadata (self ):
213+ def _read_metadata (self ) -> None :
221214 """Loads the project's metadata from JSON"""
215+ if self ._metadata is not None :
216+ return
222217 if not os .path .exists (self .fpath_meta ("mergin.json" )):
223218 raise InvalidProject ("Project metadata has not been created yet" )
224219 with open (self .fpath_meta ("mergin.json" ), "r" ) as file :
@@ -254,9 +249,7 @@ def is_versioned_file(self, file):
254249 :returns: if file is compatible with geodiff lib
255250 :rtype: bool
256251 """
257- diff_extensions = [".gpkg" , ".sqlite" ]
258- f_extension = os .path .splitext (file )[1 ]
259- return f_extension in diff_extensions
252+ return is_versioned_file (file )
260253
261254 def is_gpkg_open (self , path ):
262255 """
0 commit comments