Exemplo n.º 1
0
 def call_omit_drawers(self):
     """
     Invokes the filenametimestamp module with basic parameters skipping the drawers
     """
     argv = "--suppress-messages --omit-drawers --folder " + self._tmp_dir
     memacs = FileNameTimeStamps(argv=argv.split())
     return memacs.test_get_entries()
    def test_functional(self):
        tmpfile = self.TMPFOLDER + os.sep + '2011-12-19T23.59.12_test1.txt'
        entry = "** <2011-12-19 Mon 23:59:12> [[" + tmpfile + \
            "][2011-12-19T23.59.12_test1.txt]]"

        # touch file
        open(tmpfile, 'w').close()

        argv = "-s -f " + self.TMPFOLDER
        memacs = FileNameTimeStamps(argv=argv.split())
        data = memacs.test_get_entries()

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

        self.assertEqual(data[0], entry)
        self.assertEqual(data[1], "   :PROPERTIES:")
        # id changes because data_for_hashing = link
        #self.assertEqual(
        #    data[2],
        #    "   :ID:             e3b38e22498caa8812c755ec20276714a1eb1919")
        self.assertEqual(data[3], "   :END:")

        os.remove(tmpfile)
        self.assertEqual(data[0], entry, "filenametimestamps - error")
Exemplo n.º 3
0
 def call_basic(self):
     """
     Invokes the filenametimestamp module with basic parameters resulting in drawers with IDs
     """
     argv = "--suppress-messages --folder " + self._tmp_dir
     memacs = FileNameTimeStamps(argv=argv.split())
     return memacs.test_get_entries()
Exemplo n.º 4
0
    def test_functional(self):
        tmpfile = self.TMPFOLDER + os.sep + '2011-12-19T23.59.12_test1.txt'
        entry = "** <2011-12-19 Mon 23:59:12> [[" + tmpfile + \
            "][2011-12-19T23.59.12_test1.txt]]"

        # touch file
        open(tmpfile, 'w').close()

        argv = "-s -f " + self.TMPFOLDER
        memacs = FileNameTimeStamps(argv=argv.split())
        data = memacs.test_get_entries()

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

        self.assertEqual(
            data[0],
            entry)
        self.assertEqual(
            data[1],
            "   :PROPERTIES:")
        # id changes because data_for_hashing = link
        #self.assertEqual(
        #    data[2],
        #    "   :ID:             e3b38e22498caa8812c755ec20276714a1eb1919")
        self.assertEqual(
            data[3],
            "   :END:")

        os.remove(tmpfile)
        self.assertEqual(data[0], entry, "filenametimestamps - error")
Exemplo n.º 5
0
def main():
    global memacs
    memacs = FileNameTimeStamps(prog_version=PROG_VERSION_NUMBER,
                                prog_version_date=PROG_VERSION_DATE,
                                prog_description=PROG_DESCRIPTION,
                                prog_short_description=PROG_SHORT_DESCRIPTION,
                                prog_tag=PROG_TAG,
                                copyright_year=COPYRIGHT_YEAR,
                                copyright_authors=COPYRIGHT_AUTHORS)
    memacs.handle_main()
Exemplo n.º 6
0
    def test_functional(self):
        # touch file
        tmpfile = os.path.join(self._tmp_dir, '2011-12-19T23.59.12_test1.txt')
        with open(tmpfile, 'w'):
            pass

        entry = "** <2011-12-19 Mon 23:59> [[" + tmpfile + \
            "][2011-12-19T23.59.12_test1.txt]]"

        argv = "-s -f " + self._tmp_dir
        memacs = FileNameTimeStamps(argv=argv.split())
        data = memacs.test_get_entries()

        self.assertEqual(data[0], entry)
        self.assertEqual(data[1], "   :PROPERTIES:")
        self.assertEqual(data[3], "   :END:")
Exemplo n.º 7
0
    def test_functional(self):
        # touch file
        tmpfile = os.path.join(self._tmp_dir, '2011-12-19T23.59.12_test1.txt')
        with open(tmpfile, 'w'):
            pass

        entry = "** <2011-12-19 Mon 23:59> [[" + tmpfile + \
            "][2011-12-19T23.59.12_test1.txt]]"

        argv = "-s -f " + self._tmp_dir
        memacs = FileNameTimeStamps(argv=argv.split())
        data = memacs.test_get_entries()

        self.assertEqual(data[0], entry)
        self.assertEqual(data[1], "   :PROPERTIES:")
        self.assertEqual(data[3], "   :END:")
