diff --git a/game-programmer-zh-cn.dot b/game-programmer-zh-cn.dot index 44750a8..b895df5 100644 --- a/game-programmer-zh-cn.dot +++ b/game-programmer-zh-cn.dot @@ -97,7 +97,7 @@ digraph { learntoprogramwithscratch [label=<
动手玩转Scratch2.0编程 (2015)
> URL="https://book.douban.com/subject/26658602/"] helpyoukidswithcomputercoding [label=<
Help Your Kids
with Computer Coding
(2015)
> URL="https://www.amazon.com/dp/146541956X/"] - inventgamepython3 [label=<
Invent Your Own
Computer Games with
Python 3rd Ed (2015)
> URL="https://www.amazon.com/dp/1503212300/"] + inventgamepython4 [label=<
Invent Your Own
Computer Games with
Python 4th Ed (2016)
> URL="https://www.amazon.com/dp/1593277954/"] makinggamespython [label=<
Making Games with
Python & Pygame (2012)
> URL="https://www.amazon.com/dp/1469901730/"] learntoprogramwithminecraft [label=<
Learn to Program
with Minecraft (2015)
> URL="https://www.amazon.com/dp/1593276702/"] adventuresinminecraft [label=<
零基础学Minecraft编程
(2015)
> URL="https://book.douban.com/subject/26613247/"] @@ -107,7 +107,7 @@ digraph { age8 -> codinggamesinscratch -> helpyoukidswithcomputercoding -> kidintermediate [arrowhead=normal, style=solid] age8 -> superscratchprogadv -> learntoprogramwithscratch -> kidintermediate - kidintermediate -> inventgamepython3 -> makinggamespython + kidintermediate -> inventgamepython4 -> makinggamespython kidintermediate -> learntoprogramwithminecraft -> adventuresinminecraft kidintermediate -> "3dgpforkids" @@ -718,7 +718,7 @@ digraph { } { rank=same - gameaipro [label=<
Game AI Pro (2013)
> URL="https://www.amazon.com/dp/1466565969/"] + gameaipro [label=<
游戏人工智能(2017)
> URL="https://book.douban.com/subject/27154117/"] gameaipro2 [label=<
Game AI Pro 2 (2015)
> URL="https://www.amazon.com/dp/1482254794/"] gameaipro3 [label=<
Game AI Pro 3 (2017)
> URL="https://www.amazon.com/dp/1482254794/"] } @@ -750,7 +750,7 @@ digraph { networkprog [label="网络编程"] } - multiplayergp [label=<
Multiplayer Game
Programming (2015)
> URL="https://www.amazon.com/dp/0134034309/"] + multiplayergp [label=<
网络多人游戏架构与编程
(2017)
> URL="https://book.douban.com/subject/27135506/"] massivelymultiplayergd [label=<
大型多人在线游戏开发
(2006)
> URL="https://book.douban.com/subject/1940567/"] massivelymultiplayergd2 [label=<
Massively Multiplayer
Game Development 2
(2005)
> URL="https://www.amazon.com/dp/1584503904/"] diff --git a/game-programmer.dot b/game-programmer.dot index 70e9347..6fdcbea 100644 --- a/game-programmer.dot +++ b/game-programmer.dot @@ -99,7 +99,7 @@ digraph { learntoprogramwithscratch [label=<
Learn to Program
with Scratch
(2014)
> URL="https://www.amazon.com/dp/1593275439/"] helpyoukidswithcomputercoding [label=<
Help Your Kids
with Computer Coding
(2015)
> URL="https://www.amazon.com/dp/146541956X/"] - inventgamepython3 [label=<
Invent Your Own
Computer Games with
Python 3rd Ed (2015)
> URL="https://www.amazon.com/dp/1503212300/"] + inventgamepython4 [label=<
Invent Your Own
Computer Games with
Python 4th Ed (2016)
> URL="https://www.amazon.com/dp/1593277954/"] makinggamespython [label=<
Making Games with
Python & Pygame (2012)
> URL="https://www.amazon.com/dp/1469901730/"] learntoprogramwithminecraft [label=<
Learn to Program
with Minecraft (2015)
> URL="https://www.amazon.com/dp/1593276702/"] adventuresinminecraft [label=<
Adventures in
Minecraft (2014)
> URL="https://www.amazon.com/dp/111894691X/"] @@ -109,7 +109,7 @@ digraph { age8 -> codinggamesinscratch -> helpyoukidswithcomputercoding -> kidintermediate [arrowhead=normal, style=solid] age8 -> superscratchprogadv -> learntoprogramwithscratch -> kidintermediate - kidintermediate -> inventgamepython3 -> makinggamespython + kidintermediate -> inventgamepython4 -> makinggamespython kidintermediate -> learntoprogramwithminecraft -> adventuresinminecraft kidintermediate -> "3dgpforkids" @@ -131,9 +131,9 @@ digraph { csmath [label="Mathematics for CS"] } - sicp2 [label=<
Structure and Interpretation
of Computer Programs
(SICP) 2nd Ed (1996)
> URL="https://www.amazon.com/dp/0133001482/"] - csapp3 [label=<
Computer Systems
(CSAPP) 3rd Ed (2015)
> URL="https://www.amazon.com/dp/0133001482/"] - caaqa5 [label=<
Computer Architecture
(CAAQA) 5th Ed (2011)
> URL="https://www.amazon.com/dp/0123838738/"] + sicp2 [label=<
Structure and Interpretation
of Computer Programs
(SICP) 2nd Ed (1996)
> URL="https://www.amazon.com/dp/0262510871/"] + csapp3 [label=<
Computer Systems
(CSAPP) 3rd Ed (2015)
> URL="https://www.amazon.com/dp/013409266X/"] + caaqa5 [label=<
Computer Architecture
(CAAQA) 5th Ed (2011)
> URL="https://www.amazon.com/dp/012383872X/"] mos4 [label=<
Modern Operating
System (MOS)
4th Ed (2014)
> URL="https://www.amazon.com/dp/013359162X/"] clrs3 [label=<
Introduction to
Algorithms (CLRS)
3rd Ed (2009)
> URL="https://www.amazon.com/dp/0262033844/"] @@ -195,7 +195,7 @@ digraph { insidecppobjectmodel [label=<
Inside the C++
Object Model (1996)
> URL="https://www.amazon.com/dp/0201834545/"] imperfectcpp [label=<
Imperfect C++ (2004)
> URL="https://www.amazon.com/dp/0321228774/"] - cpptemplates [label=<
C++ Templates (2002)
> URL="https://www.amazon.com/dp/0201734842/"] + cpptemplates2 [label=<
C++ Templates 2nd Ed (2017)
> URL="https://www.amazon.com/dp/0321714121/"] elementsofprogramming [label=<
Elements of
Programming (2009)
> URL="https://www.amazon.com/dp/032163537X/"] frommathtogeneric [label=<
From Mathematics
to Generic Programming
(2014)
> URL="https://www.amazon.com/dp/0321942043/"] moderncppdesign [label=<
Modern C++ Design (2001)
> URL="https://www.amazon.com/dp/0201704315/"] @@ -224,9 +224,9 @@ digraph { effectivemoderncpp -> optimizedcpp -> cppadvance cpppractice -> exceptionalcpp -> moreexceptionalcpp -> exceptionalcppstyle -> cppcodingstandard -> cppadvance cppadvance -> elementsofprogramming -> frommathtogeneric - cppadvance -> { insidecppobjectmodel; cpptemplates } + cppadvance -> { insidecppobjectmodel; cpptemplates2 } insidecppobjectmodel -> imperfectcpp - cpptemplates -> moderncppdesign + cpptemplates2 -> moderncppdesign lua -> programminginlua4 -> luaprogramminggems diff --git a/images-zh-cn/gameaipro.jpg b/images-zh-cn/gameaipro.jpg index b23e32d..cc99529 100644 Binary files a/images-zh-cn/gameaipro.jpg and b/images-zh-cn/gameaipro.jpg differ diff --git a/images-zh-cn/multiplayergp.jpg b/images-zh-cn/multiplayergp.jpg index c00b73b..1645869 100644 Binary files a/images-zh-cn/multiplayergp.jpg and b/images-zh-cn/multiplayergp.jpg differ diff --git a/images/cpptemplates.jpg b/images/cpptemplates.jpg deleted file mode 100644 index caa4731..0000000 Binary files a/images/cpptemplates.jpg and /dev/null differ diff --git a/images/cpptemplates2.jpg b/images/cpptemplates2.jpg new file mode 100644 index 0000000..af64386 Binary files /dev/null and b/images/cpptemplates2.jpg differ diff --git a/images/inventgamepython3.jpg b/images/inventgamepython3.jpg deleted file mode 100644 index 19c395b..0000000 Binary files a/images/inventgamepython3.jpg and /dev/null differ diff --git a/images/inventgamepython4.jpg b/images/inventgamepython4.jpg new file mode 100644 index 0000000..2f68f4a Binary files /dev/null and b/images/inventgamepython4.jpg differ diff --git a/isbn.csv b/isbn.csv index 6c49152..7389b9c 100644 --- a/isbn.csv +++ b/isbn.csv @@ -190,7 +190,7 @@ aigpwisdom3,9781584504573, 未找到中文, None aigpwisdom4,9781584505235, 未找到中文, None gameaipro,9781466565968, 未找到中文, None gameaipro2,9781482254792, 未找到中文, None -multiplayergp,9780134034300, 未找到中文, None +multiplayergp,9780134034300, 网络多人游戏架构与编程,9787115457790 massivelymultiplayergd,9781584502432, 大型多人在线游戏开发,9787115152671 massivelymultiplayergd2,9781584503903, 未找到中文, None progposixthreads,9780201633924, POSIX多线程程序设计,9787508313955 diff --git a/zh-cn.py b/zh-cn.py index 33f7230..214c651 100644 --- a/zh-cn.py +++ b/zh-cn.py @@ -1,12 +1,18 @@ +#!/usr/bin/env python # -*- coding:utf8 -*- """ 读取game-programmer.dot将其转换为中文版的game-programmer-zh-cn.dot """ -import json -import re -import urllib2 +from __future__ import print_function import csv +import json import os +import re +try: + from urllib.request import urlopen # Python 3 +except ImportError: + from urllib2 import urlopen # Python 2 + IMAGE_PATH = './images-zh-cn/{book_index}.jpg' @@ -16,12 +22,12 @@ def get_image(isbn, image_filename): :rtype: str """ print("get_image(" + isbn + "," + isbn + ")") - response = urllib2.urlopen(book_url) + response = urlopen(book_url) html = response.read() re_image_url = r"https://img/d/.doubanio/.com/lpic/s/d*/.jpg" image_url = re.search(re_image_url, html).group() with open(image_filename, 'w') as ft: - response = urllib2.urlopen(image_url) + response = urlopen(image_url) image = response.read() ft.write(image) @@ -30,12 +36,12 @@ def get_book_url_year(isbn): url = "https://api.douban.com/v2/book/isbn/" + isbn result = "https://book.douban.com/", "" try: - response = urllib2.urlopen(url) + response = urlopen(url) detail = response.read() return json.loads(detail)["alt"], json.loads(detail)["pubdate"][:4] except Exception as e: - print isbn - print e + print(isbn) + print(e) return result def get_book_info(book_index): @@ -161,25 +167,25 @@ def get_book_info(book_index): label_line_match = RE_LABEL_LINE.match(line_without_space) content_line_match = RE_CONTENT_LINE.match(line_without_space) - if book_line_match != None: + if book_line_match is not None: book_index = line_without_space.split(" ")[0] book_title, book_url, book_year = get_book_info(book_index.strip('"')) - if book_title == None: + if book_title is None: zh_f.write(line) else: image_path = IMAGE_PATH.format(book_index=book_index.strip('"')) writeline = space_front+ BOOK_LINE.format(book_index=book_index, image_path=image_path, book_title=book_title, book_year=book_year, url=book_url) zh_f.write(writeline) - elif section_line_match != None: + elif section_line_match is not None: sectionID = re.search(r'\d+\.', line_without_space).group() writeline = space_front + SECTION_LINE.format(section_title=SECTION_TITLE_DICT[sectionID]) zh_f.write(writeline) - elif label_line_match != None: + elif label_line_match is not None: label_index = label_line_match.group().split(' ')[0] en_label_content = re.search(r'label="[\w -=\./\\]*"', line_without_space).group()[7:-1] writeline = space_front + LABEL_LINE.format(label_index=label_index, label=LABEL_DICT[en_label_content]) zh_f.write(writeline) - elif content_line_match != None: + elif content_line_match is not None: sectionID = line_without_space.split('.')[0][37:] + '.' section_title =SECTION_TITLE_DICT[sectionID] if '<' in line_without_space: