"Fossies" - the Fresh Open Source Software Archive

Member "svnchecker-0.3/checks/Keywords.py" (12 Mar 2008, 1753 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 "Keywords.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 """
   16 Checks for svn:keywords on all added files in this commit.
   17  
   18 subversion knows the following keywords for substitution:
   19 svn:keywords  also known as
   20 =======================================
   21 Date          LastChangeDate
   22 Revision      LastChangedRevision | Rev
   23 Author        LastChangedBy
   24 HeadURL       URL
   25 Id
   26 """
   27 
   28 from modules.Transaction import PropertyNotFoundException
   29 
   30 def run(transaction, config) :
   31 
   32     check = config.getArray("Keywords.CheckFiles", [".*"])
   33     ignore = config.getArray("Keywords.IgnoreFiles", [])
   34     files = transaction.getFiles(check, ignore)
   35 
   36     msg = ""
   37     keywordsShould = config.getArray("Keywords.Keywords")
   38 
   39     for filename, attribute in files.iteritems():
   40         if attribute in ["A", "U", "_U", "UU"]:
   41             try:
   42                 keywordsIs = transaction.getProperty("svn:keywords", filename)
   43             except PropertyNotFoundException:
   44                 keywordsIs = ""
   45 
   46             for keyword in keywordsShould:
   47                 if keyword not in keywordsIs:
   48                     msg += "Missing keyword %r on file %r.\n" % (keyword, filename) 
   49 
   50     if msg:
   51         return (msg, 1)
   52     else:
   53         return ("", 0)