gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1766259 - in /gump/live/python/gump/core: build/ant.py model/builder.py
Date Sun, 23 Oct 2016 09:29:39 GMT
Author: bodewig
Date: Sun Oct 23 09:29:39 2016
New Revision: 1766259

URL: http://svn.apache.org/viewvc?rev=1766259&view=rev
Log:
make pylint happier

Modified:
    gump/live/python/gump/core/build/ant.py
    gump/live/python/gump/core/model/builder.py

Modified: gump/live/python/gump/core/build/ant.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/build/ant.py?rev=1766259&r1=1766258&r2=1766259&view=diff
==============================================================================
--- gump/live/python/gump/core/build/ant.py (original)
+++ gump/live/python/gump/core/build/ant.py Sun Oct 23 09:29:39 2016
@@ -7,9 +7,9 @@
 # The ASF licenses this file to You under the Apache License, Version 2.0
 # (the "License"); you may not use this file except in compliance with
 # the License.  You may obtain a copy of the License at
-# 
+#
 #     http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,81 +26,73 @@ __license__   = "http://www.apache.org/l
 	An Ant builder (uses ant to build projects)
 """
 
-import os.path
-import sys
-
 from gump import log
-from gump.core.run.gumprun import *
-from gump.core.config import dir, default, basicConfig, setting
 
-from gump.util.note import Annotatable
-from gump.util.work import *
+from gump.core.config import setting
+from gump.core.model.state import REASON_BUILD_FAILED, REASON_BUILD_TIMEDOUT, STATE_FAILED,\
+    STATE_SUCCESS
+
+from gump.util.process.command import CMD_STATE_SUCCESS, CMD_STATE_TIMED_OUT, Cmd, Parameters
+from gump.util.process.launcher import execute
+from gump.core.run.gumprun import RunSpecific
+from gump.util.work import CommandWorkItem, WORK_TYPE_BUILD
 
-from gump.util.tools import *
+class AntBuilder(RunSpecific):
 
-from gump.core.model.workspace import *
-from gump.core.model.module import Module
-from gump.core.model.project import Project
-from gump.core.model.depend import  ProjectDependency
-from gump.core.model.stats import *
-from gump.core.model.state import *
-
-class AntBuilder(gump.core.run.gumprun.RunSpecific):
-    
-    def __init__(self,run):
+    def __init__(self, run):
         """
         	The Ant Builder is a Java Builder
-    	""" 
-        gump.core.run.gumprun.RunSpecific.__init__(self,run)
+    	"""
+        RunSpecific.__init__(self, run)
 
-    def buildProject(self,project,language,stats):
+    def buildProject(self, project, language, stats):
         """
         	Build a project using Ant, based off the <ant metadata.
-        	
+
         	Note: switch on -verbose|-debug based of the stats for this
         	project, i.e. how long in a state of failure.
         """
-        
-        workspace=self.run.getWorkspace()
-                 
+
+        workspace = self.run.getWorkspace()
+
         log.info('Run Ant on Project: #[' + `project.getPosition()` + '] : ' + project.getName())
-    
+
         # Get the appropriate build command...
-        cmd=self.getAntCommand(project, language, self.run.getEnvironment().getJavaCommand())
+        cmd = self.getAntCommand(project, language, self.run.getEnvironment().getJavaCommand())
 
         if cmd:
             # Execute the command ....
-            cmdResult=execute(cmd,workspace.tmpdir)
-    
+            cmdResult = execute(cmd, workspace.tmpdir)
+
             # Update context with the fact that this work was done
-            work=CommandWorkItem(WORK_TYPE_BUILD,cmd,cmdResult)
+            work = CommandWorkItem(WORK_TYPE_BUILD, cmd, cmdResult)
             project.performedWork(work)
             project.setBuilt(True)
-                    
-            # Update context state based of the result  
-            if not cmdResult.state==CMD_STATE_SUCCESS:
-                reason=REASON_BUILD_FAILED
-                if cmdResult.state==CMD_STATE_TIMED_OUT:
-                    reason=REASON_BUILD_TIMEDOUT
-                project.changeState(STATE_FAILED,reason)                        
-            else:                         
+
+            # Update context state based of the result
+            if cmdResult.state != CMD_STATE_SUCCESS:
+                reason = REASON_BUILD_FAILED
+                if cmdResult.state == CMD_STATE_TIMED_OUT:
+                    reason = REASON_BUILD_TIMEDOUT
+                project.changeState(STATE_FAILED, reason)
+            else:
                 # For now, things are going good...
                 project.changeState(STATE_SUCCESS)
