Prettify Code Samples
I have just made a tiny change to the CSS stylesheet for this site and the indentETree function in markdown. I might want to post code samples here in the future but there was nothing set up for making the code samples stand out; this was evident in my last blog update post when I posted the line that I use to embed YouTube videos. What I did was minimal but it will be enough for now. Let's see if this works.
def validateURL (full_url, video_item=True):
"""Make sure the url passed is in a valid form and return a video parser object"""
if not isinstance (full_url, str):
raise TypeError ("Argument must be a string")
youtube_video = None
# Use each parser regular expression to determine what type of URL was given
for parser in video_parser_list:
match = parser.const_video_url_re.match (full_url)
if match:
page_parser = parser (video_id = match.group (1))
if video_item:
youtube_video = VideoItem (page_parser)
else:
return page_parser
break
# An invalid URL was given. Return None
if not youtube_video:
return None
return youtube_video

