Giter VIP home page Giter VIP logo

readmdict's Introduction

readmdict License: MITPyPI version

Read mdx/mdd files (repacking of readmdict from mdict-analysis)

This is a repacking of readmdict.py in https://github.com/csarron/mdict-analysis. All credit goes to the original author(s).

Prerequisite python-lzo

If python-lzo is not present, you' ll see "LZO compression support is not available" when running readmdict.

pip install python-lzo
# or poetry add python-lzo

In Windows without a functioning C++ environment, you won't be able to install python-lzo via pip. Head to https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-lzo. Download and install python-lzo whl for your python version.

Installation

pip install readmdict
# or poetry add readmdict

Usage

Command line

  • Browse a mdx or mdd file and print its meta information
readmdict

or

python -m readmdict
  • Print meta info of a file file.mdx
readmdict file.mdx

or

python -m readmdict file.mdx
  • Print a short summary
readmdict -h

or

python -m readmdict -h

In Python code

from readmdict import MDX, MDD

filename = "some.mdx"
headwords = [*MDX(filename).header]
print(headwords[:10])  # fisrt 10 in bytes format
for hdw in headwords[:10]:
	print(hdw.decode())   # fisrt 10 in string format

items = [*MDX(filename).items()]
for key, val in items[:10]:
	print(key.decode(), val.decode())  # first 10 entries

# read an mdd file
filename = "some.mdd"
items = MDD(filename).items()
idx = 0
for filename, content in items:
  idx += 1
  if idx > 10:
    break
	print(filename.decode(), content.decode())  # first 10 entries

readmdict's People

Contributors

ffreemt avatar paveloom avatar

Watchers

 avatar

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.