From: <ze...@us...> - 2007-05-27 11:46:12
|
Revision: 5702 http://svn.sourceforge.net/translate/?rev=5702&view=rev Author: zejn Date: 2007-05-27 04:46:13 -0700 (Sun, 27 May 2007) Log Message: ----------- [django-migration] Moved listdir to storage_client. Modified Paths: -------------- src/branches/django-migration/Pootle/path.py src/branches/django-migration/Pootle/storage/PootleStorageServer.py src/branches/django-migration/Pootle/storage_client.py src/branches/django-migration/Pootle/web/models.py Modified: src/branches/django-migration/Pootle/path.py =================================================================== --- src/branches/django-migration/Pootle/path.py 2007-05-27 11:44:06 UTC (rev 5701) +++ src/branches/django-migration/Pootle/path.py 2007-05-27 11:46:13 UTC (rev 5702) @@ -39,9 +39,9 @@ from Pootle.utils import NotImplementedException from Pootle.conf import instance from Pootle.utils.convert import convert_translation_store +from Pootle import storage_client from translate.filters import checks from translate.storage import po -from django.conf import settings from urllib import urlopen __version__ = '2.1' @@ -87,9 +87,9 @@ _textmode = 'U' translatable_file_re = re.compile(".*?\.(po|xli?ff?)$") -list_remote_re = re.compile("(\w+)/? stats t: (\d+)w (\d+)s (\d+)p f: (\d+)w (\d+)s (\d+)p u: (\d+)w (\d+)s (\d+)p all: (\d+)w (\d+)s\n") + class TreeWalkWarning(Warning): pass @@ -982,22 +982,11 @@ # --- Special stuff for Pootle - def listdir_remote(self): - url = settings.STORAGE_ROOT_URL + self[1:] - urlfd = urlopen(url) - data = urlfd.read() - urlfd.close() + def listdir_remote(self, subdir=None): + if subdir != None: + return (self / subdir).listdir_remote() + return storage_client.listdir(self) - dirlist = [] - cur = 0 - match = list_remote_re.match(data, cur) - while match: - direntry = match.groups() - dirlist.append( (direntry[0], map(int, direntry[1:]))) - cur = match.end() - match = list_remote_re.match(data, cur) - return dirlist - # conveniently convert translation store convert = convert_translation_store Modified: src/branches/django-migration/Pootle/storage/PootleStorageServer.py =================================================================== --- src/branches/django-migration/Pootle/storage/PootleStorageServer.py 2007-05-27 11:44:06 UTC (rev 5701) +++ src/branches/django-migration/Pootle/storage/PootleStorageServer.py 2007-05-27 11:46:13 UTC (rev 5702) @@ -156,7 +156,7 @@ fullname = os.path.join(path, name) displayname = linkname = name # Append / for directories or @ for symbolic links - if os.path.isdir(fullname): + if os.path.isdir(fullname) and not fullname.endswith(".po"): displayname = name + "/" linkname = name + "/" if os.path.islink(fullname): Modified: src/branches/django-migration/Pootle/storage_client.py =================================================================== --- src/branches/django-migration/Pootle/storage_client.py 2007-05-27 11:44:06 UTC (rev 5701) +++ src/branches/django-migration/Pootle/storage_client.py 2007-05-27 11:46:13 UTC (rev 5702) @@ -5,9 +5,33 @@ from urllib import urlencode from Pootle.settings import STORAGE_ROOT_URL from translate.storage.po import pounit +import re +list_remote_re = re.compile("([\w\./]+?)? stats t: (\d+)w (\d+)s (\d+)p f: (\d+)w (\d+)s (\d+)p u: (\d+)w (\d+)s (\d+)p all: (\d+)w (\d+)s\n") + class ImproperlyConfigured(Exception): pass + +class StorageFile(object): + + def __init__(self, content): + self.stats = content[1] + self.val = content[0] + if self.val.endswith("/"): # is a dir + self.icon = 'folder' + self.href = '%s' % self.val + self.isdir = True + self.isfile = False + else: # is a file + self.icon = 'file' + self.href = '%s' % self.val + self.isdir = False + self.isfile = True + + def basename(self): + return str(self.val) + + _layout = None def get_layout(): global _layout @@ -59,3 +83,24 @@ return get_unit(file, id, unit) +def listdir(dirname): + if dirname.startswith("/"): + url = storage_root + dirname[1:] + else: + url = storage_root + dirname + + urlfd = urlopen(url) + data = urlfd.read() + urlfd.close() + + dirlist = [] + cur = 0 + match = list_remote_re.match(data, cur) + while match: + direntry = match.groups() + dirlist.append( StorageFile((direntry[0], map(int, direntry[1:])))) + cur = match.end() + match = list_remote_re.match(data, cur) + return dirlist + + Modified: src/branches/django-migration/Pootle/web/models.py =================================================================== --- src/branches/django-migration/Pootle/web/models.py 2007-05-27 11:44:06 UTC (rev 5701) +++ src/branches/django-migration/Pootle/web/models.py 2007-05-27 11:46:13 UTC (rev 5702) @@ -134,8 +134,8 @@ def _get_podir(self): if not self._podir: - self._podir = storage_client.get_po_dir(self) - return self._podir + self._podir = path(storage_client.get_po_dir(self)) + self._podir podir = property(_get_podir) def dir(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |