569 def register(self, since=(MINRUN,MINLBK), tag="", chan=-1, payload=None):
570 """
571 Registers the folder in the database.
572 - since: lower limit of IOV
573 - tag : The tag to write to
574 - chan : COOL channel to write, if negative - all COOL channels are written
575 Comment channel is always written
576
577 The interpretation of the 'since' inputs depends on their type:
578 - tuple(int,int) : run and lbk number
579 """
580
581 if self.__payload is None and payload is None:
582 jdata = {}
583 for drawerIdx,blob in self.__drawerBlob.items():
584 if chan<0 or drawerIdx==chan or drawerIdx==1000:
585 if blob is None or blob==0:
586 b64string = ''
587 else:
588 blob.seek(0)
589 b64string = str(base64.b64encode(blob.read()), 'ascii')
590 jdata[drawerIdx] = [b64string]
591 else:
592 if payload is not None:
593 self.__payload = payload
594 jdata = self.__payload
595
596 (sinceRun, sinceLumi) = since
597
598 if not self.__db or (self.__db and self.__db.endswith('.json')):
599
600 fullTag = tag
601 if self.__folderPath and not (tag.upper().startswith('TILE') or tag.upper().startswith('CALO')):
603 fileName = f"{fullTag}.{sinceRun}.{sinceLumi}.json"
604 if self.__db:
605 fileName = f'{self.__db[:-5]}.{fileName}'
606
607 with open(fileName, 'w') as the_file:
608 json.dump(jdata, the_file, separators=(',', ':'), sort_keys=True)
609
610
611 self.log().info( 'Writting tag "%s"', fullTag)
612 self.log().info( '... since : [%s,%s]' , sinceRun, sinceLumi)
613 if self.__payload is None:
614 self.log().info( '... with comment field: "%s"', self.getComment())
615 self.log().info( '... into file : %s' , fileName)
616
static std::string getFullTag(const std::string &folder, const std::string &tag)
Returns the full tag string, composed of camelized folder name and tag part.