-    
-    def getAntCommand(self,project,language,javaCommand='java'):
+
+    def getAntCommand(self, project, language, javaCommand='java'):
         """
         	Build an ANT command for this project, based on the <ant metadata
-   			select targets and build files as appropriate.     	
+   			select targets and build files as appropriate.
         """
-        
+
         # The original model information...
-        ant=project.ant
+        ant = project.ant
         # The ant target (or none == ant default target)
-        target= ant.getTarget()
-    
+        target = ant.getTarget()
+
         # The ant build file (or none == build.xml)
         buildfile = ant.getBuildFile()
-    
+
         # Optional 'timeout'
         if ant.hasTimeout():
             timeout = ant.getTimeout()
@@ -108,85 +100,86 @@ class AntBuilder(gump.core.run.gumprun.R
             timeout = setting.TIMEOUT
 
         # Optional 'verbose' or 'debug'
-        verbose=ant.isVerbose()
-        debug=ant.isDebug()
-    
+        verbose = ant.isVerbose()
+        debug = ant.isDebug()
+
         # Where to run this:
         basedir = ant.getBaseDirectory() or project.getBaseDirectory()
-    
+
         # Build a classpath (based upon dependencies)
-        (classpath,bootclasspath)=language.getClasspaths(project)
-    
+        (classpath, bootclasspath) = language.getClasspaths(project)
+
         # Get properties
-        properties=self.getAntProperties(project)
-   
+        properties = self.getAntProperties(project)
+
         # Get system properties
-        sysproperties=self.getAntSysProperties(project)
-   
+        sysproperties = self.getAntSysProperties(project)
+
         # Run java on apache Ant...
-        cmd=Cmd(javaCommand,'build_'+project.getModule().getName()+'_'+project.getName(),
-            basedir,{'CLASSPATH':classpath}, timeout)
-            
+        cmd = Cmd(javaCommand, 'build_' + project.getModule().getName() + '_' + project.getName(),
+                  basedir, {'CLASSPATH' : classpath}, timeout)
+
         # These are workspace + project system properties
         cmd.addNamedParameters(sysproperties)
-        
+
         # Add BOOTCLASSPATH
         if bootclasspath:
-            cmd.addPrefixedParameter('-X','bootclasspath/p',bootclasspath,':')
-            
+            cmd.addPrefixedParameter('-X', 'bootclasspath/p', bootclasspath, ':')
+
         # Get/set JVM properties
-        jvmargs=language.getJVMArgs(project)
+        jvmargs = language.getJVMArgs(project)
         if jvmargs:
             cmd.addParameters(jvmargs)
-            
+
         # The Ant interface
-        cmd.addParameter('org.apache.tools.ant.Main')  
-    
+        cmd.addParameter('org.apache.tools.ant.Main')
+
         # Allow ant-level debugging...
-        if project.getWorkspace().isDebug() or project.isDebug() or debug: 
-            cmd.addParameter('-debug')  
-        if project.getWorkspace().isVerbose()  or project.isVerbose() or verbose: 
-            cmd.addParameter('-verbose')  
-    
+        if project.getWorkspace().isDebug() or project.isDebug() or debug:
+            cmd.addParameter('-debug')
+        if project.getWorkspace().isVerbose()  or project.isVerbose() or verbose:
+            cmd.addParameter('-verbose')
+
         # Some builds might wish for this information
         # :TODO: Grant greater access to Gump variables from
         # within.
-        mergeFile=project.getWorkspace().getMergeFile()
+        mergeFile = project.getWorkspace().getMergeFile()
         if mergeFile:
-            cmd.addPrefixedParameter('-D','gump.merge',str(mergeFile),'=')        
-    
+            cmd.addPrefixedParameter('-D', 'gump.merge', str(mergeFile), '=')
+
         # These are from the project and/or workspace
         # These are 'normal' properties.
         cmd.addNamedParameters(properties)
-    
+
         # Pass the buildfile
-        if buildfile: cmd.addParameter('-f',buildfile)
-    
+        if buildfile:
+            cmd.addParameter('-f', buildfile)
+
         # End with the target (or targets)...
-        if target: 
+        if target:
             for targetParam in target.split(','):
                 cmd.addParameter(targetParam)
-    
+
         return cmd
-  
-    def getAntProperties(self,project):
+
+    def getAntProperties(self, project):
         """ Get properties for a project """
-        properties=Parameters()
-        for property in project.getWorkspace().getProperties()+project.getAnt().getProperties():
-            properties.addPrefixedNamedParameter('-D',property.name,property.getValue(),'=')
+        properties = Parameters()
+        for property in project.getWorkspace().getProperties() + project.getAnt().getProperties():
+            properties.addPrefixedNamedParameter('-D', property.name, property.getValue(),
'=')
         return properties
 
-    def getAntSysProperties(self,project):
+    def getAntSysProperties(self, project):
         """ Get sysproperties for a project """
-        properties=Parameters()
-        for property in project.getWorkspace().getSysProperties()+project.getAnt().getSysProperties():
-            properties.addPrefixedNamedParameter('-D',property.name,property.value,'=')
+        properties = Parameters()
+        for property in project.getWorkspace().getSysProperties() + \
+            project.getAnt().getSysProperties():
+            properties.addPrefixedNamedParameter('-D', property.name, property.value, '=')
         return properties
-                
-    def preview(self,project,language,stats):        
+
+    def preview(self, project, language, stats):
         """
         	Preview what an Ant build would look like.
         """
-        command=self.getAntCommand(project,language) 
-        command.dump()
- 
+        cmd = self.getAntCommand(project, language)
+        cmd.dump()

Modified: gump/live/python/gump/core/model/builder.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/model/builder.py?rev=1766259&r1=1766258&r2=1766259&view=diff
==============================================================================
--- gump/live/python/gump/core/model/builder.py (original)
+++ gump/live/python/gump/core/model/builder.py Sun Oct 23 09:29:39 2016
@@ -6,9 +6,9 @@
 # The ASF licenses this file to You under the Apache License, Version 2.0
 # (the "License"); you may not use this file except in compliance with
 # the License.  You may obtain a copy of the License at
-# 
+#
 #     http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -91,7 +91,7 @@ class Builder(ModelObject, PropertyConta
                 pname = getDomAttributeValue(ddom, 'project')
                 pelement.setAttribute('name', pname)
                 project.addWarning('Unnamed property for [' + project.name \
-                                       + '] in depend on: ' + pname )
+                                       + '] in depend on: ' + pname)
 
             # :TODO: AJ added this, no idea if it is right/needed.
             if hasDomAttribute(ddom, 'id'):
