2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-05-03 09:17:29 +05:30
|
|
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2003-12-06 05:44:25 +05:30
|
|
|
# $Id$
|
|
|
|
|
2004-06-21 10:40:27 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2004-07-01 09:39:55 +05:30
|
|
|
import shutil
|
2004-06-21 10:40:27 +05:30
|
|
|
from gettext import gettext as _
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2004-05-08 10:18:59 +05:30
|
|
|
import gobject
|
2004-06-21 10:40:27 +05:30
|
|
|
import gnome
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import Utils
|
|
|
|
import const
|
|
|
|
import GrampsCfg
|
2004-05-08 10:18:59 +05:30
|
|
|
import QuestionDialog
|
2004-06-28 18:49:06 +05:30
|
|
|
import Plugins
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# DbPrompter
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DbPrompter:
|
|
|
|
"""Make sure a database is opened"""
|
|
|
|
|
2004-06-28 23:46:42 +05:30
|
|
|
def __init__(self,parent,want_new,parent_window=None):
|
2004-06-21 10:40:27 +05:30
|
|
|
self.parent = parent
|
2004-06-28 18:49:06 +05:30
|
|
|
self.parent_window = parent_window
|
2003-08-17 07:44:33 +05:30
|
|
|
opendb = gtk.glade.XML(const.gladeFile, "opendb","gramps")
|
2003-03-06 11:42:51 +05:30
|
|
|
top = opendb.get_widget('opendb')
|
2004-06-21 10:40:27 +05:30
|
|
|
if parent_window:
|
|
|
|
top.set_transient_for(parent_window)
|
2003-03-06 11:42:51 +05:30
|
|
|
title = opendb.get_widget('title')
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2003-03-06 11:42:51 +05:30
|
|
|
Utils.set_titles(top,title,_('Open a database'))
|
2004-05-05 09:24:02 +05:30
|
|
|
|
2004-05-08 10:18:59 +05:30
|
|
|
new = opendb.get_widget("new")
|
|
|
|
new.set_active(want_new)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-08 10:18:59 +05:30
|
|
|
while 1:
|
|
|
|
response = top.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
2004-06-28 23:46:42 +05:30
|
|
|
if new.get_active():
|
|
|
|
prompter = NewNativeDbPrompter(self.parent,self.parent_window)
|
|
|
|
else:
|
|
|
|
prompter = ExistingDbPrompter(self.parent,self.parent_window)
|
|
|
|
if prompter.chooser():
|
2004-05-08 10:18:59 +05:30
|
|
|
break
|
|
|
|
elif response == gtk.RESPONSE_CANCEL:
|
|
|
|
break
|
|
|
|
elif response == gtk.RESPONSE_HELP:
|
|
|
|
try:
|
|
|
|
gnome.help_display('gramps-manual','choose-db-start')
|
|
|
|
except gobject.GError,msg:
|
|
|
|
QuestionDialog.ErrorDialog(_('Help not available'),msg)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-08 10:18:59 +05:30
|
|
|
top.destroy()
|
|
|
|
if response == gtk.RESPONSE_CANCEL:
|
|
|
|
gtk.main_quit()
|
2003-12-06 05:44:25 +05:30
|
|
|
|
2004-06-28 23:46:42 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ExistingDbPrompter
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ExistingDbPrompter:
|
|
|
|
"""
|
|
|
|
This class allows to open an existing database.
|
|
|
|
|
|
|
|
Any data format is allowed. The available formats are obtained
|
|
|
|
from the plugins. If the selected format is non-native (non-grdb)
|
|
|
|
then the call is made to set up a new native grdb database.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,parent,parent_window=None):
|
|
|
|
self.parent = parent
|
|
|
|
self.parent_window = parent_window
|
|
|
|
|
|
|
|
def chooser(self):
|
|
|
|
"""
|
|
|
|
Select the new file.
|
|
|
|
Return 1 when selection is made and 0 otherwise.
|
|
|
|
"""
|
|
|
|
choose = gtk.FileChooserDialog(_('GRAMPS: Open database'),
|
2004-06-28 18:49:06 +05:30
|
|
|
self.parent_window,
|
2004-05-08 10:18:59 +05:30
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL,
|
|
|
|
gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN,
|
|
|
|
gtk.RESPONSE_OK))
|
2004-05-24 10:02:19 +05:30
|
|
|
choose.set_local_only(gtk.FALSE)
|
2004-06-28 18:49:06 +05:30
|
|
|
# Always add automatic (macth all files) filter
|
2004-05-03 09:17:29 +05:30
|
|
|
filter = gtk.FileFilter()
|
2004-06-28 18:49:06 +05:30
|
|
|
filter.set_name(_('Automatic'))
|
|
|
|
filter.add_pattern('*')
|
2004-05-03 09:17:29 +05:30
|
|
|
choose.add_filter(filter)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-28 18:49:06 +05:30
|
|
|
# Always add native format filter
|
2004-05-03 09:17:29 +05:30
|
|
|
filter = gtk.FileFilter()
|
2004-06-28 18:49:06 +05:30
|
|
|
filter.set_name(_('GRAMPS databases'))
|
|
|
|
filter.add_mime_type('application/x-gramps')
|
2004-05-03 09:17:29 +05:30
|
|
|
choose.add_filter(filter)
|
2004-06-28 18:49:06 +05:30
|
|
|
|
2004-06-28 23:46:42 +05:30
|
|
|
# Add more data type selections if opening existing db
|
|
|
|
for (importData,filter,mime_type) in Plugins._imports:
|
|
|
|
choose.add_filter(filter)
|
2004-06-28 18:49:06 +05:30
|
|
|
|
|
|
|
response = choose.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
filename = choose.get_filename()
|
2004-06-28 23:46:42 +05:30
|
|
|
filetype = gnome.vfs.get_mime_type(filename)
|
|
|
|
if filetype == 'application/x-gramps':
|
2004-06-28 18:49:06 +05:30
|
|
|
choose.destroy()
|
|
|
|
self.parent.read_file(filename)
|
|
|
|
return 1
|
2004-06-28 23:46:42 +05:30
|
|
|
(junk,the_file) = os.path.split(filename)
|
|
|
|
for (importData,filter,mime_type) in Plugins._imports:
|
|
|
|
if filetype == mime_type or the_file == mime_type:
|
2004-06-28 18:49:06 +05:30
|
|
|
choose.destroy()
|
2004-06-28 23:46:42 +05:30
|
|
|
QuestionDialog.OkDialog( _("Opening non-native format"),
|
2004-06-28 18:49:06 +05:30
|
|
|
_("New gramps database has to be set up "
|
|
|
|
"when opening non-native formats. The "
|
|
|
|
"following dialog will let you select "
|
|
|
|
"the new database."),
|
|
|
|
self.parent_window)
|
2004-06-28 23:46:42 +05:30
|
|
|
prompter = NewNativeDbPrompter(self.parent,self.parent_window)
|
|
|
|
if prompter.chooser():
|
2004-06-28 18:49:06 +05:30
|
|
|
importData(self.parent.db,filename)
|
|
|
|
self.parent.import_tool_callback()
|
|
|
|
return 1
|
2004-06-28 23:46:42 +05:30
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
QuestionDialog.ErrorDialog( _("Could not open file: %s") % filename,
|
|
|
|
_('The type "%s" is not in the list of known file types') % filetype )
|
|
|
|
return 0
|
|
|
|
|
|
|
|
else:
|
|
|
|
choose.destroy()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ImportDbPrompter
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ImportDbPrompter:
|
|
|
|
"""
|
|
|
|
This class allows to import a database. The data is imported into
|
|
|
|
the currently opened database, so we don't have to worry about
|
|
|
|
setting up the native database.
|
|
|
|
|
|
|
|
Any data format is allowed. The available formats are obtained
|
|
|
|
from the plugins.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,parent,parent_window=None):
|
|
|
|
self.parent = parent
|
|
|
|
self.parent_window = parent_window
|
|
|
|
|
|
|
|
def chooser(self):
|
|
|
|
"""
|
|
|
|
Select the new file.
|
|
|
|
Return 1 when selection is made and 0 otherwise.
|
|
|
|
"""
|
|
|
|
choose = gtk.FileChooserDialog(_('GRAMPS: Import database'),
|
|
|
|
self.parent_window,
|
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL,
|
|
|
|
gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN,
|
|
|
|
gtk.RESPONSE_OK))
|
|
|
|
choose.set_local_only(gtk.FALSE)
|
|
|
|
# Always add automatic (macth all files) filter
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name(_('Automatic'))
|
|
|
|
filter.add_pattern('*')
|
|
|
|
choose.add_filter(filter)
|
|
|
|
|
|
|
|
# FIXME: Uncomment when we have grdb importer
|
|
|
|
#
|
|
|
|
# # Always add native format filter
|
|
|
|
# filter = gtk.FileFilter()
|
|
|
|
# filter.set_name(_('GRAMPS databases'))
|
|
|
|
# filter.add_mime_type('application/x-gramps')
|
|
|
|
# choose.add_filter(filter)
|
|
|
|
|
|
|
|
# Add more data type selections if opening existing db
|
|
|
|
for (importData,filter,mime_type) in Plugins._imports:
|
|
|
|
choose.add_filter(filter)
|
|
|
|
|
|
|
|
response = choose.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
filename = choose.get_filename()
|
|
|
|
filetype = gnome.vfs.get_mime_type(filename)
|
|
|
|
# FIXME: Uncomment when we have grdb importer
|
|
|
|
#
|
|
|
|
# if filetype == 'application/x-gramps':
|
|
|
|
# choose.destroy()
|
|
|
|
# self.parent.read_file(filename)
|
|
|
|
# return 1
|
|
|
|
(junk,the_file) = os.path.split(filename)
|
|
|
|
for (importData,filter,mime_type) in Plugins._imports:
|
|
|
|
if filetype == mime_type or the_file == mime_type:
|
|
|
|
choose.destroy()
|
|
|
|
importData(self.parent.db,filename)
|
|
|
|
self.parent.import_tool_callback()
|
|
|
|
return 1
|
|
|
|
QuestionDialog.ErrorDialog( _("Could not open file: %s") % filename,
|
|
|
|
_('The type "%s" is not in the list of known file types') % filetype )
|
|
|
|
return 0
|
2004-06-28 18:49:06 +05:30
|
|
|
|
|
|
|
else:
|
|
|
|
choose.destroy()
|
|
|
|
return 0
|
|
|
|
|
2004-06-28 23:46:42 +05:30
|
|
|
|
2004-06-28 18:49:06 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# NewNativeDbPrompter
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class NewNativeDbPrompter:
|
2004-06-28 23:46:42 +05:30
|
|
|
"""
|
|
|
|
This class allows to set up a new empty native (grdb) database.
|
|
|
|
The filename is forced to have an '.grdb' extension. If not given,
|
|
|
|
it is appended.
|
|
|
|
"""
|
2004-06-28 18:49:06 +05:30
|
|
|
|
2004-06-28 23:46:42 +05:30
|
|
|
def __init__(self,parent,parent_window=None):
|
2004-06-28 18:49:06 +05:30
|
|
|
self.parent = parent
|
|
|
|
self.parent_window = parent_window
|
|
|
|
|
|
|
|
def chooser(self):
|
2004-06-28 23:46:42 +05:30
|
|
|
"""
|
|
|
|
Select the new file. Suggest the Untitled_X.grdb name.
|
|
|
|
Return 1 when selection is made and 0 otherwise.
|
|
|
|
"""
|
2004-06-28 18:49:06 +05:30
|
|
|
choose = gtk.FileChooserDialog(_('GRAMPS: Create GRAMPS database'),
|
|
|
|
self.parent_window,
|
|
|
|
gtk.FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
(gtk.STOCK_CANCEL,
|
|
|
|
gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN,
|
|
|
|
gtk.RESPONSE_OK))
|
|
|
|
self.parent.clear_database()
|
|
|
|
|
|
|
|
# Always add automatic (macth all files) filter
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name(_('Automatic'))
|
|
|
|
filter.add_pattern('*')
|
|
|
|
choose.add_filter(filter)
|
|
|
|
|
|
|
|
# Always add native format filter
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name(_('GRAMPS databases'))
|
|
|
|
filter.add_mime_type('application/x-gramps')
|
|
|
|
choose.add_filter(filter)
|
|
|
|
|
2004-07-03 10:16:51 +05:30
|
|
|
new_filename = get_new_filename('grdb')
|
2004-06-28 23:46:42 +05:30
|
|
|
|
|
|
|
choose.set_filename(new_filename)
|
|
|
|
choose.set_current_name(os.path.split(new_filename)[1])
|
2004-05-08 10:18:59 +05:30
|
|
|
|
2004-05-03 09:17:29 +05:30
|
|
|
response = choose.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
filename = choose.get_filename()
|
2004-06-28 18:49:06 +05:30
|
|
|
if os.path.splitext(filename)[1] != ".grdb":
|
2004-05-10 08:43:43 +05:30
|
|
|
filename = filename + ".grdb"
|
2004-05-08 10:18:59 +05:30
|
|
|
choose.destroy()
|
2004-06-21 10:40:27 +05:30
|
|
|
self.parent.read_file(filename)
|
2004-05-08 10:18:59 +05:30
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
choose.destroy()
|
|
|
|
return 0
|
2004-06-28 23:46:42 +05:30
|
|
|
|
2004-07-01 09:39:55 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SaveAsDbPrompter
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SaveAsDbPrompter:
|
|
|
|
"""
|
|
|
|
This class allows to save (export) an existing database.
|
|
|
|
|
|
|
|
Any data format is allowed. The available formats are obtained
|
|
|
|
from the plugins. If the selected format is non-native (non-grdb)
|
|
|
|
then corresponding export routine is called. Native save as just
|
|
|
|
copies file to another name.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,parent,parent_window=None):
|
|
|
|
self.parent = parent
|
|
|
|
self.parent_window = parent_window
|
|
|
|
|
|
|
|
def chooser(self):
|
|
|
|
"""
|
|
|
|
Select the new file.
|
|
|
|
Return 1 when selection is made and 0 otherwise.
|
|
|
|
"""
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose = gtk.FileChooserDialog(_('GRAMPS: Export database'),
|
2004-07-01 09:39:55 +05:30
|
|
|
self.parent_window,
|
|
|
|
gtk.FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
(gtk.STOCK_CANCEL,
|
|
|
|
gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN,
|
|
|
|
gtk.RESPONSE_OK))
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose.set_local_only(gtk.FALSE)
|
2004-07-01 09:39:55 +05:30
|
|
|
# Always add automatic (macth all files) filter
|
2004-07-03 10:16:51 +05:30
|
|
|
all_filter = gtk.FileFilter()
|
|
|
|
all_filter.set_name(_('By extension'))
|
|
|
|
all_filter.add_pattern('*')
|
|
|
|
self.choose.add_filter(all_filter)
|
2004-07-01 09:39:55 +05:30
|
|
|
|
|
|
|
# Always add native format filter
|
2004-07-03 10:16:51 +05:30
|
|
|
native_filter = gtk.FileFilter()
|
|
|
|
native_filter.set_name(_('GRAMPS databases'))
|
|
|
|
native_filter.add_mime_type('application/x-gramps')
|
|
|
|
self.choose.add_filter(native_filter)
|
2004-07-02 21:03:16 +05:30
|
|
|
|
2004-07-03 10:16:51 +05:30
|
|
|
chooser_default = self.choose.get_children()[0].get_children()[0].get_children()[0]
|
|
|
|
chooser_default.connect('notify::filter',self.change_suggested_name)
|
2004-07-01 09:39:55 +05:30
|
|
|
|
2004-07-03 10:16:51 +05:30
|
|
|
# Add more data type selections from export plugins
|
2004-07-01 09:39:55 +05:30
|
|
|
for (exportData,filter,pattern_list) in Plugins._exports:
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose.add_filter(filter)
|
2004-07-01 09:39:55 +05:30
|
|
|
|
2004-07-03 10:16:51 +05:30
|
|
|
new_filename = get_new_filename('grdb')
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose.set_filename(new_filename)
|
|
|
|
self.choose.set_current_name(os.path.split(new_filename)[1])
|
2004-07-01 09:39:55 +05:30
|
|
|
|
2004-07-02 21:03:16 +05:30
|
|
|
response = self.choose.run()
|
2004-07-01 09:39:55 +05:30
|
|
|
if response == gtk.RESPONSE_OK:
|
2004-07-02 21:03:16 +05:30
|
|
|
filename = self.choose.get_filename()
|
2004-07-01 09:39:55 +05:30
|
|
|
filename = os.path.normpath(os.path.abspath(filename))
|
|
|
|
(junk,the_file) = os.path.split(filename)
|
|
|
|
the_ext = os.path.splitext(filename)[1]
|
2004-07-03 10:16:51 +05:30
|
|
|
the_filter = self.choose.get_filter()
|
2004-07-01 09:39:55 +05:30
|
|
|
|
2004-07-03 10:16:51 +05:30
|
|
|
# Save as grdb if either explictly selected by the filter
|
|
|
|
# or the filter is ALL and the extension is grdb
|
|
|
|
if the_filter.get_name() == native_filter.get_name() \
|
|
|
|
or (the_filter.get_name() == all_filter.get_name()
|
|
|
|
and the_ext in ('.grdb', '.GRDB')):
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose.destroy()
|
2004-07-01 09:39:55 +05:30
|
|
|
try:
|
|
|
|
shutil.copyfile(self.parent.db.get_save_path(),filename)
|
|
|
|
return 1
|
2004-07-02 21:03:16 +05:30
|
|
|
except IOError, msg:
|
2004-07-01 09:39:55 +05:30
|
|
|
QuestionDialog.ErrorDialog( _("Could not write file: %s") % filename,
|
|
|
|
_('System message was: %s') % msg )
|
|
|
|
return 0
|
|
|
|
|
|
|
|
for (exportData,filter,pattern_list) in Plugins._exports:
|
2004-07-03 10:16:51 +05:30
|
|
|
# Save as this type if either explictly selected by the filter
|
|
|
|
# or the filter is ALL and the extension is in this type's list
|
|
|
|
if the_filter.get_name() == filter.get_name() \
|
|
|
|
or (the_filter.get_name() == all_filter.get_name()
|
|
|
|
and the_ext in pattern_list):
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose.destroy()
|
2004-07-01 09:39:55 +05:30
|
|
|
exportData(self.parent.db,filename)
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
QuestionDialog.ErrorDialog( _("Could not write file: %s") % filename,
|
|
|
|
_('The type is not in the list of known file types') )
|
|
|
|
return 0
|
|
|
|
else:
|
2004-07-02 21:03:16 +05:30
|
|
|
self.choose.destroy()
|
2004-07-01 09:39:55 +05:30
|
|
|
return 0
|
2004-07-02 21:03:16 +05:30
|
|
|
|
|
|
|
def change_suggested_name(self,*args):
|
|
|
|
"""
|
|
|
|
This is the callback of the filter change handler. The suggested
|
|
|
|
file name is set according to the selected filter.
|
|
|
|
"""
|
|
|
|
the_filter = self.choose.get_filter()
|
|
|
|
if the_filter.get_name().find('XML') + 1:
|
2004-07-03 10:16:51 +05:30
|
|
|
new_filename = 'data.gramps'
|
|
|
|
elif the_filter.get_name() == _('GRAMPS packages'):
|
|
|
|
new_filename = get_new_filename('gpkg')
|
|
|
|
new_filename = os.path.split(new_filename)[1]
|
2004-07-02 21:03:16 +05:30
|
|
|
else:
|
2004-07-03 10:16:51 +05:30
|
|
|
new_filename = get_new_filename('grdb')
|
|
|
|
new_filename = os.path.split(new_filename)[1]
|
|
|
|
self.choose.set_current_name()
|
2004-07-02 21:03:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-03 10:16:51 +05:30
|
|
|
_NEW_NAME_PATTERN = '~/Untitled_%d.%s'
|
|
|
|
|
|
|
|
def get_new_filename(ext):
|
2004-07-02 21:03:16 +05:30
|
|
|
ix = 1
|
2004-07-03 10:16:51 +05:30
|
|
|
while os.path.isfile(os.path.expanduser(_NEW_NAME_PATTERN % (ix,ext) )):
|
2004-07-02 21:03:16 +05:30
|
|
|
ix = ix + 1
|
2004-07-03 10:16:51 +05:30
|
|
|
return os.path.expanduser(_NEW_NAME_PATTERN % (ix,ext))
|