def handle_noargs(self, **options): verbosity = int(options['verbosity']) def verbose(msg): """ Output wrapper """ if verbosity > 1: print(msg) verbose("== Starting PEP page generation") verbose("Generating RSS Feed") get_peps_rss() verbose("Generating PEP0 index page") pep0_page, _ = get_pep0_page() image_paths = set() # Find pep pages for f in os.listdir(settings.PEP_REPO_PATH): if self.is_image(f): verbose("- Deferring import of image '{}'".format(f)) image_paths.add(f) continue # Skip files we aren't looking for if not self.is_pep_page(f): verbose("- Skipping non-PEP file '{}'".format(f)) continue if 'pep-0000.html' in f: verbose("- Skipping duplicate PEP0 index") continue verbose("Generating PEP Page from '{}'".format(f)) pep_match = pep_number_re.match(f) if pep_match: pep_number = pep_match.groups(1)[0] p = get_pep_page(pep_number) else: verbose("- Skipping invalid '{}'".format(f)) # Find pep images. This needs to happen afterwards, because we need for img in image_paths: pep_match = pep_number_re.match(img) if pep_match: pep_number = pep_match.groups(1)[0] verbose("Generating image for PEP {} at '{}'".format( pep_number, img)) add_pep_image(pep_number, img) else: verbose("- Skipping non-PEP related image '{}'".format(img)) verbose("== Finished")
def handle_noargs(self, **options): verbosity = int(options['verbosity']) def verbose(msg): """ Output wrapper """ if verbosity > 1: print(msg) verbose("== Starting PEP page generation") verbose("Generating RSS Feed") peps_rss = get_peps_rss() if not peps_rss: verbose("Could not find generated RSS feed. Skipping.") verbose("Generating PEP0 index page") pep0_page, _ = get_pep0_page() image_paths = set() # Find pep pages for f in os.listdir(settings.PEP_REPO_PATH): if self.is_image(f): verbose("- Deferring import of image '{}'".format(f)) image_paths.add(f) continue # Skip files we aren't looking for if not self.is_pep_page(f): verbose("- Skipping non-PEP file '{}'".format(f)) continue if 'pep-0000.html' in f: verbose("- Skipping duplicate PEP0 index") continue verbose("Generating PEP Page from '{}'".format(f)) pep_match = pep_number_re.match(f) if pep_match: pep_number = pep_match.groups(1)[0] p = get_pep_page(pep_number) else: verbose("- Skipping invalid '{}'".format(f)) # Find pep images. This needs to happen afterwards, because we need for img in image_paths: pep_match = pep_number_re.match(img) if pep_match: pep_number = pep_match.groups(1)[0] verbose("Generating image for PEP {} at '{}'".format( pep_number, img)) add_pep_image(pep_number, img) else: verbose("- Skipping non-PEP related image '{}'".format(img)) verbose("== Finished")
def handle(self, **options): verbosity = int(options['verbosity']) def verbose(msg): """ Output wrapper """ if verbosity > 1: print(msg) verbose("== Starting PEP page generation") with ExitStack() as stack: if settings.PEP_REPO_PATH is not None: artifacts_path = settings.PEP_REPO_PATH else: verbose( f"== Fetching PEP artifact from {settings.PEP_ARTIFACT_URL}" ) temp_file = self.get_artifact_tarball(stack) if not temp_file: verbose("== No update to artifacts, we're done here!") return temp_dir = stack.enter_context(TemporaryDirectory()) tar_ball = stack.enter_context( TarFile.open(fileobj=temp_file, mode='r:gz')) tar_ball.extractall(path=temp_dir, numeric_owner=False) artifacts_path = os.path.join(temp_dir, 'peps') verbose("Generating RSS Feed") peps_rss = get_peps_rss(artifacts_path) if not peps_rss: verbose("Could not find generated RSS feed. Skipping.") verbose("Generating PEP0 index page") pep0_page, _ = get_pep0_page(artifacts_path) if pep0_page is None: verbose("HTML version of PEP 0 cannot be generated.") return image_paths = set() # Find pep pages for f in os.listdir(artifacts_path): if self.is_image(f): verbose("- Deferring import of image '{}'".format(f)) image_paths.add(f) continue # Skip files we aren't looking for if not self.is_pep_page(f): verbose("- Skipping non-PEP file '{}'".format(f)) continue if 'pep-0000.html' in f: verbose("- Skipping duplicate PEP0 index") continue verbose("Generating PEP Page from '{}'".format(f)) pep_match = pep_number_re.match(f) if pep_match: pep_number = pep_match.groups(1)[0] p = get_pep_page(artifacts_path, pep_number) if p is None: verbose("- HTML version PEP {!r} cannot be generated.". format(pep_number)) verbose("====== Title: '{}'".format(p.title)) else: verbose("- Skipping invalid '{}'".format(f)) # Find pep images. This needs to happen afterwards, because we need for img in image_paths: pep_match = pep_number_re.match(img) if pep_match: pep_number = pep_match.groups(1)[0] verbose("Generating image for PEP {} at '{}'".format( pep_number, img)) add_pep_image(artifacts_path, pep_number, img) else: verbose( "- Skipping non-PEP related image '{}'".format(img)) verbose("== Finished")
def handle(self, **options): verbosity = int(options['verbosity']) def verbose(msg): """ Output wrapper """ if verbosity > 1: print(msg) verbose("== Starting PEP page generation") with ExitStack() as stack: verbose(f"== Fetching PEP artifact from {settings.PEP_ARTIFACT_URL}") temp_file = self.get_artifact_tarball(stack) if not temp_file: verbose("== No update to artifacts, we're done here!") return temp_dir = stack.enter_context(TemporaryDirectory()) tar_ball = stack.enter_context(TarFile.open(fileobj=temp_file, mode='r:gz')) tar_ball.extractall(path=temp_dir, numeric_owner=False) artifacts_path = os.path.join(temp_dir, 'peps') verbose("Generating RSS Feed") peps_rss = get_peps_rss(artifacts_path) if not peps_rss: verbose("Could not find generated RSS feed. Skipping.") verbose("Generating PEP0 index page") pep0_page, _ = get_pep0_page(artifacts_path) if pep0_page is None: verbose("HTML version of PEP 0 cannot be generated.") return image_paths = set() # Find pep pages for f in os.listdir(artifacts_path): if self.is_image(f): verbose("- Deferring import of image '{}'".format(f)) image_paths.add(f) continue # Skip files we aren't looking for if not self.is_pep_page(f): verbose("- Skipping non-PEP file '{}'".format(f)) continue if 'pep-0000.html' in f: verbose("- Skipping duplicate PEP0 index") continue verbose("Generating PEP Page from '{}'".format(f)) pep_match = pep_number_re.match(f) if pep_match: pep_number = pep_match.groups(1)[0] p = get_pep_page(artifacts_path, pep_number) if p is None: verbose( "- HTML version PEP {!r} cannot be generated.".format( pep_number ) ) verbose("====== Title: '{}'".format(p.title)) else: verbose("- Skipping invalid '{}'".format(f)) # Find pep images. This needs to happen afterwards, because we need for img in image_paths: pep_match = pep_number_re.match(img) if pep_match: pep_number = pep_match.groups(1)[0] verbose("Generating image for PEP {} at '{}'".format( pep_number, img)) add_pep_image(artifacts_path, pep_number, img) else: verbose("- Skipping non-PEP related image '{}'".format(img)) verbose("== Finished")