Example #1
0
def do_query_cmd(args):
    ri = args.rom_image
    rs = RomSplitter()
    if not rs.find_rom(ri):
        print(ri, "not found in split database!")
        return 100
    else:
        rs.print_rom(print)
        if args.modules is None:
            e = rs.get_all_entries()
        else:
            e = rs.query_entries(args.modules)
        rs.print_entries(print, e)
        return 0
Example #2
0
def do_query_cmd(args):
  ri = args.rom_image
  rs = RomSplitter()
  if not rs.find_rom(ri):
    print(ri, "not found in split database!")
    return 100
  else:
    rs.print_rom(print)
    if args.modules is None:
      e = rs.get_all_entries()
    else:
      e = rs.query_entries(args.modules)
    rs.print_entries(print,e)
    return 0
Example #3
0
def do_split_cmd(args):
  ri = args.rom_image
  rs = RomSplitter()
  rom = rs.find_rom(ri)
  if rom is None:
    logging.error(ri, "not found in split database!")
    return 100
  else:
    rs.print_rom(logging.info)
    # no output dir? end now
    out_path = args.output_dir
    if out_path is None:
      return 0
    # get modules to export
    if args.modules is None:
      entries = rs.get_all_entries()
    else:
      entries = rs.query_entries(args.modules)
    # setup output dir
    if not args.no_version_dir:
      out_path = os.path.join(out_path, rom.short_name)
    # make dirs
    if not os.path.isdir(out_path):
      logging.info("creating directory '%s'", out_path)
      os.makedirs(out_path)
    # create index file
    if not args.no_index:
      idx_path = os.path.join(out_path, "index.txt")
      logging.info("writing index to '%s'", idx_path)
      rs.write_index_file(idx_path)
    # extract entries
    bfh = BinFmtHunk()
    for e in entries:
      rs.print_entry(logging.info, e)
      bin_img = rs.extract_bin_img(e)
      out_file = os.path.join(out_path, e.name)
      logging.info("writing file '%s'", out_file)
      bfh.save_image(out_file, bin_img)
    return 0
Example #4
0
def do_list_cmd(args):
  rs = RomSplitter()
  rs.list_roms(print, args.rom, show_entries=args.modules)
  return 0
Example #5
0
def do_split_cmd(args):
    ri = args.rom_image
    rs = RomSplitter()
    rom = rs.find_rom(ri)
    if rom is None:
        logging.error(ri, "not found in split database!")
        return 100
    else:
        rs.print_rom(logging.info)
        # no output dir? end now
        out_path = args.output_dir
        if out_path is None:
            return 0
        # get modules to export
        if args.modules is None:
            entries = rs.get_all_entries()
        else:
            entries = rs.query_entries(args.modules)
        # setup output dir
        if not args.no_version_dir:
            out_path = os.path.join(out_path, rom.short_name)
        # make dirs
        if not os.path.isdir(out_path):
            logging.info("creating directory '%s'", out_path)
            os.makedirs(out_path)
        # create index file
        if not args.no_index:
            idx_path = os.path.join(out_path, "index.txt")
            logging.info("writing index to '%s'", idx_path)
            rs.write_index_file(idx_path)
        # extract entries
        bfh = BinFmtHunk()
        for e in entries:
            rs.print_entry(logging.info, e)
            bin_img = rs.extract_bin_img(e)
            out_file = os.path.join(out_path, e.name)
            logging.info("writing file '%s'", out_file)
            bfh.save_image(out_file, bin_img)
        return 0
Example #6
0
def do_list_cmd(args):
    rs = RomSplitter()
    rs.list_roms(print, args.rom, show_entries=args.modules)
    return 0