Trees | Indices | Help |
|
---|
|
1 #-*- coding: utf8 -* 2 # 3 # Max E. Kuznecov <syhpoon@syhpoon.name> 2009 4 # 5 # This file is part of XYZCommander. 6 # XYZCommander is free software: you can redistribute it and/or modify 7 # it under the terms of the GNU Lesser Public License as published by 8 # the Free Software Foundation, either version 3 of the License, or 9 # (at your option) any later version. 10 # XYZCommander is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Lesser Public License for more details. 14 # You should have received a copy of the GNU Lesser Public License 15 # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>. 16 17 import re 18 import subprocess 19 20 from libxyz.core import FSRule 21 from libxyz.core.plugins import BasePlugin 2224 "Magic database FSRule" 25 26 NAME = u"magic" 27 AUTHOR = u"Max E. Kuznecov <syhpoon@syhpoon.name>" 28 VERSION = u"0.1" 29 BRIEF_DESCRIPTION = u"Magic database FSRule" 30 FULL_DESCRIPTION = _(u"Plugin extends FSRule functionality to match "\ 31 u"objects based on magic database description") 32 NAMESPACE = u"fsrules" 33 MIN_XYZ_VERSION = None 34 DOC = None 35 HOMEPAGE = "http://xyzcmd.syhpoon.name" 36 39 40 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 44 45 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 49 50 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 517753 """ 54 Transformation function for magic FSRule 55 """ 56 57 # Treat input argument as a regular expression to match on 58 #`file` output 59 60 return re.compile(arg, re.I)61 62 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 """ 66 Match function for magic 67 """ 68 69 try: 70 result = subprocess.Popen([ 71 "/usr/bin/env", "file", "-b", 72 vfsobj.path], stdout=subprocess.PIPE).communicate()[0].strip() 73 74 return arg.search(result) is not None 75 except Exception: 76 return False
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu May 6 20:50:56 2010 | http://epydoc.sourceforge.net |