• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python date_util.get_date_from_db_date函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: then_i_have_6_microposts_ordered_by_date

def then_i_have_6_microposts_ordered_by_date(step, nbposts):
    nbposts = int(nbposts)
    assert nbposts == len(world.microposts)

    for i in range(0, nbposts -1):
       assert date_util.get_date_from_db_date(world.microposts[i].get("date")) > \
               date_util.get_date_from_db_date(world.microposts[i+1].get("date")) 
开发者ID:rakoo,项目名称:newebe,代码行数:7,代码来源:steps.py


示例2: checks_that_notes_are_sorted_by_date

def checks_that_notes_are_sorted_by_date(step):
    for i in range(len(world.notes)):
        if i > 0:
            if isinstance(world.test_notes[i], dict):
                assert date_util.get_date_from_db_date(world.test_notes[i - 1]["lastModified"]).time()  > \
                      date_util.get_date_from_db_date(world.test_notes[i]["lastModified"]).time(),  (world.test_notes[i - 1]["lastModified"]) + u" " + (world.test_notes[i]["lastModified"])
            else:
                assert world.test_notes[i - 1].lastModified.time() > \
                      world.test_notes[i].lastModified.time() 
开发者ID:rakoo,项目名称:newebe,代码行数:9,代码来源:steps.py


示例3: and_this_micropost_has_same_date_as_the_posted_one

def and_this_micropost_has_same_date_as_the_posted_one(step, timezone):
    micropost = world.microposts[0]
    
    posted_date = date_util.get_date_from_db_date(world.date_micropost["date"])
    posted_date = date_util.convert_timezone_date_to_utc(posted_date)

    tz = pytz.timezone(timezone)
    contact_date = date_util.get_date_from_db_date(micropost["date"])
    contact_date = date_util.convert_timezone_date_to_utc(contact_date, tz)

    assert contact_date == posted_date
开发者ID:rakoo,项目名称:newebe,代码行数:11,代码来源:steps.py


示例4: put

    def put(self, key):
        '''
        Resend deletion of micropost with *key* as key to the contact given in
        the posted JSON. Corresponding activity ID is given inside the posted
        json.
        Here is the format : {"contactId":"data","activityId":"data"}
        '''

        data = self.get_body_as_dict(
                expectedFields=["contactId", "activityId", "extra"])

        if data:

            contactId = data["contactId"]
            activityId = data["activityId"]
            date = data["extra"]

            contact = ContactManager.getTrustedContact(contactId)
            activity = ActivityManager.get_activity(activityId)

            if not contact:
                self.return_failure("Contact not found", 404)
            elif not activity:
                self.return_failure("Activity not found", 404)
            else:

                user = UserManager.getUser()
                micropost = MicroPost(
                    authorKey=user.key,
                    date=date_util.get_date_from_db_date(date)
                )

                logger.info(
                    "Attempt to resend a post deletion to contact: {}.".format(
                        contact.name))
                httpClient = ContactClient()
                body = micropost.toJson(localized=False)

                try:
                    httpClient.put(contact, CONTACT_PATH, body,
                                   callback=(yield gen.Callback("retry")))
                    response = yield gen.Wait("retry")

                    if response.error:
                        self.return_failure(
                                "Deleting micropost to contact failed.")

                    else:
                        for error in activity.errors:
                            if error["contactKey"] == contact.key:
                                activity.errors.remove(error)
                                activity.save()
                                self.return_success(
                                        "Micropost correctly redeleted.")

                except:
                    self.return_failure("Deleting micropost to contact failed.")

        else:
            self.return_failure("Micropost not found", 404)
开发者ID:mpmedia,项目名称:newebe,代码行数:60,代码来源:handlers.py


示例5: then_my_activity_date_is_converted_to_my_timezone

def then_my_activity_date_is_converted_to_my_timezone(step):
    assert 0 < len(world.data)
    date = world.data[0].get("date")
    date = date_util.get_date_from_db_date(date)
    date = date_util.convert_timezone_date_to_utc(date)

    assert world.activity.date.replace(tzinfo=pytz.utc) == date, date
开发者ID:rakoo,项目名称:newebe,代码行数:7,代码来源:steps.py


示例6: put

    def put(self, key):
        """
        Resend deletion of micropost with *key* as key to the contact given in
        the posted JSON. Corresponding activity ID is given inside the posted
        json.
        Here is the format : {"contactId":"data","activityId":"data"}
        """
        data = self.get_body_as_dict(expectedFields=["contactId", "activityId", "extra"])

        if data:

            contactId = data["contactId"]
            activityId = data["activityId"]
            date = data["extra"]

            contact = ContactManager.getTrustedContact(contactId)
            activity = ActivityManager.get_activity(activityId)

            if not contact:
                self.return_failure("Contact not found", 404)

            elif not activity:
                self.return_failure("Activity not found", 404)

            else:
                user = UserManager.getUser()
                picture = Picture(authorKey=user.key, date=date_util.get_date_from_db_date(date))

                info = "Attempt to resend a picture deletion to contact: {}."
                logger.info(info.format(contact.name))

                self.forward_to_contact(picture, contact, activity, method="PUT")

        else:
            self.return_failure("Micropost not found", 404)
开发者ID:WentaoXu,项目名称:newebe,代码行数:35,代码来源:handlers.py


示例7: checks_that_dict_convert_date_to_the_current_time_zone

def checks_that_dict_convert_date_to_the_current_time_zone(step):
    lastModifiedDate = world.note.lastModified.replace(tzinfo=pytz.utc)
    lastModifiedDictDate = world.note.toDict()["lastModified"]
    lastModifiedDictDate = date_util.get_date_from_db_date(lastModifiedDictDate)
    lastModifiedDictDate = date_util.convert_timezone_date_to_utc(lastModifiedDictDate)

    assert lastModifiedDate == lastModifiedDictDate
开发者ID:savitasinghvit,项目名称:newebe,代码行数:7,代码来源:steps.py


示例8: and_this_micropost_has_timezone_date

def and_this_micropost_has_timezone_date(step):
    world.date_micropost = world.microposts[0]
    db_micropost = MicroPostManager.get_micropost(world.date_micropost["_id"])
    
    date = date_util.get_date_from_db_date(world.date_micropost["date"])
    
    assert db_micropost.date.replace(tzinfo=pytz.utc) == \
        date_util.convert_timezone_date_to_utc(date)
开发者ID:rakoo,项目名称:newebe,代码行数:8,代码来源:steps.py


示例9: retrieve_through_handler_the_note_with_note_id

def retrieve_through_handler_the_note_with_note_id(step):
    note = client.fetch_document("notes/" + world.note._id + "/")
    world.test_note = Note(
        author=note["author"],
        title=note["title"],
        content=note["content"],
        lastModified=date_util.convert_timezone_date_to_utc(date_util.get_date_from_db_date(note["lastModified"])),
        isMine=note["isMine"],
    )
开发者ID:savitasinghvit,项目名称:newebe,代码行数:9,代码来源:steps.py


示例10: check_that_request_date_is_set_to_europe_paris_timezone

def check_that_request_date_is_set_to_europe_paris_timezone(step, timezone):
    Contact._db = db2
    contact = ContactManager.getRequestedContacts().first()
    Contact._db = db

    date = date_util.get_date_from_db_date(world.contacts[0]["requestDate"])
    tz = pytz.timezone(timezone)
    date = date.replace(tzinfo=tz)
    assert_equals(
            date_util.convert_utc_date_to_timezone(contact.requestDate, tz),
            date)
开发者ID:mpmedia,项目名称:newebe,代码行数:11,代码来源:steps.py


示例11: create_through_handler_a_note

def create_through_handler_a_note(step):
    world.note = Note(title="test note creation", content="test content creation", date=datetime.datetime.utcnow())
    response = client.post("notes/all/", body=world.note.toJson())
    noteDict = json_decode(response.body)
    world.note = Note(
        author=noteDict["author"],
        title=noteDict["title"],
        content=noteDict["content"],
        lastModified=date_util.convert_timezone_date_to_utc(date_util.get_date_from_db_date(noteDict["lastModified"])),
        isMine=noteDict["isMine"],
    )
    world.note._id = noteDict["_id"]
