Mercurial > hg > pyloader
comparison pyloader/factory.py @ 23:9b2ca32e7a36
wire up command line entry point
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 06 Jun 2011 07:46:18 -0700 |
parents | b16d6a204ac1 |
children | ce8fa574324d |
comparison
equal
deleted
inserted
replaced
22:b16d6a204ac1 | 23:9b2ca32e7a36 |
---|---|
1 #!/usr/bin/env python | |
2 | |
1 """ | 3 """ |
2 abstract factories | 4 abstract factories |
3 """ | 5 """ |
4 | 6 |
5 import cast | 7 import cast |
6 import loader | 8 import loader |
7 import os | 9 import os |
8 import sys | 10 import sys |
11 from optparse import OptionParser | |
9 from ConfigParser import InterpolationMissingOptionError | 12 from ConfigParser import InterpolationMissingOptionError |
10 from ConfigParser import InterpolationSyntaxError | 13 from ConfigParser import InterpolationSyntaxError |
11 from ConfigParser import SafeConfigParser as ConfigParser | 14 from ConfigParser import SafeConfigParser as ConfigParser |
12 | 15 |
13 __all__ = ['CircularReferenceError', 'PyFactory', 'IniFactory'] | 16 __all__ = ['CircularReferenceError', 'PyFactory', 'IniFactory'] |
139 | 142 |
140 return config | 143 return config |
141 | 144 |
142 def main(args=sys.argv[1:]): | 145 def main(args=sys.argv[1:]): |
143 """command line entry point""" | 146 """command line entry point""" |
147 parser = OptionParser() | |
148 options, args = parser.parse_args(args) | |
149 | |
150 if len(args) != 1: | |
151 parser.print_usage() | |
152 parser.exit() | |
153 | |
154 factory = IniFactory(args[0]) | |
155 print factory.load() | |
144 | 156 |
145 if __name__ == '__main__': | 157 if __name__ == '__main__': |
146 main() | 158 main() |