Giter Site home page Giter Site logo

gryf / mc_extfslib Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 34 KB

Midnight Commander extfs for several filetypes using Python

Home Page: https://bitbucket.org/gryf/mc_extfs

License: Other

Python 100.00%
mc midnight-commander fs-plugin adf dms lha lzx amiga python

mc_extfslib's Introduction

Midnight Commander extfslib

Midnight Commander extfslib helper library for writing extfs archive plugins.

Description

Extfslib help with building Midnight Commander extfs plugins, especially for those which operates on different kind of archives.

Simplest plugin built on top of this lib would be:

import extfslib


class MyArchive(extfslib.Archive):

    ARCHIVER = "fancyarch"

    def list(self):
        if not self._contents:
            return 1

        for item in self._contents:
            sys.stdout.buffer.write(self.ITEM % item)


arch = MyArchive('/path/to/file.fancyarch')
arch.list()

In this example class instance should be able to be called with list method. All methods:

  • list
  • copyin
  • copyout
  • rm
  • mkdir
  • rmdir
  • run

should be implemented if needed, since by default all of them are just defined, but not implemented.

Of course, real life example can be a little bit more complicated, since there would be possible need for adapting LINE_PAT which is regular expression for getting attributes for the list compatible with MC along with the ITEM which holds the output pattern and utilizes dictionary from LINE_PAT, CMD which maps between class and archiver commands. Possibly there might be needed some other adjustments.

Additionally there is an optional Config class, which might be used for reading Midnight Commander ini file (ususally located in ~/.config/mc/ini), so that for the example above:

import extfslib


class MyArchive(extfslib.Archive):

    ARCHIVER = "fancyarch"

    def __init__(self):
        super().__init__()
        self.conf = extfslib.Config(self)
        if self.conf,getint('config_key'):
            # do something

where the ini config file would contain:

[myarchive]
config_key = 300
…

So, section name [myarchive] must match class name in lower case, and name of the option is arbitrary string folowed by value. Note, the section and options must be added manually.

Installation

Install from Pypi

# pip install extfslib

or, as a user:

$ pip install extfslib --user

or use virtualenv:

$ git clone https://github.com/gryf/mc_extfslib
$ cd mc_extfslib
$ virtualenv venv
$ source venv/bin/activate
(venv) $ pip install

License

This software is licensed under 3-clause BSD license. See LICENSE file for details.

mc_extfslib's People

Contributors

gryf avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jeffv03

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.