@@ -7643,7 +7643,7 @@ def curveSimilarity(self) -> tuple[float|None, float|None]: # pylint: disable=no
76437643 try:
76447644 # we masked the -1 error values
76457645 np_etb_masked = numpy.ma.masked_equal(np_etb, -1)
7646- np_timeB_etb_masked = numpy.ma.masked_array(np_timeB, np_etb_masked.mask) # type:ignore[operator,unused-ignore] # ty:ignore[call-non-callable] # pylint:disable=no-member
7646+ np_timeB_etb_masked = numpy.ma.masked_array(np_timeB, np_etb_masked.mask) # type:ignore[operator,unused-ignore] # pylint:disable=no-member
76477647 # ignore the masked error values on computing the interpolation and fill (especially on the left) with -1 values
76487648 interp_np_etb = numpy.interp(np_timex,np_timeB_etb_masked.compressed(),np_etb_masked.compressed(),left=-1,right=-1) # pyright:ignore[reportUnknownArgumentType] # pylint:disable=no-member
76497649
@@ -7668,7 +7668,7 @@ def curveSimilarity(self) -> tuple[float|None, float|None]: # pylint: disable=no
76687668 try:
76697669 # we masked the -1 error values
76707670 np_btb_masked = numpy.ma.masked_equal(np_btb, -1)
7671- np_timeB_btb_masked = numpy.ma.masked_array(np_timeB, np_btb_masked.mask) # type:ignore[operator,unused-ignore] # ty:ignore[call-non-callable] # pylint:disable=no-member
7671+ np_timeB_btb_masked = numpy.ma.masked_array(np_timeB, np_btb_masked.mask) # type:ignore[operator,unused-ignore] pylint:disable=no-member
76727672 # ignore the masked error values on computing the interpolation and fill (especially on the left) with -1 values
76737673 interp_np_btb = numpy.interp(np_timex,np_timeB_btb_masked.compressed(),np_btb_masked.compressed(),left=-1,right=-1) # pyright:ignore[reportUnknownArgumentType] # pylint:disable=no-member
76747674
@@ -13350,12 +13350,7 @@ def automaticsave(self, interactive:bool = True) -> str|None:
1335013350 if res:
1335113351 #write
1335213352 pf = self.getProfile()
13353- sync_record_hash = plus.controller.updateSyncRecordHashAndSync()
13354- if sync_record_hash is not None:
13355- # we add the hash over the sync record to be able to detect offline changes
13356- hash_encoded = encodeLocal(sync_record_hash)
13357- if hash_encoded is not None:
13358- pf['plus_sync_record_hash'] = hash_encoded
13353+ # pf should not be modified before saving anymore this would break its hash
1335913354 self.plusAddPath(cast(dict[str, Any], pf), filename_path)
1336013355 serialize(filename_path, cast(dict[str, Any], pf))
1336113356 self.sendmessage(QApplication.translate('Message','Profile {0} saved in: {1}').format(filename,self.qmc.autosavepath))
@@ -17027,7 +17022,7 @@ def computedProfileInformation(self) -> 'ComputedProfileInformation':
1702717022
1702817023 #used by filesave()
1702917024 #wrap values in unicode(.) if and only if those are of type string
17030- def getProfile(self) -> 'ProfileData':
17025+ def getProfile(self, copy:bool = False ) -> 'ProfileData':
1703117026 try:
1703217027 profile = ProfileData()
1703317028 profile['recording_version'] = self.recording_version
@@ -17120,10 +17115,15 @@ def getProfile(self) -> 'ProfileData':
1712017115 profile['roastbatchnr'] = self.qmc.roastbatchnr
1712117116 profile['roastbatchprefix'] = encodeLocalStrict(self.qmc.roastbatchprefix)
1712217117 profile['roastbatchpos'] = self.qmc.roastbatchpos
17123- if self.qmc.roastUUID is None:
17118+ if copy:
17119+ # if the copy flag is set, we generate a new roastUUID
1712417120 import uuid
17125- self.qmc.roastUUID = uuid.uuid4().hex # generate UUID
17126- profile['roastUUID'] = self.qmc.roastUUID
17121+ profile['roastUUID'] = uuid.uuid4().hex # generate UUID
17122+ else:
17123+ if self.qmc.roastUUID is None:
17124+ import uuid
17125+ self.qmc.roastUUID = uuid.uuid4().hex # generate UUID
17126+ profile['roastUUID'] = self.qmc.roastUUID
1712717127 if self.qmc.scheduleID is not None:
1712817128 profile['scheduleID'] = self.qmc.scheduleID
1712917129 if self.qmc.scheduleDate is not None:
@@ -17304,6 +17304,14 @@ def getProfile(self) -> 'ProfileData':
1730417304 _, _, exc_tb = sys.exc_info()
1730517305 self.qmc.adderror((QApplication.translate('Error Message', 'Exception:') + ' getProfile(): {0}').format(str(ex)),getattr(exc_tb, 'tb_lineno', '?'))
1730617306
17307+ # set sync_record_hash if any
17308+ sync_record_hash = plus.controller.updateSyncRecordHashAndSync()
17309+ if sync_record_hash is not None:
17310+ # we add the hash over the sync record to be able to detect offline changes
17311+ srh = encodeLocal(sync_record_hash)
17312+ if srh is not None:
17313+ profile['plus_sync_record_hash'] = srh
17314+
1730717315 # add hash
1730817316 import hashlib
1730917317 import json
@@ -17353,20 +17361,9 @@ def fileSave(self, fname:str|None, copy:bool = False) -> bool:
1735317361 filename = self.ArtisanSaveFileDialog(msg=QApplication.translate('Message', 'Save Profile'), path=fname)
1735417362 if filename:
1735517363 #write
17356- pf = self.getProfile()
17364+ pf = self.getProfile(copy)
17365+ # pf should not be modified before saving anymore this would break its hash
1735717366 if pf:
17358- # if the copy flag is set, we generate a new roastUUID
17359- if copy:
17360- import uuid
17361- pf['roastUUID'] = uuid.uuid4().hex # generate UUID
17362-
17363- sync_record_hash = plus.controller.updateSyncRecordHashAndSync()
17364- if sync_record_hash is not None:
17365- # we add the hash over the sync record to be able to detect offline changes
17366- srh = encodeLocal(sync_record_hash)
17367- if srh is not None:
17368- pf['plus_sync_record_hash'] = srh
17369-
1737017367 # we save the file and set the filename
1737117368 self.plusAddPath(cast(dict[str,Any], pf), filename)
1737217369 serialize(filename, cast(dict[str,Any], pf))
0 commit comments