コード例 #1
0
ファイル: main.py プロジェクト: aschmied/advent-of-code-2016
def main():
    with open('input') as f:
        input = f.read().strip()

    decoded_by_v1 = decoder.get(1).decode(input)
    len_decoded_by_v1 = len(decoded_by_v1)
    len_decoded_by_v2 = decoder.get(2).len_decoded(input)

    print(len_decoded_by_v1)
    print(len_decoded_by_v2)
コード例 #2
0
    def downloadChapter(self, url):
        abstraction = get(self.baseURL + "/" + url)
        mangaName = abstraction['bname']
        chapterName = abstraction['cname']
        length = abstraction['len']
        e = abstraction['sl']['e']
        m = abstraction['sl']['m']
        path = abstraction['path']

        localPath = self.path + "/" + mangaName + "/" + chapterName + "/"
        self.createDirectory(localPath)
        print('下载 %s %s 中 共%s页' % (mangaName, chapterName, length))

        for filename in abstraction['files']:
            pgUrl = 'https://i.hamreus.com' + path + filename
            print(os.path.basename(pgUrl))
            self.downloadPg(pgUrl, e, m, localPath)
            time.sleep(0.5)  # 0.5s interval
        return True
コード例 #3
0
 def setUp(self):
   self.protocol_version = 1
   self.decoder = decoder.get(self.protocol_version)
コード例 #4
0
 def test_invlid_protocol_version(self):
   with self.assertRaises(ValueError):
     decoder.get(3)