當前位置: 首頁>>代碼示例>>Python>>正文


Python rrule.DAILY屬性代碼示例

本文整理匯總了Python中dateutil.rrule.DAILY屬性的典型用法代碼示例。如果您正苦於以下問題:Python rrule.DAILY屬性的具體用法?Python rrule.DAILY怎麽用?Python rrule.DAILY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在dateutil.rrule的用法示例。


在下文中一共展示了rrule.DAILY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testRRuleAll

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def testRRuleAll(self):
        from dateutil.rrule import rrule
        from dateutil.rrule import rruleset
        from dateutil.rrule import rrulestr
        from dateutil.rrule import YEARLY, MONTHLY, WEEKLY, DAILY
        from dateutil.rrule import HOURLY, MINUTELY, SECONDLY
        from dateutil.rrule import MO, TU, WE, TH, FR, SA, SU

        rr_all = (rrule, rruleset, rrulestr,
                  YEARLY, MONTHLY, WEEKLY, DAILY,
                  HOURLY, MINUTELY, SECONDLY,
                  MO, TU, WE, TH, FR, SA, SU)

        for var in rr_all:
            self.assertIsNot(var, None)

        # In the public interface but not in all
        from dateutil.rrule import weekday
        self.assertIsNot(weekday, None) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:21,代碼來源:test_imports.py

示例2: date_range

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def date_range(start_date, end_date, step=5):
    """Create a range generator for dates.

    Given a start date and end date make an generator that returns the next date
    in the range with the given interval.

    """
    if isinstance(start_date, str):
        start_date = parser.parse(start_date)
    if isinstance(end_date, str):
        end_date = parser.parse(end_date)

    dates = rrule(freq=DAILY, dtstart=start_date, until=end_date, interval=step)

    for date in dates:
        yield date.date()
    if end_date not in dates:
        yield end_date.date() 
開發者ID:project-koku,項目名稱:koku,代碼行數:20,代碼來源:common.py

示例3: ubuntu_url

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def ubuntu_url(start_date, end_date):
    """
    Args:
        start_date (date object): Starting date from which logs need to be fetched 
        end_date (date object) : Last date for which logs need to be fetched
    Returns:
        Yields channel name, current_date, and url at which log for returned
        channel and current_date is present.
    """
    
    for current_date in rrule(freq=DAILY, dtstart=start_date, until=end_date):
        url = UBUNTU_ENDPOINT.format(current_date.year,month=current_date.month, day=current_date.day)
        
        r = send_request(url)
        soup = BeautifulSoup(r)
        links = soup.findAll(href=re.compile(".txt"))
        
        for link in links:
            channel = link.string
            channel_ = channel[1:]
            
            yield channel, current_date, UBUNTU_CHANNEL_ENDPOINT.format(current_date.year, month=current_date.month, day=current_date.day, channel=channel_) 
開發者ID:prasadtalasila,項目名稱:IRCLogParser,代碼行數:24,代碼來源:log_download.py

示例4: day_blocks

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def day_blocks(start, end):
    """
    Create pairs of start and end with max a day in between, to deal with usage restrictions on the API

    Parameters
    ----------
    start : dt.datetime | pd.Timestamp
    end : dt.datetime | pd.Timestamp

    Returns
    -------
    ((pd.Timestamp, pd.Timestamp))
    """
    rule = rrule.DAILY

    res = []
    for day in rrule.rrule(rule, dtstart=start, until=end):
        res.append(pd.Timestamp(day))
    res.append(end)
    res = sorted(set(res))
    res = pairwise(res)
    return res 
開發者ID:EnergieID,項目名稱:entsoe-py,代碼行數:24,代碼來源:misc.py

示例5: _getWhen

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def _getWhen(self, offset, numDays=1):
        retval = ""
        if self.freq == DAILY:
            retval = self.__getDailyWhen()

        elif self.freq == WEEKLY:
            retval = self.__getWeeklyWhen(offset)

        elif self.freq == MONTHLY:
            retval = self.__getMonthlyWhen(offset)

        elif self.freq == YEARLY:
            retval = self.__getYearlyWhen(offset)

        if numDays >= 2:
            retval += " "+_("for {n} days").format(n=numDays)
        if self.until:
            until = self.until + dt.timedelta(days=offset)
            retval += " "+_("(until {when})").format(when=dateShortFormat(until))
        return retval 
開發者ID:linuxsoftware,項目名稱:ls.joyous,代碼行數:22,代碼來源:recurrence.py

示例6: get_workdays

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def get_workdays(self, start_date, end_date):
        WORKDAYS = xrange(0, 5)
        r = rrule(DAILY, dtstart=start_date, until=end_date, byweekday=WORKDAYS)
        return r.count() 
開發者ID:fpsw,項目名稱:Servo,代碼行數:6,代碼來源:calendar.py

示例7: generate_cdm_data_for_course

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def generate_cdm_data_for_course(course_id):
    """
    Just getting it working first, then we'll make the values more reasonable

    like value = sorted([lower_bound, x, upper_bound])[1]

    """
    cdm_data = []
    yesterday = {}
    end_date = prev_day(datetime.datetime.now())
    start_date = days_from(end_date, -180)

    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        enrollment_count = yesterday.get('enrollment_count', 0) + randint(0, 10)
        average_progress = gen_avg_progress(yesterday.get('average_progress', 0))
        average_days_to_complete = randint(10, 30)
        num_learners_completed = gen_num_learners_completed(yesterday)

        rec = dict(
            course_id=course_id,
            date_for=dt.strftime('%Y-%m-%d'),
            enrollment_count=enrollment_count,
            active_learners_today=randint(0, enrollment_count / 2),
            average_progress=average_progress,
            average_days_to_complete=average_days_to_complete,
            num_learners_completed=num_learners_completed,
        )
        cdm_data.append(rec)
        yesterday = rec
    return cdm_data 
開發者ID:appsembler,項目名稱:figures,代碼行數:32,代碼來源:course_daily_metrics.py

示例8: days_back_list

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def days_back_list(days_back):
    end_date = prev_day(datetime.datetime.now())
    start_date = days_from(end_date, abs(days_back) * -1)
    return [day for day in rrule(DAILY, dtstart=start_date, until=end_date)] 
開發者ID:appsembler,項目名稱:figures,代碼行數:6,代碼來源:seed.py

示例9: seed_course_daily_metrics_for_course

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def seed_course_daily_metrics_for_course(course_id):
    end_date = LAST_DAY
    start_date = days_from(end_date, -DAYS_BACK)

    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        if VERBOSE:
            print('populating day {} for course {}'.format(dt, course_id))
        cdm, created = pipeline_cdm.CourseDailyMetricsLoader(course_id).load(
            date_for=dt, force_update=True) 
開發者ID:appsembler,項目名稱:figures,代碼行數:11,代碼來源:seed.py

示例10: seed_site_daily_metrics

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def seed_site_daily_metrics(data=None):
    """
    Run seed_course_daily_metrics first

    Then, for each date for which we have a CDM record
    """
    end_date = LAST_DAY
    start_date = days_from(end_date, -DAYS_BACK)
    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        pipeline_sdm.SiteDailyMetricsLoader().load(
            site=get_site(),
            date_for=dt, force_update=True) 
開發者ID:appsembler,項目名稱:figures,代碼行數:14,代碼來源:seed.py

示例11: generate_sdm_series

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def generate_sdm_series(site, first_day, last_day):

    return [SiteDailyMetricsFactory(site=site, date_for=dt) 
        for dt in rrule(DAILY, dtstart=first_day, until=last_day)] 
開發者ID:appsembler,項目名稱:figures,代碼行數:6,代碼來源:test_site_daily_metrics_view.py

