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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mozdownload/timezones.py ('k') | pylama.ini » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mozdownload/utils.py
diff --git a/mozdownload/utils.py b/mozdownload/utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..ddd4491b647cf574969531d41348206747ef65f4
--- /dev/null
+++ b/mozdownload/utils.py
@@ -0,0 +1,32 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+"""Module to store various helper functions used in mozdownload."""
+
+import hashlib
+
+
+def urljoin(*fragments):
+ """Concatenates multi part strings into urls"""
+
+ # Strip possible already existent final slashes of fragments except for the last one
+ parts = [fragment.rstrip('/') for fragment in fragments[:len(fragments) - 1]]
+ parts.append(fragments[-1])
+
+ return '/'.join(parts)
+
+
+def create_md5(path):
+ """Creates the md5 hash of a file using the hashlib library"""
+
+ m = hashlib.md5()
+ # rb necessary to run correctly in windows.
+ with open(path, "rb") as f:
+ while True:
+ data = f.read(8192)
+ if not data:
+ break
+ m.update(data)
+
+ return m.hexdigest()
« 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