using prospector --tool=dodgy --tool=pyflakes -M to find python flaws

This commit is contained in:
Martin Diehl 2016-03-01 18:25:14 +01:00
parent 54d0a0a704
commit 2a50c6bf86
49 changed files with 58 additions and 56 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,re,string,fnmatch,vtk import os,sys,re,fnmatch,vtk
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,8 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,re,sys,string import os,re,sys
import math # flake8: noqa import math # noqa
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,9 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,re,sys,math,string,h5py import os,string,h5py
import numpy as np import numpy as np
import damask
from optparse import OptionParser, Option from optparse import OptionParser, Option
# ----------------------------- # -----------------------------

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,itertools import os,sys,itertools
import numpy as np import numpy as np
from scipy import ndimage from scipy import ndimage
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import os,sys,string,time,copy import os,sys,time,copy
import numpy as np import numpy as np
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,math,string import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,math,string import os,sys,math
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,numpy as np import os,sys,numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,math,string import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
import scipy.ndimage import scipy.ndimage
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask
@ -55,11 +55,16 @@ for name in filenames:
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------
table.head_read() table.head_read()
errors = []
# ------------------------------------------ sanity checks ---------------------------------------- # ------------------------------------------ sanity checks ----------------------------------------
if table.label_dimension(options.coords) != 3: errors.append('coordinates {} are not a vector.'.format(options.coords)) if table.label_dimension(options.coords) != 3:
else: coordCol = table.label_index(options.coords) damask.util.croak('coordinates {} are not a vector.'.format(options.coords))
table.close(dismiss = True)
continue
else:
coordCol = table.label_index(options.coords)
# ------------------------------------------ assemble header -------------------------------------- # ------------------------------------------ assemble header --------------------------------------

View File

@ -1,7 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,re,sys,string,fnmatch,math,random import os,re,sys
import math # noqa
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,re,sys,fnmatch,math,random import os,re,sys,fnmatch
import math # noqa
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
from PIL import Image from PIL import Image

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
from PIL import Image, ImageDraw from PIL import Image, ImageDraw

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
from PIL import Image from PIL import Image

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os, sys, string import os,sys
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import string,sys,os import sys,os
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,math import os,sys,math
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string import os,sys
import numpy as np import numpy as np
from optparse import OptionParser from optparse import OptionParser
import damask import damask

View File

@ -144,16 +144,12 @@ for file in files:
posOffset = (shift+[0.5,0.5,0.5])*dimension/resolution posOffset = (shift+[0.5,0.5,0.5])*dimension/resolution
elementSize = dimension/resolution*packing elementSize = dimension/resolution*packing
elem = 1
for c in xrange(downSized[2]): for c in xrange(downSized[2]):
for b in xrange(downSized[1]): for b in xrange(downSized[1]):
for a in xrange(downSized[0]): for a in xrange(downSized[0]):
datavar[a,b,c,locationCol:locationCol+3] = posOffset + [a,b,c]*elementSize datavar[a,b,c,locationCol:locationCol+3] = posOffset + [a,b,c]*elementSize
datavar[a,b,c,elemCol] = elem
table.data = datavar[a,b,c,:].tolist() table.data = datavar[a,b,c,:].tolist()
table.data_write() # output processed line table.data_write() # output processed line
elem += 1
# ------------------------------------------ output result --------------------------------------- # ------------------------------------------ output result ---------------------------------------

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,string,glob,re import os,glob,re
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,vtk import os,sys,vtk
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,vtk import os,vtk
import damask import damask
from collections import defaultdict from collections import defaultdict
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,vtk import os,sys,vtk
import damask import damask
from collections import defaultdict from collections import defaultdict
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,vtk import os,sys,vtk
import numpy as np import numpy as np
import damask import damask
from optparse import OptionParser from optparse import OptionParser

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 no BOM -*- # -*- coding: UTF-8 no BOM -*-
import os,sys,string,shutil import os,sys,shutil
import damask import damask
from optparse import OptionParser from optparse import OptionParser
from vtk import * from vtk import *