Пример #1
0
def affair(parse, files, fetch, output, downdir, verbose):
    from mootdx.affairs import Affairs
    from prettytable import PrettyTable
    affairs = Affairs.files()

    if files:
        t = PrettyTable(["filename", "filesize", "hash"])
        t.align["filename"] = "l"
        t.align["filesize"] = "l"
        t.align["hash"] = "l"
        t.padding_width = 1

        for x in affairs:
            t.add_row([x['filename'], x['filesize'], x['hash']])

        print(t)

    if fetch:
        if fetch == 'all':
            for x in affairs:
                Affairs.fetch(downdir=downdir, filename=x['filename'])
        else:
            Affairs.fetch(downdir=downdir, filename=fetch.strip('.zip') + '.zip')

    if parse:
        filelist = [x['filename'] for x in affairs]
        if parse in filelist:
            if os.path.exists(os.path.join(downdir, parse)):
                Affairs.parse(downdir=downdir, filename=parse.strip('.zip') + '.zip').to_csv(output)
            else:
                print('file not found.')
Пример #2
0
 def test_fetch_one(self):
     Affairs.fetch(downdir='tmp', filename='gpcw19960630.zip')
     self.assertTrue(os.path.exists('gpcw19960630.csv'))
Пример #3
0
 def test_fetch_all(self):
     data = Affairs.fetch(downdir='tmp')
     self.assertTrue(data)