supybot-plugin-create: Also make a local directory in the plugin directory

This is to be used for storing third party modules that the plugin needs to
use.  The plugin should then import them using

universalImport('module', 'local.module')

so system-wide/packaged installs of the module are preferred, falling back to
the version shipped with the plugin.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-03-11 19:36:13 -04:00
parent 150f29dbde
commit 777f69dcf0

View File

@ -2,6 +2,7 @@
###
# Copyright (c) 2002-2005, Jeremiah Fincher
# Copyright (c) 2009, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -253,12 +254,13 @@ def main():
if name.endswith('.py'):
name = name[:-3]
copyright %= (realName, license)
pathname = name
# Make the directory.
os.mkdir(name)
os.mkdir(pathname)
def writeFile(filename, s):
fd = file(os.path.join(name, filename), 'w')
fd = file(os.path.join(pathname, filename), 'w')
try:
fd.write(s)
finally:
@ -271,6 +273,11 @@ def main():
writeFile('test.py', testTemplate % (copyright, name, name))
writeFile('README.txt', readmeTemplate)
pathname = os.path.join(pathname, 'local')
os.mkdir(pathname)
writeFile('__init__.py',
'# Stub so local is a module, used for third-party modules\n')
print 'Your new plugin template is in the %s directory.' % name
if __name__ == '__main__':