Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: mozdownload/utils.py

Issue 1451373002: Updating mozdownload (excluding tests) (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/mozdownload@master
Patch Set: Updated README.md Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mozdownload/timezones.py ('k') | pylama.ini » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 """Module to store various helper functions used in mozdownload."""
6
7 import hashlib
8
9
10 def urljoin(*fragments):
11 """Concatenates multi part strings into urls"""
12
13 # Strip possible already existent final slashes of fragments except for the last one
14 parts = [fragment.rstrip('/') for fragment in fragments[:len(fragments) - 1] ]
15 parts.append(fragments[-1])
16
17 return '/'.join(parts)
18
19
20 def create_md5(path):
21 """Creates the md5 hash of a file using the hashlib library"""
22
23 m = hashlib.md5()
24 # rb necessary to run correctly in windows.
25 with open(path, "rb") as f:
26 while True:
27 data = f.read(8192)
28 if not data:
29 break
30 m.update(data)
31
32 return m.hexdigest()
OLDNEW
« no previous file with comments | « mozdownload/timezones.py ('k') | pylama.ini » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698