Package plugins :: Package vfs :: Package vfsutils :: Module main
[hide private]
[frames] | no frames]

Source Code for Module plugins.vfs.vfsutils.main

 1  #-*- coding: utf8 -* 
 2  # 
 3  # Max E. Kuznecov <syhpoon@syhpoon.name> 2009 
 4  # 
 5   
 6  import os 
 7   
 8  import libxyz.ui as uilib 
 9   
10  from libxyz.core.utils import ustring 
11  from libxyz.core.plugins import BasePlugin 
12   
13 -class XYZPlugin(BasePlugin):
14 "Plugin vfsutils" 15 16 NAME = u"vfsutils" 17 AUTHOR = u"Max E. Kuznecov <syhpoon@syhpoon.name>" 18 VERSION = u"0.1" 19 BRIEF_DESCRIPTION = u"Useful VFS routines" 20 FULL_DESCRIPTION = u"" 21 NAMESPACE = u"vfs" 22 MIN_XYZ_VERSION = None 23 DOC = None 24 HOMEPAGE = "http://xyzcmd.syhpoon.name" 25
26 - def __init__(self, xyz):
27 super(XYZPlugin, self).__init__(xyz) 28 29 self._panel = None 30 31 self.export(self.mkdir)
32 33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 34
35 - def _load_panel(self):
36 """ 37 Load :sys:panel plugin 38 """ 39 40 if self._panel is None: 41 self._panel = self.xyz.pm.load(":sys:panel")
42 43 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 44
45 - def mkdir(self, newdir=None):
46 """ 47 Create new directory 48 """ 49 50 self._load_panel() 51 52 _box = uilib.InputBox(self.xyz, self.xyz.top, 53 _(u"New directory name"), 54 title=_(u"Create directory")) 55 56 _dir = _box.show() 57 58 if not _dir: 59 return 60 61 try: 62 os.mkdir(_dir) 63 except Exception, e: 64 xyzlog.error(_(u"Unable to create directory: %s") % 65 ustring(str(e))) 66 else: 67 self._panel.reload() 68 self._panel.select(_dir)
69 70 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 71
72 - def remove(self):
73 """ 74 Remove VFS object (if possible) 75 """ 76 77 pass
78