OSDN Git Service

Prepare for Release of 4.3.6
authorShyouzou Sugitani <shy@users.sourceforge.jp>
Sat, 10 Dec 2011 13:43:01 +0000 (22:43 +0900)
committerShyouzou Sugitani <shy@users.sourceforge.jp>
Sat, 10 Dec 2011 13:43:01 +0000 (22:43 +0900)
ChangeLog
lib/ninix/install.py
lib/ninix/sakura.py
lib/ninix/version.py
setup.py

index 06322e1..1561dc3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,23 @@
+Sat December 10 2011   Shyouzou Sugitani <shy@users.sourceforge.jp>
+       * バージョン4.3.6リリース.
+       * install.pyに残っていたninix-installコマンドのためのコードを削除した.
+       * Sakuraクラスのifghostメソッドが落ちる問題(typo)を修正した.
+       * Installerを日本語(cp932)のファイル名を含むZIPアーカイブに対応させた.
+         (文字コードを決め打ちしているので他の言語には非対応.)
+
 Wed December 7 2011   Shyouzou Sugitani <shy@users.sourceforge.jp>
        * コメントの単位は[]で括るようにした.
-       * satori.pyが落ちる問題を修正した. 
+       * satori.pyが落ちる問題を修正した.
          (Unicodeに変換した文字列とShift_JISのままの文字列を連結しようとして
           落ちていた.)
          この修正でゴースト「マイマイトーカ」が起動するようになった.
-       * ã\83\90ã\83«ã\83¼ã\83³ã\81®ã\83\87ã\83¼ã\82¿èª­ã\81¿è¾¼ã\81¿ã\82\92ã\82´ã\83¼ã\82¹ã\83\88å\90\8cæ§\98ã\81«æ\8c\87å®\9aã\81\97ã\81\9fã\83\87ã\82£ã\83¬ã\82¯ã\83\88ã\83ªã\81«
-         対してのみ行なえるようにした.(バルーンがインストールされた際に
-         その情報のみを読み込むため.)
+       * ã\82´ã\83¼ã\82¹ã\83\88ã\81¨å\90\8cæ§\98ã\81«ã\83\90ã\83«ã\83¼ã\83³ã\81«ã\81¤ã\81\84ã\81¦ã\82\82ã\83\87ã\83¼ã\82¿èª­ã\81¿è¾¼ã\81¿ã\82\92æ\8c\87å®\9aã\81\97ã\81\9f
+         ディレクトリに対してのみ行なえるようにした.
+         (バルーンがインストールされた際にその情報のみを読み込むため.)
        * HolonとMemeクラスをlib/ninix/metamagic.pyファイルに分離した.
          それぞれを抽象ベースクラス(ABC)とし, Holonを継承してGhostクラスを
          Memeを継承してShellMemeとBalloonMemeクラスを作成した.
-         (MemeとHolonの間の継承関係は今回は敢えて作らなかった.)
+         (MemeとHolonの間の継承関係は敢えて作らなかった.)
        * シェルとバルーンの管理にMemeクラスを使用するようにした.
        * バルーンのメニューの項目をgtk.RadioMenuItemからシェルと同じ
          gtk.MenuItemに変更した.
index ef7130c..8540ab8 100644 (file)
@@ -24,19 +24,12 @@ import tempfile
 import urllib
 import zipfile
 
-try:
-    import gtk
-except:
-    gtk = None
+import gtk
 
 import ninix.home
 import ninix.version
 
 
-# mode masks ## FIXME
-INTERACTIVE = 1
-DOWNLOAD    = 2
-
 class URLopener(urllib.FancyURLopener):
     version = 'ninix-aya/{0}'.format(ninix.version.VERSION)
 
@@ -54,40 +47,34 @@ def fatal(error):
 
 class Installer(object):
 
-    def __init__(self, mode=INTERACTIVE|DOWNLOAD, gui=1):
+    def __init__(self):
         self.fs_encoding = 'mbcs' if os.name == 'nt' else 'utf-8'
-        self.mode = mode
-        if gui and gtk is not None:
-            self.dialog = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION,
-                                            buttons=gtk.BUTTONS_YES_NO)
-            self.select_dialog = gtk.Dialog(
-                buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
-                         gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
-            ls = gtk.ListStore(int, str)
-            tv = gtk.TreeView(model=ls)
-            tv.set_rules_hint(True)
-            renderer = gtk.CellRendererText()
-            col0 = gtk.TreeViewColumn('No.',renderer,text=0)
-            col1 = gtk.TreeViewColumn('Path',renderer,text=1)
-            tv.append_column(col0)
-            tv.append_column(col1)
-            sw = gtk.ScrolledWindow()
-            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-            sw.add(tv)
-            sw.show_all() # XXX
-            self.treeview = tv
-            label = gtk.Label(
-                'Multiple candidates found.\n'
-                'Select the path name of the supplement target.') ## FIXME
-            ##label.set_use_markup(True)
-            self.select_dialog.vbox.pack_start(label)
-            label.show()
-            self.select_dialog.vbox.pack_start(sw) # XXX
-            self.select_dialog.set_title('Select the target') ## FIXME
-        else:
-            self.dialog = None
-            self.select_dialog = None
-            self.treeview = None
+        self.dialog = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION,
+                                        buttons=gtk.BUTTONS_YES_NO)
+        self.select_dialog = gtk.Dialog(
+            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+                     gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+        ls = gtk.ListStore(int, str)
+        tv = gtk.TreeView(model=ls)
+        tv.set_rules_hint(True)
+        renderer = gtk.CellRendererText()
+        col0 = gtk.TreeViewColumn('No.',renderer,text=0)
+        col1 = gtk.TreeViewColumn('Path',renderer,text=1)
+        tv.append_column(col0)
+        tv.append_column(col1)
+        sw = gtk.ScrolledWindow()
+        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        sw.add(tv)
+        sw.show_all() # XXX
+        self.treeview = tv
+        label = gtk.Label(
+            'Multiple candidates found.\n'
+            'Select the path name of the supplement target.') ## FIXME
+        ##label.set_use_markup(True)
+        self.select_dialog.vbox.pack_start(label)
+        label.show()
+        self.select_dialog.vbox.pack_start(sw) # XXX
+        self.select_dialog.set_title('Select the target') ## FIXME
 
     def check_archive(self, filename):
         # check archive format
@@ -113,15 +100,20 @@ class Installer(object):
             if filename is None:
                 shutil.rmtree(tmpdir)
                 fatal('cannot download the archive file')
-        zf = zipfile.ZipFile(filename)
         try:
-            zf.extractall(tmpdir)
-            zf.close()
+            with zipfile.ZipFile(filename) as zf:
+                for name in zf.namelist():
+                    uname = name.decode('cp932') # XXX
+                    buf = zf.read(name)
+                    path = os.path.join(tmpdir, uname.encode(self.fs_encoding))
+                    dname, fname = os.path.split(path)
+                    if not os.path.exists(dname):
+                        os.makedirs(dname)
+                    with open(path, 'wb') as of:
+                        of.write(buf)
         except:
             shutil.rmtree(tmpdir)
             fatal('cannot extract files from the archive')
-        if url and not self.mode & DOWNLOAD: ## FIXME
-            os.remove(filename)
         for (dirpath, dirnames, filenames) in os.walk(tmpdir):
             for name in dirnames:
                 path = os.path.join(dirpath, name)
@@ -195,9 +187,6 @@ class Installer(object):
         #    logging.debug(
         #        '(size = {0} bytes)'.format(headers.get('content-length')))
         arcdir = ninix.home.get_archive_dir()
-        if self.mode & DOWNLOAD: ## FIXME
-            if not os.path.exists(arcdir):
-                os.makedirs(arcdir)
         if not os.path.exists(arcdir):
             os.makedirs(arcdir)
         basedir = arcdir
@@ -282,24 +271,10 @@ class Installer(object):
         return n
 
     def confirm(self, message):
-        if self.dialog is not None:
-            self.dialog.set_markup(message)
-            response = self.dialog.run()
-            self.dialog.hide()
-            return response == gtk.RESPONSE_YES
-        else:
-            if not self.mode & INTERACTIVE:
-                return True
-            print ''.join(('Ninix Install:', message, '(yes/no)'))
-            try:
-                answer = raw_input()
-            except EOFError:
-                answer = None
-            except KeyboardInterrupt:
-                raise SystemExit
-            if not answer:
-                return False
-            return answer.lower().startswith('y')
+        self.dialog.set_markup(message)
+        response = self.dialog.run()
+        self.dialog.hide()
+        return response == gtk.RESPONSE_YES
 
     def confirm_overwrite(self, path, type_string):
         if os.name == 'nt':
@@ -315,38 +290,18 @@ class Installer(object):
         assert len(candidates) >= 1
         if len(candidates) == 1:
             return candidates[0]
-        if self.select_dialog is not None:
-            ls = self.treeview.get_model()
-            ls.clear()
-            for i, item in enumerate(candidates):
-                ls.append((i, item))
-            ts = self.treeview.get_selection()
-            ts.select_iter(ls.get_iter_first())
-            response = self.select_dialog.run()
-            self.select_dialog.hide()
-            if response != gtk.RESPONSE_ACCEPT:
-                return None
-            model, it = ts.get_selected()
-            return model.get_value(it, 1)
-        else:
-            print 'multiple candidates found'
-            for i, candidate in enumerate(candidates):
-                print '    ', i, candidate
-            if not self.mode & INTERACTIVE: ## FIXME
-                raise SystemExit
-            print 'Input target number:'
-            try:
-                answer = raw_input()
-            except EOFError:
-                answer = None
-            except KeyboardInterrupt:
-                raise SystemExit
-            try:
-                num = int(answer)
-                assert num < len(candidates)
-            except:
-                raise SystemExit
-            return candidate[num]
+        ls = self.treeview.get_model()
+        ls.clear()
+        for i, item in enumerate(candidates):
+            ls.append((i, item))
+        ts = self.treeview.get_selection()
+        ts.select_iter(ls.get_iter_first())
+        response = self.select_dialog.run()
+        self.select_dialog.hide()
+        if response != gtk.RESPONSE_ACCEPT:
+            return None
+        model, it = ts.get_selected()
+        return model.get_value(it, 1)
 
     def install_ghost(self, archive, tmpdir, homedir):
         # find install.txt
@@ -408,8 +363,6 @@ class Installer(object):
                 self.install_files(balloon_list)
         if os.path.exists(prefix):
             inst_dst = ninix.home.read_install_txt(prefix)
-            if not inst_dst or inst_dst.get('name') != inst.get('name'):
-                self.mode |= INTERACTIVE ## FIXME
             if inst.get_with_type('refresh', int, 0):
                 # uninstall older versions of the ghost
                 if self.confirm_removal(prefix, 'ghost'):
@@ -495,8 +448,6 @@ class Installer(object):
         ##                 os.path.join(dstdir, 'install.txt')))
         if os.path.exists(dstdir):
             inst_dst = ninix.home.read_install_txt(dstdir)
-            if not inst_dst or inst_dst.get('name') != inst.get('name'):
-                self.mode |= INTERACTIVE
             if inst.get_with_type('refresh', int, 0):
                 # uninstall older versions of the balloon
                 if self.confirm_removal(dstdir, 'balloon'):
index 296612f..3a59140 100644 (file)
@@ -499,7 +499,7 @@ class Sakura(object):
     def ifghost(self, ifghost):
         names = self.get_ifghost()
         name = '{0}'.format(self.get_selfname())
-        return bool(if_ghost in [name, names])
+        return bool(ifghost in [name, names])
 
     def get_name(self, default=unicode(_('Sakura&Unyuu'), 'utf-8')):
         return self.desc.get('name', default)
index 396c0c2..dc6c460 100644 (file)
@@ -10,7 +10,7 @@
 #  PURPOSE.  See the GNU General Public License for more details.
 #
 
-NUMBER = '4.3.5'
+NUMBER = '4.3.6'
 CODENAME = 'juggling eggs'
 
 VERSION = '{0} ({1})'.format(NUMBER, CODENAME)
index 46d6a2f..472a977 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ for lang in langs:
 
 setup(
     name = 'ninix-aya',
-    version = '4.3.5',
+    version = '4.3.6',
     package_dir = {'': 'lib'},
     packages=['ninix', 'ninix.dll'],
     scripts = ['lib/ninix_main.py', 'ninix_win32_postinst.py'],