"Fossies" - the Fresh Open Source Software Archive 
Member "svnchecker-0.3/checks/Checkstyle.py" (9 Jul 2008, 1609 Bytes) of package /linux/privat/old/svnchecker-0.3.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "Checkstyle.py" see the
Fossies "Dox" file reference documentation.
1 # Copyright 2008 German Aerospace Center (DLR)
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 """ Checks Java files for coding style errors using Checkstyle. """
16
17 from modules import Process
18
19 def run(transaction, config):
20
21 check = config.getArray("Checkstyle.CheckFiles", [".*\.java"])
22 ignore = config.getArray("Checkstyle.IgnoreFiles", [])
23 files = transaction.getFiles(check, ignore)
24
25 java = config.getString("Checkstyle.Java")
26 classpath = config.getString("Checkstyle.Classpath")
27 config = config.getString("Checkstyle.ConfigFile")
28
29 command = "%s -classpath %s com.puppycrawl.tools.checkstyle.Main -c %s " % (java, classpath, config)
30
31 files = [transaction.getFile(oneFile[0]) for oneFile in files.iteritems() if oneFile[1] in ["A", "U", "UU"]]
32
33 try:
34 Process.execute(command + " ".join(files))
35 except Process.ProcessException, e:
36 msg = "Coding style errors found:\n\n"
37 msg += e.output + "\n"
38 msg += "See Checkstyle documentation for a detailed description: http://checkstyle.sourceforge.net/"
39 return (msg, 1)
40
41 return ("", 0)