__init__.py :  » Language-Interface » ChinesePython » chinesepython2.1.3-0.4 » Mac » Lib » mkcwproject » 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 » Language Interface » ChinesePython 
ChinesePython » chinesepython2.1.3 0.4 » Mac » Lib » mkcwproject » __init__.py
import cwxmlgen
import cwtalker
import os
import AppleEvents
import macfs

def mkproject(outputfile, modulename, settings, force=0, templatename=None):
  #
  # Copy the dictionary
  #
  dictcopy = {}
  for k, v in settings.items():
    dictcopy[k] = v
  #
  # Fill in mac-specific values
  #
  dictcopy['mac_projectxmlname'] = outputfile + '.xml'
  dictcopy['mac_exportname'] = os.path.split(outputfile)[1] + '.exp'
  if not dictcopy.has_key('mac_outputdir'):
    dictcopy['mac_outputdir'] = ':lib:'
  if not dictcopy.has_key('mac_dllname'):
    dictcopy['mac_dllname'] = modulename + '.ppc.slb'
  if not dictcopy.has_key('mac_targetname'):
    dictcopy['mac_targetname'] = modulename + '.ppc'
  if os.path.isabs(dictcopy['sysprefix']):
    dictcopy['mac_sysprefixtype'] = 'Absolute'
  else:
    dictcopy['mac_sysprefixtype'] = 'Project' # XXX not sure this is right...
  #
  # Generate the XML for the project
  #
  xmlbuilder = cwxmlgen.ProjectBuilder(dictcopy, templatename=templatename)
  xmlbuilder.generate()
  if not force:
    # We do a number of checks and all must succeed before we decide to
    # skip the build-project step:
    # 1. the xml file must exist, and its content equal to what we've generated
    # 2. the project file must exist and be newer than the xml file
    # 3. the .exp file must exist
    if os.path.exists(dictcopy['mac_projectxmlname']):
      fp = open(dictcopy['mac_projectxmlname'])
      data = fp.read()
      fp.close()
      if data == dictcopy["tmp_projectxmldata"]:
        if os.path.exists(outputfile) and \
            os.stat(outputfile)[os.path.ST_MTIME] > os.stat(dictcopy['mac_projectxmlname'])[os.path.ST_MTIME]:
          if os.path.exists(outputfile + '.exp'):
            return
  fp = open(dictcopy['mac_projectxmlname'], "w")
  fp.write(dictcopy["tmp_projectxmldata"])
  fp.close()
  #
  # Generate the export file
  #
  fp = open(outputfile + '.exp', 'w')
  fp.write('init%s\n'%modulename)
  if dictcopy.has_key('extraexportsymbols'):
    for sym in dictcopy['extraexportsymbols']:
      fp.write('%s\n'%sym)
  fp.close()
  #
  # Generate the project from the xml
  #
  makeproject(dictcopy['mac_projectxmlname'], outputfile)
  
def makeproject(xmlfile, projectfile):
  cw = cwtalker.MyCodeWarrior(start=1)
  cw.send_timeout = AppleEvents.kNoTimeOut
  xmlfss = macfs.FSSpec(xmlfile)
  prjfss = macfs.FSSpec(projectfile)
  cw.activate()
  cw.my_mkproject(prjfss, xmlfss)
  
def buildproject(projectfile):
  cw = cwtalker.MyCodeWarrior(start=1)
  cw.send_timeout = AppleEvents.kNoTimeOut
  prjfss = macfs.FSSpec(projectfile)
  cw.open(prjfss)
  cw.Make_Project()  # XXX Should set target
  cw.Close_Project()
  
def cleanproject(projectfile):
  cw = cwtalker.MyCodeWarrior(start=1)
  cw.send_timeout = AppleEvents.kNoTimeOut
  prjfss = macfs.FSSpec(projectfile)
  cw.open(prjfss)
  cw.Remove_Binaries()
    
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.