Exemplo n.º 8
0
    def test_functional_with_unusual_year(self):
        # touch file
        tmpfile = os.path.join(self._tmp_dir, '1899-12-30T00.00.00_P1000286.jpg')
        with open(tmpfile, 'w'):
            pass

        entry = "** <1899-12-30 Sat 00:00> [[" + tmpfile + \
            "][1899-12-30T00.00.00_P1000286.jpg]]"

        argv = "-s -f " + self._tmp_dir
        memacs = FileNameTimeStamps(argv=argv.split())
        data = memacs.test_get_entries()

        self.assertEqual(data[0], entry)
        self.assertEqual(data[1], "   :PROPERTIES:")
        self.assertEqual(data[3], "   :END:")
Exemplo n.º 9
0
PROG_TAG = u"filedatestamps"
PROG_DESCRIPTION = u"""This script parses a text file containing absolute paths
to files with ISO datestamps and timestamps in their file names:

Examples:  "2010-03-29T20.12 Divegraph.tiff"
           "2010-12-31T23.59_Cookie_recipies.pdf"
           "2011-08-29T08.23.59_test.pdf"

Emacs tmp-files like file~ are automatically ignored

Then an Org-mode file is generated that contains links to the files.

At files, containing only the date information i.e. "2013-03-08_foo.txt", the
time will be extracted from the filesystem, when both dates are matching. To
Turn off this feature see argument "--skip-file-time-extraction"
"""
COPYRIGHT_YEAR = "2011-2014"
COPYRIGHT_AUTHORS = """Karl Voit <*****@*****.**>,
Armin Wieser <*****@*****.**>"""

if __name__ == "__main__":

    memacs = FileNameTimeStamps(prog_version=PROG_VERSION_NUMBER,
                                prog_version_date=PROG_VERSION_DATE,
                                prog_description=PROG_DESCRIPTION,
                                prog_short_description=PROG_SHORT_DESCRIPTION,
                                prog_tag=PROG_TAG,
                                copyright_year=COPYRIGHT_YEAR,
                                copyright_authors=COPYRIGHT_AUTHORS)
    memacs.handle_main()
Exemplo n.º 10
0
 def test__check_timestamp_correctness(self):
     argv = "--suppress-messages --omit-drawers --folder " + self._tmp_dir
     memacs = FileNameTimeStamps(argv=argv.split())
     self.assertTrue(
         memacs._FileNameTimeStamps__check_timestamp_correctness('00:00'))
     self.assertTrue(
         memacs._FileNameTimeStamps__check_timestamp_correctness('23:59'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('1:2'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('12:2'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('1:23'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness(''))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('abcde'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('ab:cd'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('24:00'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('23:61'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('12.34'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_timestamp_correctness('a'))
Exemplo n.º 11
0
 def test__check_datestamp_correctness(self):
     argv = "--suppress-messages --omit-drawers --folder " + self._tmp_dir
     memacs = FileNameTimeStamps(argv=argv.split())
     self.assertTrue(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '2019-12-31'))
     self.assertTrue(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '2000-01-01'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '1999-00-01'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '1999-01-00'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '1999-13-00'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '1999-12-32'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness('abc'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness(''))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness('1'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness('1-2-3'))
     self.assertFalse(
         memacs._FileNameTimeStamps__check_datestamp_correctness(
             '2000-2-3'))
Exemplo n.º 12
0
 def call_active_time_stamps(self):
     argv = "--suppress-messages --omit-drawers --folder " + self._tmp_dir
     memacs = FileNameTimeStamps(argv=argv.split())
     return memacs.test_get_entries()
Exemplo n.º 13
0
 def call_skip_file_time_extraction(self):
     argv = "--skip-file-time-extraction --suppress-messages --omit-drawers --folder " + self._tmp_dir
     memacs = FileNameTimeStamps(argv=argv.split())
     return memacs.test_get_entries()