示例#1
0
 def get_calendars(self):
     now = timezone.now()
     this_year = now.year
     this_month = now.month
     this_month_cal = Calendar(this_year, this_month)
     next_month_cal = Calendar(this_year, this_month + 1 if this_month != 12 else 1)
     return [this_month_cal, next_month_cal]
示例#2
0
 def get_calendars(self):
     now = timezone.now()
     this_month = Calendar(now.year, now.month)
     if now.month != 12:
         next_month = Calendar(now.year, now.month + 1)
     else:
         next_month = Calendar(now.year + 1, 1)
     return [this_month, next_month]
示例#3
0
    def __init__(questions=100, dt=datetime.datetime.now()):
        # make questions
        self.questions = 100
        self.entries = []
        self.dt = dt
        self.cal = Calendar(dt)

        self.fill()
示例#4
0
 def get_calendars(self):
     year = timezone.now().year
     month = timezone.now().month
     next_month = month + 1
     if month == 12:
         next_month = 1
     this_month_cal = Calendar(year, month)
     next_month_cal = Calendar(year, next_month)
     return [this_month_cal, next_month_cal]
示例#5
0
 def get_calendars(self):
     year = datetime.today().year
     month = datetime.today().month
     this_month = Calendar(year, month)
     if month != 12:
         next_month = Calendar(year, month + 1)
     else:
         next_month = Calendar(year + 1, 1)
     return [this_month, next_month]
示例#6
0
def change_calendar():
    print("Pobieranie danych o świętach...")
    cal = Calendar()
    temp2 = ""
    holidays = cal.get_holidays()
    for k, v in holidays.items():
        temp2 = temp2 + "{} - {}\n".format(k, v)
    hol_val.set(temp2)
    u_hol_val.set(cal.get_unusual_day())
    day_val.set(cal.get_day())
示例#7
0
 def get_calendars(self):
     now = timezone.localtime()
     this_year = now.year
     this_month = now.month
     this_month_cal = Calendar(this_year, this_month)
     if this_month == 12:
         next_month_cal = Calendar(this_year + 1, 1)
     else:
         next_month_cal = Calendar(this_year, this_month + 1)
     return [this_month_cal, next_month_cal]
示例#8
0
 def get_calendars(self):
     now = timezone.now()
     this_year = now.year
     this_month = now.month
     next_month = this_month + 1
     if this_month == 12:
         next_month = 1
     this_month_cal = Calendar(this_year, this_month)
     next_month_cal = Calendar(this_year, next_month)
     return [this_month_cal, next_month_cal]
示例#9
0
    def get_calendar(self):
        now = timezone.now()
        this_month = Calendar(now.year, now.month)
        next_year = now.year
        next_month = now.month + 1
        if now.month == 12:
            next_year += 1
            next_month = 1

        next_month = Calendar(next_year, next_month)
        return [this_month, next_month]
示例#10
0
 def get_calendars(self):
     now = timezone.now()
     this_year = now.year
     this_month = now.month
     next_month = (this_month + 1) % 12
     next_year = this_year
     if this_month == 12:
         next_year = this_year + 1
     this_month_calendar = Calendar(this_year, this_month)
     next_month_calendar = Calendar(next_year, next_month)
     return [this_month_calendar, next_month_calendar]
示例#11
0
    def get_calendars(self):

        now = timezone.now()
        this_month_cal = Calendar(now.year, now.month)
        if now.month != 12:
            next_month_cal = Calendar(now.year, now.month + 1)
        else:
            next_month_cal = Calendar(now.year, 1)
        calendars = [this_month_cal, next_month_cal]

        return enumerate(calendars)
示例#12
0
 def get_calendars(self):
     now = timezone.now()
     if now.month == 12:
         next_Year = now.year + 1
         next_Month = 1
     else:
         next_Year = now.year
         next_Month = now.month + 1
     this_month = Calendar(now.year, now.month)
     next_month = Calendar(next_Year, next_Month)
     return [this_month, next_month]
示例#13
0
 def get_calendars(self):
     now = timezone.localtime()
     year = now.year
     month = now.month
     next_year = now.year
     next_month = now.month + 1
     if month == 12:
         next_year += 1
         next_month = 1
     ob_this_month = Calendar(year, month)
     ob_next_month = Calendar(next_year, next_month)
     return [ob_this_month, ob_next_month]
示例#14
0
 def get_calendars(self):
     now = timezone.now()
     year1 = now.year
     this_month = now.month
     year2 = now.year
     next_month = this_month + 1
     if this_month == 12:
         next_month = 1
         year2 += 1
     this_month = Calendar(year1, this_month)
     next_month = Calendar(year2, next_month)
     return [this_month, next_month]
示例#15
0
    def get_calendars(self):
        year = timezone.now().year
        this_month = timezone.now().month
        next_month = this_month + 1

        cal_this_month = Calendar(year, this_month)
        if this_month == 12:
            year += 1
            next_month = 1
        cal_next_month = Calendar(year, next_month)

        return [cal_this_month, cal_next_month]
示例#16
0
 def get_calendars(self):
     now = timezone.now()
     current_year = now.year
     current_month = now.month
     following_month = 1
     if current_month == 12:
         following_month == 1
     else:
         following_month = current_month + 1
     current_month = Calendar(current_year, current_month)
     next_month = Calendar(current_year, following_month)
     return [current_month, next_month]
示例#17
0
 def get_calendars(self):
     now = timezone.now()
     this_month = now.month
     this_year = now.year
     if this_month == 12:
         next_month = 1
         next_year = this_year + 1
     else:
         next_month += 1
         next_year = this_year
     this_month = Calendar(this_year, this_month)
     next_month = Calendar(next_year, next_month)
     return this_month, next_month
示例#18
0
    def get_this_and_next_months(self):
        now = timezone.now()
        year = now.year
        month = now.month
        next_month = month+1
        next_year = year

        if month == 12:
            next_month = 1
            next_year = year+1

        this_month_day = Calendar(year, month)
        next_month_day = Calendar(next_year, next_month)

        return [this_month_day, next_month_day]
示例#19
0
    def get_calendars(self):
        now = timezone.now()
        if now.month == 12:
            this_year = now.year
            this_month = now.month
            next_year = this_year + 1
            next_month = 1
        else:
            this_year = now.year
            this_month = now.month
            next_year = this_year
            next_month = this_month + 1

        this_month = Calendar(this_year, this_month)
        next_month = Calendar(next_year, next_month)
        return [this_month, next_month]
示例#20
0
    def get_calendars(self):
        now = timezone.now()
        year = now.year
        year_temp = year

        this_month_temp = now.month

        if this_month_temp == 12:
            year_temp = year_temp + 1
            next_month_temp = 1

        else:
            next_month_temp = this_month_temp + 1

        this_month = Calendar(year, this_month_temp)
        next_month = Calendar(year_temp, next_month_temp)

        return [this_month, next_month]
示例#21
0
def create_calendar():
    print("Tworzenie nowego kalendarza...")
    tk_cal = T_cal(root, selectmode='none', headersforeground='white', headersbackground='black',
                   normalbackground='black', normalforeground='white', disabledbackground='black',
                   disabledforeground='gray', weekendbackground='black', weekendforeground='gray',
                   othermonthbackground='black', othermonthforeground='gray',
                   othermonthwebackground='black', tooltipforeground='red', tooltipbackground='black',
                   tooltipalpha=float(1), borderwidth=0, showothermonthdays=False, locale='pl_PL',
                   selectbackground='gray')
    from cal import Calendar
    calendar = Calendar()
    for k, v in calendar.get_holidays().items():
        k = k + str(' 10:47:14.489795')
        date = datetime.datetime.strptime(k, '%Y-%m-%d %H:%M:%S.%f')
        if v[0] == '!':
            tk_cal.calevent_create(date, v, 'other')
        else:
            tk_cal.calevent_create(date, v, 'holidays')
    tk_cal.tag_config('holidays', background='red', foreground='white')
    tk_cal.tag_config('other', background='green', foreground='white')

    tk_cal.pack(fill="none", expand=False)
    ttk.Label(root, textvariable=u_hol_val, background='black', foreground='white', justify='center').pack()
示例#22
0
from patients import Patient, PatientRecords
from employees import Doctor, Receptionist, PayRoll
from cal import Calendar


if __name__ == "__main__":
    providers = PayRoll('employees.csv')
    patients = PatientRecords('patients.csv')
    c = Calendar('appointments.csv')

    c.show_calendar()
示例#23
0
class Page:
    def __init__(questions=100, dt=datetime.datetime.now()):
        # make questions
        self.questions = 100
        self.entries = []
        self.dt = dt
        self.cal = Calendar(dt)

        self.fill()

    def fill(self):
        # first, determine how many questions are in the real database for this time period

        # open up database

        engine = create_engine('sqlite:///data.db', echo=True)
        metadata = MetaData()

        submitted = table_submitted(metadata)

        # get all data from this month
        s = select([submitted]).where(cookies.c.month == self.date.month)
        submitted_entries = connection.execute(s)

        # if the amount is less than we want
        num_genarated = self.questions - rp.count()
        genarated_entries = self.genarate(num_genarated, metadata)

        # add the submitted q's in first, tell calendar where things lie

        # add these bad boys into entries
        for entry in submitted_entries:
            self.add_submitted_entry(entry)

        # tell calendar it can now fill things up
        self.cal.genarate(num_genarated)

        # fill up the entries with fake components
        for entry in genarated_entries:
            self.add_genarated_entry

        # order all entries by date
        entries = sorted(entries, key=lambda entry: entry.get_comparison())

        # page done

    def add_genarated_entry(self, e):
        entry = Entry(self.cal.get_next_entry(), {
            'question': e.question,
            'answer': e.answer
        })
        self.entries.append(entry)

    def add_submitted_entry(self, e):
        # tell calendar you've updated
        cal.add_entry(e.datetime)

        # make an entry
        entry = Entry(e.datetime, {'question': e.question, 'answer': e.answer})

        # add the entry
        self.entries.append(entry)

    def genarate(self, num, metadata):

        genarated = table_genarated(metadata)
        s = select([submitted]).order_by(func.random()).limit(num)
        return connection.execute(s)

    def get_entries(self):
        return self.entries

    def get_num_qs(self):
        pct_single = 95
        pct_double = 4
        pct_triple = 1

        randy = random.random() * (pct_single + pct_double + pct_triple)

        if randy < pct_single:
            num_qs = 1
        elif randy < pct_single + pct_double:
            num_qs = 2
        else:
            num_qs = 3

        return num_qs
示例#24
0
from oauth2client import client
from oauth2client import tools

from cal import Calendar

from pytz import timezone

# general config
SCOPES = 'https://www.googleapis.com/auth/calendar'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Competitive Programming Event Cal Aggregate'
CRED_STORAGE_DIR = '.credentials/'
CRED_STORAGE = CRED_STORAGE_DIR + 'cred.json'

# cal config
CALENDAR_OUTPUT = Calendar('*****@*****.**')
IGNORE_EVENTS_AFTER_WEEKS = 52

LOCAL_TIMEZONE = timezone('Australia/Adelaide')

# 5am to 12am w.r.t the specified local timezone
GLOBAL_TIME_RANGE = (5, 24)

MIN_HOURS_OUTSIDE_RANGE = 1