开发者ID:savitasinghvit,项目名称:newebe,代码行数:12,代码来源:steps.py


示例12: creates_x_activities

def creates_x_activities(step, nb_activities, nb_owner_activities, date):
    for i in range(int(nb_activities)):
        activity = Activity(
            author="me",
            docId="aaavvvbbbb%d" % i,
            verb="write",
            method="POST",
            isMine=i < int(nb_owner_activities),
            errors=[],
            docType="micropost",
            date=date_util.get_date_from_db_date(date),
        )
        activity.save()
开发者ID:rakoo,项目名称:newebe,代码行数:13,代码来源:steps.py


示例13: post

    def post(self):
        '''
        Extract picture and file linked to the picture from request, then
        creates a picture in database for the contact who sends it. An
        activity is created too.

        If author is not inside trusted contacts, the request is rejected.
        '''

        file = self.request.files['picture'][0]
        data = json_decode(self.get_argument("json"))

        if file and data:
            contact = ContactManager.getTrustedContact(
                    data.get("authorKey", ""))

            if contact:
                date = date_util.get_date_from_db_date(data.get("date", ""))

                picture = PictureManager.get_contact_picture(
                            contact.key, data.get("date", ""))

                if not picture:
                    picture = Picture(
                        _id=data.get("_id", ""),
                        title=data.get("title", ""),
                        path=data.get("path", ""),
                        contentType=data.get("contentType", ""),
                        authorKey=data.get("authorKey", ""),
                        author=data.get("author", ""),
                        tags=contact.tags,
                        date=date,
                        isMine=False,
                        isFile=False
                    )
                    picture.save()
                    picture.put_attachment(content=file["body"],
                                           name="th_" + picture._id)
                    picture.save()

                    self.create_creation_activity(contact,
                            picture, "publishes", "picture")

                logger.info("New picture from %s" % contact.name)
                self.return_success("Creation succeeds", 201)

            else:
                self.return_failure("Author is not trusted.", 400)
        else:
            self.return_failure("No data sent.", 405)
开发者ID:DopeChicCity,项目名称:newebe,代码行数:50,代码来源:handlers.py


示例14: post

    def post(self):
        """
        When post request is received, micropost content is expected inside
        a string under *content* of JSON object. It is extracted from it
        then stored inside a new Microposts object. Micropost author and date
        are set from incoming data.
        """

        data = self.get_body_as_dict(expectedFields=["date", "authorKey"])

        if data:
            db_date = data.get("date")
            date = date_util.get_date_from_db_date(db_date)
            authorKey = data.get("authorKey")

            contact = ContactManager.getTrustedContact(authorKey)
            micropost = MicroPostManager.get_contact_micropost(authorKey, db_date)

            if contact:
                if not micropost:
                    micropost = MicroPost(
                        authorKey=authorKey,
                        author=data["author"],
                        content=data["content"],
                        date=date,
                        attachments=data.get("attachments", []),
                        pictures_to_download=data.get("pictures", []),
                        commons_to_download=data.get("commons", []),
                        isMine=False,
                        tags=contact.tags,
                    )
                    micropost.save()

                    self.create_creation_activity(contact, micropost, "writes", "micropost")
                    self._write_create_log(micropost)

                    postIndexer = indexer.Indexer()
                    postIndexer.index_micropost(micropost)
                    for websocket_client in websocket_clients:
                        websocket_client.write_message(micropost.toJson())

                self.return_json(micropost.toJson(), 201)

            else:
                self.return_failure("Contact is not registered.", 405)

        else:
            self.return_failure("No data sent.", 405)
开发者ID:prologic,项目名称:newebe,代码行数:48,代码来源:handlers.py


示例15: toDict

    def toDict(self, localized=True):
        '''
        Return a dict representation of the document (copy).

        Removes _rev key and convert date field and last modified field
        to local timezone if *localized* is set to True.
        '''

        docDict = NewebeDocument.toDict(self, localized)

        if localized and "lastModified" in docDict:
            
            utc_date = get_date_from_db_date(docDict.get("lastModified"))
            date = convert_utc_date_to_timezone(utc_date)
            docDict["lastModified"] = get_db_date_from_date(date)

        return docDict
开发者ID:mike-perdide,项目名称:newebe,代码行数:17,代码来源:models.py


示例16: toDict

    def toDict(self, localized=True):
        """
        Return a dict representation of the document (copy).

        Removes _rev key and convert date field and request date field
        to local timezone if *localized* is set to True.
        """

        docDict = NewebeDocument.toDict(self, localized)

        if localized and docDict.get("requestDate", ""):

            utc_date = date_util.get_date_from_db_date(docDict.get("requestDate"))
            date = date_util.convert_utc_date_to_timezone(utc_date)
            docDict["requestDate"] = date_util.get_db_date_from_date(date)

        return docDict
开发者ID:WentaoXu,项目名称:newebe,代码行数:17,代码来源:models.py


示例17: toDict

    def toDict(self, localized=True):
        '''
        Return a dict representation of the document (copy).

        Removes _rev key.
        '''

        docDict = self.__dict__["_doc"].copy()

        if "_rev" in docDict:
            del docDict["_rev"]

        if localized and docDict.get("date", None):

            utc_date = get_date_from_db_date(docDict.get("date"))
            docDict["date"] = get_db_date_from_date(utc_date)

        return docDict
开发者ID:gelnior,项目名称:newebe,代码行数:18,代码来源:models.py


示例18: post

    def post(self):
        '''
        When post request is received, micropost content is expected inside
        a string under *content* of JSON object. It is extracted from it
        then stored inside a new Microposts object. Micropost author and date
        are set from incoming data.
        '''

        data = self.get_body_as_dict(expectedFields=["date", "authorKey"])

        if data:
            db_date = data.get("date")
            date = date_util.get_date_from_db_date(db_date)
            authorKey = data.get("authorKey")

            contact = ContactManager.getTrustedContact(authorKey)
            micropost = MicroPostManager.get_contact_micropost(
                             authorKey, db_date)

            if contact:
                if not micropost:
                    micropost = MicroPost(
                        authorKey = authorKey,
                        author = data["author"],
                        content = data['content'],
                        date = date,
                        attachments = data.get("attachments", []),
                        isMine = False,
                        tags = contact.tags
                    )
                    micropost.save()
                    self._notify_suscribers(micropost)

                self.create_creation_activity(contact, micropost, 
                        "writes", "micropost")
                self._write_create_log(micropost)
            
                self.return_json(micropost.toJson(), 201)

            else:
                self.return_failure("Contact is not registered.", 405)

        else:
            self.return_failure("No data sent.", 405)
开发者ID:mike-perdide,项目名称:newebe,代码行数:44,代码来源:handlers.py


示例19: toDict

    def toDict(self, localized=True):
        '''
        Return a dict representation of the document (copy).

        Removes _rev key and convert date field to local timezone
        if *localized* is set to True.
        '''

        docDict = self.__dict__["_doc"].copy()

        if "_rev" in docDict:
            del docDict["_rev"]

        if localized and docDict.get("date", None):

            utc_date = get_date_from_db_date(docDict.get("date"))
            date = convert_utc_date_to_timezone(utc_date)
            docDict["date"] = get_db_date_from_date(date)

        return docDict
开发者ID:DopeChicCity,项目名称:newebe,代码行数:20,代码来源:models.py


示例20: assert_that_date_is_well_converted_to_2011_02_01t12_45_32z

def assert_that_date_is_well_converted_to_2011_02_01t12_45_32z(step, db_date):

    date = date_util.get_date_from_db_date(db_date)
    assert db_date == date.strftime(date_util.DB_DATETIME_FORMAT)
开发者ID:DopeChicCity,项目名称:newebe,代码行数:4,代码来源:steps.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python http_util.ContactClient类代码示例发布时间:2022-05-27
下一篇:
Python models.ContactManager类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap