conduit r1365 - in trunk: conduit conduit/dataproviders conduit/datatypes test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1365 - in trunk: conduit conduit/dataproviders conduit/datatypes test/python-tests
- Date: Wed, 12 Mar 2008 04:09:22 +0000 (GMT)
Author: jstowers
Date: Wed Mar 12 04:09:22 2008
New Revision: 1365
URL: http://svn.gnome.org/viewvc/conduit?rev=1365&view=rev
Log:
2008-03-12 John Stowers <john stowers gmail com>
* conduit/Vfs.py: Remove unneeded print
* conduit/dataproviders/File.py:
* conduit/datatypes/File.py: Calculate relative path as needed
* test/python-tests/TestSyncFolderFolder.py:
* test/python-tests/common.py: Test Unicode filenames
Modified:
trunk/conduit/Vfs.py
trunk/conduit/dataproviders/File.py
trunk/conduit/datatypes/File.py
trunk/test/python-tests/TestSyncFolderFolder.py
trunk/test/python-tests/common.py
Modified: trunk/conduit/Vfs.py
==============================================================================
--- trunk/conduit/Vfs.py (original)
+++ trunk/conduit/Vfs.py Wed Mar 12 04:09:22 2008
@@ -121,7 +121,7 @@
try:
return gnomevfs.exists(gnomevfs.URI(uri)) == 1
except Exception, err:
- print err
+ log.warn("Error checking if location exists")
return False
def uri_make_directory_and_parents(uri):
Modified: trunk/conduit/dataproviders/File.py
==============================================================================
--- trunk/conduit/dataproviders/File.py (original)
+++ trunk/conduit/dataproviders/File.py Wed Mar 12 04:09:22 2008
@@ -215,14 +215,15 @@
newURI = self.folder+os.sep+vfsFile.get_filename()
else:
#Look for corresponding groups
+ relpath = vfsFile.get_relative_uri()
if self.folderGroupName == vfsFile.group:
log.debug("FolderTwoWay: Found corresponding group")
#put in the folder
- newURI = self.folder+vfsFile.relpath
+ newURI = self.folder+relpath
else:
log.debug("FolderTwoWay: Recreating group %s --- %s --- %s" % (vfsFile._get_text_uri(),vfsFile.basePath,vfsFile.group))
#unknown. Store in the dir but recreate the group
- newURI = self.folder+os.sep+os.path.join(vfsFile.group+vfsFile.relpath)
+ newURI = self.folder+os.sep+os.path.join(vfsFile.group+relpath)
destFile = File.File(URI=newURI)
comp = vfsFile.compare(
Modified: trunk/conduit/datatypes/File.py
==============================================================================
--- trunk/conduit/datatypes/File.py (original)
+++ trunk/conduit/datatypes/File.py Wed Mar 12 04:09:22 2008
@@ -38,9 +38,6 @@
#optional args
self.basePath = kwargs.get("basepath","")
self.group = kwargs.get("group","")
-
- #calculate the relative path
- self.relpath = self._get_text_uri().replace(self.basePath,"")
#instance
self.fileInfo = None
@@ -170,7 +167,6 @@
self.URI = f.URI
self.basePath = f.basePath
self.group = f.group
- self.relpath = f.relpath
self.fileInfo = f.fileInfo
self.fileExists = f.fileExists
self.triedOpen = f.triedOpen
@@ -422,6 +418,12 @@
return u
else:
return self.to_tempfile()
+
+ def get_relative_uri(self):
+ """
+ @returns: The files URI relative to its basepath
+ """
+ return self._get_text_uri().replace(self.basePath,"")
def compare(self, B, sizeOnly=False, existOnly=False):
"""
@@ -486,7 +488,6 @@
data = DataType.DataType.__getstate__(self)
data['basePath'] = self.basePath
data['group'] = self.group
- data['relpath'] = self.relpath
data['filename'] = self.get_filename()
data['filemtime'] = self.get_mtime()
@@ -503,7 +504,6 @@
self.URI = gnomevfs.URI(name)
self.basePath = data['basePath']
self.group = data['group']
- self.relpath = data['relpath']
self._defer_rename(data['filename'])
self._defer_new_mtime(data['filemtime'])
Modified: trunk/test/python-tests/TestSyncFolderFolder.py
==============================================================================
--- trunk/test/python-tests/TestSyncFolderFolder.py (original)
+++ trunk/test/python-tests/TestSyncFolderFolder.py Wed Mar 12 04:09:22 2008
@@ -7,7 +7,6 @@
import os.path
import traceback
-import random
import time
#Repeat syncs a few times to check for duplicate mapping bugs, etc
@@ -36,7 +35,8 @@
FILES = []
for i in range(0, NUM_FILES):
- name = Utils.random_string()
+ #test unicode
+ name = "%s UNICODE %s" % (Utils.random_string(), get_unicode_character())
contents = Utils.random_string()
f = File.TempFile(contents)
f.force_new_filename(name)
Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py (original)
+++ trunk/test/python-tests/common.py Wed Mar 12 04:09:22 2008
@@ -1,3 +1,4 @@
+#coding: utf-8
import sys
import cgitb
import os
@@ -6,6 +7,7 @@
import datetime
import traceback
import ConfigParser
+import random
# make sure we have conduit folder in path!
my_path = os.path.dirname(__file__)
@@ -136,7 +138,12 @@
data[k] = v
return data
-
+
+def get_unicode_character():
+ #Convenience function to get a unicode character.
+ UNICODE_CHARS = ('Ã','Ã','Ã','Ã','Ã','Ã')
+ return UNICODE_CHARS[random.randint(0,len(UNICODE_CHARS)-1)]
+
#Functions to construct new types
def new_file(filename):
if filename == None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]