Commit 99baef6b authored by payno's avatar payno Committed by payno
Browse files

reformat files using black

parent 0566a1d8
......@@ -16,7 +16,7 @@
import sys
import os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ext'))
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "ext"))
# If extensions (or modules to document with autodoc) are in another directory,
......@@ -27,44 +27,41 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ext'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'nbsphinx',
]
extensions = ["sphinx.ext.autodoc", "nbsphinx"]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates']
templates_path = ["templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.md']
#source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
source_suffix = [".rst", ".md"]
# source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# General information about the project.
project = 'est'
copyright = '2016-2019, ESRF'
author = 'ESRF'
project = "est"
copyright = "2016-2019, ESRF"
author = "ESRF"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.3'
version = "0.3"
# The full version, including alpha/beta/rc tags.
release = '0.3'
release = "0.3"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -75,37 +72,37 @@ language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['build']
exclude_patterns = ["build"]
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
......@@ -115,22 +112,22 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'nature'
html_theme = "nature"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
......@@ -139,7 +136,7 @@ html_logo = "img/icon_medium.svg"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
......@@ -149,119 +146,110 @@ html_logo = "img/icon_medium.svg"
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
#html_search_language = 'en'
# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'est'
htmlhelp_basename = "est"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'est', 'est Documentation',
[author], 1)
]
man_pages = [(master_doc, "est", "est Documentation", [author], 1)]
htmlhelp_pages = [
(master_doc, 'est', 'est Add-on Documentation',
[author], 1)
]
htmlhelp_pages = [(master_doc, "est", "est Add-on Documentation", [author], 1)]
# If true, show URL addresses after external links.
#man_show_urls = False
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
......@@ -270,19 +258,25 @@ htmlhelp_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'est', 'est Documentation',
author, 'est', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"est",
"est Documentation",
author,
"est",
"One line description of project.",
"Miscellaneous",
)
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# texinfo_no_detailmenu = False
......@@ -36,12 +36,15 @@ __date__ = "06/12/2019"
import logging
logging.basicConfig()
import sys
from silx.utils.launcher import Launcher
try:
import est._version
import_version = True
except ImportError:
import_version = False
......@@ -57,20 +60,21 @@ def main():
:returns: The execution status
"""
if import_version is False:
_version = '???'
_version = "???"
else:
_version = est._version.version
launcher = Launcher(prog="est", version=_version)
launcher.add_command("canvas",
module_name="est.app.canvas",
description="open the orange-canvas")
launcher.add_command("process",
module_name="est.app.process",
description="process a workflow from a .xml.ows file"
"description")
launcher.add_command("test",
module_name="est.app.test_",
description="Launch est unittest")
launcher.add_command(
"canvas", module_name="est.app.canvas", description="open the orange-canvas"
)
launcher.add_command(
"process",
module_name="est.app.process",
description="process a workflow from a .xml.ows file" "description",
)
launcher.add_command(
"test", module_name="est.app.test_", description="Launch est unittest"
)
status = launcher.execute(sys.argv)
return status
......
from .launcher import Launcher
\ No newline at end of file
from .launcher import Launcher
......@@ -20,9 +20,7 @@ class EstConfig(config.Config):
@staticmethod
def core_packages():
return super(EstConfig, EstConfig).core_packages() + [
"est-add-on",
]
return super(EstConfig, EstConfig).core_packages() + ["est-add-on"]
@staticmethod
def application_icon():
......@@ -31,16 +29,26 @@ class EstConfig(config.Config):
class EstSplashScreen(qt.QSplashScreen):
"""SplashScreen to overwrite the one of Orange"""
def __init__(self, parent=None, pixmap=None, textRect=None,
textFormat=qt.Qt.PlainText, **kwargs):
def __init__(
self,
parent=None,
pixmap=None,
textRect=None,
textFormat=qt.Qt.PlainText,
**kwargs
):
qt.QSplashScreen.__init__(self, parent, pixmap=pixmap, **kwargs)
def showMessage(self, message, alignment=qt.Qt.AlignLeft, color=qt.Qt.black):
super().showMessage(version(), qt.Qt.AlignCenter | qt.Qt.AlignBottom, qt.QColor("#e68f17"))
super().showMessage(
version(), qt.Qt.AlignCenter | qt.Qt.AlignBottom, qt.QColor("#e68f17")
)
class Launcher:
"""Proxy to orange-canvas"""
def launch(self, argv):
config.Config = EstConfig
self.fix_application_dirs()
......@@ -91,4 +99,5 @@ class Launcher:
def main(self, argv):
from Orange.canvas.__main__ import main
main(argv)
......@@ -11,7 +11,7 @@ def splash_screen():
note: QRect is used by orange to define a mask to display the message.
In our case we overwrite the QSplashScreen so we don't need this.
"""
pixmap = icons.getQPixmap('est')
pixmap = icons.getQPixmap("est")
return pixmap, qt.QRect(0, 0, 0, 0)
......@@ -21,5 +21,5 @@ def getIcon():
:return: application icon
:rtype: QIcon
"""
pixmap = icons.getQPixmap('est')
pixmap = icons.getQPixmap("est")
return qt.QIcon(pixmap)
......@@ -2,8 +2,10 @@ import argparse
import sys
from ..pushworkflow.scheme.parser import scheme_load
import logging
try:
import h5py
has_h5py = True
except:
has_h5py = False
......@@ -17,23 +19,24 @@ def exec_(scheme, input_=None, output_=None):
if input_:
# monkey patch the input file for start nodes if an input is given
for node in scheme.nodes:
if node.properties and '_input_file_setting' in node.properties:
node.properties['_input_file_setting'] = input_
if node.properties and "_input_file_setting" in node.properties:
node.properties["_input_file_setting"] = input_
manage_input()
def manage_output():
if output_:
# monkey patch the input file for start nodes if an input is given
for node in scheme.nodes:
if node.properties and '_output_file_setting' in node.properties:
node.properties['_output_file_setting'] = output_
if node.properties and "_output_file_setting" in node.properties:
node.properties["_output_file_setting"] = output_
# TODO: if the input file contains configuration, then overwrite the node
# properties...
manage_output()
if len(scheme._start_actor.listDownStreamActor) is 0:
_logger.warning('no downstream node defined')
_logger.warning("no downstream node defined")
return None
scheme._start_actor.trigger(input_)
scheme._end_actor.join()
......@@ -51,18 +54,27 @@ def getInputFrmHdf5(file_path):
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'workflow_file',
help='Workflow file providing the workflow description (.ows, .xml)')
parser.add_argument("-i", dest="input_", default=None,
help="Input of the workflow. require at most one "
"instance of XASInputOW")
parser.add_argument("-o", dest="output_", default=None,
help="Output file of the workflow. Require at most one "
"instance of XASOutputOW")
"workflow_file",
help="Workflow file providing the workflow description (.ows, .xml)",
)
parser.add_argument(
"-i",
dest="input_",
default=None,
help="Input of the workflow. require at most one " "instance of XASInputOW",
)
parser.add_argument(
"-o",
dest="output_",
default=None,
help="Output file of the workflow. Require at most one "
"instance of XASOutputOW",
)
options = parser.parse_args(argv[1:])
scheme = scheme_load(_file=options.workflow_file)
exec_(scheme, options.input_, options.output_)
if __name__ == "__main__":
main(sys.argv)
......@@ -3,8 +3,10 @@ import sys
import logging
from est.core.types import XASObject
from est.core.reprocessing import get_process_instance_frm_h5_desc
try:
import h5py
has_h5py = True
except:
has_h5py = False
......@@ -13,26 +15,29 @@ logging.basicConfig(level=logging.DEBUG)
_logger = logging.getLogger(__name__)
def exec_(h5_file, entry='scan1', spectra_path=None, energy_path=None,
configuration_path=None):
def exec_(
h5_file, entry="scan1", spectra_path=None, energy_path=None, configuration_path=None
):
try:
xas_obj = XASObject.from_file(h5_file=h5_file,
entry=entry or 'scan1',
spectra_path=spectra_path or 'data/absorbed_beam',
energy_path=energy_path or 'data/energy',
configuration_path=configuration_path)
xas_obj = XASObject.from_file(
h5_file=h5_file,
entry=entry or "scan1",
spectra_path=spectra_path or "data/absorbed_beam",
energy_path=energy_path or "data/energy",
configuration_path=configuration_path,
)
xas_obj.link_to_h5(h5_file=h5_file)
except Exception as e:
_logger.error(e)
xas_obj = None
if not xas_obj:
_logger.error('Unable to create an object from the given file and path')
_logger.error("Unable to create an object from the given file and path")
xas_processes = xas_obj.get_process_flow()
if len(xas_processes) == 0:
_logger.warning('no xas process found in the given h5 file')
_logger.warning("no xas process found in the given h5 file")
return
xas_obj.clean_process_flow()
for i_process, process in xas_processes.items():
......@@ -53,21 +58,39 @@ def getInputFrmHdf5(file_path):
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'workflow_file',
help='Workflow file providing the workflow description (.h5)')
parser.add_argument("--spectra_path", dest="spectra_path", default=None,
help="path to the spectra data")
parser.add_argument("--energy_path", dest="energy_path", default=None,
help="path to the energy data")
parser.add_argument("--configuration_path", dest="configuration_path", default=None,
help="path to the process configuration")
parser.add_argument("--entry", dest="entry to load",
default=None,
help="path to the process configuration")
"workflow_file", help="Workflow file providing the workflow description (.h5)"
)
parser.add_argument(
"--spectra_path",
dest="spectra_path",
default=None,
help="path to the spectra data",
)
parser.add_argument(
"--energy_path",
dest="energy_path",
default=None,
help="path to the energy data",
)
parser.add_argument(
"--configuration_path",
dest="configuration_path",
default=None,
help="path to the process configuration",
)
parser.add_argument(
"--entry",
dest="entry to load",
default=None,
help="path to the process configuration",
)
options = parser.parse_args(argv[1:])
exec_(h5_file=options.workflow_file, spectra_path=options.spectra_path,
energy_path=options.energy_path,
configuration_path=options.configuration_path)
exec_(
h5_file=options.workflow_file,
spectra_path=options.spectra_path,
energy_path=options.energy_path,
configuration_path=options.configuration_path,
)
if __name__ == "__main__":
......
......@@ -34,6 +34,7 @@ from est.core.utils import DownloadDataset
from ...pushworkflow.scheme.parser import scheme_load
from ..process import exec_