Skip to content

Commit

Permalink
flake8: fix indent, new-lines, spaces and line-length
Browse files Browse the repository at this point in the history
More specifically:
* Add new line between global functions
* Remove extra line(s) from end of file
* Remove extra space(s)
* Fix line-length
* Move import(s) at the top of the file
  • Loading branch information
jcfr committed Jul 19, 2016
1 parent 57f1b73 commit f0eb036
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 78 deletions.
26 changes: 14 additions & 12 deletions ci/appveyor/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@

from urllib2 import urlopen


def log(s):
print(s)
sys.stdout.flush()


class DriverContext(object):
def __init__(self, driver, env_file="env.json"):
self.driver = driver
Expand All @@ -42,6 +44,7 @@ def __exit__(self, exc_type, exc_value, traceback):

self.driver.unload_env()


class Driver(object):
def __init__(self):
self.env = None
Expand All @@ -57,7 +60,7 @@ def load_env(self, env_file="env.json"):
if os.path.exists(self._env_file):
self.env.update(json.load(open(self._env_file)))

self.env = {str(k): str(v) for k,v in self.env.items()}
self.env = {str(k): str(v) for k, v in self.env.items()}

def save_env(self, env_file=None):
if env_file is None:
Expand Down Expand Up @@ -131,12 +134,11 @@ def drive_install(self):
self.env["PATH"].split(os.pathsep)

if (
os.path.normpath(dir).lower() == mingw_bin

or not (
os.path.exists(os.path.join(dir, "sh.exe"))
or os.path.exists(os.path.join(dir, "sh.bat"))
or os.path.exists(os.path.join(dir, "sh"))
os.path.normpath(dir).lower() == mingw_bin or
not (
os.path.exists(os.path.join(dir, "sh.exe")) or
os.path.exists(os.path.join(dir, "sh.bat")) or
os.path.exists(os.path.join(dir, "sh"))
)
)
)
Expand Down Expand Up @@ -168,8 +170,10 @@ def drive_install(self):

log("Unpacking CMake")

try: os.mkdir("C:\\cmake")
except OSError: pass
try:
os.mkdir("C:\\cmake")
except OSError:
pass

with zipfile.ZipFile("C:\\cmake.zip") as local_zip:
local_zip.extractall("C:\\cmake")
Expand All @@ -188,8 +192,7 @@ def drive_build(self):
def drive_test(self):
extra_test_args = shlex.split(self.env.get("EXTRA_TEST_ARGS", ""))
self.check_call(
["python", "-m", "nose", "-v", "-w", "tests"]
+ extra_test_args)
["python", "-m", "nose", "-v", "-w", "tests"] + extra_test_args)

def drive_after_test(self):
self.check_call(["python", "setup.py", "bdist_wheel"])
Expand All @@ -214,4 +217,3 @@ def drive_after_test(self):
d.drive_after_test()
else:
raise Exception("invalid stage: {}".format(stage))

5 changes: 2 additions & 3 deletions skbuild/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

from .distutils_wrap import setup

__author__ = 'The scikit-build team'
__email__ = 'scikit-build@googlegroups.com'
__version__ = '0.2.0'

from .distutils_wrap import setup

22 changes: 14 additions & 8 deletions skbuild/cmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
RE_FILE_INSTALL = re.compile(
r"""[ \t]*file\(INSTALL DESTINATION "([^"]+)".*"([^"]+)"\).*""")


def pop_arg(arg, a, default=None):
"""Pops an arg(ument) from an argument list a and returns the new list
and the value of the argument if present and a default otherwise.
Expand Down Expand Up @@ -49,6 +50,7 @@ def _remove_cwd_prefix(path):

return result


def _touch_init(folder):
init = os.path.join(folder, "__init__.py")
if not os.path.exists(init):
Expand All @@ -68,12 +70,14 @@ def __init__(self, **defines):
self.platform = get_platform()

def configure(self, clargs=(), generator_id=None):
"""Calls cmake to generate the makefile (or VS solution, or XCode project).
"""Calls cmake to generate the makefile (or VS solution,
or XCode project).
Input:
------
generator_id: string
The string representing the CMake generator to use. If None, uses defaults for your platform.
The string representing the CMake generator to use.
If None, uses defaults for your platform.
"""

# if no provided default generator_id, check environment
Expand Down Expand Up @@ -115,8 +119,10 @@ def configure(self, clargs=(), generator_id=None):

# if Python.h not found (or python_include_dir is None), try to find a
# suitable include dir
if (python_include_dir is None or
not os.path.exists(os.path.join(python_include_dir, 'Python.h'))):
found_python_h = os.path.exists(
os.path.join(python_include_dir, 'Python.h'))

if python_include_dir is None or not found_python_h:
candidate_prefixes = []

try:
Expand Down Expand Up @@ -182,7 +188,7 @@ def configure(self, clargs=(), generator_id=None):

# if static (or nonexistent), try to find a suitable dynamic libpython
if (python_library is None or
os.path.splitext(python_library)[1][-2:] == '.a'):
os.path.splitext(python_library)[1][-2:] == '.a'):

candidate_lib_prefixes = ['', 'lib']

Expand Down Expand Up @@ -257,8 +263,9 @@ def configure(self, clargs=(), generator_id=None):
# to generate makefile
rtn = subprocess.check_call(cmd, cwd=CMAKE_BUILD_DIR)
if rtn != 0:
raise RuntimeError("Could not successfully configure your project. "
"Please see CMake's output for more information.")
raise RuntimeError("Could not successfully configure "
"your project. Please see CMake's "
"output for more information.")

# Try to catch files that are meant to be installed outside the project
# root before they are actually installed. We can not wait for the
Expand Down Expand Up @@ -300,7 +307,6 @@ def configure(self, clargs=(), generator_id=None):
(" " + _install) for _install in bad_installs)
)))


def make(self, clargs=(), config="Release", source_dir="."):
"""Calls the system-specific make program to compile code.
"""
Expand Down
2 changes: 1 addition & 1 deletion skbuild/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from .. import cmaker


class build(_build):
def finalize_options(self):
if not self.build_base or self.build_base == 'build':
self.build_base = cmaker.DISTUTILS_INSTALL_DIR
_build.finalize_options(self)

6 changes: 3 additions & 3 deletions skbuild/command/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from .. import cmaker


class clean(_clean):
def finalize_options(self):
if not self.build_base or self.build_base == 'build':
Expand All @@ -15,9 +16,8 @@ def finalize_options(self):
def run(self):
_clean.run(self)
for dir_ in (cmaker.CMAKE_INSTALL_DIR,
cmaker.CMAKE_BUILD_DIR,
cmaker.SKBUILD_DIR):
cmaker.CMAKE_BUILD_DIR,
cmaker.SKBUILD_DIR):
log.info("removing '%s'", dir_)
if not self.dry_run:
rmtree(dir_)

2 changes: 1 addition & 1 deletion skbuild/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from .. import cmaker


class install(_install):
def finalize_options(self):
if not self.build_base or self.build_base == 'build':
self.build_base = cmaker.DISTUTILS_INSTALL_DIR
_install.finalize_options(self)

8 changes: 4 additions & 4 deletions skbuild/distutils_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
from .command import build, install, clean
from .exceptions import SKBuildError


def move_arg(arg, a, b, newarg=None, f=lambda x: x, concatenate_value=False):
"""Moves an argument from a list to b list, possibly giving it a new name
and/or performing a transformation on the value. Returns a and b. The arg need
not be present in a.
and/or performing a transformation on the value. Returns a and b. The arg
need not be present in a.
"""
newarg = newarg or arg
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -79,7 +80,7 @@ def setup(*args, **kw):
py_modules = kw.get('py_modules', [])

scripts = kw.get('scripts', [])
new_scripts = { script: False for script in scripts }
new_scripts = {script: False for script in scripts}

data_files = {
(parent_dir or '.'): set(file_list)
Expand Down Expand Up @@ -224,4 +225,3 @@ def setup(*args, **kw):
kw['cmdclass'] = cmdclass

return distutils.core.setup(*args, **kw)

1 change: 0 additions & 1 deletion skbuild/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class SKBuildError(Exception):
pass

21 changes: 12 additions & 9 deletions skbuild/platform_specifics/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def cleanup_test():
shutil.rmtree(test_folder)

def get_cmake_exe_path(self):
"""Override this method with additional logic where necessary if CMake is not on PATH.
"""Override this method with additional logic where necessary
if CMake is not on PATH.
"""
return "cmake"

Expand All @@ -41,12 +42,14 @@ def get_best_generator(
Parameters:
generator: string or None
If provided, uses only provided generator, instead of trying system defaults.
If provided, uses only provided generator, instead of trying
system defaults.
languages: tuple
the languages you'll need for your project, in terms that CMake recognizes.
the languages you'll need for your project, in terms that
CMake recognizes.
cleanup: bool
If True, cleans up temporary folder used to test generators. Set to False
for debugging to see CMake's output files.
If True, cleans up temporary folder used to test generators.
Set to False for debugging to see CMake's output files.
"""

candidate_generators = self.default_generators
Expand All @@ -61,7 +64,8 @@ def get_best_generator(
# back up current folder so we go back to it when done testing
backup_folder = os.getcwd()

# cd into the cmake_test_compile folder as working dir (rmtree this later for cleanliness)
# cd into the cmake_test_compile folder as working dir (rmtree this
# later for cleanliness)
# TODO: make this more robust in terms of checking where we are, if the
# folder exists, etc.
os.chdir(test_folder)
Expand All @@ -86,8 +90,8 @@ def get_best_generator(
except OSError as e:
# ignore errors from the OS - just don't report success for
# this generator.
print(
"Error encountered when attempting to use generator {:s}:".format(generator))
print("Error encountered when attempting to use generator {:s}:"
.format(generator))
print(e)
# cmake succeeded, this generator should work
if status == 0:
Expand All @@ -101,4 +105,3 @@ def get_best_generator(
CMakePlatform.cleanup_test()

return working_generator

1 change: 0 additions & 1 deletion skbuild/platform_specifics/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ class UnixPlatform(abstract.CMakePlatform):
def __init__(self):
super(UnixPlatform, self).__init__()
self.default_generators = ["Unix Makefiles", ]

2 changes: 1 addition & 1 deletion skbuild/platform_specifics/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import abstract


class WindowsPlatform(abstract.CMakePlatform):

def __init__(self):
Expand Down Expand Up @@ -46,4 +47,3 @@ def __init__(self):
# string IDs seem to be just the vs_base.

self.default_generators.insert(0, vs_base)

1 change: 0 additions & 1 deletion tests/samples/hello-cython/hello/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
if __name__ == "__main__":
from . import _hello as hello
hello.hello("World")

1 change: 0 additions & 1 deletion tests/samples/hello/hello/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
if __name__ == "__main__":
from . import _hello as hello
hello.hello("World")

1 change: 0 additions & 1 deletion tests/samples/pen2-cython/scripts/pen2_cython
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

from pen2_cython import main
main()

28 changes: 15 additions & 13 deletions tests/samples/pen2-cython/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DEFAULT_DT = 0.001*int(1000.0/60.0)
DEFAULT_DURATION = None


def main():
from argparse import ArgumentParser

Expand Down Expand Up @@ -71,17 +72,18 @@ def main():
time_step=args.time_step,
duration=args.duration)


def run_simulation(**kwds):
from math import pi, sqrt, sin, cos
from vtk import vtkInteractorStyleTerrain, \
vtkRenderWindowInteractor, \
vtkRenderWindow, \
vtkRenderer, \
vtkActor, \
vtkPolyDataMapper, \
vtkSphereSource, \
vtkCylinderSource, \
vtkTransform
from vtk import (vtkInteractorStyleTerrain,
vtkRenderWindowInteractor,
vtkRenderWindow,
vtkRenderer,
vtkActor,
vtkPolyDataMapper,
vtkSphereSource,
vtkCylinderSource,
vtkTransform)

from vtk.util.colors import red, blue, brown

Expand Down Expand Up @@ -164,6 +166,7 @@ def run_simulation(**kwds):
interactor.Initialize()

state = [None]

def callback(*args, **kwds):
if state[0] is None:
state[0] = list(sim.initial_state())
Expand All @@ -180,8 +183,8 @@ def callback(*args, **kwds):

cTran1.Translate(x0, y0, 0.0)

cTran0.RotateZ(180.0*(th0 )/pi)
cTran1.RotateZ(180.0*( th1)/pi)
cTran0.RotateZ(180.0 * th0 / pi)
cTran1.RotateZ(180.0 * th1 / pi)

cTran0.Translate(0.0, -0.5*L0, 0.0)
cTran1.Translate(0.0, -0.5*L1, 0.0)
Expand All @@ -198,7 +201,6 @@ def callback(*args, **kwds):
interactor.ExitCallback()

interactor.AddObserver("TimerEvent", callback)
timerid = interactor.CreateRepeatingTimer(int(1000*dt));
timerid = interactor.CreateRepeatingTimer(int(1000*dt))

interactor.Start()

1 change: 0 additions & 1 deletion tests/samples/pen2-cython/src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
if __name__ == "__main__":
from . import main
main()

1 change: 0 additions & 1 deletion tests/samples/tower-of-babel/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@

scripts=['scripts/tbabel'],
)

Loading

0 comments on commit f0eb036

Please sign in to comment.