提交 425a267b 编写于 作者: Z Zeyu Chen

remove Chinese comments

上级 99835e3c
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# coding=utf-8 # coding=utf-8
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
...@@ -64,9 +64,9 @@ def download_and_uncompress(url, save_name=None): ...@@ -64,9 +64,9 @@ def download_and_uncompress(url, save_name=None):
os.makedirs(dirname) os.makedirs(dirname)
#TODO(ZeyuChen) add download md5 file to verify file completeness #TODO(ZeyuChen) add download md5 file to verify file completeness
file_name = os.path.join( file_name = os.path.join(dirname,
dirname, url.split('/')[-1]
url.split('/')[-1] if save_name is None else save_name) if save_name is None else save_name)
retry = 0 retry = 0
retry_limit = 3 retry_limit = 3
...@@ -76,9 +76,8 @@ def download_and_uncompress(url, save_name=None): ...@@ -76,9 +76,8 @@ def download_and_uncompress(url, save_name=None):
if retry < retry_limit: if retry < retry_limit:
retry += 1 retry += 1
else: else:
raise RuntimeError( raise RuntimeError("Cannot download {0} within retry limit {1}".
"Cannot download {0} within retry limit {1}".format( format(url, retry_limit))
url, retry_limit))
print("Cache file %s not found, downloading %s" % (file_name, url)) print("Cache file %s not found, downloading %s" % (file_name, url))
r = requests.get(url, stream=True) r = requests.get(url, stream=True)
total_length = r.headers.get('content-length') total_length = r.headers.get('content-length')
...@@ -95,8 +94,8 @@ def download_and_uncompress(url, save_name=None): ...@@ -95,8 +94,8 @@ def download_and_uncompress(url, save_name=None):
dl += len(data) dl += len(data)
f.write(data) f.write(data)
done = int(50 * dl / total_length) done = int(50 * dl / total_length)
sys.stdout.write( sys.stdout.write("\r[%s%s]" % ('=' * done,
"\r[%s%s]" % ('=' * done, ' ' * (50 - done))) ' ' * (50 - done)))
sys.stdout.flush() sys.stdout.flush()
print("file download completed!", file_name) print("file download completed!", file_name)
...@@ -119,14 +118,6 @@ class TqdmProgress(tqdm): ...@@ -119,14 +118,6 @@ class TqdmProgress(tqdm):
last_block = 0 last_block = 0
def update_to(self, block_num=1, block_size=1, total_size=None): def update_to(self, block_num=1, block_size=1, total_size=None):
'''
block_num : int, optional
到目前为止传输的块 [default: 1].
block_size : int, optional
每个块的大小 (in tqdm units) [default: 1].
total_size : int, optional
文件总大小 (in tqdm units). 如果[default: None]保持不变.
'''
if total_size is not None: if total_size is not None:
self.total = total_size self.total = total_size
self.update((block_num - self.last_block) * block_size) self.update((block_num - self.last_block) * block_size)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册