def __init__(self, dates): self.dates = dates self.years = Bindings() for index, date in enumerate(dates): try: self.years[date.year].add(index, date) except (KeyError, ValueError), err: self.years[date.year] = YearIndices(index, date)
def __init__(self, start_index, start_date): self.start_date = date(start_date.year, 01, 01) self.last_date = date(start_date.year, 12, 31) self.year = start_date.year self.months = Bindings() self.indices = [] self.add(start_index, start_date)
def __init__(self, start_index, start_date): self.start_date = date(start_date.year, start_date.month, 01) if start_date.month == 12: self.last_date = date(start_date.year, 12, 31) else: self.last_date = date(start_date.year, start_date.month + 1, 01) - timedelta(1) self.month = start_date.month self.months = Bindings() self.indices = [] self.add(start_index, date)
def getContextBindings(): """Returns a L{Bindings} instance of plopt name-to-value pairs. The bindings could thereafter be used to re-create the current context from a command-line:: bindings = plargs.getContextBindings() cmdline = [ "%s=%s"%(opt, bindings['opt']) for opt in bindings ] actual_command_line = " ".join(cmdline) """ context = actualContext(plargs) bindings = Bindings() for binder in plargs.getBinders(): for opt in plopt.iterator(binder): bindings[opt.getName()] = opt.get() for namespace in plargs.getNamespaces(): for opt in plopt.iterator(namespace): key = "%s.%s" % (namespace.__name__, opt.getName()) bindings[key] = opt.get() return bindings