@@ -105,7 +105,7 @@ class Builder(ModelObject, PropertyConta
 
             # Store it
             self.expandDomProperty(pelement, project, workspace)
-            self.importProperty(pelement) 
+            self.importProperty(pelement)
 
             # Stash the constructed property DOM (the doc above the element)
             if not hasattr(project, 'extraDoms'):
@@ -114,7 +114,7 @@ class Builder(ModelObject, PropertyConta
 
     def expandDomProperties(self, project, workspace):
         #
-        # convert Ant property elements which reference a project 
+        # convert Ant property elements which reference a project
         # into dependencies
         #
         for pdom in self.getDomChildIterator('property'):
@@ -122,7 +122,7 @@ class Builder(ModelObject, PropertyConta
             self.importProperty(pdom)
 
         #
-        # convert Ant sysproperty elements which reference a project 
+        # convert Ant sysproperty elements which reference a project
         # into dependencies
         #
         for spdom in self.getDomChildIterator('sysproperty'):
@@ -147,12 +147,12 @@ class Builder(ModelObject, PropertyConta
             return
 
         # If the pdom is not as simple as srcdir
-        reference = getDomAttributeValue(pdom, 'reference') 
+        reference = getDomAttributeValue(pdom, 'reference')
         if reference == 'srcdir':
             return
 
         # If it isn't already a classpath dependency
-        if project.hasFullDependencyOnNamedProject(projectName): 
+        if project.hasFullDependencyOnNamedProject(projectName):
             self.addDebug('Dependency on ' + projectName + \
                     ' exists, no need to add for property ' + \
                         name + '.')
@@ -164,20 +164,20 @@ class Builder(ModelObject, PropertyConta
         # Runtime?
         runtime = domAttributeIsTrue(pdom, 'runtime')
 
-        if workspace.hasProject(projectName): 
+        if workspace.hasProject(projectName):
 
             # A Property
             noclasspath = not hasDomAttribute(pdom, 'classpath')
 
             # Add a dependency (to bring property)
-            dependency = ProjectDependency(project,       \
-                            workspace.getProject(projectName),  \
-                            INHERIT_NONE,       \
-                            runtime,
-                            False,      \
-                            ids,
-                            noclasspath,
-                            'Property Dependency for ' + name)
+            dependency = ProjectDependency(project,
+                                           workspace.getProject(projectName),
+                                           INHERIT_NONE,
+                                           runtime,
+                                           False,
+                                           ids,
+                                           noclasspath,
+                                           'Property Dependency for ' + name)
 
 
             # Add depend to project...
@@ -202,10 +202,10 @@ class Builder(ModelObject, PropertyConta
 
         if self.hasDomAttribute('basedir'):
             self.basedir = os.path.abspath(os.path.join(
-                    self.project.getModule().getWorkingDirectory()
-                    or dir.base,
-                    self.getDomAttributeValue('basedir')
-                    ))
+                self.project.getModule().getWorkingDirectory()
+                or dir.base,
+                self.getDomAttributeValue('basedir')
+            ))
         else:
             self.basedir = self.project.getBaseDirectory()
 
@@ -215,7 +215,7 @@ class Builder(ModelObject, PropertyConta
 
         self.setComplete(True)
 
-    def dump(self, indent = 0, output = sys.stdout):
+    def dump(self, indent=0, output=sys.stdout):
         """ Display the contents of this object """
         i = getIndent(indent)
         output.write(i + self.__class__.__name__ + '\n')
@@ -265,7 +265,7 @@ class BaseAnt(Builder):
     def getTimeout(self):
         return self.timeout
 
-    def dump(self, indent = 0, output = sys.stdout):
+    def dump(self, indent=0, output=sys.stdout):
         """ Display the contents of this object """
         Builder.dump(self, indent, output)
         i = getIndent(indent+1)
@@ -276,7 +276,7 @@ class BaseAnt(Builder):
         if self.timeout():
             output.write(i+'Timeout: ' + self.getTimeout() + '\n')
 
-class Ant(BaseAnt): 
+class Ant(BaseAnt):
     """ An Ant command (within a project) """
     pass
 
@@ -302,7 +302,7 @@ class Maven1(Builder):
     def getGoal(self):
         return self.goal
 
-    def dump(self, indent = 0, output = sys.stdout):
+    def dump(self, indent=0, output=sys.stdout):
         """ Display the contents of this object """
         Builder.dump(self, indent, output)
         i = getIndent(indent + 1)
@@ -313,10 +313,10 @@ MVN_VERSION3 = '3'
 
 # represents an <mvn/> element
 class Maven(Builder):
-    
+
     """ A Maven 2.x/3.x command (within a project)"""
 
-    def __init__(self, dom, project, version = MVN_VERSION2):
+    def __init__(self, dom, project, version=MVN_VERSION2):
         Builder.__init__(self, dom, project)
 
         self.goal = self.getDomAttributeValue('goal', 'package')
@@ -334,7 +334,7 @@ class Maven(Builder):
         """ The profile to use, may be None """
         return self.profile
 
-    def dump(self, indent = 0, output = sys.stdout):
+    def dump(self, indent=0, output=sys.stdout):
         """ Display the contents of this object """
         Builder.dump(self, indent, output)
         i = getIndent(indent + 1)
@@ -371,7 +371,7 @@ class MvnInstall(Maven):
     VERSION = 'version'
     GROUP_ID = 'groupId'
 
-    def __init__(self, dom, project, version = MVN_VERSION2):
+    def __init__(self, dom, project, version=MVN_VERSION2):
         Maven.__init__(self, dom, project, version)
         self.goal = MvnInstall.GOAL
         self.packaging = self.getDomAttributeValue(MvnInstall.PACKAGING,
@@ -394,7 +394,7 @@ class MvnInstall(Maven):
         self._add_property(impl, MvnInstall.FILE, self.file)
         if self.artifactVersion:
             self._add_property(impl, MvnInstall.VERSION, self.artifactVersion)
-        elif not self.packaging == MvnInstall.POM:
+        elif self.packaging != MvnInstall.POM:
             project.addError("version attribute is mandatory if the file is"
                              + " not a POM.")
 
@@ -409,7 +409,7 @@ class MvnInstall(Maven):
             try:
                 pomDoc = self._read_pom()
                 root = pomDoc.documentElement
-                if not root.tagName == 'project':
+                if root.tagName != 'project':
                     self.project.addError('file is not a POM, its root element'
                                           + ' is ' + root.tagName)
                     return
@@ -446,7 +446,7 @@ class MvnInstall(Maven):
         self.importProperty(_create_dom_property(impl, name, value))
 
     def _read_pom(self):
-        """ locates the POM, parses it and returns it as DOM Document """ 
+        """ locates the POM, parses it and returns it as DOM Document """
         pom = os.path.join(self.getBaseDirectory(), self.file)
         return xml.dom.minidom.parse(pom)
 
@@ -478,7 +478,7 @@ class Configure(Builder):
 
     def expandDomProperties(self, project, workspace):
         #
-        # convert Ant property elements which reference a project 
+        # convert Ant property elements which reference a project
         # into dependencies
         #
         for pdom in self.getDomChildIterator('arg'):
@@ -542,7 +542,7 @@ class Gradle(Builder):
         """ The task to execute """
         return self.task
 
-    def dump(self, indent = 0, output = sys.stdout):
+    def dump(self, indent=0, output=sys.stdout):
         """ Display the contents of this object """
         Builder.dump(self, indent, output)
         i = getIndent(indent + 1)



Mime
View raw message