Browse DevX
Sign up for e-mail newsletters from DevX


Python Boosts JAR File Auditor Functionality : Page 4

A Python port of a Java jar file auditor is cleaner in its implementation and more complete in its auditing capabilities. This article presents the Python port, discusses its advantages, and highlights some of the great Python features that allow you to produce robust functionality with minimal code.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

XSL Stylesheets Dress Up the Output
As I mentioned previously, using Python's print statement in conjunction with simple command-line redirection makes it easy to send the output XML document to wherever you'd like. Unfortunately, the following generic XML output is rather tough to read because the tags that the XML binding library implemented aren't specifically named to correspond to the individual data elements in the dictionaries:

<entry> <key type="string" value="FileScanner.class" /> <val type="tuple" > <item type="string" value="C:\\Ant1.5\\lib\\ant.jar" /> <item type="string" value="org/apache/tools/ant" /> <item type="string" value="7/9/2002" /> </val> </entry>

Fear not, this can be overcome. An XSL stylesheet can format the raw output into tables. The tables (see Figure 1) may not be works of art, but they are easier to read than the raw XML. I'll leave it to you to enhance the look and feel as you see fit.

Figure 1: XSL Stylesheet Formats Raw Output into Tables

Powerful Apps, Minimal Code
Python's powerful libraries and minimalist syntax allow you to write readable, high- octane applications in fewer lines of code than with Java. In this case, the Python port of the auditor takes full advantage of the following features to deliver more robust functionality in far fewer lines of code than the Java auditor did:

  • Python's flexible data structures make it easy to create complex data relationships.
  • Python is an object-oriented language, so you can make use of cutting edge XML binding technology to reduce the coding time and effort it takes to produce XML data tailored to meet your needs.
  • A wealth of open-source code libraries are available to help bolster Python's out-of-the-box offerings.

  • Doug Tillman is a senior Java developer at the FindMRO business unit of W.W. Grainger. He recently designed a distributed RMI search application and set up the Java- and Jython-driven open source load testing tool, the Grinder.
    Thanks for your registration, follow us on our social networks to keep up-to-date