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