transform exercises order and true-or-false to WL1
[redakcja.git] / lib / vstorage / __init__.py
index a98f8de..bc66d50 100644 (file)
@@ -162,7 +162,7 @@ class VersionedStorage(object):
 
     def _file_to_title(self, filename):
         assert filename.startswith(self.repo_prefix)
 
     def _file_to_title(self, filename):
         assert filename.startswith(self.repo_prefix)
-        name = filename[len(self.repo_prefix):].strip('/').split('.', 1)[0]
+        name = filename[len(self.repo_prefix):].strip('/').rsplit('.', 1)[0]
         return urlunquote(name)
 
     def __contains__(self, title):
         return urlunquote(name)
 
     def __contains__(self, title):
@@ -180,7 +180,8 @@ class VersionedStorage(object):
         self.repo.dirstate.setparents(parent_node)
         node = self._commit([repo_file], text, user)
 
         self.repo.dirstate.setparents(parent_node)
         node = self._commit([repo_file], text, user)
 
-        partial = lambda filename: repo_file == filename
+        def partial(filename):
+            return repo_file == filename
 
         # If p1 is equal to p2, there is no work to do. Even the dirstate is correct.
         p1, p2 = self.repo[None].parents()[0], self.repo[tip_node]
 
         # If p1 is equal to p2, there is no work to do. Even the dirstate is correct.
         p1, p2 = self.repo[None].parents()[0], self.repo[tip_node]
@@ -233,9 +234,9 @@ class VersionedStorage(object):
 
     def save_data(self, title, data, **kwargs):
         """Save data as specified page."""
 
     def save_data(self, title, data, **kwargs):
         """Save data as specified page."""
+        temp_path = tempfile.mkdtemp(dir=self.path)
+        file_path = os.path.join(temp_path, 'saved')
         try:
         try:
-            temp_path = tempfile.mkdtemp(dir=self.path)
-            file_path = os.path.join(temp_path, 'saved')
             f = open(file_path, "wb")
             f.write(data)
             f.close()
             f = open(file_path, "wb")
             f.write(data)
             f.close()
@@ -416,8 +417,7 @@ class VersionedStorage(object):
         tip = self.repo['tip']
         """Iterate over the titles of all pages in the wiki."""
         return [self._file_to_title(filename) for filename in tip
         tip = self.repo['tip']
         """Iterate over the titles of all pages in the wiki."""
         return [self._file_to_title(filename) for filename in tip
-                  if not filename.startswith('.')
-                    and filename.endswith(type) ]
+                if not filename.startswith('.') and filename.endswith(type)]
 
     def changed_since(self, rev):
         """Return all pages that changed since specified repository revision."""
 
     def changed_since(self, rev):
         """Return all pages that changed since specified repository revision."""
@@ -428,6 +428,7 @@ class VersionedStorage(object):
             for page in self.all_pages():
                 yield page
                 return
             for page in self.all_pages():
                 yield page
                 return
+            return
         current = self.repo.lookup('tip')
         status = self.repo.status(current, last)
         modified, added, removed, deleted, unknown, ignored, clean = status
         current = self.repo.lookup('tip')
         status = self.repo.status(current, last)
         modified, added, removed, deleted, unknown, ignored, clean = status