CALANDERS_QUERY = [
    # topcoder
    Calendar(
        '*****@*****.**',
        include_events=['SRM', 'TCO'],
        time_range=GLOBAL_TIME_RANGE),
示例#25
0
def main(args):
    with open(args.constraints, 'r') as f:
        constraints = yaml.safe_load(f)
    calendar = Calendar()
    calendar.weekly_events('primary', 1)
示例#26
0
 def get_calendars(self):
     today = datetime.date.today()
     nextmonth = today + relativedelta.relativedelta(months=1)
     this_month = Calendar(today.year, today.month)
     next_month = Calendar(nextmonth.year, nextmonth.month)
     return [this_month, next_month]
示例#27
0
 def get_calendars(self):
     today = date.today()
     this_month = Calendar(today.year, today.month)
     next_month = Calendar(today.year, today.month + 1)
     return [this_month, next_month]
示例#28
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--calendar', default='calendar')

    # ADD EVENT:
    # Mandatory: -e description, -dt start_times, -len duration
    # Optional: -len duration (defaults to 1 hour)
    #           -loc location, -r days_delta, -ex exceptions, -u enddate to specify a repeater.
    parser.add_argument('-e', '--event')
    parser.add_argument('-dt', '--dates', nargs='+')
    parser.add_argument('-len', '--duration')
    parser.add_argument('-loc', '--location')

    parser.add_argument('-r', '--days-delta')
    parser.add_argument('-ex', '--exceptions', nargs='+')
    parser.add_argument('-u', '--enddate')

    # ADD DUE TASK
    # Mandatory: -t description, -due due_dates
    # Optional: -r days_delta, -ex exceptions, -u enddate to specify a repeater.
    parser.add_argument('-t', '--task')
    parser.add_argument('-due', '--due-dates', nargs='+')

    # ADD PRIORITY TASK -t <description
    # Mandatory: -t description
    # Optional: -p priority (defaults to Priority.LOW)
    parser.add_argument('-p', '--priority')

    # COMPLETE TASK
    # Mandatory: -f task description substring to search
    parser.add_argument('-f', '--finish')

    # EDIT
    # Mandatory: -edit description substring to search
    # Optional: any number of arguments to edit
    parser.add_argument('-edit', '--edit')

    # DELETE
    # Mandatory: -del description substring to search
    parser.add_argument('-del', '--delete')

    # SHOW
    # Mandatory: -s description substring to search
    parser.add_argument('-s', '--show')

    # DISPLAY
    # -day Display schedule for day to display
    # -today Display today's schedule + todos
    # -week Display weekly schedule + todos
    # -todo Display all tasks
    parser.add_argument('-day', '--day')
    parser.add_argument('-week', '--week', action='store_true')
    parser.add_argument('-today', '--today', action='store_true')
    parser.add_argument('-tasks', '--tasks', action='store_true')

    args = parser.parse_args()

    # Record timestamp to produce consistent output with respect to dateparser
    timestamp = local_now()

    # TODO: Better error messages
    calendar = Calendar(args.calendar)

    parsed_dates = []
    parsed_due_dates = []
    parsed_exceptions = []
    parsed_duration = None
    parsed_enddate = None
    parsed_day = None

    try:
        # Make sure original dates are parsed successfully
        if args.dates:
            parsed_dates = list(
                map(lambda x: parse_datetime(x, timestamp), args.dates))
        if args.due_dates:
            parsed_due_dates = list(
                map(lambda x: parse_datetime(x, timestamp), args.due_dates))
        # Make sure length string is parsed successfully
        if args.duration:
            parsed_duration = parse_timedelta(args.duration)
        # If the event is repeating, make sure the exception dates and enddate
        # is parsed successfully
        if args.exceptions:
            parsed_exceptions = list(
                map(lambda x: parse_datetime(x, timestamp), args.exceptions))
        if args.enddate:
            parsed_enddate = parse_datetime(args.enddate, timestamp)
        # Make sure date to show schedule for is parsed correctly
        if args.day:
            parsed_day = parse_datetime(args.day, timestamp)

        # Display calendar
        if args.week:
            calendar.display_week(timestamp)
        elif args.today:
            calendar.display_today(timestamp)
        elif args.day:
            calendar.display_daily_schedule(parsed_day)
        elif args.tasks:
            calendar.display_all_tasks(timestamp)
        # Complete a task
        elif args.finish:
            calendar.complete_task(args.finish, timestamp)
        # Delete something
        elif args.delete:
            calendar.delete(args.delete)
        # Add an event
        elif args.event:
            calendar.add_event(
                args.event,
                parsed_dates,
                duration=parsed_duration,
                location=args.location,
                days_delta=int(args.days_delta) if args.days_delta else None,
                exceptions=parsed_exceptions,
                enddate=parsed_enddate)
        # Add a task
        elif args.task:
            if args.due_dates:
                calendar.add_due_task(args.task,
                                      parsed_due_dates,
                                      days_delta=int(args.days_delta)
                                      if args.days_delta else None,
                                      exceptions=parsed_exceptions,
                                      enddate=parsed_enddate)
            else:
                # Initialize a task to be low priority if no due-date or priority is specified
                if not args.priority:
                    args.priority = 1
                calendar.add_priority_task(args.task, int(args.priority))
        else:
            calendar.display_today(timestamp)

    except InputError as err:
        print(err)
def calendar_client():
    calendar = Calendar()
    yield calendar
示例#30
0
文件: __main__.py 项目: jarulsamy/mhc
    if args.get("--start") is not None:
        try:
            start_date = datetime.datetime.strptime(args.get("--start"),
                                                    "%m-%d-%Y").date()
        except ValueError as e:
            raise ValueError(
                "Incorrect date format, must be MM-DD-YYYY") from e

    if args.get("--end") is not None:
        try:
            end_date = datetime.datetime.strptime(args.get("--end"),
                                                  "%m-%d-%Y").date()
        except ValueError as e:
            raise ValueError(
                "Incorrect date format, must be MM-DD-YYYY") from e
    cal = Calendar(db, start_date=start_date, end_date=end_date)
    print(str(cal))

else:
    if not db.find(datetime.date.today()):
        rating = get_rating()
        db.insert(datetime.date.today(), rating)
    else:
        print("You've already entered a day rating today.")

    try:
        with open(QUOTE_PATH, "r") as f:
            quotes = f.read().split("\n.")

        print("\n" + random.choice(quotes).strip() + "\n")
    except FileNotFoundError: