eTechtips

Tech Tips and Insights

Category: Scripting

  • Perl: Missing ParserDetails.ini

    I have some scripts that were giving me the following message:
    could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.10/XML/SAX

    The way that I worked around this message was to create the ParserDetails.ini file in the /usr/lib/perl5/vendor_perl/5.10/XML/SAX directory with the following contents.

    [XML::SAX::PurePerl]
    http://xml.org/sax/features/namespaces = 1
    
    2 Comments
  • Python: AttributeError: ‘getopt’ module has no attribute ‘GetoptError’

    So I was figuring out how to parse command line arguments with python and using the getopt module with the following code

    
    #!/usr/bin/env python
    import sys
    import getopt
    
    def main(argv):
       infile = "some.xml"
       try:
          opts,args = getopt.getopt(argv,"hi:d",["help","infile="]
       except getopt.GetoptError:
          usage()
          sys.exit(2)
    
    if __name__ == "__main__":
        main(sys.argv[1:])
    

    And I was getting the following error:

    AttributeError: ‘getopt’ module has no attribute ‘GetoptError’

    So my first problem was that I had named my script getopt.py and after renaming the script, I got the same error. Well you now need to remove the getopt.pyc file that was generated from your earlier running of the poorly named script.

    4 Comments