Commit aa11e808 authored by Henri Payno's avatar Henri Payno
Browse files

PEP8

parent e4cf2f9f
Pipeline #64515 passed with stages
in 6 minutes and 21 seconds
......@@ -36,15 +36,14 @@ __date__ = "04/01/2018"
import logging
logging.basicConfig()
import sys
from silx.utils.launcher import Launcher as _Launcher
import nxtomomill.version
from collections import namedtuple
import traceback
logging.basicConfig()
DeprecationWarning = namedtuple(
"DeprecationWarning", ["since", "reason", "replacement"]
......
......@@ -38,7 +38,6 @@ import tempfile
from nxtomomill.test.utils.dxfile import MockDxFile
from nxtomomill.app.dxfile2nx import main
import os
import subprocess
def test_dxfile2nx_application():
......@@ -50,7 +49,7 @@ def test_dxfile2nx_application():
n_darks = 2
n_flats = 4
mock = MockDxFile(
MockDxFile(
file_path=dx_file_path,
n_projection=n_projections,
n_darks=n_darks,
......
......@@ -38,7 +38,6 @@ import tempfile
from tomoscan.esrf.mock import MockEDF
from nxtomomill.app.edf2nx import main
import os
import subprocess
def test_edf2nx_application():
......
......@@ -38,7 +38,6 @@ import tempfile
from nxtomomill.test.utils.bliss import MockBlissAcquisition
from nxtomomill.app.h52nx import main
import os
import subprocess
def test_h52nx_application():
......
......@@ -37,9 +37,7 @@ __date__ = "30/08/2021"
import tempfile
from tomoscan.esrf.mock import MockHDF5
from nxtomomill.app.patch_nx import main
import h5py
import os
import subprocess
def test_patch_nx_application():
......
from .edf.edfconverter import edf_to_nx
from .hdf5.hdf5converter import from_h5_to_nx
from .hdf5.hdf5converter import h5_to_nx
from .hdf5.hdf5converter import get_bliss_tomo_entries
from .edf.edfconverter import EDFFileKeys
from .dxfile.dxfileconverter import from_dx_to_nx
from .edf.edfconverter import edf_to_nx # noqa F401
from .hdf5.hdf5converter import from_h5_to_nx # noqa F401
from .hdf5.hdf5converter import h5_to_nx # noqa F401
from .hdf5.hdf5converter import get_bliss_tomo_entries # noqa F401
from .edf.edfconverter import EDFFileKeys # noqa F401
from .dxfile.dxfileconverter import from_dx_to_nx # noqa F401
......@@ -31,4 +31,4 @@ __authors__ = ["H. Payno"]
__date__ = "07/06/2020"
__license__ = "MIT"
from .dxfileconverter import from_dx_to_nx
from .dxfileconverter import from_dx_to_nx # noqa F401
......@@ -329,7 +329,7 @@ class _DxFileToNxConverter(BaseConverter):
if self.energy is None:
try:
self._configuration.energy = self._read_energy()
except Exception as e:
except Exception:
self._configuration.energy = None
if self.energy is None:
self._configuration.energy = self.DEFAULT_BEAM_ENERGY
......@@ -552,7 +552,7 @@ class _DxFileToNxConverter(BaseConverter):
where="end",
logger=_logger,
).process()
except Exception as e:
except Exception:
_logger.warning(
"No projections found in {} or unable to add them to the dataset".format(
self._data_proj_url.path()
......
......@@ -46,10 +46,10 @@ from nxtomomill.settings import Tomo
from tomoscan.esrf.edfscan import EDFTomoScan
from tomoscan.unitsystem import metricsystem
from tomoscan.io import HDF5File
import datetime
import fabio
import numpy
import os
import logging
EDF_MOTOR_POS = Tomo.EDF.MOTOR_POS
EDF_MOTOR_MNE = Tomo.EDF.MOTOR_MNE
......@@ -61,8 +61,6 @@ EDF_X_TRANS = Tomo.EDF.X_TRANS
EDF_Y_TRANS = Tomo.EDF.Y_TRANS
EDF_Z_TRANS = Tomo.EDF.Z_TRANS
import logging
_logger = logging.getLogger(__name__)
......@@ -181,7 +179,7 @@ def edf_to_nx(
.split(" ")
.index(file_keys.rot_angle_key)
)
except:
except (KeyError, ValueError):
rotangle_index = -1
try:
xtrans_index = (
......@@ -189,7 +187,7 @@ def edf_to_nx(
.split(" ")
.index(file_keys.x_trans_key)
)
except:
except (KeyError, ValueError):
xtrans_index = -1
try:
ytrans_index = (
......@@ -197,7 +195,7 @@ def edf_to_nx(
.split(" ")
.index(file_keys.y_trans_key)
)
except:
except (KeyError, ValueError):
ytrans_index = -1
try:
ztrans_index = (
......@@ -205,7 +203,7 @@ def edf_to_nx(
.split(" ")
.index(file_keys.z_trans_key)
)
except:
except (KeyError, ValueError):
ztrans_index = -1
if hasattr(fid, "bytecode"):
......@@ -248,7 +246,7 @@ def edf_to_nx(
if sample_name is None:
try:
sample_name = os.path.abspath(scan.path).split(os.sep)[-3:]
except:
except Exception:
sample_name = "unknow"
h5d["/entry/sample/name"] = sample_name
if instrument_name is not None:
......@@ -363,7 +361,7 @@ def edf_to_nx(
else:
data = fabio_file.getframe(index).data
header = fabio_file.getframe(index).header
except Exception as e:
except Exception:
data = None
header = None
finally:
......@@ -614,7 +612,7 @@ def edf_to_nx(
# create beam group at root for compatibility
try:
link_nxbeam_to_root(file_path=output_file, entry_path="entry")
except Exception as e:
except Exception:
pass
return fileout_h5, "entry"
......@@ -28,7 +28,6 @@ __license__ = "MIT"
__date__ = "09/10/2020"
import shutil
import tempfile
import os
from nxtomomill import converter
......@@ -52,7 +51,7 @@ def test_edf_to_nx_converter(progress):
n_proj = 120
n_alignment_proj = 5
dim = 100
mock = MockEDF(
MockEDF(
scan_path=scan_path,
n_radio=n_proj,
n_ini_radio=n_proj,
......
......@@ -36,7 +36,7 @@ __date__ = "27/11/2020"
import h5py
try:
import hdf5plugin
import hdf5plugin # noqa F401
except ImportError:
pass
from nxtomomill.plugins import (
......@@ -525,7 +525,7 @@ class BaseAcquisition:
info_retrieve=resource_name,
expected_unit=None,
)
except (ValueError, KeyError) as e:
except (ValueError, KeyError):
pass
else:
return values, None
......
......@@ -52,7 +52,7 @@ from silx.io.url import DataUrl
from typing import Union
try:
import hdf5plugin
import hdf5plugin # noqa F401
except ImportError:
pass
import logging
......
......@@ -37,7 +37,7 @@ import typing
import h5py
try:
import hdf5plugin
import hdf5plugin # noqa F401
except ImportError:
pass
import logging
......@@ -84,7 +84,7 @@ def get_entry_type(
try:
title = h5py_read_dataset(entry["title"])
except Exception as e:
except Exception:
_logger.error("fail to find title for %s, skip this group" % entry.name)
else:
init_titles = list(configuration.init_titles)
......
......@@ -42,7 +42,7 @@ import h5py
from silx.io.url import DataUrl
try:
import hdf5plugin
import hdf5plugin # noqa F401
except ImportError:
pass
import logging
......@@ -137,4 +137,4 @@ class XRDCTAcquisition(StandardAcquisition):
def _write_beam(self, root_node, request_input, input_callback):
instrument_node = root_node.require_group("instrument")
beam_node = instrument_node.require_group("beam")
instrument_node.require_group("beam")
......@@ -46,7 +46,7 @@ import h5py
from silx.io.url import DataUrl
try:
import hdf5plugin
import hdf5plugin # noqa F401
except ImportError:
pass
......@@ -59,7 +59,7 @@ def is_z_series_frm_titles(entry: h5py.Group, configuration: TomoHDF5Config) ->
"""
try:
title = h5py_read_dataset(entry["title"])
except Exception as e:
except Exception:
return False
else:
return title in configuration.zserie_init_titles
......
......@@ -60,10 +60,10 @@ import os
import h5py
try:
import hdf5plugin
import hdf5plugin # noqa F401
except ImportError:
pass
## import that should be removed when h5_to_nx will be removed
# import that should be removed when h5_to_nx will be removed
from nxtomomill.converter.hdf5.utils import H5FileKeys
from nxtomomill.converter.hdf5.utils import H5ScanTitles
......
from .config import *
from .config import * # noqa F401,F403
......@@ -22,7 +22,7 @@
# THE SOFTWARE.
#
#
# ###########################################################################*/
# ###########################################################################
"""
contains the HDF5Config
......@@ -1099,7 +1099,7 @@ class TomoHDF5Config:
]
flat_titles_dks.extend(TomoHDF5Config.FLAT_TILES_ALIASES)
flat_title_key_picked = None
## handle flat titles
# handle flat titles
for alias in flat_titles_dks:
flat_titles = dict_.get(alias, None)
if flat_titles is not None:
......
......@@ -107,8 +107,6 @@ class FrameGroup:
@url.setter
def url(self, url: Union[DataUrl, str]):
if isinstance(url, str):
from nxtomomill.io.utils import is_url_path
# handle if the string path is not a "full url" then we consider
# this is only the data path.
self._url = DataUrl(path=url)
......@@ -200,7 +198,7 @@ class FrameGroup:
urls_str = ",\n".join(["{}".format(str(url)) for url in urls])
return """(
{}
)
)
""".format(
urls_str
)
......@@ -211,7 +209,7 @@ class FrameGroup:
Create an instance of FrameGroup from it string representation.
"""
if not isinstance(input_str, str):
raise TypeError("input_str should be a string".format(input_str))
raise TypeError(f"{input_str} should be a string")
from nxtomomill.io.utils import (
remove_parenthesis_or_brackets,
......@@ -333,7 +331,7 @@ def filter_acqui_frame_type(
frame_types = frame_types[current_acqui_idx + 1 :]
try:
next_acqui = frame_types.index(AcquisitionStep.INITIALIZATION) - 1
except ValueError as e:
except ValueError:
next_acqui = -1
sequence_target = sequence_target[:next_acqui]
filter_fct = lambda a: a.frame_type is frame_type
......
......@@ -31,7 +31,7 @@ __date__ = "23/02/2021"
import unittest
import shutil
import tempfile
from nxtomomill.io.config import TomoHDF5Config, generate_default_h5_config
from nxtomomill.io.config import TomoHDF5Config
from nxtomomill import settings
import os
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment