本文整理汇总了Python中tmparms.tmparms函数的典型用法代码示例。如果您正苦于以下问题:Python tmparms函数的具体用法?Python tmparms怎么用?Python tmparms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tmparms函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: key
def key(self):
return (self.area, self.clubnumber)
### Insert classes and functions here. The main program begins in the "if" statement below.
if __name__ == "__main__":
import tmparms
# Handle parameters
parms = tmparms.tmparms()
parms.add_argument('--quiet', '-q', action='count', default=0)
parms.parser.add_argument("--fromend", dest='fromend', type=int, default=12)
parms.parser.add_argument("--toend", dest='toend', type=int, default=2)
parms.parser.add_argument("--outfile", dest='outfile', type=argparse.FileType('w'), default='punch.html')
parms.parser.add_argument("--needed", dest='needed', type=int, default=5)
parms.parser.add_argument("--renewbase", dest='renewbase', type=int, default=2)
parms.parser.add_argument("--renewbyend", dest='renewbyend', type=int, default=3)
# Do global setup
globals.setup(parms)
curs = globals.curs
conn = globals.conn
today = datetime.now()
示例2: len
s = 'with extension of ' + ', '.join(extensions[:-1])
if len(extensions) > 2:
s += ','
s += ' OR ' + extensions[-1]
output.warning += ' ' + s
return output
if __name__ == "__main__":
import tmutil, tmparms
tmutil.gotodatadir()
reload(sys).setdefaultencoding('utf8')
# Handle parameters
parms = tmparms.tmparms(description=__doc__)
parms.add_argument('--verbose', '-v', action='count', help="Increase verbosity of output")
parms.add_argument('--directory', dest='directory', default='', help="Dropbox directory to examine")
parms.add_argument('--extensions', dest='extensions', metavar="EXTENSION", type=str, nargs='+', action="append", help="extensions to consider")
parms.add_argument('--outfile', dest='outfile', default='-', help="filename for output file; specify '-' for stdout; specify '+' to use the name of the file found; specify 'something.+' to keep the extension of the file but force the name to be 'something'. File is not changed if no file is found.")
parms.add_argument('--namefile', dest='namefile', default=None, help='filename into which to write the name of the output file. Not changed if nothing is written.')
parms.add_argument('--outdir', dest='outdir', default='', help="output directory for output file, especially useful if outfile is '+'")
parms.add_argument('--dropboxtoken', dest='dropboxtoken', help="Dropbox access token")
group = parms.add_mutually_exclusive_group()
group.add_argument('--cursor', dest='cursor', default=None, help="Dropbox cursor")
group.add_argument('--cfile', dest='cfile', default=None, help="Text file containing a Dropbox cursor; gets updated or created if required.")
# Add other parameters here
parms.parse()
# Flatten extension in case it was specified many times
if parms.extensions:
示例3: flatten
import tmglobals
globals = tmglobals.tmglobals()
from collections.abc import Iterable
def flatten(l):
### From http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python
for el in l:
if isinstance(el, Iterable) and not isinstance(el, str):
for sub in flatten(el):
yield sub
else:
yield el
# Handle parameters
parms = tmparms.tmparms(description=__doc__, YMLfile="tmmail.yml", includedbparms=False)
parms.parser.add_argument("--htmlfile", dest='htmlfile')
parms.parser.add_argument("--textfile", dest='textfile')
parms.parser.add_argument("--mailserver", dest='mailserver')
parms.parser.add_argument("--mailpw", dest='mailpw')
parms.parser.add_argument("--mailport", dest='mailport')
parms.parser.add_argument("--from", dest='from')
parms.parser.add_argument("--to", dest='to', nargs='+', default=[], action='append')
parms.parser.add_argument("--cc", dest='cc', nargs='+', default=[], action='append')
parms.parser.add_argument("--bcc", dest='bcc', nargs='+', default=[], action='append')
parms.parser.add_argument("--subject", dest='subject', default='Mail from the District Webmaster')
globals.setup(parms, connect=False)
parms.sender = parms.__dict__['from'] # Get around reserved word
示例4: setup
self.setup(*args,**kwargs)
return
def setup(self, *args, **kwargs):
self.parms = args[0]
self.conn = None
self.curs = None
self.tmyear = None
if kwargs.get('gotodatadir', True):
curdir = os.path.realpath(os.curdir) # Get the canonical directory
lastpart = curdir.split(os.sep)[-1]
if lastpart.lower() != 'data':
os.chdir('data') # Fails if there is no data directory; that is intentional.
if kwargs.get('defaultencoding', ''):
reload(sys).setdefaultencoding(defaultencoding)
if kwargs.get('parse', True):
self.parms.parse()
if kwargs.get('connect', True):
self.conn = dbconn.dbconn(self.parms.dbhost, self.parms.dbuser, self.parms.dbpass, self.parms.dbname)
self.curs = self.conn.cursor()
self.curs.execute("SELECT MAX(tmyear) FROM lastfor")
self.tmyear = self.curs.fetchone()[0]
self.today = date.today()
return self
if __name__ == '__main__':
import tmparms
p = tmparms.tmparms()
g = tmglobals()
g.setup(p)
示例5: return
return (' <td>%s</td><td>%s</td><td>%.2f%%</td>' % (self.area, self.clubname, self.pct))
def key(self):
return (self.area, self.clubnumber)
if __name__ == "__main__":
import tmparms, latest, os, sys, csv
from datetime import datetime
from tmutil import showclubswithvalues, cleandate, getClubBlock, gotodatadir
import tmglobals
globals = tmglobals.tmglobals()
# Define args and parse command line
parms = tmparms.tmparms(description=__doc__, epilog='pct and earns must have the same number of items.\nIf names is specified, it must have the same number as well.')
parms.add_argument('--finaldate', default='', dest='finaldate', help="Final date for qualifying.")
parms.add_argument('--outfileprefix', default='', dest='outfileprefix', type=str, help="Output file prefix.")
parms.add_argument('--format', default='$%d in District Credit')
parms.add_argument('--pct', dest='pct', nargs='+', type=float, help='Threshold to qualify (in percent) for each level.', default='75.0')
parms.add_argument('--earns', dest='earns', nargs='+', type=int, help='Amount earned for each level.', default='50')
parms.add_argument('--program', choices=['madness', 'stellar'])
parms.add_argument('--name', dest='name', nargs='+', type=str, help='Name for each level. Specify \'\' if no name for a level.')
# Do global setup
globals.setup(parms)
curs = globals.curs
conn = globals.conn
# Ensure proper matching of names, pct, and earns.
if not isinstance(parms.pct, list):