Bugzilla – Attachment 168410 Details for
Bug 124141
Create a document analyser for LibreOffice triage and QA
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
document analyser (modified)
document_analyser.py (text/x-python), 2.56 KB, created by
wingednova
on 2020-12-22 13:13:50 UTC
(
hide
)
Description:
document analyser (modified)
Filename:
MIME Type:
Creator:
wingednova
Created:
2020-12-22 13:13:50 UTC
Size:
2.56 KB
patch
obsolete
>#python3 > >""" >Document analyser uses the odfpy module: https://pypi.org/project/odfpy/ > >This script prints: >bookmark count, cell count, changetracking count, character count, >comment count, draw count, frame count, hyperlink count, >image count, non-whitespace character count, object count, OLE object count, >page count, paragraph count, row count, sentence count, >syllable count, table count, textbox count, word count, and paragraph styles. > >""" > >import odf >from odf.namespaces import TEXTNS >from odf.element import Element >from odf.opendocument import load >from odf import text,meta,office,draw > > >print("Enter filename: ") >filename=input() > >doc=load(filename) > >#--------------------document statistics from the odf.meta module-------------------- >print("\nDOCUMENT STATISTICS\n") >for stat in doc.getElementsByType(meta.DocumentStatistic): > print("Cell count",stat.getAttribute('cellcount')) > print("Character count:",stat.getAttribute('charactercount')) > print("Draw count:",stat.getAttribute('drawcount')) > print("Frame count:",stat.getAttribute('framecount')) > print("Image count:",stat.getAttribute('imagecount')) > print("Non-whitespace character count:",stat.getAttribute('nonwhitespacecharactercount')) > print("Object count:",stat.getAttribute('objectcount')) > print("Object linking and embedding (OLE) object count:",stat.getAttribute('oleobjectcount')) > print("Page count:",stat.getAttribute('pagecount')) > print("Paragraph count:",stat.getAttribute('paragraphcount')) > print("Row count:",stat.getAttribute('rowcount')) > print("Sentence count:",stat.getAttribute('sentencecount')) > print("Syllable count:",stat.getAttribute('syllablecount')) > print("Table count:",stat.getAttribute('tablecount')) > print("Word count:",stat.getAttribute('wordcount')) > > >#--------------------type counter for attributes not covered by odf.meta.DocumentStatistic-------------------- >def type_counter(doc,type): > count=0 > for element in doc.getElementsByType(type): > count+=1 > return count > >types={ > 'Bookmark':text.Bookmark, > 'Changetracking':text.FormatChange, > 'Comment':office.Annotation, > 'Hyperlink':text.A, > 'Textbox':draw.TextBox >} > >for key,value in types.items(): > print(key,'count:',type_counter(doc,value)) > >#--------------------paragraph styles-------------------- >def paragraph_style(doc): > i = 1 > for paragraph in doc.getElementsByType(text.P): > print('Paragraph',i,'style:',paragraph.getAttribute('stylename')) > i+=1 > >paragraph_style(doc)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 124141
:
150623
|
159166
|
168089
|
168100
| 168410