summary refs log tree commit diff stats
path: root/examples/plugin_avfs.py
blob: 07968a0353826bcb147164615f7c09670333b18d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Tested with ranger 1.9.1
#
# A very simple and possibly buggy support for AVFS
# (http://avf.sourceforge.net/), that allows ranger to handle
# archives.
#
# Run `:avfs' to browse the selected archive.

from __future__ import (absolute_import, division, print_function)

import os
import os.path

from ranger.api.commands import Command


class avfs(Command):  # pylint: disable=invalid-name
    avfs_root = os.path.join(os.environ["HOME"], ".avfs")
    avfs_suffix = "#"

    def execute(self):
        if os.path.isdir(self.avfs_root):
            archive_directory = "".join([
                self.avfs_root,
                self.fm.thisfile.path,
                self.avfs_suffix,
            ])
            if os.path.isdir(archive_directory):
                self.fm.cd(archive_directory)
            else:
                self.fm.notify("This file cannot be handled by avfs.", bad=True)
        else:
            self.fm.notify("Install `avfs' and run `mountavfs' first.", bad=True)
ight">
parse/0: instruction: 1
parse/0:   ingredient: {name: "34", type: 0}
parse/0:   product: {name: "1", type: 1}
parse/0: instruction: 1
parse/0:   ingredient: {name: "35", type: 0}
parse/0:   product: {name: "2", type: 1}
parse/0: instruction: 16
parse/0:   ingredient: {name: "1", type: 1}
parse/0:   ingredient: {name: "2", type: 1}
parse/0:   product: {name: "3", type: 1}
run/0: instruction main/0
run/0: ingredient 0 is 34
mem/0: storing in location 1
run/0: instruction main/1
run/0: ingredient 0 is 35
mem/0: storing in location 2
run/0: instruction main/2
run/0: ingredient 0 is 1
mem/0: location 1 is 34
run/0: ingredient 1 is 2
mem/0: location 2 is 35
run/0: product 0 is 0
mem/0: storing in location 3