/usr/lib/python2.7/dist-packages/PythonCard/tools/textEditor/scriptlets/selectionWordCount.py is in python-pythoncard 0.8.2-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import wx
from PythonCard import dialog
def wordCount(text):
chars = len(text)
words = len(text.split())
# this doesn't always match the getNumberOfLines() method
# so this should probably be changed
lines = len(text.splitlines())
return chars, words, lines
if bg.documentPath is None:
filename = 'Untitled'
else:
filename = os.path.basename(bg.documentPath)
text = bg.components.fldDocument.getStringSelection()
dialog.MessageDialog(bg, "Document: %s\n" % filename + "%d chars, %d words, %d lines" % wordCount(text), 'Word Count', wx.ICON_INFORMATION | wx.OK)
|