Exemplo n.º 1
0
 def left(self, year):
     if year == "current":
         year = date.today().year
     leave = Query()
     taken = self.storage.countdays(year)
     total = int(getconf().get("days_of_leave", 0))
     return f"{total - taken} days left."
Exemplo n.º 2
0
 def is_holliday(self):
     conf = getconf()
     country = conf["country_for_holidays"]
     country_code = get_country_code(country)
     if country_code:
         cal = registry.get_calendar_class(country_code)()
         return cal.is_holliday(self.date)
     else:
         return
Exemplo n.º 3
0
def configure():
    """
    Prompts user for configuration settings
    """
    keys = get_keys()
    actualconfig = getconf()
    newconf = {}
    click.echo("Modify configuration")
    for k in keys:
        newconf[k[0]] = click.prompt(
            f"{slightlybeautify(k[0])}".capitalize(),
            default=actualconfig.get(k[0], None),
            type=k[1],
        )
    setconf(newconf)
Exemplo n.º 4
0
 def store(self):
     conf = getconf()
     approved = "Approved" if self.approved else "Pending"
     data = dict(rawdate=self.rawdate,
                 year=self.year,
                 approved=self.approved)
     if not conf.get("work_on_public_holidays", False):
         if not conf.get("work_on_weekends", False):
             if not self.is_working_day():
                 return f"({self.rawdate}) is on a weekend"
         else:
             if self.is_holliday():
                 return f"({self.rawdate}) seems to be on a public holiday"
     if self.storage.put(self.rawdate, data):
         return f"{self.rawdate} added"