neverrend / XMLChecker

Cyber Ninjas XML Checker
GNU General Public License v3.0
1 stars 0 forks source link

File Error and Path Checking #10

Closed neverrend closed 4 years ago

neverrend commented 5 years ago

The script doesn't have any decent file path checking or file error checking to prevent it from blowing up when it can't read the file ingested by it or from a bad path misspelling.

$ XMLCheck.py xl.xml
Traceback (most recent call last):
  File "C:\Users\name\Documents\python\XMLChecker\XMLCheck.py", line 191, in <module>
    main()
  File "C:\Users\name\Documents\python\XMLChecker\XMLCheck.py", line 179, in main
    et = parse(xmlFile)
  File "C:\Users\name\AppData\Local\Programs\Python\Python37-32\lib\site-packages\defusedxml\common.py", line 105, in parse
    return _parse(source, parser)
  File "C:\Users\name\AppData\Local\Programs\Python\Python37-32\lib\xml\etree\ElementTree.py", line 1197, in parse
    tree.parse(source, parser)
  File "C:\Users\name\AppData\Local\Programs\Python\Python37-32\lib\xml\etree\ElementTree.py", line 587, in parse
    source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'xl.xml'
neverrend commented 4 years ago

Fixed in c357727 commit.