From 2fb86dfbf7402e8308f3e634f4d8bf43a9b6d93b Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Mon, 18 May 2020 17:38:25 +0200
Subject: [PATCH] DataQuality: Move flake8 checking to build stage

Move the flake8 checking to the build stage. Use the
`--extend-select`/`--extend-ignore` to modify the default `ATLAS_FLAKE8`
options instead of overwriting them entirely.
---
 DataQuality/DQDefects/CMakeLists.txt                     | 9 +++------
 DataQuality/DQUtils/CMakeLists.txt                       | 9 +++------
 DataQuality/DQUtils/python/ext/table_printer.py          | 1 +
 DataQuality/DataQualityUtils/CMakeLists.txt              | 9 +++------
 DataQuality/DataQualityUtils/python/DQGetHistogramMod.py | 4 ++--
 5 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/DataQuality/DQDefects/CMakeLists.txt b/DataQuality/DQDefects/CMakeLists.txt
index fd8bd936d56..78af5128d1f 100644
--- a/DataQuality/DQDefects/CMakeLists.txt
+++ b/DataQuality/DQDefects/CMakeLists.txt
@@ -14,15 +14,12 @@ find_package( Oracle )
 find_package( pyyaml )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py python/tests python/data )
+atlas_install_python_modules( python/*.py python/tests python/data
+   POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-select E11,E402,W1 )
+
 atlas_install_scripts( share/*.py share/*.sh )
 
 # Add tests
 atlas_add_test( DQDefects SCRIPT test/DQDefects_test.sh
                 LOG_IGNORE_PATTERN "^Ran .* tests in"
                 PROPERTIES TIMEOUT 300 )
-		
-# Code quality check
-atlas_add_test( flake8
-   SCRIPT flake8 --select=ATL,E11,E402,E71,E72,E9,W1,W6,F ${CMAKE_CURRENT_SOURCE_DIR}/python/
-   POST_EXEC_SCRIPT nopost.sh )
diff --git a/DataQuality/DQUtils/CMakeLists.txt b/DataQuality/DQUtils/CMakeLists.txt
index 611fb0d9a2f..5ffbd7d58b0 100644
--- a/DataQuality/DQUtils/CMakeLists.txt
+++ b/DataQuality/DQUtils/CMakeLists.txt
@@ -39,10 +39,7 @@ atlas_add_dictionary( DQUtilsDict
                       LINK_LIBRARIES ${ORACLE_LIBRARIES} ${Boost_LIBRARIES} ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${Python_LIBRARIES} ${CORAL_LIBRARIES} CoraCool DQUtils )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py python/ext python/sugar )
-atlas_install_scripts( share/count_filled_lbs.py share/dqu_grldiff.py share/dqu_lumi.py share/dqu_grl_extract_period.py share/dqu_dump_periods.py )
+atlas_install_python_modules( python/*.py python/ext python/sugar
+   POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-select E11,E402,W1 --extend-ignore E731 )
 
-# Code quality check
-atlas_add_test( flake8
-   SCRIPT flake8 --select=ATL,E11,E402,E71,E72,E9,W1,W6,F ${CMAKE_CURRENT_SOURCE_DIR}/python/
-   POST_EXEC_SCRIPT nopost.sh )
+atlas_install_scripts( share/count_filled_lbs.py share/dqu_grldiff.py share/dqu_lumi.py share/dqu_grl_extract_period.py share/dqu_dump_periods.py )
diff --git a/DataQuality/DQUtils/python/ext/table_printer.py b/DataQuality/DQUtils/python/ext/table_printer.py
index 9b160519045..4fe8bfb5c56 100644
--- a/DataQuality/DQUtils/python/ext/table_printer.py
+++ b/DataQuality/DQUtils/python/ext/table_printer.py
@@ -1,3 +1,4 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 #coding: UTF8
 """
 Prints out a table, padded to make it pretty.
diff --git a/DataQuality/DataQualityUtils/CMakeLists.txt b/DataQuality/DataQualityUtils/CMakeLists.txt
index 0d9432883b4..de9d784c782 100644
--- a/DataQuality/DataQualityUtils/CMakeLists.txt
+++ b/DataQuality/DataQualityUtils/CMakeLists.txt
@@ -80,7 +80,9 @@ atlas_add_executable( han-results-print
                       LINK_LIBRARIES ${Boost_LIBRARIES} ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} DataQualityInterfaces DataQualityUtils )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py
+   POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-select E11,E402,W1 --extend-ignore E731 )
+
 atlas_install_scripts( scripts/CreateDB.py scripts/CreateDB_Histo.py scripts/DQHistogramMerge.py scripts/DQHistogramPrintStatistics.py scripts/DQWebDisplay.py scripts/hancool_histo.py scripts/hancool.py scripts/handi.py scripts/DQFileMove.py scripts/CreateMDTConfig_algos.sh scripts/CreateMDTConfig_chambers.sh scripts/CreateMDTConfig_config.sh scripts/CreateMDTConfig_files.sh scripts/CreateMDTConfig_readme.sh scripts/DQM_Tier0Wrapper_trf.py scripts/DQM_Tier0Wrapper_tf.py scripts/DQHistogramMergeRegExp.py scripts/dq_make_web_display.py scripts/ScanHistFile.py scripts/physval_make_web_display.py )
 
 # Aliases:
@@ -96,8 +98,3 @@ atlas_add_alias( CreateMDTConfig_readme "CreateMDTConfig_readme.sh" )
 atlas_add_alias( DQHistogramMerge "DQHistogramMerge.py" )
 atlas_add_alias( DQWebDisplay "DQWebDisplay.py" )
 atlas_add_alias( CreateMDTConfig_chambers "CreateMDTConfig_chambers.sh" )
-
-# Code quality check
-atlas_add_test( flake8
-   SCRIPT flake8 --select=ATL,E11,E402,E71,E72,E9,W1,W6,F ${CMAKE_CURRENT_SOURCE_DIR}/python/
-   POST_EXEC_SCRIPT nopost.sh )
diff --git a/DataQuality/DataQualityUtils/python/DQGetHistogramMod.py b/DataQuality/DataQualityUtils/python/DQGetHistogramMod.py
index 6b0e2c8a752..3882bb9a9fd 100644
--- a/DataQuality/DataQualityUtils/python/DQGetHistogramMod.py
+++ b/DataQuality/DataQualityUtils/python/DQGetHistogramMod.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 
 # +---------------------------------------------+
@@ -36,7 +36,7 @@ def getMetadataDict(dir):
     keyNext = iter.Next()
     while keyNext:
         if keyNext.GetClassName() == "TDirectory":
-            retDict.update(getMetadataDict(keyNext.ReadObj()));
+            retDict.update(getMetadataDict(keyNext.ReadObj()))
         keyNext = iter.Next()
 
     return retDict
-- 
GitLab