Skip to content

Commit

Permalink
Capture failed regex and return a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
nikdoof committed Oct 27, 2020
1 parent 89e5212 commit 7c610cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tildejsongen.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def get_title(filename):
data = fobj.read()
res = re.search(r'<title>(.*?)</title>', data)
try:
return res.group(1)
except IndexError:
if res:
return res.group(1)
return '~somebody'
except (IndexError, AttributeError):
logging.debug(f'No HTML title found in {filename}')
pass

Expand Down

0 comments on commit 7c610cf

Please sign in to comment.