[gedit] The user snippet dir may not exist yet
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] The user snippet dir may not exist yet
- Date: Sat, 18 Jun 2011 10:44:50 +0000 (UTC)
commit 1ab52745d032e3e455b21380c43b88139ab71c43
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Jun 18 12:30:56 2011 +0200
The user snippet dir may not exist yet
Fixes bug #651938
plugins/snippets/snippets/importer.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/plugins/snippets/snippets/importer.py b/plugins/snippets/snippets/importer.py
index 1e267eb..8b63e48 100644
--- a/plugins/snippets/snippets/importer.py
+++ b/plugins/snippets/snippets/importer.py
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
+import errno
import tempfile
import sys
import shutil
@@ -39,7 +40,7 @@ class Importer:
filename = os.path.join(userdir, root + '_' + str(i) + ext)
i += 1
- return filename
+ return (userdir, filename)
def import_file(self, filename):
if not os.path.exists(filename):
@@ -49,7 +50,14 @@ class Importer:
return _('File "%s" is not a valid snippets file') % filename
# Find destination for file to copy to
- dest = self.import_destination(filename)
+ destdir, dest = self.import_destination(filename)
+
+ # Make sure dir exists
+ try:
+ os.makedirs(destdir)
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ raise
# Copy file
shutil.copy(filename, dest)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]