File: options.py

package info (click to toggle)
texlive-bin 2025.20250727.75242%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 209,764 kB
  • sloc: ansic: 893,576; cpp: 156,185; perl: 101,166; sh: 37,697; python: 13,679; javascript: 9,754; makefile: 8,930; xml: 8,361; lex: 5,176; pascal: 3,814; java: 3,569; yacc: 2,935; tcl: 2,903; exp: 2,031; ruby: 712; lisp: 687; sed: 375; asm: 140; csh: 46; awk: 30
file content (31 lines) | stat: -rw-r--r-- 906 bytes parent folder | download | duplicates (2)
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
#! /usr/bin/python
# -*- coding: utf-8 -*-
# @creator (C) 2003 Guido U. Draheim
# @license http://creativecommons.org/licenses/by-nc-sa/2.0/de/

from zzipdoc.match import Match

# use as o.optionname to check for commandline options.
class Options:
    var = {}
    def __getattr__(self, name):
        if not name in self.var: return None
        return self.var[name]
    def __setattr__(self, name, value):
        self.var[name] = value
    def scan(self, optionstring): # option-name or None
        x = Match()
        if optionstring & x(r"^--?(\w+)=(.*)"):
            self.var[x[1]] = x[2] ;  return x[1]
        if optionstring & x(r"^--?no-(\w+)$"):
            self.var[x[1]] = "" ; return x[1]
        if optionstring & x(r"^--?(\w+)$"):
            self.var[x[1]] = "*"; return x[1]
        return None
#end Options

if False:
    o = Options()
    o.help = """
    scans for options
    """