当前位置: 首页>>代码示例>>Python>>正文


Python isoweek.Week类代码示例

本文整理汇总了Python中isoweek.Week的典型用法代码示例。如果您正苦于以下问题:Python Week类的具体用法?Python Week怎么用?Python Week使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Week类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_deliveries

 def create_deliveries(self):
     s, e = Week.fromstring(str(self.start)), Week.fromstring(str(self.end))
     if self.receive_only_once:
         d = self.delivery_set.create(date=s)
     else:
         for i in range(0, e+1-s, self.frequency):
             d = self.delivery_set.create(date=s+i)
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:7,代码来源:models.py

示例2: decide_forecast_time

def decide_forecast_time(timeby,value):
		
	if timeby == "Daily":
		d = "2014"+value[4:]
		start = parse(d)
		starti = (parse(d)-parse('2014-1-1')).days * 24
	
		end = parse(d)+timedelta(days=1)
		endi = starti + 24
		
	elif timeby == "Weekly":
		d = Week(2011, 40).monday()
		s = d.strftime("%Y-%m-%d")
		d = "2014"+s[4:]
		start = parse(d)
		starti = (parse(d)-parse('2014-1-1')).days * 24
		end = parse(d)+timedelta(days=7)
		endi = starti + (7*24)
	else:
		d = get_first_date(value)
		start = parse(d)
		starti = (parse(d)-parse('2014-1-1')).days * 24
		end = parse(d)+timedelta(days=30)
		endi = starti + (30*24)
		
	if end.year == 2015:
		end = parse("2014-12-31")
		endi = starti + ((end-parse(d)).days *24)
	
	return start,end,starti,endi
开发者ID:durgaravi,项目名称:non-intrusive-load-monitoring,代码行数:30,代码来源:timeseries.py

示例3: week_display

def week_display():
    # Default view is the current week. 
    if session.week is None:
        session.week = Week.thisweek()[1]
        session.year = date.today().year

    week = session.week
    year = session.year

    # some years end in week 53, others in week 52
    lastweekofyear = Week.last_week_of_year(year)[1]
    # If it is the last week of the year, fix forward button
    if lastweekofyear == week:
        forward = {"week":1,"year":year + 1}
    else:
        forward = {"week":week + 1,"year":year}
    # If it is the first week of the year, fix back button
    if week == 1:
        back = {"week":Week.last_week_of_year(year - 1)[1],"year":year - 1}
    else:
        back = {"week":week - 1,"year":year}

    # Our startdate will be current week, beginning with monday
    # set remaining sessions to new values and move on
    session.startday = Week(year, week).monday()
    session.back = back
    session.forward = forward
    session.week = week
    session.year = year 
开发者ID:rikardq,项目名称:rimi,代码行数:29,代码来源:instructor.py

示例4: __init__

 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     start = self.fields['start']
     cw = Week.thisweek()
     choices = [str(w + cw.week) for w in Week.weeks_of_year(cw.year)]
     start.choices = zip(choices, choices)
     start.initial = cw+1
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:7,代码来源:__init__.py

示例5: handle_noargs

    def handle_noargs(self, **options):
        translation.activate('fr')

        logging.debug('Command in progress')

        week_limit = Week.withdate(Week.thisweek().day(settings.VALIDATING_DAY_OF_WEEK) + relativedelta(days=settings.DELAY_BETWEEN_DEFINITON_N_DELIVERY))

        # first changed the status of expired deliveries
        deliveries_canceled = models.Delivery.objects.filter(date__lt=week_limit, status='w', subscription__enabled=True)
        for delivery in deliveries_canceled:
            delivery.status = 'e'
            delivery.save()
            logging.debug('delivery %d expired' % delivery.id)

        # secondly, get all the deliveries with a date higher or equal to J+9 and lesser than J+9+7 with a waiting status and a subscription which accepts direct debit.
        deliveries = models.Delivery.objects.filter(date__gte=week_limit, date__lt=week_limit+1, status='w', subscription__direct_debit=True, subscription__enabled=True)

        for delivery in deliveries:
            delivery.status = 'p'
            try:
                delivery.save()
            except ValueError as e:
                logging.debug('delivery %d not payed' % delivery.id)
            else:
                logging.debug('delivery %d payed' % delivery.id)

        translation.deactivate()
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:27,代码来源:directdebits.py

