本文整理汇总了Python中main.Main.create方法的典型用法代码示例。如果您正苦于以下问题:Python Main.create方法的具体用法?Python Main.create怎么用?Python Main.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main.Main
的用法示例。
在下文中一共展示了Main.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import create [as 别名]
def init(argv):
opts, methods = getopt(argv, 'hl:r:vm:s:a:fi:NP:ducS', ['help', 'lang=', 'reference=', 'version' ,'main=', 'skeleton=', 'add=', 'cout', 'force', 'include=', 'prefix=', 'downcase', 'uppercase', 'camel', 'snake'])
xunit = load()
includes = []
prefix = 1
force = 0
cout = 0
add = None
skeleton = None
main = None
lang = None
downcase = None
snake = None
for opt, value in opts:
if '-h' == opt or '--help' == opt:
usage()
sys.exit(0)
elif '-v' == opt or '--version' == opt:
version()
for lang in xunit.lang.items():
print ' ' + lang[1].version + '(--lang ' + lang[0] + ')'
sys.exit(0)
elif '-r' == opt or '--reference' == opt:
try:
print xunit.lang[value].reference
except KeyError:
sys.stderr.write('Un Support Language:%s' % value)
sys.exit(1)
elif '-l' == opt or '--lang' == opt:
try:
lang = xunit.lang[value]
except KeyError:
sys.stderr.write('Un Support Language:%s' % value)
sys.exit(1)
elif '-m' == opt or '--main' == opt:
main = value
elif '-s' == opt or '--skeleton' == opt:
skeleton = value
elif '-a' == opt or '--add' == opt:
add = value
force = 1
elif '-P' == opt or '--prefix' == opt:
if value == '+':
prefix = 1
elif value == '-':
prefix = 0
else:
raise ValueError, "prefix option can accept only '+' or '-'"
elif '-f' == opt or '--force' == opt:
force = 1
elif '-d' == opt or '--downcase' == opt:
downcase = 1
elif '-u' == opt or '--uppercase' == opt:
downcase = 0
elif '-S' == opt or '--snake' == opt:
snake = 1
elif '-c' == opt or '--camel' == opt:
snake = 0
elif '--cout' == opt:
cout = 1
elif '-i' == opt or '--include' == opt:
includes.append(value)
if add is not None:
add = Add(add, language(xunit, lang, add), methods, includes)
add.create()
output(add.filename, add.result, force, cout)
else:
if skeleton is not None:
skeleton = Skeleton(skeleton, methods, includes, prefix,
language(xunit, lang, skeleton))
skeleton.create()
output(skeleton.filename, skeleton.result, force, cout)
if main is not None:
main = Main(main, language(xunit, lang, main))
main.create()
output(main.filename, main.result, force, cout)