def prepare_issuance_batch(unsigned_certs_dir, signed_certs_dir, blockchain_certs_dir, work_dir,<EOL>file_extension=JSON_EXT):
<EOL>os.makedirs(work_dir, exist_ok=True)<EOL>os.makedirs(blockchain_certs_dir, exist_ok=True)<EOL>os.makedirs(signed_certs_dir, exist_ok=True)<EOL>for item in os.listdir(work_dir):<EOL><INDENT>file_path = os.path.join(work_dir, item)<EOL>if os.path.isdir(file_path):<EOL><INDENT>shutil.rmtree(file_path)<EOL><DEDENT><DEDENT>unsigned_certs_work_dir = os.path.join(work_dir, UNSIGNED_CERTIFICATES_DIR)<EOL>signed_certs_work_dir = os.path.join(work_dir, SIGNED_CERTIFICATES_DIR)<EOL>blockchain_certs_work_dir = os.path.join(work_dir, BLOCKCHAIN_CERTIFICATES_DIR)<EOL>shutil.copytree(unsigned_certs_dir, unsigned_certs_work_dir)<EOL>os.makedirs(signed_certs_work_dir, exist_ok=True)<EOL>os.makedirs(blockchain_certs_work_dir, exist_ok=True)<EOL>cert_info = collections.OrderedDict()<EOL>input_file_pattern = str(os.path.join(unsigned_certs_work_dir, '<STR_LIT:*>' + file_extension))<EOL>matches = glob2.iglob(input_file_pattern, with_matches=True)<EOL>if not matches:<EOL><INDENT>logging.warning('<STR_LIT>')<EOL>raise NoCertificatesFoundError('<STR_LIT>')<EOL><DEDENT>for filename, (uid,) in sorted(matches):<EOL><INDENT>certificate_metadata = CertificateMetadata(uid=uid,<EOL>unsigned_certs_dir=unsigned_certs_work_dir,<EOL>signed_certs_dir=signed_certs_work_dir,<EOL>blockcerts_dir=blockchain_certs_work_dir,<EOL>final_blockcerts_dir=blockchain_certs_dir,<EOL>file_extension=file_extension)<EOL>cert_info[uid] = certificate_metadata<EOL><DEDENT>logging.info('<STR_LIT>', len(cert_info))<EOL>return cert_info<EOL>
Prepares file system for issuing a batch of certificates. Copies inputs to work_dir, and ensures
that all output dirs required for processing the batch exist.
:param unsigned_certs_dir: input certificates
:param signed_certs_dir: output dir
:param blockchain_certs_dir: output dir
:param work_dir: work dir
:return: