コード例 #1
0
ファイル: cmdline.py プロジェクト: tobybird/mootdx
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_parse_all(self):
     data = Affairs.parse(downdir='tmp')
     self.assertTrue(data)
コード例 #3
0
 def test_fetch_one(self):
     Affairs.fetch(downdir='tmp', filename='gpcw19960630.zip')
     self.assertTrue(os.path.exists('gpcw19960630.csv'))
コード例 #4
0
 def test_fetch_all(self):
     data = Affairs.fetch(downdir='tmp')
     self.assertTrue(data)
コード例 #5
0
 def test_files(self):
     data = Affairs.files()
     self.assertTrue(type(data) is list)
コード例 #6
0
 def test_parse_export(self):
     Affairs.parse(downdir='tmp',
                   filename='gpcw19960630.zip').to_csv('gpcw19960630.csv')
     self.assertTrue(os.path.exists('gpcw19960630.csv'))
コード例 #7
0
 def test_parse_one(self):
     data = Affairs.parse(downdir='tmp', filename='gpcw19960630.zip')
     self.assertTrue(data)
コード例 #8
0
from mootdx.affairs import Affairs

Affairs.parse(downdir='tmp') # 解析全部
# Affairs.parse(downdir='tmp', filename='gpcw19960630.zip') # 解析文件
# Affairs.parse(downdir='tmp', filename='gpcw19960630.zip').to_csv('gpcw19960630.csv') # 转存文件

# Affairs.files() # 显示列表
# Affairs.fetch(filelist=True) # 显示列表
# Affairs.fetch(downdir='tmp') # 下载全部
# Affairs.fetch(downdir='tmp', filename='gpcw19960630.zip') # 下载文件