Skip to content

Commit

Permalink
Merge pull request #14046 from mantidproject/14044_pylint_tools
Browse files Browse the repository at this point in the history
Fixing pylint  in tools
  • Loading branch information
peterfpeterson committed Oct 19, 2015
2 parents 283f3e7 + e50a1a6 commit e502519
Show file tree
Hide file tree
Showing 46 changed files with 335 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def _divide(self, lhs, rhs):
divide.setProperty("RHSWorkspace", rhs)
divide.execute()
return divide.getProperty("OutputWorkspace").value

def _add(self, lhs, rhs):
divide = self.createChildAlgorithm("Plus")
divide.setProperty("LHSWorkspace", lhs)
divide.setProperty("RHSWorkspace", rhs)
divide.execute()
return divide.getProperty("OutputWorkspace").value

def _integrate_bands(self, bands, in_ws):
# Formulate bands, integrate and sum
accumulated_output = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=no-init
from mantid.simpleapi import *
from mantid.api import *
from mantid.kernel import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def PyInit(self):
direction=Direction.Output),
doc='Fitted parameter output')

self.declareProperty(ITableWorkspaceProperty('OutputWorkspaceTable', '',
optional=PropertyMode.Optional,
self.declareProperty(ITableWorkspaceProperty('OutputWorkspaceTable', '',
optional=PropertyMode.Optional,
direction=Direction.Output),
doc='Table workspace of fit parameters')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=invalid-name
#pylint: disable=no-init
from mantid import config
import os
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinxext/mantiddoc/directives/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _insert_deprecation_warning(self):

#------------------------------------------------------------------------------------------------------------

def html_collect_pages(app):
def html_collect_pages(dummy_app):
"""
Write out unversioned algorithm pages that redirect to the highest version of the algorithm
"""
Expand Down
1 change: 1 addition & 0 deletions docs/sphinxext/mantiddoc/directives/properties.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=invalid-name
from mantiddoc.directives.base import AlgorithmBaseDirective
import string

Expand Down
30 changes: 16 additions & 14 deletions docs/sphinxext/mantiddoc/directives/sourcelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def parse_source_tree(self):
builddir = os.path.join(builddir, "..", "..")
builddir = os.path.abspath(builddir)

for dirName, subdirList, fileList in os.walk(self.source_root):
for dirName, dummy_subdirList, fileList in os.walk(self.source_root):
if dirName.startswith(builddir):
continue # don't check or add to the cache
for fname in fileList:
Expand Down Expand Up @@ -186,29 +186,31 @@ def output_to_page(self, file_paths,file_name,sanity_checks):
suggested_path = "os_agnostic_path_to_file_from_Code/Mantid"
if len(valid_ext_list) == 0:
raise SourceLinkError("No file possibilities for " + file_name + " have been found\n" +
"Please specify a better one using the :filename: opiton or use the " + str(self.file_types.keys()) + " options\n" +
"e.g. \n" +
".. sourcelink:\n" +
" :" + self.file_types.keys()[0] + ": " + suggested_path + "\n "+
"or \n" +
".. sourcelink:\n" +
" :filename: " + file_name)
"Please specify a better one using the :filename: opiton or use the " +
str(self.file_types.keys()) + " options\n" +
"e.g. \n" +
".. sourcelink:\n" +
" :" + self.file_types.keys()[0] + ": " + suggested_path + "\n "+
"or \n" +
".. sourcelink:\n" +
" :filename: " + file_name)
#if the have a cpp we should also have a h
if ("cpp" in valid_ext_list) or ("h" in valid_ext_list):
if ("cpp" not in valid_ext_list) or ("h" not in valid_ext_list):
raise SourceLinkError("Only one of .h and .cpp found for " + file_name + "\n" +
"valid files found for " + str(valid_ext_list) + "\n" +
"Please specify the missing one using an " + str(self.file_types.keys()) + " option\n" +
"e.g. \n" +
".. sourcelink:\n" +
" :" + self.file_types.keys()[0] + ": " + suggested_path)
"valid files found for " + str(valid_ext_list) + "\n" +
"Please specify the missing one using an " +
str(self.file_types.keys()) + " option\n" +
"e.g. \n" +
".. sourcelink:\n" +
" :" + self.file_types.keys()[0] + ": " + suggested_path)
return

def output_path_to_page(self, filepath, extension):
"""
Outputs the source link for a file to the rst page
"""
dirName,fName = os.path.split(filepath)
dummy_dirName,fName = os.path.split(filepath)
self.add_rst(self.file_types[extension] + ": `" + fName + " <" + self.convert_path_to_github_url(filepath) + ">`_\n\n")
return

Expand Down
4 changes: 2 additions & 2 deletions docs/sphinxext/mantiddoc/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def __repr__(self):

@property
def passed(self):
return (self.failure_descr == "")
return self.failure_descr == ""

@property
def failed(self):
Expand Down Expand Up @@ -309,7 +309,7 @@ def __parse_document(self, results):
% text[1])
results = results[2:] # trim off top two lines of header information
maintests, cleanup = self.__split_on_cleanup(results)
overall_success = not (maintests[0] == FAILURE_MARKER)
overall_success = not maintests[0] == FAILURE_MARKER

if overall_success:
testcases = self.__parse_success(fullname, maintests)
Expand Down
2 changes: 2 additions & 0 deletions scripts/HFIR_4Circle_Reduction/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pylint: disable=invalid-name
#pylint: disable=invalid-name
1 change: 1 addition & 0 deletions scripts/Inelastic/Direct/DirectEnergyConversion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
from mantid.simpleapi import *
from mantid.kernel import funcreturns
Expand Down
6 changes: 3 additions & 3 deletions scripts/Inelastic/Direct/ISISDirecInelasticConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ def is_inelastic(self,instr_name):
#
def init_user(self,fedIDorUser,theUser=None):
"""Define settings, specific to a user
Supports two interfaces -- old and the new one
Supports two interfaces -- old and the new one
where
OldInterface: requested two input parameters
OldInterface: requested two input parameters
fedID -- users federal id
theUser -- class defining all other user property
NewInterface: requested single parameter:
NewInterface: requested single parameter:
theUser -- class defining all user's properties including fedID
"""
if not theUser:
Expand Down
1 change: 1 addition & 0 deletions scripts/Inelastic/Direct/PropertiesDescriptors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
""" File contains collection of Descriptors used to define complex
properties in NonIDF_Properties and PropertyManager classes
Expand Down
5 changes: 3 additions & 2 deletions scripts/Inelastic/Direct/RunDescriptor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
""" File contains Descriptors used describe run for direct inelastic reduction """

Expand Down Expand Up @@ -995,8 +996,8 @@ def load_file(self,inst_name,ws_name,run_number=None,load_mon_with_workspace=Fal
Load(Filename=data_file, OutputWorkspace=ws_name,LoadMonitors = '1',MonitorsAsEvents='0')
#HACK >>> , necessary until #11565 is fixed
if nxs_file :
instr_name = RunDescriptor._holder.instr_name
if instr_name == 'LET' and self._run_number>14151 and self._run_number<14382:
instr_name = RunDescriptor._holder.instr_name
if instr_name == 'LET' and self._run_number>14151 and self._run_number<14382:
FrameworkManager.clearInstruments()
idf_file = api.ExperimentInfo.getInstrumentFilename(instr_name)
idf_path,tile = os.path.split(idf_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def to_script(self, file_name=None):
file_name, autosavexmlfname)
wbuf += script
wbuf += "\n========== End of Script ==========="
print (wbuf)
print wbuf

return script

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name,unused-import
from PyQt4 import QtGui, QtCore
import reduction_gui.widgets.util as util
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
from PyQt4 import QtGui, uic, QtCore
import reduction_gui.widgets.util as util
Expand Down
1 change: 1 addition & 0 deletions scripts/Interface/ui/reflectometer/refl_gui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
import ui_refl_window
import refl_save
Expand Down
1 change: 1 addition & 0 deletions scripts/Reflectometry/isis_reflectometry/procedures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
from math import *

Expand Down
3 changes: 2 additions & 1 deletion scripts/SANS/ISISCommandInterface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
"""
Enables the SANS commands (listed at http://www.mantidproject.org/SANS) to
Expand Down Expand Up @@ -574,7 +575,7 @@ def _fitRescaleAndShift(rAnds, frontData, rearData):

# We need to make sure at this point that the workspaces are 1D. We
# don't really know how to match the workspaces for the 2D case.
if (not su.is_1D_workspace(mtd[frontData]) or not su.is_1D_workspace(mtd[rearData])):
if not su.is_1D_workspace(mtd[frontData]) or not su.is_1D_workspace(mtd[rearData]):
sanslog.warning("Request to perform a fit to find the shift and scale values for"
"a non-1D workspace is not possible. Default values are provided.")
scale = rAnds.scale
Expand Down
1 change: 1 addition & 0 deletions scripts/SANS/SANSUtility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
#########################################################
# This module contains utility functions common to the
Expand Down
1 change: 1 addition & 0 deletions scripts/SANS/isis_instrument.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
import math
import os
Expand Down
1 change: 1 addition & 0 deletions scripts/SANS/isis_reduction_steps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
"""
This file defines what happens in each step in the data reduction, it's
Expand Down
1 change: 1 addition & 0 deletions scripts/reduction/instruments/reflectometer/wks_utility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=too-many-lines
#pylint: disable=invalid-name
from numpy import zeros, arctan2, arange, shape, sqrt, fliplr, asfarray, mean, sum, NAN
from mantid.simpleapi import *
Expand Down
1 change: 1 addition & 0 deletions tools/DOI/authors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=invalid-name
from itertools import chain, ifilterfalse
import string, os, re

Expand Down
1 change: 1 addition & 0 deletions tools/DOI/doi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=invalid-name
"""A script for generating DataCite DOI's for Mantid releases, to be called by
a Jenkins job during the release process. When given a major, minor and patch
release number along with username and password credentials, it will build a
Expand Down
10 changes: 5 additions & 5 deletions tools/DefaultConfigFiles/configToCpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

with open(sys.argv[2]) as f:
for line in f:
line = line.rstrip('\n')
if line == "":
print sys.argv[1] + " << std::endl;"
else:
print sys.argv[1] + " << \"" + line + "\" << std::endl;"
line = line.rstrip('\n')
if line == "":
print sys.argv[1] + " << std::endl;"
else:
print sys.argv[1] + " << \"" + line + "\" << std::endl;"
1 change: 1 addition & 0 deletions tools/PeriodicTable/generate_atom_code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pylint: disable=invalid-name
#!/usr/bin/env python

VERSION = "1.0"
Expand Down
Loading

0 comments on commit e502519

Please sign in to comment.