You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
786 B
28 lines
786 B
#! /usr/bin/env python3 |
|
|
|
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 |
|
"""
|
|
|