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


Python utils.parse_date函数代码示例

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


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

示例1: process

    def process(self):
        """process meetings"""
        parser = etree.XMLParser(recover=True)
        r = requests.get(self.timerange_url)
        xml = r.text.encode('ascii','xmlcharrefreplace') 
        root = etree.fromstring(xml, parser=parser)

        for item in root[1].iterchildren():
            meeting = {}
            for e in item.iterchildren():
                meeting[e.tag] = e.text

            meeting['start_date'] = parse_date(meeting['sisbvcs'])
            meeting['end_date'] = parse_date(meeting['sisevcs'])
            meeting['tz_start_date'] = parse_date(meeting['sisbvcs'], tzinfo=utc).astimezone(self.tzinfo)
            meeting['tz_end_date'] = parse_date(meeting['sisevcs'], tzinfo=utc).astimezone(self.tzinfo)
            silfdnr = meeting['silfdnr']
            try:
                result = self.process_agenda(silfdnr)
                meeting.update(result)
            except Exception, e:
                meeting['ERROR'] = True
                print e
            meeting['_id'] = int(meeting['silfdnr'])
            self.db.meetings.save(meeting)
开发者ID:OpenRuhr,项目名称:ris-scraper-allris,代码行数:25,代码来源:meetings.py

示例2: process

    def process(self):
        """process meetings"""
        parser = etree.XMLParser(recover=True)
        r = requests.get(self.timerange_url)
        xml = r.text.encode('ascii','xmlcharrefreplace') 
        root = etree.fromstring(xml, parser=parser)

        start_at = root.find("list")
        for item in start_at.iterchildren():
            meeting = {}
            for e in item.iterchildren():
                meeting[e.tag] = e.text

            meeting['start_date'] = parse_date(meeting['sisbvcs'])
            meeting['end_date'] = parse_date(meeting['sisevcs'])
            meeting['tz_start_date'] = parse_date(meeting['sisbvcs'], tzinfo=utc).astimezone(self.tzinfo)
            meeting['tz_end_date'] = parse_date(meeting['sisevcs'], tzinfo=utc).astimezone(self.tzinfo)
            silfdnr = meeting['silfdnr']
            print "processing meeting %s" %silfdnr
            try:
                result = self.process_agenda(silfdnr)
                meeting.update(result)
            except Exception, e:
                meeting['ERROR'] = True
                print "exception when trying to parse meeting %s" %silfdnr
                print e
            meeting['meeting_id'] = str(meeting['silfdnr'])
            meeting['_id'] = "%s:%s" %(self.city, silfdnr)
            meeting['city'] = self.city
            self.db.meetings.save(meeting)
开发者ID:comlounge,项目名称:pyallris,代码行数:30,代码来源:meetings.py

示例3: history

def history(begin=None, end=None, week=False, month=False):
    if week or month:
        end = datetime.datetime.now()
        if week:
            begin = end - datetime.timedelta(days=7)
        if month:
            begin = end - datetime.timedelta(days=28)
    else:
        try:
            begin = utils.parse_date(begin, dtime=True)
        except ValueError:
            return 'Error: unable to parse date %s' % begin
        try:
            end = utils.parse_date(end, dtime=True)
        except ValueError:
            return 'Error: unable to parse date %s' % end
    cd = utils.compose_date
    if not begin <= end:
        return 'Error: %s is not before %s' % (cd(begin), cd(end))
    db = utils.read_db()
    days = [utils.compose_date(begin + datetime.timedelta(days=x)) for x in xrange(0,
        (end-begin).days)]
    matches = ['from: %s to: %s' % (cd(begin), cd(end))]
    for day in days:
        matches.append('%s: %s' % (day, utils.daily_points(day, db)))

    return '\n'.join(matches)
开发者ID:findgriffin,项目名称:pointy,代码行数:27,代码来源:history.py

示例4: tweets

def tweets(uid,min_date=None,max_date=None,limit=100):
    "returns all the tweets for a user between min_date and max_date"
    start = parse_date(min_date)
    end = parse_date(max_date)
    limit = int(limit) if limit else None
    tweets = Tweet.find(
        (Tweet.user_id==int(uid)) &
        (Tweet.created_at.range(start,end)),
        limit=limit,
        sort=Tweet._id)
    return [t.to_d() for t in tweets]
开发者ID:JeffAMcGee,项目名称:crowdy,代码行数:11,代码来源:user.py

