[SSG] Isolate argument parsing.
This commit is contained in:
parent
5b13ce2a2f
commit
917d3addb6
20
nova.py
20
nova.py
|
@ -94,13 +94,13 @@ class EpisodeList(UserList):
|
|||
|
||||
class Episode:
|
||||
"Represents one episode of podcast"
|
||||
def __init__(self, date, slug, title, show_notes, video_src, audo_src):
|
||||
def __init__(self, date, slug, title, show_notes, video_src, audio_src):
|
||||
self.date = date
|
||||
self.slug = slug
|
||||
self.title = title.strip()
|
||||
self.show_notes = markdown.markdown(show_notes)
|
||||
self.video = video_src
|
||||
self.audio = audo_src
|
||||
self.audio = audio_src
|
||||
|
||||
def render(self, template, thumbnail_src):
|
||||
"Renders the Episode with the given template"
|
||||
|
@ -118,15 +118,21 @@ class Episode:
|
|||
subprocess.run(args, check=False)
|
||||
|
||||
|
||||
def main():
|
||||
"Main method"
|
||||
root = path.dirname(sys.argv[0]).rstrip("/") + "/"
|
||||
def parse_args():
|
||||
"Parses arguments"
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("input_dir", help="Input directory")
|
||||
parser.add_argument("output_dir", help="Output directory")
|
||||
args = parser.parse_args()
|
||||
input_dir = args.input_dir.rstrip("/") + "/"
|
||||
output_dir = args.output_dir.rstrip("/") + "/"
|
||||
return input_dir, output_dir
|
||||
|
||||
|
||||
def main():
|
||||
"Main method"
|
||||
root = path.dirname(sys.argv[0]).rstrip("/") + "/"
|
||||
input_dir, output_dir = parse_args()
|
||||
|
||||
# Input validation
|
||||
paths = [
|
||||
|
@ -139,8 +145,8 @@ def main():
|
|||
print("Invalid Input", file=sys.stderr)
|
||||
return
|
||||
|
||||
if not path.isdir(args.output_dir):
|
||||
os.mkdir(args.output_dir)
|
||||
if not path.isdir(output_dir):
|
||||
os.mkdir(output_dir)
|
||||
|
||||
env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(root),
|
||||
|
|
Loading…
Reference in New Issue