Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# if uri.startswith("freenet:CHK@") or uri.startswith("CHK@"):
# uri = os.path.splitext(uri)[0]
# process uri, including possible namesite lookups
uri = uri.split("freenet:")[-1]
if len(uri) < 5 or (uri[:4] not in ('SSK@', 'KSK@', 'CHK@', 'USK@', 'SVK@')):
# we seem to have a 'domain name' uri
try:
domain, rest = uri.split("/", 1)
except:
domain = uri
rest = ''
tgtUri = self.namesiteLookup(domain)
if not tgtUri:
raise FCPNameLookupFailure(
"Failed to resolve freenet domain '%s'" % domain)
if rest:
uri = (tgtUri + "/" + rest).replace("//", "/")
else:
uri = tgtUri
opts['URI'] = uri
opts['MaxRetries'] = kw.get("maxretries", -1)
opts['MaxSize'] = kw.get("maxsize", "1000000000000")
opts['PriorityClass'] = int(kw.get("priority", 1))
opts['timeout'] = int(kw.pop("timeout", ONE_YEAR))
#print "get: opts=%s" % opts
if opts['Global'] == 'true' and opts['Persistence'] == 'connection':
raise Exception("Global requests must be persistent")
# process uri, including possible namesite lookups
uri = uri.split("freenet:")[-1]
if len(uri) < 4 or (uri[:4] not in ('SSK@', 'KSK@', 'CHK@', 'USK@', 'SVK@')):
# we seem to have a 'domain name' uri
try:
domain, rest = uri.split("/", 1)
except:
domain = uri
rest = ''
tgtUri = self.namesiteLookup(domain)
if not tgtUri:
raise FCPNameLookupFailure(
"Failed to resolve freenet domain '%s'" % domain)
if rest:
uri = (tgtUri + "/" + rest).replace("//", "/")
else:
uri = tgtUri
opts['URI'] = uri
# determine a mimetype
mimetype = kw.get("mimetype", None)
if kw.has_key('mimetype'):
# got an explicit mimetype - use it
mimetype = kw['mimetype']
else:
# not explicitly given - figure one out
ext = os.path.splitext(uri)[1]