示例6: handle_noargs

    def handle_noargs(self, **options):
        translation.activate('fr')

        week_limit = Week.withdate(Week.thisweek().day(settings.VALIDATING_DAY_OF_WEEK) + relativedelta(days=settings.DELAY_BETWEEN_DEFINITON_N_DELIVERY))
        deliveries = models.Delivery.objects.filter(date__lte=week_limit, status='P', subscription__enabled=True).order_by('subscription__customer__account__email')
        count=0

        for delivery in deliveries:
            logger_delivery = logging.getLogger('[%d]' % delivery.id)

            subscription = delivery.subscription
            customer = subscription.customer

            logger_delivery.info(delivery.__unicode__())

            for content in delivery.content_set.all():
                __extent = content.extent

                logger_content = logging.getLogger('[%d] [%20s] [%c] [%3s%%]' % (delivery.id, content.product.name[:20], '*' if content.customized else ' ', __extent))

                for contentproduct in content.contentproduct_set.all():
                    logger_content.info('%d x %20s (%4d) %s' % (contentproduct.quantity, contentproduct.product.name[:20], contentproduct.product.id, contentproduct.product.main_price.supplier_product_url))
                    if options['browse']:
                        webbrowser.open(contentproduct.product.main_price.supplier_product_url)
                        count += 1
                        if count >= options['pages']:
                            count = 0
                            try:
                                input()
                            except KeyboardInterrupt:
                                print('Interrupted'); sys.exit()

            logger_delivery.info('')

        translation.deactivate()
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:35,代码来源:generate_order.py

示例7: get_menus_list

    def get_menus_list(self):
        r = requests.get("https://sites.google.com/site/fedorestbe/menu-fr/menu-noga-fr")

        soup = BeautifulSoup(r.content, "lxml")

        current_week = Week.thisweek().week
        current_year = Week.thisweek().year

        content = ""

        content += "Voici les menus disponibles concoctes par les chefs Fedorest. Nous sommes en semaine {}-{} : \n".format(current_year, current_week)

        link_cells = soup.find_all("td", {"class": "td-file"})
        regex = r"noga_fr_(\d+)_(\d+)\.pdf"

        for cell in link_cells:
            links = cell.find_all("a")
            for link in links:
                url = link.get("href")
                matches = re.findall(regex, url)
                if matches:
                    (week, year) = matches[0]
                    content += "* ["+year + "-"+week + "](" + GOOGLE_SITE_BASE + url + ")\n"

        return content
开发者ID:Juljan,项目名称:python-zulip-api,代码行数:25,代码来源:fedorest.py

示例8: validate_period

def validate_period(period, first_date):
    '''
    make sure only period is  between first_date and today
    '''  
    today = datetime.now().strftime('%Y%m%d')

    # Day yyyyMMdd
    if type_of_period(period) == 'day':
        if period >= first_date and period <= today:
            return True
    
    # Week yyyy-Www
    elif type_of_period(period) == 'week':
        this_week = Week.thisweek()
        period_week = Week.fromstring(period)
        first_date_week = Week.withdate(datetime.strptime(first_date, '%Y%m%d'))
        if period_week >= first_date_week and period_week <= this_week:
            return True

    # Month yyyyMM
    elif type_of_period(period) == 'month':
        this_month       = datetime.now().strftime('%Y%m')
        period_month     = period[0:6]
        first_date_month = first_date[0:6]
        if period_month >= first_date_month and period_month <= this_month:
            return True
        
    return False
开发者ID:JayWayChen,项目名称:wkcycle,代码行数:28,代码来源:utils.py

示例9: _task_completed

def _task_completed(user_id, task_id, year, week_number):
    
    """ Return true if a task is completed for this specific user and week """
    
    week = Week(year, week_number)
    monday = week.monday().isoformat()
    next_monday = week.sunday() + timedelta(days=1)
    return _db.is_task_completed(user_id, task_id, monday, next_monday)
