def parse_metadata_cache(cls, bl, prefix, name): json_codec = JsonCodec() need_sync = False cache_file = cls.normalize_path(os.path.join(prefix, name)) if os.access(cache_file, os.R_OK): try: with lopen(cache_file, 'rb') as f: json_codec.decode_from_file(f, bl, cls.book_class, prefix) except: import traceback traceback.print_exc() bl = [] need_sync = True else: need_sync = True return need_sync
def parse_metadata_cache(self, bl): need_sync = True if not self.bambook: return need_sync # Get the metadata virtual book from Bambook with TemporaryDirectory() as tdir: if self.bambook.GetFile(self.METADATA_FILE_GUID, tdir): cache_name = os.path.join(tdir, self.METADATA_CACHE) if self.bambook.ExtractSNBContent(os.path.join(tdir, self.METADATA_FILE_GUID), 'snbc/' + self.METADATA_CACHE, cache_name): json_codec = JsonCodec() if os.access(cache_name, os.R_OK): try: with open(cache_name, 'rb') as f: json_codec.decode_from_file(f, bl, self.book_class, '') need_sync = False except: import traceback traceback.print_exc() bl = [] return need_sync
def parse_metadata_cache(self, bl): need_sync = True if not self.bambook: return need_sync # Get the metadata virtual book from Bambook with TemporaryDirectory() as tdir: if self.bambook.GetFile(self.METADATA_FILE_GUID, tdir): cache_name = os.path.join(tdir, self.METADATA_CACHE) if self.bambook.ExtractSNBContent( os.path.join(tdir, self.METADATA_FILE_GUID), 'snbc/' + self.METADATA_CACHE, cache_name): json_codec = JsonCodec() if os.access(cache_name, os.R_OK): try: with open(cache_name, 'rb') as f: json_codec.decode_from_file( f, bl, self.book_class, '') need_sync = False except: import traceback traceback.print_exc() bl = [] return need_sync