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


Python OrgFormat.datetime方法代码示例

本文整理汇总了Python中memacs.lib.orgformat.OrgFormat.datetime方法的典型用法代码示例。如果您正苦于以下问题:Python OrgFormat.datetime方法的具体用法?Python OrgFormat.datetime怎么用?Python OrgFormat.datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在memacs.lib.orgformat.OrgFormat的用法示例。


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

示例1: test_autotag

# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import datetime [as 别名]
    def test_autotag(self):
        test_filename = self.TMPFOLDER + "testautotag.org"

        autotag_dict = {}
        autotag_dict["TUG"] = ["tugraz", "university"]
        autotag_dict["programming"] = ["programming", "python", "java"]

        output = "Programming for my bachelor thesis at University"

        # writing test output
        writer = OrgOutputWriter(short_description="short-des",
                                 tag="tag",
                                 file_name=test_filename,
                                 autotag_dict=autotag_dict)
        timestamp = OrgFormat.datetime(time.gmtime(0))

        properties = OrgProperties("data_for_hashing")

        writer.write_org_subitem(timestamp=timestamp,
                                 output=output,
                                 properties=properties)
        writer.close()

        # read and check the file_handler
        file_handler = codecs.open(test_filename, "r", "utf-8")
        input_handler = file_handler.readlines()
        file_handler.close()

        self.assertEqual(input_handler[4],
                         u"** <1970-01-01 Thu 00:00> Programming for my " + \
                         "bachelor thesis at University\t:programming:TUG:\n")

        #cleaning up
        os.remove(self.TMPFOLDER + "testautotag.org")
开发者ID:Daniel1234,项目名称:Memacs,代码行数:36,代码来源:orgwriter_test.py

示例2: test_properties_with_own_created

# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import datetime [as 别名]
    def test_properties_with_own_created(self):
        p = OrgProperties()
        p.add(u"CREATED",
              OrgFormat.datetime(time.gmtime(0)))
        properties = unicode(p).splitlines()

        self.assertEqual(properties[0], u"   :PROPERTIES:")
        self.assertEqual(properties[1], u"   :CREATED:    <1970-01-0" + \
                         "1 Thu 00:00>")
        self.assertEqual(properties[2], u"   :ID:         fede47e9" + \
                         "f49e1b7f5c6599a6d607e9719ca98625")
        self.assertEqual(properties[3], u"   :END:")
开发者ID:Daniel1234,项目名称:Memacs,代码行数:14,代码来源:orgproperty_test.py

示例3: test_datetime

# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import datetime [as 别名]
    def test_datetime(self):

        ## fixed time with seconds:
        self.assertEqual(
            OrgFormat.datetime(time.struct_time([1980,12,31,23,59,58,0,0,0])),
            u'<1980-12-31 Wed 23:59>' )  ## seconds are not (yet) defined in Org-mode

        ## fixed time without seconds:
        self.assertEqual(
            OrgFormat.datetime(time.struct_time([1980,12,31,23,59,0,0,0,0])),
            u'<1980-12-31 Wed 23:59>' )

        YYYYMMDDwday = time.strftime('%Y-%m-%d %a', time.localtime())
        hhmmss = time.strftime('%H:%M', time.localtime())  ## seconds are not (yet) defined in Org-mode

        ## show_time parameter not named:
        self.assertEqual(
            OrgFormat.datetime(time.localtime()),
            u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
        
        ## show_time parameter named:
        self.assertEqual(
            OrgFormat.datetime(time.localtime()),
            u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
开发者ID:andrewjss,项目名称:Memacs,代码行数:26,代码来源:orgformat_test.py

示例4: test_datetime

# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import datetime [as 别名]
    def test_datetime(self):

        ## fixed time with seconds:
        self.assertEqual(
            OrgFormat.datetime(time.struct_time([1980,12,31,23,59,58,0,0,0])),
            u'<1980-12-31 Mon 23:59:58>' )  ## however, it was a Wednesday

        ## fixed time without seconds:
        self.assertEqual(
            OrgFormat.datetime(time.struct_time([1980,12,31,23,59,0,0,0,0])),
            u'<1980-12-31 Mon 23:59>' )  ## however, it was a Wednesday

        YYYYMMDDwday = time.strftime('%Y-%m-%d %a', time.localtime())
        hhmmss = time.strftime('%H:%M:%S', time.localtime())

        ## show_time parameter not named:
        self.assertEqual(
            OrgFormat.datetime(time.localtime()),
            u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
        
        ## show_time parameter named:
        self.assertEqual(
            OrgFormat.datetime(time.localtime()),
            u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
开发者ID:ajft,项目名称:Memacs,代码行数:26,代码来源:orgformat_test.py

示例5: test_ouput_to_file

# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import datetime [as 别名]
    def test_ouput_to_file(self):
        """
        Simple Test
        """
        test_filename = self.TMPFOLDER + "testfile.org"

        properties = OrgProperties("data_for_hashing")

        # writing test output
        writer = OrgOutputWriter("short descript", "test-tag", test_filename)
        writer.write("## abc\n")
        writer.writeln("## abc")
        writer.write_comment("abc\n")
        writer.write_commentln("abc")
        writer.write_org_item("begin")

        timestamp = OrgFormat.datetime(time.gmtime(0))
        writer.write_org_subitem(timestamp=timestamp,
                                 output="sub",
                                 properties=properties)
        writer.write_org_subitem(timestamp=timestamp,
                                 output="sub",
                                 tags=["foo", "bar"],
                                 properties=properties)
        writer.close()

        # read and check the file_handler
        file_handler = codecs.open(test_filename, "r", "utf-8")
        data = file_handler.readlines()

        #for d in range(len(data)):
        #   print "self.assertEqual(\n\tdata[%d],\n\t\"%s\")" % \
        #       (d, data[d])

#        self.assertEqual(
#            data[1],
#            "## this file is generated by "...
#        ")
#        self.assertEqual(
#            data[2],
#            "## To add this file to your org-agenda " ...
#        ")
        self.assertEqual(
            data[3],
            "* short descript          :Memacs:test-tag:\n")
        self.assertEqual(
            data[4],
            "## abc\n")
        self.assertEqual(
            data[5],
            "## abc\n")
        self.assertEqual(
            data[6],
            "## abc\n")
        self.assertEqual(
            data[7],
            "## abc\n")
        self.assertEqual(
            data[8],
            "* begin\n")
        self.assertEqual(
            data[9],
            "** <1970-01-01 Thu 00:00> sub\n")
        self.assertEqual(
            data[10],
            "   :PROPERTIES:\n")
        self.assertEqual(
            data[11],
            "   :ID:         9cc53a63e13e18437401513316185f6f3b7ed703\n")
        self.assertEqual(
            data[12],
            "   :END:\n")
        self.assertEqual(
            data[13],
            "\n")
        self.assertEqual(
            data[14],
            "** <1970-01-01 Thu 00:00> sub\t:foo:bar:\n")
        self.assertEqual(
            data[15],
            "   :PROPERTIES:\n")
        self.assertEqual(
            data[16],
            "   :ID:         9cc53a63e13e18437401513316185f6f3b7ed703\n")
        self.assertEqual(
            data[17],
            "   :END:\n")
        #cleaning up
        file_handler.close()
        os.remove(self.TMPFOLDER + "testfile.org")
开发者ID:Daniel1234,项目名称:Memacs,代码行数:92,代码来源:orgwriter_test.py

示例6: test_ouput_to_file

# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import datetime [as 别名]
    def test_ouput_to_file(self):
        """
        Simple Test
        """
        test_filename = self.TMPFOLDER + "testfile.org"

        properties = OrgProperties("data_for_hashing")

        # writing test output
        writer = OrgOutputWriter("short descript", "test-tag", test_filename)
        writer.write("## abc\n")
        writer.writeln("## abc")
        writer.write_comment("abc\n")
        writer.write_commentln("abc")
        writer.write_org_item("begin")

        timestamp = OrgFormat.datetime(time.gmtime(0))
        writer.write_org_subitem(timestamp=timestamp,
                                 output="sub",
                                 properties=properties)
        writer.write_org_subitem(timestamp=timestamp,
                                 output="sub",
                                 tags=["foo", "bar"],
                                 properties=properties)
        writer.close()

        # read and check the file_handler
        with codecs.open(test_filename, "r", "utf-8") as file_handler:
            data = file_handler.readlines()

        self.assertEqual(
            data[3],
            "* short descript          :Memacs:test-tag:\n")
        self.assertEqual(
            data[4],
            "## abc\n")
        self.assertEqual(
            data[5],
            "## abc\n")
        self.assertEqual(
            data[6],
            "## abc\n")
        self.assertEqual(
            data[7],
            "## abc\n")
        self.assertEqual(
            data[8],
            "* begin\n")
        self.assertEqual(
            data[9],
            "** <1970-01-01 Thu 00:00> sub\n")
        self.assertEqual(
            data[10],
            "   :PROPERTIES:\n")
        self.assertEqual(
            data[11],
            "   :ID:         9cc53a63e13e18437401513316185f6f3b7ed703\n")
        self.assertEqual(
            data[12],
            "   :END:\n")
        self.assertEqual(
            data[13],
            "\n")
        self.assertEqual(
            data[14],
            "** <1970-01-01 Thu 00:00> sub\t:foo:bar:\n")
        self.assertEqual(
            data[15],
            "   :PROPERTIES:\n")
        self.assertEqual(
            data[16],
            "   :ID:         9cc53a63e13e18437401513316185f6f3b7ed703\n")
        self.assertEqual(
            data[17],
            "   :END:\n")
开发者ID:easeflyer,项目名称:Memacs,代码行数:77,代码来源:orgwriter_test.py


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