Bugzilla – Attachment 159166 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]
Script for counting elements in *.odt documents
attachment_mod.py (text/x-python), 1.29 KB, created by
Sebastian O.
on 2020-03-30 18:13:50 UTC
(
hide
)
Description:
Script for counting elements in *.odt documents
Filename:
MIME Type:
Creator:
Sebastian O.
Created:
2020-03-30 18:13:50 UTC
Size:
1.29 KB
patch
obsolete
>""" >This script requires the "odfpy" module. >Requires a path to a *.odt document in the command line. >""" >from odf.opendocument import load >from odf import draw, table, text, teletype, office >import sys, os.path > >def type_counter(document,type): ># If there are no manual page breaks it prints out the corret page number > if type == text.SoftPageBreak: > count = 1 > else: > count = 0 ># Sorting out all those empty paragraphs, (return key without any text) > if type == text.P: > for element in document.getElementsByType(type): > if len(teletype.extractText(element)) > 0: > count+=1 > else: > for element in document.getElementsByType(type): > count+= 1 > > return (count) > ># Extendable for future additions >typ = { > 'bookmarks': text.Bookmark, > 'changetrackings': text.FormatChange, > 'comments': office.Annotation, > 'hyperlinks': text.A, > 'images': draw.Image, > 'paragraphs': text.P, > 'pages': text.SoftPageBreak, > 'tables': table.Table, > 'text-boxes': draw.TextBox >} > > >if os.path.exists(sys.argv[1]) and sys.argv[1].endswith(".odt"): > doc = load(sys.argv[1]) > i = 0 > for key, value in typ.items(): > print("Number of", key, ":", type_counter(doc, value)) >else: > print("Document not found, or wrong type")
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