Anonymous avatar Anonymous committed 958858c

Only compressing history and objectdb if gzip is available

Comments (0)

Files changed (2)

rope/base/history.py

             self.max_undos = maxundos
         self.compress = project.get_prefs().get('compress_history', False)
         if self.compress:
-            import gzip
-            self.opener = gzip.open
-        else:
+            try:
+                import gzip
+                self.opener = gzip.open
+            except ImportError:
+                self.compress = False
+        if not self.compress:
             self.opener = open
         self._load_history()
         self.current_change = None
                 self._import_old_files()
             if not self.history_file.exists():
                 return
-            input_file = self.opener(self.history_file.real_path)
+            input_file = self.opener(self.history_file.real_path, 'rb')
             to_change = change.DataToChange(self.history_file.project)
             for data in pickle.load(input_file):
                 self._undo_list.append(to_change(data))
     def sync(self):
         if self.history_file is not None:
             self._remove_extra_items()
-            output_file = self.opener(self.history_file.real_path, 'w')
+            output_file = self.opener(self.history_file.real_path, 'wb')
             to_data = change.ChangeToData()
             pickle.dump([to_data(change_) for change_ in self.undo_list],
                         output_file, 2)

rope/base/oi/memorydb.py

         self.files = self
         self.compress = project.prefs.get('compress_objectdb', False)
         if self.compress:
-            import gzip
-            self.opener = gzip.open
-        else:
+            try:
+                import gzip
+                self.opener = gzip.open
+            except ImportError:
+                self.compress = False
+        if not self.compress:
             self.opener = open
         self._load_files()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.