diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index bffc1f742d6a2f814caced77931bef5b60df3428..265ab3c0c5ee37d66798d43936537cc24efad94e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,6 +1,6 @@ function(install_python_package curdir packagelist) message(STATUS "Installing python package dorie.${curdir}") - dune_install_python_package(PATH ${curdir} ADDITIONAL_PIP_PARAMS "-r ${CMAKE_CURRENT_SOURCE_DIR}/${curdir}/requirements.txt -q") + dune_install_python_package(PATH ${curdir} ADDITIONAL_PIP_PARAMS -r ${CMAKE_CURRENT_SOURCE_DIR}/${curdir}/requirements.txt -q) set(${packagelist} ${${packagelist}} ${CMAKE_CURRENT_SOURCE_DIR}/${curdir} PARENT_SCOPE) endfunction() diff --git a/python/parscraper/dorie/parscraper/match_parameters.py b/python/parscraper/dorie/parscraper/match_parameters.py index 487c867e18654674fddd9efd1381b22b3ac38324..2ec84c88dac95eb5c113e1236bbdae12202305e0 100644 --- a/python/parscraper/dorie/parscraper/match_parameters.py +++ b/python/parscraper/dorie/parscraper/match_parameters.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import os from warnings import warn diff --git a/python/parscraper/dorie/parscraper/readers/xml.py b/python/parscraper/dorie/parscraper/readers/xml.py index cce02d2f2e3344a50496d028ceeb96108d7473f4..b0a6d428ceb07c91b58b143b4fe347d6cdb590b6 100644 --- a/python/parscraper/dorie/parscraper/readers/xml.py +++ b/python/parscraper/dorie/parscraper/readers/xml.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import xml.etree.ElementTree as ET from warnings import warn from collections import OrderedDict diff --git a/python/parscraper/dorie/parscraper/wrapper/__init__.py b/python/parscraper/dorie/parscraper/wrapper/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/python/parscraper/dorie/parscraper/wrapper/scrape_folder.py b/python/parscraper/dorie/parscraper/wrapper/scrape_folder.py index d6ee944fe9ea61cbf06111d337fbe6113b0254d4..96283d00587909f5d1b78ee818b013cf948ba4e0 100644 --- a/python/parscraper/dorie/parscraper/wrapper/scrape_folder.py +++ b/python/parscraper/dorie/parscraper/wrapper/scrape_folder.py @@ -2,6 +2,7 @@ import os import sys import warnings import argparse +import traceback from dorie.parscraper import readers, writers, match_parameters from dorie.parscraper.warnings import OutputWarning @@ -45,6 +46,9 @@ def scrape(xml_file,source_folder,out,css=None,debug=False): raise else: warnings.warn("Output failed for file {0} with error:\n{1}".format(o,repr(e)), OutputWarning) + if debug: + exc_type, exc_value, exc_traceback = sys.exc_info() + traceback.print_exception(exc_type, exc_value, exc_traceback) else: warnings.warn("Unknown output format: .{}. Skipping output".format(file_suffix), OutputWarning) diff --git a/python/parscraper/dorie/parscraper/writers/html.py b/python/parscraper/dorie/parscraper/writers/html.py index 3094058beb36719e423b98745e8c4ae34ffa90e1..ad2ce6af976f9c49020d70bf2ecef6a5cd667151 100644 --- a/python/parscraper/dorie/parscraper/writers/html.py +++ b/python/parscraper/dorie/parscraper/writers/html.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import datetime import os import re diff --git a/python/parscraper/dorie/parscraper/writers/ini.py b/python/parscraper/dorie/parscraper/writers/ini.py index cb7e5ffeb699ef1c89fb7c19a3ebef8147bbb066..fdc9ad8d530defd88186a0b8028fab2ff58b3858 100644 --- a/python/parscraper/dorie/parscraper/writers/ini.py +++ b/python/parscraper/dorie/parscraper/writers/ini.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import datetime import os import re diff --git a/python/parscraper/dorie/parscraper/writers/rst.py b/python/parscraper/dorie/parscraper/writers/rst.py index 8cc680ded9175011470580ea14f308fd022a01ee..0afd0b6b839e347e99ecb85fd1a1284057cdbf09 100644 --- a/python/parscraper/dorie/parscraper/writers/rst.py +++ b/python/parscraper/dorie/parscraper/writers/rst.py @@ -1,7 +1,14 @@ +from __future__ import unicode_literals + import datetime import os import re +try: + str = unicode +except NameError: + pass + from dorie.utilities.check_path import check_path from dorie.parscraper.parameter import Parameter @@ -35,10 +42,10 @@ def write(parameters,out,path_base,*args,**kwargs): check_path(out) with open(out,"w") as output: rst_document = _format_rst(parameters, headings, widths, table_content) - output.write(rst_document) + output.write(rst_document.encode('utf-8')) def _format_rst(parameters,headers,widths,content_function): - rst = "" + rst = u"" for category in parameters: rst += _format_heading(category) table_content = [content_function(p) for p in parameters[category]] @@ -49,7 +56,7 @@ def _format_table(content,headers,widths): tab = " " delimiter = "," - table = "" + table = u"" table += ".. csv-table::\n" table += tab + ":header: {}\n".format(", ".join(headers)) table += tab + ":delim: {}\n".format(delimiter) @@ -72,15 +79,6 @@ def _format_heading(text): sep = "+"*len(text) return text + "\n" + sep + "\n\n" -def _format_footer(): - # UNUSED - tab = " " - footer = "" - footer += ".. class:: center" - footer += tab + "Automatically created by the :mod:`DORiE parameter scraper `\n\n" - footer += tab + "{0:%d-%m-%Y, %H:%M}".format(datetime.datetime.today()) - return footer - def _sources(p,path_base): """ Assembles the cell text for the sources of a parameter. Since the diff --git a/python/parscraper/wrapper/scrape_folder.py b/python/parscraper/wrapper/scrape_folder.py index c3422830fff9e9d9b5a6e0f923911c584923efe1..0a9e45222ff51fb4d556c74fe6c369da4caf3b8d 100644 --- a/python/parscraper/wrapper/scrape_folder.py +++ b/python/parscraper/wrapper/scrape_folder.py @@ -9,7 +9,7 @@ Script invoking the parameter scraper on a folder given via command line. """ if __name__ == "__main__": - try: # catch all exceptions we we can output an error message + try: # catch all exceptions so we can output an error message with warnings.catch_warnings(record=True) as warn: # catch all warnings so we can count them # PARSE COMMAND LINE parser = argparse.ArgumentParser()