Rev477, FindHashId command for optional files, Renaming some variables to make it more clear, Optional files downloading in WorkerManager, Test FindHash, Test Optional download, Test FindOptional

This commit is contained in:
HelloZeroNet 2015-10-22 11:42:55 +02:00
parent e8ce26587d
commit a8dae8dd85
9 changed files with 348 additions and 93 deletions

View file

@ -2,6 +2,7 @@ import os
import socket
import struct
import re
import collections
def atomicWrite(dest, content, mode="w"):
@ -44,3 +45,17 @@ def getDirname(path):
# Return: data/site/content.json -> content.json
def getFilename(path):
return re.sub("^.*/", "", path)
# Convert hash to hashid for hashfield
def toHashId(hash):
return int(hash[0:4], 16)
# Merge dict values
def mergeDicts(dicts):
back = collections.defaultdict(set)
for d in dicts:
for key, val in d.iteritems():
back[key].update(val)
return dict(back)