Пример #1
0
    def test_by_name(self):
        dot_c = Mime.get_type_by_name('foo.c')
        self.check_mimetype(dot_c, 'text', 'x-csrc')
        dot_C = Mime.get_type_by_name('foo.C')
        self.check_mimetype(dot_C, 'text', 'x-c++src')

        # But most names should be case insensitive
        dot_GIF = Mime.get_type_by_name('IMAGE.GIF')
        self.check_mimetype(dot_GIF, 'image', 'gif')
Пример #2
0
 def test_by_name(self):
     dot_c = Mime.get_type_by_name('foo.c')
     self.check_mimetype(dot_c, 'text', 'x-csrc')
     dot_C = Mime.get_type_by_name('foo.C')
     self.check_mimetype(dot_C, 'text', 'x-c++src')
     
     # But most names should be case insensitive
     dot_GIF = Mime.get_type_by_name('IMAGE.GIF')
     self.check_mimetype(dot_GIF, 'image', 'gif')
Пример #3
0
 def _filltree(self, root=''):
     self._pending_filltree = None
     self.treeView.heading('#0', text=os.path.basename(self.currentPath))
     while len(self.treeView.get_children(root)):
         self.treeView.delete(self.treeView.get_children(root)[0])
     if not root:
         image = self.module._get_icon_for_mime(("folder",))
         self.insert_child(self.currentPath, '..', image)
     for current, dirs, files in os.walk(os.path.join(self.currentPath, root)):
         for dir_ in sorted(dirs):
             if not self.module.apply_exclude(dir_):
                 continue
             image = self.module._get_icon_for_mime(("folder",))
             self.insert_child(current,  dir_, image)
             self.insert_child(os.path.join(current, dir_), '.', image=None)
         dirs[:] = []
         for file_ in sorted(files):
             if not self.module.apply_exclude(file_):
                 continue
             image = None
             if hasImageSupport:
                 fullPath = os.path.join(current, file_)
                 mime = str(Mime.get_type_by_name(fullPath)).split('/')
                 image = self.module._get_icon_for_mime(mime)
             self.insert_child(current, file_, image)
Пример #4
0
 def test_get_type_by_name(self):
     appzip = Mime.get_type_by_name("foo.zip")
     self.check_mimetype(appzip, 'application', 'zip')
Пример #5
0
 def test_get_type_by_name(self):
     appzip = Mime.get_type_by_name("foo.zip")
     self.check_mimetype(appzip, 'application', 'zip')
Пример #6
0
 def test_by_name(self):
     dot_c = Mime.get_type_by_name('foo.c')
     self.check_mimetype(dot_c, 'text', 'x-csrc')
     dot_C = Mime.get_type_by_name('foo.C')
     self.check_mimetype(dot_C, 'text', 'x-c++src')
Пример #7
0
from xdg import Mime

print(Mime.get_type_by_name("foo.zip"))