示例5: get

    def get(self, args):
        """ Return the courses matching your query """

        # Parameters
        date_string = args['date']
        department = args['department']
        place = args['place']
        comment = args['comment']

        # Base query
        courses = Course.query

        # Apply filters
        if date_string:
            courses = courses.filter_by(date=parse_date(date_string))
        if place:
            courses = courses.filter_by(place=place)
        if department:
            courses = courses.filter_by(department=department)
        if comment:
            # Can be useful to select a group in a course
            courses = courses.filter_by(department=comment)

        # Do the query
        courses = courses.order_by(Course.time_begin).limit(1000).all()

        # Format it
        course_list = [course.__toJSON__() for course in courses]

        return course_list, 200
开发者ID:KIClubinfo,项目名称:EDTAPI,代码行数:30,代码来源:api.py

示例6: parse_template_3

    def parse_template_3(self, element):
        """
        A template for joint proceedings of two workshops.

        Examples:
            - http://ceur-ws.org/Vol-1098/
            - http://ceur-ws.org/Vol-989/
        """
        workshop_1 = {'id': 1}
        workshop_2 = {'id': 2}
        summary = self.rex(element[1], [
            r"(joint\s+proceedings\s+of\s+([\s\w,]+)\(([a-zA-Z]+)['\s]?\d+\)[and,\s]+"
            r"([:\s\w-]+)\(([a-zA-Z]+)['\s]?\d+\)([\w\s\-.,^\(]*|[,\s]+workshops\s+of.*|[,\s]+co-located.*))Edited by.*",

            r"(proceedings\s+of\s+joint([\s\w,]+)\(([a-zA-Z]+)['\s]?\d{0,4}\)[and,\s]+"
            r"([:,\s\w-]+)\(([a-zA-Z]+)['\s]?\d{0,4}\)([\w\s\-.,^\(]*|[,\s]+workshops\s+of.*|[,\s]+co-located.*))Edited by.*"
        ], re.I | re.S)

        if len(summary.groups()) != 6:
            raise DataNotFound()

        title = summary.group(1)

        workshop_1['volume_number'] = workshop_2['volume_number'] = \
            WorkshopSummaryParser.extract_volume_number(element[0].get('href'))
        workshop_1['url'] = workshop_2['url'] = element[0].get('href')
        workshop_1['time'] = workshop_2['time'] = utils.parse_date(title)

        workshop_1['label'] = summary.group(2)
        workshop_1['short_label'] = summary.group(3)
        workshop_2['label'] = summary.group(4)
        workshop_2['short_label'] = summary.group(5)

        self.add_workshop(workshop_1)
        self.add_workshop(workshop_2)
开发者ID:ailabitmo,项目名称:sempubchallenge2014-task1,代码行数:35,代码来源:workshop_parser.py

示例7: parse_template_5

    def parse_template_5(self, element):
        """
        A template for a workshop with the conference acronym and year in the name

        Examples:
            - http://ceur-ws.org/Vol-958/
        """
        workshop = {}
        title = rex.rex(element[1], r'(.*)Edited\s*by.*', re.I | re.S).group(1)

        workshop['volume_number'] = WorkshopSummaryParser.extract_volume_number(element[0].get('href'))
        label_part = rex.rex(element[0].text, r'(.*)\sat\s(\w{2,})\s(\d{4})[\s\.]*', re.I | re.S)
        workshop['label'] = label_part.group(1)
        workshop['conf_acronym'] = label_part.group(2)
        workshop['conf_year'] = label_part.group(3)
        workshop['url'] = element[0].get('href')
        workshop['time'] = utils.parse_date(title)
        try:
            workshop['edition'] = tonumber(
                rex.rex(title,
                        r'.*Proceedings(\s*of)?(\s*the)?\s*(\d{1,}|first|second|third|forth|fourth|fifth)[thrd]*'
                        r'.*Workshop.*',
                        re.I, default=None).group(3))
        except:
            #'edition' property is optional
            pass

        self.add_workshop(workshop)
开发者ID:ailabitmo,项目名称:sempubchallenge2014-task1,代码行数:28,代码来源:workshop_parser.py

示例8: parse_template_2

    def parse_template_2(self, element):
        """
        A template for joint proceedings of two workshops:

        Examples:
            - http://ceur-ws.org/Vol-776/
        """
        workshop_1 = {'id': 1}
        workshop_2 = {'id': 2}
        summary = rex.rex(element[1], r'^\s*(proceedings\s+of\s+joint.*on.*\((\w+)\-(\w+)\s+\d+\).*)Edited by.*',
                          re.I | re.S)

        if len(summary.groups()) != 3:
            raise DataNotFound()

        title = summary.group(1)

        workshop_1['volume_number'] = workshop_2['volume_number'] = \
            WorkshopSummaryParser.extract_volume_number(element[0].get('href'))
        workshop_1['url'] = workshop_2['url'] = element[0].get('href')
        workshop_1['time'] = workshop_2['time'] = utils.parse_date(title)

        workshop_1['short_label'] = summary.group(2)
        workshop_2['short_label'] = summary.group(3)

        self.add_workshop(workshop_1)
        self.add_workshop(workshop_2)
