diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-05-03 21:34:51 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-05-03 21:34:51 +0300 |
commit | 83313e773d6dc269a6a6ec2e70c51287808d8a23 (patch) | |
tree | b430f61d3badeb2297b2185e584d284679e99209 | |
parent | d3358dfc5823b32994ce7b8a6b9a2fe198377194 (diff) | |
download | jt-tmp-83313e773d6dc269a6a6ec2e70c51287808d8a23.tar.gz |
Simplify logic by adding helper method
-rwxr-xr-x | jt | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -74,14 +74,14 @@ class DraftsDirectory(object): def get_draft_title(self, draft_id): pathname = self.get_draft_pathname(draft_id) with open(pathname) as f: - for line in f: - m = re.match(r'\[\[!meta title="(?P<title>.*)("\]\])$', line) - if m: - title = m.group('title') - break - else: - title = None - return title + return self._get_title_from_open_file(f) + + def _get_title_from_open_file(self, f): + for line in f: + m = re.match(r'\[\[!meta title="(?P<title>.*)("\]\])$', line) + if m: + return m.group('title') + return None class Command(object): |