Skip to content

Instantly share code, notes, and snippets.

@ukyo
Created September 1, 2011 13:33
Show Gist options
  • Save ukyo/1186169 to your computer and use it in GitHub Desktop.
Save ukyo/1186169 to your computer and use it in GitHub Desktop.
generate a pydev project for kay.
#!/usr/bin/python
#coding: utf8
import sys
import os
import platform
from pit import Pit
PROJECT = """\
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>%s</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
"""
PYDEVPROJECT = """\
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>GOOGLE_APP_ENGINE</key>
<value>%s</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/%s/src</path>
</pydev_pathproperty>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>${GOOGLE_APP_ENGINE}</path>
<path>${GOOGLE_APP_ENGINE}/lib/django</path>
<path>${GOOGLE_APP_ENGINE}/lib/webob</path>
<path>${GOOGLE_APP_ENGINE}/lib/yaml/lib</path>
</pydev_pathproperty>
</pydev_project>
"""
def main():
if not 'EDITOR' in os.environ:
os.environ['EDITOR'] = 'notepad' if platform.system() == 'Windows' else 'vi'
conf = Pit.get('kay_eclipse', {'require': {'kay_path': 'you\'r kay path', 'gae_path': 'you\'r gae path'}})
project_name = raw_input('project_name: ')
os.mkdir(project_name)
os.chdir(project_name)
project = open('.project', 'w')
pydev_project = open('.pydevproject', 'w')
project.write(PROJECT % project_name)
pydev_project.write(PYDEVPROJECT % (conf['gae_path'], project_name))
project.close()
pydev_project.close()
sys.path.extend((conf['kay_path'], conf['gae_path'], conf['gae_path'] + '/lib/fancy_urllib'))
from kay.management.startapp import startproject
startproject('src')
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment