commitlog.py :  » Template-Engines » Clearsilver » clearsilver-0.10.5 » scripts » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Template Engines » Clearsilver 
Clearsilver » clearsilver 0.10.5 » scripts » commitlog.py
#!/usr/bin/python
# commitlog.py
#
# Written July 2001 by David W. Jeske <jeske@neotonic.com>
#
# Released freely into the public domain.
#
#  parse CVS commit logs and make nice submit logs...
#

import sys
import os
import string
import time


def main(argv):
  PATH = argv[1]
  module = argv[2]

  body = sys.stdin.read()
  body_lines = string.split(body,"\n")

  mode = 0

  mod_files = []
  add_files = []
  rem_files = []
  log_lines = []

  for a_line in body_lines:
    if a_line == "Modified Files:":
      mode = "modfiles"
    elif a_line == "Added Files:":
      mode = "addfiles"
    elif a_line == "Log Message:":
      mode = "loglines"
    elif a_line == "Removed Files:":
      mode = "remfiles"
    else:
      if mode == "modfiles":
        mod_files.append(string.strip(a_line))
      elif mode == "addfiles":
        add_files.append(string.strip(a_line))
      elif mode == "loglines":
        log_lines.append(a_line)
      elif mode == "remfiles":
        rem_files.append(string.strip(a_line))


  # if files don't exist, we should create them...

  CVS_USER = os.environ['LOGNAME']
  DATE = time.strftime( "%I:%M%p %Y/%m/%d", time.localtime(time.time()))

  log_summary = "%10s %16s %s\n" % (CVS_USER,DATE,string.join(log_lines," ")[:60])

  filename = os.path.join(PATH,"%s.summary" % module)
  os.system('co -f -q -l %s %s,v' % (filename,filename))

  # check to see if the log line is already there
  fps = open(filename,"a+")
  try:
    fps.seek(-len(log_summary),2)
    check_data = fps.read(len(log_summary))
    if check_data != log_summary:
      fps.write(log_summary)
  except IOError:
    # Not enough data to go back that far
    fps.write(log_summary)
    

  fps.close()
  os.system('ci -q -m"none" %s %s,v' % (filename,filename))

  log_data = "----------------\n" + "USER: %s\n" % CVS_USER + "DATE: %s\n" % DATE + body

  filename = os.path.join(PATH,"%s" % module)
  os.system('co -f -q -l %s %s,v' % (filename,filename))
  fp = open(filename,"a+")
  fp.write(log_data)
  fp.close()
  os.system('ci -q -m"none" %s %s,v' % (filename,filename))

if __name__ == "__main__":
  main(sys.argv)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.