开发者ID:ailabitmo,项目名称:sempubchallenge2014-task1,代码行数:27,代码来源:workshop_parser.py

示例9: map_video

def map_video(config):
    programId = config.get('programId')
    kind = config.get('kind')
    duration = int(config.get('duration') or 0) * \
        60 or config.get('durationSeconds')
    airdate = config.get('broadcastBegin')
    if airdate is not None:
        airdate = str(utils.parse_date(airdate))

    return {
        'label': utils.format_title_and_subtitle(config.get('title'), config.get('subtitle')),
        'path': plugin.url_for('play', kind=kind, program_id=programId),
        'thumbnail': config.get('imageUrl'),
        'is_playable': True,
        'info_type': 'video',
        'info': {
            'title': config.get('title'),
            'duration': duration,
            'genre': config.get('genrePresse'),
            'plot': config.get('shortDescription') or config.get('fullDescription'),
            'plotoutline': config.get('teaserText'),
            # year is not correctly used by kodi :(
            # the aired year will be used by kodi for production year :(
            # 'year': int(config.get('productionYear')),
            'country': [country.get('label') for country in config.get('productionCountries', [])],
            'director': config.get('director'),
            'aired': airdate
        },
        'properties': {
            'fanart_image': config.get('imageUrl'),
        }
    }
开发者ID:known-as-bmf,项目名称:plugin.video.arteplussept,代码行数:32,代码来源:mapper.py

示例10: getData

def getData(request):
    from wrcc.wea_server.libwea.products.listers import getData
    error = require(request, ['stn', 'sD', 'eD'])
    if error:
        return ErrorResponse(error)

    stn = request.args.get('stn')
    sD = parse_date(request.args.get('sD'))
    eD = parse_date(request.args.get('eD'))
    units_system = request.args.get('units', 'N')  # N (native) units by default

    try:
        result = getData(stn, sD, eD, units_system=units_system)
    except IOError:
        return ErrorResponse("No data available.")

    return JsonResponse(result)
开发者ID:gkwrcc,项目名称:WRCC-wea-server,代码行数:17,代码来源:views.py

示例11: make_row

def make_row(date_string, headline):
    date = parse_date(date_string)
    L.debug("Parsed date '{}' as {}".format(date_string, date))
    return OrderedDict([
        ('venue', 'LEAF on Bold Street'),
        ('date', date),
        ('headline', headline),
        ('url', 'http://www.thisisleaf.co.uk/#/on-bold-street/events/')
    ])
开发者ID:paulfurley,项目名称:liverpool-events-scrapers,代码行数:9,代码来源:leaf.py

示例12: check_date

def check_date(d):
  if not isinstance(d, str):
    error(str(d) + ": invalid data type")
    return None
  try:
    return utils.parse_date(d)
  except Exception as e:
    error(d + ": " + str(e))
    return None
开发者ID:hugovk,项目名称:congress-legislators,代码行数:9,代码来源:validate.py

示例13: make_row

def make_row(day, headline):
    date = parse_date(day)
    L.debug("Parsed date '{}' as {}".format(day, date))
    return OrderedDict([
        ('venue', 'The Caledonia'),
        ('date', date),
        ('headline', headline),
        ('url', 'http://www.thecaledonialiverpool.com/whats-on/'),
    ])
开发者ID:paulfurley,项目名称:liverpool-events-scrapers,代码行数:9,代码来源:caledonia.py

示例14: make_row

def make_row(date_string, headline, url):
    L.debug("'{}' : '{}'".format(headline, date_string))
    date = parse_date(date_string)
    L.debug("Parsed date '{}' as {}".format(date_string, date))
    return OrderedDict([
        ('venue', "St George's Hall"),
        ('date', date),
        ('headline', headline),
        ('url', url),
    ])
开发者ID:paulfurley,项目名称:liverpool-events-scrapers,代码行数:10,代码来源:stgeorgeshall.py

示例15: make_row

def make_row(date_string, earliest_date, headline, url):
    L.debug("'{}' : '{}'".format(headline, date_string))
    date = parse_date(date_string, not_before=earliest_date)
    L.debug("Parsed date '{}' as {}".format(date_string, date))
    return OrderedDict([
        ('venue', "FACT"),
        ('date', date),
        ('headline', headline),
        ('url', url)
    ])
开发者ID:paulfurley,项目名称:liverpool-events-scrapers,代码行数:10,代码来源:fact.py


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