def GetDataPackValue(self, lang, encoding): """Returns a str represenation for a data_pack entry.""" if self.ExpandVariables(): text = self.gatherer.GetText() data = util.Encode(self._Substitute(text), encoding) else: data = self.gatherer.GetData(lang, encoding) return self.CompressDataIfNeeded(data)
def GetDataPackPair(self, lang, encoding): '''Returns a (id, string) pair that represents the string id and the string in the specified encoding, where |encoding| is one of the encoding values accepted by util.Encode. This is used to generate the data pack data file. ''' from grit.format import rc_header id_map = rc_header.GetIds(self.GetRoot()) id = id_map[self.GetTextualIds()[0]] message = self.ws_at_start + self.Translate(lang) + self.ws_at_end return id, util.Encode(message, encoding)
def GetDataPackPair(self, lang, encoding): """Returns a (id, string|None) pair that represents the resource id and raw bytes of the data (or None if no resource is generated). This is used to generate the data pack data file. """ from grit.format import rc_header id_map = rc_header.GetIds(self.GetRoot()) id = id_map[self.GetTextualIds()[0]] if self.ExpandVariables(): text = self.gatherer.GetText() return id, util.Encode(self._Substitute(text), encoding) return id, self.gatherer.GetData(lang, encoding)
def GetDataPackValue(self, lang, encoding): """Returns a bytes representation for a data_pack entry.""" if self.ExpandVariables(): text = self.gatherer.GetText() data = util.Encode(self._Substitute(text), encoding) else: data = self.gatherer.GetData(lang, encoding) if encoding != util.BINARY: data = data.encode(encoding) data = self.CompressDataIfNeeded(data) # If the asset is in the Lottie format, indicate it by prepending "LOTTIE". if self.attrs['type'] == 'lottie': data = 'LOTTIE'.encode(self.attrs['output_encoding']) + data return data
def GetDataPackValue(self, lang, encoding): '''Returns a str represenation for a data_pack entry.''' message = self.ws_at_start + self.Translate(lang) + self.ws_at_end return util.Encode(message, encoding)