Skip to content

Commit 34a9f36

Browse files
committed
Add helper for getting word count from draft
- Legacy-Id: 12655
1 parent 656ed8c commit 34a9f36

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ietf/utils/draft.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ def get_pagecount(self):
292292
self._pagecount = count_pages
293293
return self._pagecount
294294

295+
# ------------------------------------------------------------------
296+
def get_wordcount(self):
297+
count = 0
298+
# match any sequence of non-white-space characters like the Unix command "wc"
299+
word_re = re.compile(r'\S+', re.UNICODE)
300+
for l in self.lines:
301+
count += sum(1 for _ in word_re.finditer(l))
302+
return count
303+
295304
# ----------------------------------------------------------------------
296305
def get_status(self):
297306
if self._status == None:

0 commit comments

Comments
 (0)