<commit_before>import 'dart:async';

import '../refEntities/epubBookRef.dart';
import '../refEntities/epubByteContentFileRef.dart';
import '../schema/opf/epubManifestItem.dart';
import '../schema/opf/epubMetadataMeta.dart';

import 'package:image/image.dart' as images;

class BookCoverReader {
  static Future<images.Image> ReadBookCoverAsync(EpubBookRef bookRef) async {
    List<EpubMetadataMeta> metaItems = bookRef.Schema.Package.Metadata.MetaItems;
    if (metaItems == null || metaItems.length == 0)
      return null;
    EpubMetadataMeta coverMetaItem = metaItems.firstWhere((EpubMetadataMeta metaItem) => metaItem.Name.toLowerCase() == "cover", orElse: () => null);
    if (coverMetaItem == null)
      return null;
    if (coverMetaItem.Content == null || coverMetaItem.Content.isEmpty)
      throw new Exception("Incorrect EPUB metadata: cover item content is missing.");
    EpubManifestItem coverManifestItem = bookRef.Schema
                                                .Package
                                                .Manifest
                                                .Items
                                                .firstWhere((EpubManifestItem manifestItem) => manifestItem.Id.toLowerCase() == coverMetaItem.Content.toLowerCase(), orElse: () => null));
    if (coverManifestItem == null)
      throw new Exception("Incorrect EPUB manifest: item with ID = \"${coverMetaItem.Content}\" is missing.");
    EpubByteContentFileRef coverImageContentFileRef;
    if (!bookRef.Content.Images.containsKey(coverManifestItem.Href))
      throw new Exception("Incorrect EPUB manifest: item with href = \"${coverManifestItem.Href}\" is missing.");
    coverImageContentFileRef = bookRef.Content.Images[coverManifestItem.Href];
    List<int> coverImageContent = await coverImageContentFileRef.ReadContentAsBytesAsync();
    images.Image retval  = images.decodeImage(coverImageContent);
    return retval;
  }
}<commit_msg>Fixed Unbalanced Parens<commit_after>import 'dart:async';

import '../refEntities/epubBookRef.dart';
import '../refEntities/epubByteContentFileRef.dart';
import '../schema/opf/epubManifestItem.dart';
import '../schema/opf/epubMetadataMeta.dart';

import 'package:image/image.dart' as images;

class BookCoverReader {
  static Future<images.Image> ReadBookCoverAsync(EpubBookRef bookRef) async {
    List<EpubMetadataMeta> metaItems = bookRef.Schema.Package.Metadata.MetaItems;
    if (metaItems == null || metaItems.length == 0)
      return null;
    EpubMetadataMeta coverMetaItem = metaItems.firstWhere((EpubMetadataMeta metaItem) => metaItem.Name.toLowerCase() == "cover", orElse: () => null);
    if (coverMetaItem == null)
      return null;
    if (coverMetaItem.Content == null || coverMetaItem.Content.isEmpty)
      throw new Exception("Incorrect EPUB metadata: cover item content is missing.");
    EpubManifestItem coverManifestItem = bookRef.Schema
                                                .Package
                                                .Manifest
                                                .Items
                                                .firstWhere((EpubManifestItem manifestItem) => manifestItem.Id.toLowerCase() == coverMetaItem.Content.toLowerCase(), orElse: () => null);
    if (coverManifestItem == null)
      throw new Exception("Incorrect EPUB manifest: item with ID = \"${coverMetaItem.Content}\" is missing.");
    EpubByteContentFileRef coverImageContentFileRef;
    if (!bookRef.Content.Images.containsKey(coverManifestItem.Href))
      throw new Exception("Incorrect EPUB manifest: item with href = \"${coverManifestItem.Href}\" is missing.");
    coverImageContentFileRef = bookRef.Content.Images[coverManifestItem.Href];
    List<int> coverImageContent = await coverImageContentFileRef.ReadContentAsBytesAsync();
    images.Image retval  = images.decodeImage(coverImageContent);
    return retval;
  }
}
{'fraction_non_alphanumeric': 0.10963455149501661, 'fraction_numerical': 0.0005111167901865576, 'mean_word_length': 3.047569803516029, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5984228', 'n_tokens_mistral': 1007, 'n_tokens_neox': 1037, 'n_words': 222}