/usr/share/quickly/templates/ubuntu-application/add.py is in quickly-ubuntu-template 12.08.1-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/usr/bin/python
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2009 Didier Roche
#
# This file is part of Quickly ubuntu-application template
#
#This program is free software: you can redistribute it and/or modify it
#under the terms of the GNU General Public License version 3, as published
#by the Free Software Foundation.
#This program is distributed in the hope that it will be useful, but
#WITHOUT ANY WARRANTY; without even the implied warranties of
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
#PURPOSE. See the GNU General Public License for more details.
#You should have received a copy of the GNU General Public License along
#with this program. If not, see <http://www.gnu.org/licenses/>.
import glob
import imp
import os
import sys
from quickly import templatetools, commands
import gettext
from gettext import gettext as _
# set domain text
gettext.textdomain('quickly')
argv = sys.argv
ADDABLE = {}
def get_addable_from_path(_path):
'''parse addable files'''
_path = os.path.expanduser(_path)
globs = glob.glob('%s/*.py' % _path)
# get only files
addable_files = [y for y in globs if os.path.isfile(y)]
# exclude __init__.py
addable_files = [y for y in addable_files if os.path.basename(y)[0] != '_']
for _file in addable_files:
_basename = os.path.splitext(os.path.basename(_file))[0]
py_mod = imp.load_source(_basename,_file)
ADDABLE.update(((_basename, py_mod),))
def get_addable():
parent_path = os.path.dirname(__file__)
template_path = templatetools.get_template_path_from_project()
get_addable_from_path(os.path.join(parent_path, 'store'))
get_addable_from_path(os.path.join(template_path, 'store'))
get_addable()
options = {}
for item in ADDABLE.items():
try:
options[item[0]] = item[1].option
except AttributeError:
# ignore files in store that have no option for us
pass
def usage():
templatetools.print_usage(options.values())
def help():
help_list = [_('Add something to your project\n')]
# TODO sort keys
for module in ADDABLE.values():
try:
help_list.append(module.help_text)
except AttributeError:
# ignore files in store that have no help for us
pass
help_text = '\n\n'.join(help_list)
print help_text
def shell_completion(argv):
''' Complete args '''
# option completion
rv = []
if len(argv) == 1:
rv = options.keys()
if rv:
rv.sort()
print ' '.join(rv)
templatetools.handle_additional_parameters(sys.argv, help, shell_completion, usage=usage)
if len(sys.argv) < 2:
cmd = commands.get_command('add', 'ubuntu-application')
templatetools.usage_error(_("Cannot add, no plugin name provided."), cmd=cmd, template='ubuntu-application')
if argv[1] in ADDABLE.keys():
ADDABLE[argv[1]].add(options)
else:
cmd = commands.get_command('add', 'ubuntu-application')
templatetools.usage_error(_('Cannot add, did not recognize plugin name: %s' % argv[1]), cmd=cmd, template='ubuntu-application')
sys.exit(4)
|