开发者ID:dagheyman,项目名称:cleaning-week,代码行数:8,代码来源:server.py

示例10: duration2

 def duration2(self):
     if not self.start or not self.end: return None
     s, e = Week.fromstring(self.start).day(1), Week.fromstring(self.end).day(1)
     r = relativedelta(e,s)
     ret = ''
     if r.years: ret += _('%d years, ') % r.years
     if r.months: ret += _('%d months, ') % r.months
     if r.days: ret += _('%d days') % r.days
     return ret
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:9,代码来源:models.py

示例11: save

 def save(self, commit=True):
     subscription = super().save(commit=False)
     bw = Week.fromstring(self.cleaned_data['start'])
     ew = Week.withdate( bw.day(1) + relativedelta(months=int(self.cleaned_data['duration'])) )
     subscription.end = ew
     if commit:
         subscription.save()
         subscription.create_deliveries()
     return subscription
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:9,代码来源:__init__.py

示例12: get_deliveries_from_subscription

def get_deliveries_from_subscription(subscription_data):
    receive_only_once = subscription_data.get('receive_only_once')
    bw = Week.fromstring(str(subscription_data.get('start')))
    ew = Week.withdate( bw.day(1) + relativedelta(months=int(subscription_data.get('duration'))) )
    nb = len(range(0, ew+1-bw, int(subscription_data.get('frequency'))))
    init_price = subscription_data.get('size').default_price().price
    prices = get_deliveries(nb, init_price)
    if receive_only_once: prices = np.array([prices[0]])
    deliveries = [(i+1, '%s (%s %s)' % ((bw+i*2).day(settings.DELIVERY_DAY_OF_WEEK).strftime('%d-%m-%Y'), _('Week'), (bw+i*2).week), p) for i,p in enumerate(prices)]
    return deliveries, prices
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:10,代码来源:createall.py

示例13: __init__

    def __init__(self, **kwargs):
        for k, v in kwargs.iteritems():
            self.__setattr__(k, v)

        if kwargs["archive_date"]:
            self.archive_week = Week.withdate(kwargs["archive_date"])
            self.lead_time = kwargs["archive_date"] - kwargs["create_date"]
        else:
            self.archive_date = kwargs["last_move_date"]
            self.archive_week = Week.withdate(kwargs["last_move_date"])
            self.lead_time = kwargs["last_move_date"] - kwargs["create_date"]
开发者ID:remabreu,项目名称:leankit_dashboard,代码行数:11,代码来源:read_api.py

示例14: get_context_data

    def get_context_data(self, **kwargs):
        semana = Semana.objects.get(id=self.kwargs['semana_id'])

        inicio = Week(semana.creacion.isocalendar()[0],semana.creacion.isocalendar()[1]+1).tuesday()
        fin = Week(semana.creacion.isocalendar()[0],semana.creacion.isocalendar()[1]+2).monday()

        kwargs['start_date'] = inicio.strftime("%Y-%m-%d")
        kwargs['end_date'] = fin.strftime("%Y-%m-%d")
        kwargs['formador'] = Formador.objects.get(id=self.kwargs['id']).get_full_name()
        kwargs['numero_semana'] = semana.numero
        return super(CronogramaFormadorUpdateView,self).get_context_data(**kwargs)
开发者ID:Dandresfs,项目名称:sican,代码行数:11,代码来源:views.py

示例15: _populate_year

    def _populate_year(self, year):
        index = year - self.dob.year
        start_week = Week.withdate(date(year, self.dob.month, self.dob.day))
        end_week = Week.withdate(date(year + 1, self.dob.month, self.dob.day))
        next_week = start_week
        weeks = []

        while next_week.monday() < end_week.monday():
            week_info = WeekInfo(next_week)
            weeks.append(week_info)
            self._weeks[next_week] = week_info
            next_week += 1

        self._years[year] = dict(year=year, index=index, weeks=weeks)
开发者ID:rhydlewis,项目名称:life-calendar,代码行数:14,代码来源:helper.py


注:本文中的isoweek.Week类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。