예제 #1
0
    def test_05_save_a_table(self):
        try:
            os.remove(test_fldr + os.sep + 'Events2015.user01')
        except Exception:
            print('file not found, but we dont care')

        ev = mod_core.CoreTable(test_fldr, tpe='Events', user='******', header=['date', 'category', 'details'])
        ev.add(mod_core.CoreDataWhen('Sales Meeting', ['2014-01-11', 'Office', 'Catchup with client']))
        ev.add(mod_core.CoreDataWhen('Sales Meeting#3', ['2015-03-11', 'Office', 'Catchup with client']))
        ev.add(mod_core.CoreDataWhen('DEV AIKIF - core data', ['2015-05-11', 'Software', 'update TEST - no test for CORE_DATA']))
        ev.add(mod_core.CoreDataWhen('DEV LifePim - core data', ['2015-03-11', 'Software', 'use data for LifePim']))
        ev.add(mod_core.CoreDataWhen('DEV AIKIF - data tools', ['2015-05-11', 'Software', 'fix data tools ']))
        ev.save('2015')
        with open(test_fldr + os.sep + 'Events2015.user01', 'r') as f:
            txt = f.read()
        self.assertEqual(len(txt), 353)
        ev.generate_diary()


        srch = ev.find('Sales')
        self.assertEqual(str(srch[0]), 'Sales Meeting (type=when)')
        self.assertEqual(str(srch[1]), 'Sales Meeting#3 (type=when)')

        srch2 = ev.find('data')
        self.assertEqual(len(srch2), 3)

        # now save with header
        ev.save('2015', add_header='Y')
        with open(test_fldr + os.sep + 'Events2015.user01', 'r') as f:
            txt = f.read()
        self.assertEqual(len(txt), 735)
예제 #2
0
def collect_screenshots(cat, folder, file_tag='FileUsage'):
    """
    add events based on screenshot creation
    """
    hdr = ['date', 'category', 'size', 'filename', 'path']
    ev = core_data.CoreTable(op_folder, tpe='Events', user=usr, header=hdr)
    op_file = ev.get_filename(file_tag + '-' + cat)
    if os.path.exists(op_file):
        os.remove(op_file)

    # get collection of screenshots
    fl_filename = os.path.join(op_folder, 'filelist_screenshots.csv')
    fles = fl.FileList([folder], ['*.jpg', '*.png', '*.gif'],
                       ['\\thumbnails\\'], fl_filename)
    fles.save_filelist(fl_filename, ["name", "path", "size", "date"])
    files = fles.get_metadata()
    for file_dict in files:
        ev.add(
            core_data.CoreDataWhen(cat, [
                file_dict["date"], file_tag, file_dict["size"],
                file_dict["name"], file_dict["path"]
            ]))

    lg.record_process(
        'event_aggregator.py',
        'created ' + str(len(files)) + ' events for ' + cat + '-' + file_tag)
    ev.save(file_tag, add_header='Y')
예제 #3
0
    def test_03_events(self):

        # Events
        e = mod_core.CoreDataWhen('Sales Meeting', ['2015-04-11', 'Office', 'Meet with client to discuss custom software'])
        self.assertEqual(len(e.format_csv()), 85)
        self.assertEqual(len(e.format_dict()), 104)
        self.assertEqual(str(e), 'Sales Meeting (type=when)')
예제 #4
0
def add_event(fname, dte, details, remindme='', cat='Diary'):
    """
    function to take a diary / calendar or reminder note and
    add to AIKIF raw data store.
    """
    print("Adding event:", dte, remindme, details)

    e = c.CoreDataWhen('Diary', [dte, cat, details])

    with open(fname, "a") as f:
        f.write(e.format_csv())
예제 #5
0
def add_manual_events():
    """
    add events manually from code, and sample text files
    """
    hdr = ['date', 'category', 'details']
    ev_man = core_data.CoreTable(op_folder, tpe='Events', user=usr, header=hdr)
    op_file = ev_man.get_filename('Manual')
    if os.path.exists(op_file):
        os.remove(op_file)

    lg.record_process('event_aggregator.py', 'loading manual events')
    ev_man.add(
        core_data.CoreDataWhen('Build Event Aggregator', [
            '2016-06-22', 'Dev', 'Started example to generate diary with AIKIF'
        ]))

    ev_man.save('Manual', add_header='Y')
예제 #6
0
 def test_24_core_data_when(self):
     l = mod_core.CoreDataWhen('Sales Meeting', ['Meet with Clients'])
     self.assertEqual(len(l.format_csv()) >  5, True)
     self.assertEqual(str(l) , 'Sales Meeting (type=when)')
     self.assertEqual(l.type_desc , 'Event')
     self.assertEqual(l.data_type , 'when')