diff options
author | kennyballou <kballou@onyx.boisestate.edu> | 2013-03-07 18:42:42 -0700 |
---|---|---|
committer | kennyballou <kballou@onyx.boisestate.edu> | 2013-03-07 18:42:42 -0700 |
commit | 0539fded91116c2d40ddf08ae888b02fd3a0a482 (patch) | |
tree | 03d48c06cee02e1f69d286c6f859d71134f76ad9 /xnt/build | |
parent | e58f93d435b7a4bb3682ea17086a48a8ab065389 (diff) | |
download | xnt-0539fded91116c2d40ddf08ae888b02fd3a0a482.tar.gz xnt-0539fded91116c2d40ddf08ae888b02fd3a0a482.tar.xz |
pylint ALL THE THINGS!
Diffstat (limited to 'xnt/build')
-rw-r--r-- | xnt/build/__init__.py | 1 | ||||
-rw-r--r-- | xnt/build/cc.py | 61 | ||||
-rw-r--r-- | xnt/build/make.py | 40 |
3 files changed, 57 insertions, 45 deletions
diff --git a/xnt/build/__init__.py b/xnt/build/__init__.py index 64e5706..105d02f 100644 --- a/xnt/build/__init__.py +++ b/xnt/build/__init__.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +"""Build Module""" # Xnt -- A Wrapper Build Tool # Copyright (C) 2012 Kenny Ballou diff --git a/xnt/build/cc.py b/xnt/build/cc.py index e4592ca..d1a78ac 100644 --- a/xnt/build/cc.py +++ b/xnt/build/cc.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +"""Common Compilers + +Definition of commonly used compilers +""" # Xnt -- A Wrapper Build Tool # Copyright (C) 2012 Kenny Ballou @@ -16,58 +20,61 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -""" -Common Compilers -""" - import os import logging -import sys from xnt.tasks import call -logger = logging.getLogger(__name__) +LOGGER = logging.getLogger(__name__) -def gcc(src, flags=[]): +def gcc(src, flags=None): """gcc compiler, non-named output file""" return _gcc(src, flags) -def gpp(src, flags=[]): +def gpp(src, flags=None): """g++ compiler, non-named output file""" return _gcc(src, flags, "g++") -def gcc_o(src, o, flags=[]): +def gcc_o(src, output, flags=None): """gcc compiler, with output file""" - return _gcc_o(src, o, flags) + return _gcc_o(src, output, flags) -def gpp_o(src, o, flags=[]): +def gpp_o(src, output, flags=None): """g++ compiler, with output file""" - return _gcc_o(src, o, flags, "g++") + return _gcc_o(src, output, flags, "g++") -def javac(src, flags=[]): +def javac(src, flags=None): """Javac: compile Java programs""" - logger.info("Compiling %s", src) - cmd = __generateCommand(src, flags, "javac") + LOGGER.info("Compiling %s", src) + cmd = __generate_command(src, flags, "javac") return __compile(cmd) -def _gcc(src, flags=[], compiler="gcc"): - logger.info("Compiling %s", src) - return __compile(__generateCommand(src, flags, compiler)) +def _gcc(src, flags=None, compiler="gcc"): + """Compile using gcc""" + LOGGER.info("Compiling %s", src) + return __compile(__generate_command(src, flags, compiler)) -def _gcc_o(src, o, flags=[], compiler="gcc"): - logger.info("Compiling %s to %s", src, o) - cmd = __generateCommand(src, flags, compiler) +def _gcc_o(src, output, flags=None, compiler="gcc"): + """Compile with gcc specifying output file name""" + LOGGER.info("Compiling %s to %s", src, output) + cmd = __generate_command(src, flags, compiler) cmd.append("-o") - cmd.append(o) + cmd.append(output) return __compile(cmd) -def __generateCommand(src, flags=[], compiler="gcc"): +def __generate_command(src, flags=None, compiler="gcc"): + """Generate cmd list for call""" cmd = [compiler, src] - for f in flags: - cmd.append(f) + if flags: + for flag in flags: + cmd.append(flag) return cmd def __compile(cmd): + """Run Compile, using `xnt.tasks.call`""" return call(cmd) -def __is_newer(a, b): - return os.path.getmtime(a) > os.path.getmtime(b) +def __is_newer(file_a, file_b): + """Compare mmtimes of files + Return True if `file_a` is modified later than `file_b` + """ + return os.path.getmtime(file_a) > os.path.getmtime(file_b) diff --git a/xnt/build/make.py b/xnt/build/make.py index 80fcf1b..80bda63 100644 --- a/xnt/build/make.py +++ b/xnt/build/make.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +"""Wrapping methods around build tools""" # Xnt -- A Wrapper Build Tool # Copyright (C) 2012 Kenny Ballou @@ -18,32 +19,35 @@ import os import subprocess -import logging - -def ant(path="", target="",flags=[]): - cmd = __addFlags(["ant", target], flags) +def ant(path="", target="", flags=None): + """Wrapper around Apache Ant""" + cmd = __add_flags(["ant", target], flags) return __run_in(path, lambda: subprocess.call(cmd)) -def make(path="", target="",flags=[]): - cmd = __addFlags(["make", target], flags) +def make(path="", target="", flags=None): + """Wrapper around GNU Make""" + cmd = __add_flags(["make", target], flags) return __run_in(path, lambda: subprocess.call(cmd)) -def nant(path="", target="",flags=[]): - cmd = __addFlags(["nant", target], flags) +def nant(path="", target="", flags=None): + """Wrapper around .NET Ant""" + cmd = __add_flags(["nant", target], flags) return __run_in(path, lambda: subprocess.call(cmd)) -def __addFlags(cmd, flags): - c = list(cmd) - for f in flags: - c.append(f) - return c +def __add_flags(cmd, flags): + """Add flags to command and return new list""" + command = list(cmd) + for flag in flags: + command.append(flag) + return command -def __run_in(path, f): - oldPath = os.path.abspath(os.getcwd()) +def __run_in(path, function): + """Execute function while in a different running directory""" + cwd = os.path.abspath(os.getcwd()) if path and os.path.exists(path): os.chdir(os.path.abspath(path)) - result = f() - if oldPath: - os.chdir(oldPath) + result = function() + if cwd: + os.chdir(cwd) return result |