示例12: create_student_module_test_data

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def create_student_module_test_data(start_date, end_date):
    '''

    NOTE: There are many combinations of unique students, courses, and student
    state. We're going to start with a relatively simple set

    1. A single course
    2. A single set per student (learner)
    3. a small number of students to reduce test run time

    If we create a record per day then we can work off of a unique datapoint
    per day
    '''
    student_modules = []
    user = UserFactory()
    course_overview = CourseOverviewFactory()

    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        student_modules.append(StudentModuleFactory(
            student=user,
            course_id=course_overview.id,
            created=dt,
            modified=dt,
            ))

    # we'll return everything we create
    return dict(
        user=user,
        course_overview=course_overview,
        student_modules=student_modules,
    ) 
開發者ID:appsembler,項目名稱:figures,代碼行數:33,代碼來源:test_metrics.py

示例13: create_site_daily_metrics_data

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def create_site_daily_metrics_data(site, start_date, end_date):
    '''
    NOTE: We can generalize this and the `create_course_daily_metrics_data`
    function with considering that the course mertrics creation method can
    assign a course id. When we become site-aware, then the site metrics will
    also need to be able to assign a site identifier
    '''
    def incr_func(key):
        return dict(
            cumulative_active_user_count=2,
            todays_active_user_count=2,
            total_user_count=5,
            course_count=1,
            total_enrollment_count=3,
        ).get(key, 0)

    # Initial values
    data = dict(
        cumulative_active_user_count=50,
        todays_active_user_count=10,
        total_user_count=5,
        course_count=5,
        total_enrollment_count=100,
    )
    metrics = []
    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        metrics.append(SiteDailyMetricsFactory(
            date_for=dt,
            site=site,
            **data))
        data.update(
            {key: val + incr_func(key) for key, val in data.iteritems()})
    return metrics 
開發者ID:appsembler,項目名稱:figures,代碼行數:35,代碼來源:test_metrics.py

示例14: create_course_daily_metrics_data

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def create_course_daily_metrics_data(site, start_date, end_date, course_id=None):
    '''
    Creates a daily sequence of CourseDailyMetrics objects

    If course_id is provided as a parameter, then all CourseDailyMetrics objects
    will have that course_id. This is useful for testing time series for a
    specific course. Otherwise FactoryBoy assigns the course id in the
    ``tests.factories`` module
    '''
    # Initial values
    data = dict(
        enrollment_count=2,
        active_learners_today=1,
        average_progress=0.5,
        average_days_to_complete=10,
        num_learners_completed=3
    )
    # keys and the values to increment by
    incr_data = dict(
        enrollment_count=3,
        active_learners_today=2,
        average_progress=0,
        average_days_to_complete=0,
        num_learners_completed=1
    )

    if course_id:
        data['course_id'] = course_id
    metrics = []
    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        metrics.append(CourseDailyMetricsFactory(
            date_for=dt,
            site=site,
            **data))
        # This only updates the keys that are present in the incr_data dict
        data.update(
            {key: data[key] + incr_data[key] for key in incr_data.keys()})
    return metrics 
開發者ID:appsembler,項目名稱:figures,代碼行數:40,代碼來源:test_metrics.py

示例15: create_users_joined_over_time

# 需要導入模塊: from dateutil import rrule [as 別名]
# 或者: from dateutil.rrule import DAILY [as 別名]
def create_users_joined_over_time(site, is_multisite, start_date, end_date):
    """
    Creates users. Each user joins on a succesive date between the dates
    pass as arguments
    """
    users = []
    for dt in rrule(DAILY, dtstart=start_date, until=end_date):
        user = UserFactory(date_joined=dt)
        if is_multisite:
            orgs = get_organizations_for_site(site)
            assert orgs.count() == 1
            UserOrganizationMappingFactory(user=user, organization=orgs[0])
        users.append(user)
    return users 
開發者ID:appsembler,項目名稱:figures,代碼行數:16,代碼來源:test_metrics.py


注:本文中的dateutil.rrule.DAILY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。