Package src :: Module word_processing
[hide private]
[frames] | no frames]

Module word_processing

source code

The module makes the comparisons between the office document properties and requirements specified for each user.


Author: Vili Auvinen, Olli Kauppinen, Juho Tammela

To Do: Change the name of the module to word_inspector.

Functions [hide private]
 
makeDocumentDict(documentFile, fileExtension)
Creates a document dict which contains the XML files from a document file by the given fileExtension.
source code
 
processRequirements(inspector, document, requirements, results)
Processes requirements by looping through checkers dict which contains the method names described in the XML requirement file.
source code
 
printResults(resultsDict)
For testing.
source code
 
checkBooleanRequirement(function, requirement, document, results)
Checks the boolean requirements.
source code
 
checkDictRequirement(function, requirement, document, results)
Checks the dictionary requirement.
source code
 
checkRequirementEndNoteFootNote(inspector, requirement, document, results) source code
 
checkRequirementSections(inspector, requirement, document, results)
Checks the requirement sections.
source code
 
checkRequirementMargins(inspector, requirement, document, results)
Checks the requirement margins by calling the checkDictRequirement.
source code
 
checkRequirementPageSize(inspector, requirement, document, results) source code
 
checkRequirementCoverPage(inspector, requirement, document, results) source code
 
checkRequirementHeadingNumbering(inspector, requirement, document, results)
Checks the heading numbering requirement.
source code
 
checkRequirementStyles(inspector, requirement, document, results)
Checks the style requirements.
source code
 
checkRequirementTOC(inspector, requirement, document, results)
Checks if the table of the contents exists.
source code
 
checkRequirementImages(inspector, requirement, document, results)
Checks if there are images in the document.
source code
 
checkRequirementEmptyParagraphs(inspector, requirement, document, results)
Checks empty paragraphs from the document.
source code
 
checkRequirementList(inspector, requirement, document, results)
Checks if there are lists in the document.
source code
 
checkRequirementStyleUsage(inspector, requirement, document, results)
Checks the style usage.
source code
 
checkRequirementTabs(inspector, requirement, document, results)
Checks if the tabs have been used in the document.
source code
 
checkRequirementDoubleWhitespace(inspector, requirement, document, results)
Checks if double whitespaces are found in the document.
source code
 
checkRequirementAsterisk(inspector, requirement, document, results)
Checks if asterisks are found in the document.
source code
 
checkRequirementImageCaptions(inspector, requirement, document, results)
Checks if image captions are used.
source code
 
checkRequirementHeadersAndFooters(inspector, requirement, document, results)
Checks the headers and the footers requirement.
source code
 
checkRequirementIndex(inspector, requirement, document, results)
Checks if index is found in the document.
source code
 
inspect(documentFile, requirements, fileExtension)
Inspects a document by the given file extension which is either odt or docx.
source code
Variables [hide private]
  inspectorDict = {'docm': <module 'src.inspectors.docx_inspecto...
  _checkers = {'Styles': checkRequirementStyles, 'TOC': checkReq...
  __package__ = 'src'
Function Details [hide private]

makeDocumentDict(documentFile, fileExtension)

source code 

Creates a document dict which contains the XML files from a document file by the given fileExtension.

Parameters:
  • fileExtension - can be docx or odt or odp etc.
Returns:
The document dictionary.

Note: Code example: docXml = document['word/document.xml']

See Also: _checkers

processRequirements(inspector, document, requirements, results)

source code 

Processes requirements by looping through checkers dict which contains the method names described in the XML requirement file.

Parameters:
  • inspector - defines the given inspector.
  • document - defines document dictionary which contains the XML files.
  • requirements - defines Requirements object which contains the given requirements in the XML requirement file.
  • results - defines the given errors in the results dictionary.

checkBooleanRequirement(function, requirement, document, results)

source code 

Checks the boolean requirements. The inspector methods return a boolean.

Returns:
True if expectedValue is returned from the inspector method, False otherwise.

See Also: processRequirements for parameters.

checkDictRequirement(function, requirement, document, results)

source code 

Checks the dictionary requirement. The inspector methods return a dictionary of which the values are compared to the ones in XML requirement file.

See Also: processRequirements for parameters.

checkRequirementSections(inspector, requirement, document, results)

source code 

Checks the requirement sections. The inspector method takes an empty list as an argument. If its length is not zero after the inspector method, it means that errors were founded.

Returns:
out from the method if inspectorData return False.

See Also: processRequirements for parameters.

checkRequirementMargins(inspector, requirement, document, results)

source code 

Checks the requirement margins by calling the checkDictRequirement.

See Also: processRequirements for parameters and checkDictRequirement for the actual method.

checkRequirementHeadingNumbering(inspector, requirement, document, results)

source code 

Checks the heading numbering requirement.

Error ids and positions are defined in a dict which is then used in the method inspector.checkHeadingNumbering(document, errorIdsAndPositions). If the keys in the dict are not None, errors have been appended.

See Also:
docx_inspector.checkHeadingNumbering(document, errorIdsAndPositions)., processRequirements for parameters.

checkRequirementStyles(inspector, requirement, document, results)

source code 

Checks the style requirements. Compares the style requirements described in the XML file to the document properties defined by the user. Appends a default error if inspector.getStyle returns False.

Returns:
Nothing if inspector.getStyle returns False.

See Also: processRequirements for parameters.

checkRequirementTOC(inspector, requirement, document, results)

source code 

Checks if the table of the contents exists. If it does not exist, appends a default error message.

If it exists, checks if the table of contents is correctly made. If not, append an error message.

See Also: processRequirements for parameters.

checkRequirementImages(inspector, requirement, document, results)

source code 

Checks if there are images in the document. Calls the checkBooleanRequirement function.

See Also: checkBooleanRequirement(function, requirement, document, results).

checkRequirementEmptyParagraphs(inspector, requirement, document, results)

source code 

Checks empty paragraphs from the document. Appends an error message if there are some to be found.

See Also: processRequirements for parameters.

checkRequirementList(inspector, requirement, document, results)

source code 

Checks if there are lists in the document. Calls the checkBooleanRequirement function.

See Also: processRequirements for parameters.

checkRequirementStyleUsage(inspector, requirement, document, results)

source code 

Checks the style usage. An error dict (below) with two key-value pairs is used in the method inspector.checkStyleUsage. The inspector method returns the text paragraphs where manual changes have been made or style has not been used at all.

errorIdsAndPositions = {'styleNotUsed': [], 'manualChanges': []}

See Also: processRequirements for parameters.

checkRequirementTabs(inspector, requirement, document, results)

source code 

Checks if the tabs have been used in the document. Does nothing if tabs are not found, otherwise append an error message.

See Also: processRequirements for parameters.

checkRequirementDoubleWhitespace(inspector, requirement, document, results)

source code 

Checks if double whitespaces are found in the document. Does nothing if double whitespaces are not found, otherwise append an error message.

See Also: processRequirements for parameters

checkRequirementAsterisk(inspector, requirement, document, results)

source code 

Checks if asterisks are found in the document. Does nothing if asterisks are not found, otherwise append an error. A special print formatting is used here. Could be useful in other methods as well.

See Also: processRequirements for parameters.

checkRequirementImageCaptions(inspector, requirement, document, results)

source code 

Checks if image captions are used.

See Also:
checkBooleanRequirement, processRequirements for parameters.

checkRequirementHeadersAndFooters(inspector, requirement, document, results)

source code 

Checks the headers and the footers requirement.

The method can be run only if checkRequirementSections goes through. The function is hard to implement in a smart way.

See Also:
checkSections, processRequirements for parameters.

checkRequirementIndex(inspector, requirement, document, results)

source code 

Checks if index is found in the document. If index is correctly made, checks the index content.

See Also: processRequirements for parameters.

inspect(documentFile, requirements, fileExtension)

source code 

Inspects a document by the given file extension which is either odt or docx.

Parameters:
  • documentFile - docx or odt file.
  • requirements - the requirements specified in the XML requirement file.
  • fileExtension - docx or odt file.

Variables Details [hide private]

inspectorDict

Value:
{'docm': <module 'src.inspectors.docx_inspector' from '/home/olkauppi/\
Desktop/parsi-project-parsi/parsi-project-parsi/src/inspectors/docx_in\
spector.pyc'>,
 'docx': <module 'src.inspectors.docx_inspector' from '/home/olkauppi/\
Desktop/parsi-project-parsi/parsi-project-parsi/src/inspectors/docx_in\
spector.pyc'>,
 'odt': <module 'src.inspectors.odt_inspector' from '/home/olkauppi/De\
sktop/parsi-project-parsi/parsi-project-parsi/src/inspectors/odt_inspe\
...

_checkers

Value:
{'Styles': checkRequirementStyles, 'TOC': checkRequirementTOC, 'Image'\
: checkRequirementImages, 'CoverPage': checkRequirementCoverPage, 'Pag\
eSize': checkRequirementPageSize, 'Margins': checkRequirementMargins, \
'EndNoteFootNote': checkRequirementEndNoteFootNote, 'HeadingNumbering'\
: checkRequirementHeadingNumbering, 'EmptyParagraphs': checkRequiremen\
tEmptyParagraphs, 'CheckSections': checkRequirementSections, 'List': c\
heckRequirementList, 'StyleUsage': checkRequirementStyleUsage, 'Tabs':\
 checkRequirementTabs, 'DoubleWhitespaces': checkRequirementDoubleWhit\
...