()
| 514 | |
| 515 | |
| 516 | def main(): |
| 517 | global default_keywords |
| 518 | try: |
| 519 | opts, args = getopt.getopt( |
| 520 | sys.argv[1:], |
| 521 | 'ad:DEhk:Kno:p:S:Vvw:x:X:', |
| 522 | ['extract-all', 'default-domain=', 'escape', 'help', |
| 523 | 'keyword=', 'no-default-keywords', |
| 524 | 'add-location', 'no-location', 'output=', 'output-dir=', |
| 525 | 'style=', 'verbose', 'version', 'width=', 'exclude-file=', |
| 526 | 'docstrings', 'no-docstrings', |
| 527 | ]) |
| 528 | except getopt.error as msg: |
| 529 | usage(1, msg) |
| 530 | |
| 531 | # for holding option values |
| 532 | class Options: |
| 533 | # constants |
| 534 | GNU = 1 |
| 535 | SOLARIS = 2 |
| 536 | # defaults |
| 537 | extractall = 0 # FIXME: currently this option has no effect at all. |
| 538 | escape = 0 |
| 539 | keywords = [] |
| 540 | outpath = '' |
| 541 | outfile = 'messages.pot' |
| 542 | writelocations = 1 |
| 543 | locationstyle = GNU |
| 544 | verbose = 0 |
| 545 | width = 78 |
| 546 | excludefilename = '' |
| 547 | docstrings = 0 |
| 548 | nodocstrings = {} |
| 549 | |
| 550 | options = Options() |
| 551 | locations = {'gnu' : options.GNU, |
| 552 | 'solaris' : options.SOLARIS, |
| 553 | } |
| 554 | |
| 555 | # parse options |
| 556 | for opt, arg in opts: |
| 557 | if opt in ('-h', '--help'): |
| 558 | usage(0) |
| 559 | elif opt in ('-a', '--extract-all'): |
| 560 | options.extractall = 1 |
| 561 | elif opt in ('-d', '--default-domain'): |
| 562 | options.outfile = arg + '.pot' |
| 563 | elif opt in ('-E', '--escape'): |
| 564 | options.escape = 1 |
| 565 | elif opt in ('-D', '--docstrings'): |
| 566 | options.docstrings = 1 |
| 567 | elif opt in ('-k', '--keyword'): |
| 568 | options.keywords.append(arg) |
| 569 | elif opt in ('-K', '--no-default-keywords'): |
| 570 | default_keywords = [] |
| 571 | elif opt in ('-n', '--add-location'): |
| 572 | options.writelocations = 1 |
| 573 | elif opt in ('--no-location',): |
no test coverage detected