From b01b351b30449255fa1504b7acf4eacd689e84c8 Mon Sep 17 00:00:00 2001 From: dx Date: Tue, 5 May 2020 22:13:59 +0100 Subject: +argument validation for markdown file test Usign regex to check if each file is a markdown file or not, skipping any that are --- converter.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/converter.py b/converter.py index 07944f4..79624f7 100644 --- a/converter.py +++ b/converter.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from optparse import OptionParser +from re import search, sub """Command line arguments""" usage = "usage: %prog [options] file..." parser = OptionParser(usage=usage) @@ -13,3 +14,14 @@ parser.add_option('-o', '--output-type', dest='output_type', (options, args) = parser.parse_args() +"""Valid argument testing +TODO: Add support for directories +""" +markdown_files = [] +for file in args: + if search(".md", file) is not None: + # Is a markdown file + markdown_files.append(file) + else: + print(file, "is not a markdown file, skipping") + -- cgit v1.2.3-13-gbd6f