from allmydata.util.encodingutil import listdir_unicode, quote_output, \
quote_local_unicode_path, to_str, FilenameEncodingError, unicode_to_url
from allmydata.util.assertutil import precondition
-from allmydata.util.fileutil import abspath_expanduser_unicode
+from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath
def get_local_metadata(path):
print >>self.options.stderr, msg
def process(self, localpath):
- precondition(isinstance(localpath, unicode), localpath)
+ precondition_abspath(localpath)
# returns newdircap
quoted_path = quote_local_unicode_path(localpath)
# This function will raise an IOError exception when called on an unreadable file
def upload(self, childpath):
- precondition(isinstance(childpath, unicode), childpath)
+ precondition_abspath(childpath)
#self.verboseprint("uploading %s.." % quote_local_unicode_path(childpath))
metadata = get_local_metadata(childpath)
from allmydata.scripts.common_http import do_http, HTTPError
from allmydata import uri
from allmydata.util import fileutil
-from allmydata.util.fileutil import abspath_expanduser_unicode
+from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath
from allmydata.util.encodingutil import unicode_to_url, listdir_unicode, quote_output, \
quote_local_unicode_path, to_str
from allmydata.util.assertutil import precondition
class LocalFileSource:
def __init__(self, pathname):
- precondition(isinstance(pathname, unicode), pathname)
+ precondition_abspath(pathname)
self.pathname = pathname
def need_to_copy_bytes(self):
return True
def open(self, caps_only):
- return open(os.path.expanduser(self.pathname), "rb")
-
+ return open(self.pathname, "rb")
class LocalFileTarget:
def __init__(self, pathname):
- precondition(isinstance(pathname, unicode), pathname)
+ precondition_abspath(pathname)
self.pathname = pathname
def put_file(self, inf):
fileutil.put_file(self.pathname, inf)
-
class LocalMissingTarget:
def __init__(self, pathname):
- precondition(isinstance(pathname, unicode), pathname)
+ precondition_abspath(pathname)
self.pathname = pathname
def put_file(self, inf):
fileutil.put_file(self.pathname, inf)
-
class LocalDirectorySource:
def __init__(self, progressfunc, pathname):
- precondition(isinstance(pathname, unicode), pathname)
+ precondition_abspath(pathname)
self.progressfunc = progressfunc
self.pathname = pathname
class LocalDirectoryTarget:
def __init__(self, progressfunc, pathname):
- precondition(isinstance(pathname, unicode), pathname)
+ precondition_abspath(pathname)
self.progressfunc = progressfunc
self.pathname = pathname
def set_children(self):
pass
+
class TahoeFileSource:
def __init__(self, nodeurl, mutable, writecap, readcap):
self.nodeurl = nodeurl
def to_stderr(self, text):
print >>self.stderr, text
+ # FIXME reduce the amount of near-duplicate code between get_target_info and get_source_info.
+
def get_target_info(self, destination_spec):
rootcap, path = get_alias(self.aliases, destination_spec, None)
if rootcap == DefaultAliasMarker: