mirror of
git://projects.qi-hardware.com/openwrt-packages.git
synced 2024-11-22 06:03:08 +02:00
Create package for makfa, the Lojban dictionary.
{.i lo vi se finti ku vasru la makfa poi jbovlaste}
This commit is contained in:
parent
502d2f0497
commit
f4fa2d50aa
54
makfa/Makefile
Normal file
54
makfa/Makefile
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright (C) 2010 qi-hardware.com
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=makfa
|
||||
PKG_VERSION:=20091212
|
||||
PKG_REV:=e6c80dc33aa94358e767d34cbb5c1e003485db62
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git://github.com/lojban/makfa-cli
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/makfa
|
||||
SECTION:=education
|
||||
CATEGORY:=Education
|
||||
TITLE:=Lojban Dictionary
|
||||
URL:=http://gittub.com/lojban/makfa-cli
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
# Since the Ben NanoNote does not have internet access, build the dictionary
|
||||
# on the host machine and copy it into the package.
|
||||
#
|
||||
define Build/Compile
|
||||
$(PYTHON) $(PKG_BUILD_DIR)/makfa update en $(PKG_BUILD_DIR)/makfa.dump
|
||||
endef
|
||||
|
||||
define Package/makfa/install
|
||||
$(INSTALL_DIR) \
|
||||
$(1)/var/lib/$(PKG_NAME) \
|
||||
$(1)/usr/bin
|
||||
|
||||
$(INSTALL_BIN) \
|
||||
$(PKG_BUILD_DIR)/makfa \
|
||||
$(1)/usr/bin/
|
||||
|
||||
$(INSTALL_DATA) \
|
||||
$(PKG_BUILD_DIR)/makfa.dump \
|
||||
$(1)/var/lib/$(PKG_NAME)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,makfa))
|
63
makfa/patches/00-pickle.patch
Normal file
63
makfa/patches/00-pickle.patch
Normal file
@ -0,0 +1,63 @@
|
||||
diff --git a/makfa b/makfa
|
||||
index af7a8b7..488007e 100755
|
||||
--- a/makfa
|
||||
+++ b/makfa
|
||||
@@ -296,19 +296,16 @@ class Update(object):
|
||||
"""Update dictionary."""
|
||||
|
||||
def __init__(self):
|
||||
- self.parser = OptionParser(usage='makfa update [language]',
|
||||
+ self.parser = OptionParser(usage='makfa update [language] [filename]',
|
||||
description=self.__class__.__doc__)
|
||||
|
||||
def parse(self, argv):
|
||||
options, args = self.parser.parse_args(argv)
|
||||
print 'Updating dictionary...'
|
||||
- if args:
|
||||
- try:
|
||||
- Updater(args[0])
|
||||
- except SyntaxError:
|
||||
- print 'Invalid language code.'
|
||||
- else:
|
||||
- Updater()
|
||||
+ try:
|
||||
+ Updater(*args)
|
||||
+ except SyntaxError:
|
||||
+ print 'Invalid language code.'
|
||||
|
||||
|
||||
class Find(object):
|
||||
@@ -488,7 +485,7 @@ class Type(Command):
|
||||
|
||||
class Updater(object):
|
||||
|
||||
- def __init__(self, lang='en'):
|
||||
+ def __init__(self, lang='en', filename=os.path.expanduser('~/makfa.dump')):
|
||||
self.db = {'order': [], 'entries': {}}
|
||||
url = 'http://jbovlaste.lojban.org/export/xml-export.html?lang=%s'
|
||||
tree = etree.parse(urllib.urlopen(url % lang))
|
||||
@@ -506,7 +503,7 @@ class Updater(object):
|
||||
self.db['entries'][word]['places'][place] = []
|
||||
self.db['entries'][word]['places'][place]. \
|
||||
append((valsi.get('word'), sense))
|
||||
- pickle.dump(self.db, open(os.path.expanduser('~/.makfa.dump'), 'w'), -1)
|
||||
+ pickle.dump(self.db, open(filename, 'w'), -1)
|
||||
|
||||
def _save(self, valsi):
|
||||
word = valsi.get('word')
|
||||
@@ -618,12 +615,12 @@ class Filter(object):
|
||||
|
||||
class Dictionary(object):
|
||||
|
||||
- def __init__(self):
|
||||
+ def __init__(self, filename=os.path.expanduser('~/makfa.dump')):
|
||||
try:
|
||||
- self._db = pickle.load(open(os.path.expanduser('~/.makfa.dump')))
|
||||
+ self._db = pickle.load(open(filename))
|
||||
except:
|
||||
print >>sys.stderr, '(Fetching dictionary, this may take a minute.)'
|
||||
- self._db = Updater().db
|
||||
+ self._db = Updater(filename=filename).db
|
||||
self._longest = max(map(len, self))
|
||||
|
||||
def definition(self, entry):
|
22
makfa/patches/01-path.patch
Normal file
22
makfa/patches/01-path.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/makfa b/makfa
|
||||
index 488007e..a19a5c8 100755
|
||||
--- a/makfa
|
||||
+++ b/makfa
|
||||
@@ -485,7 +485,7 @@ class Type(Command):
|
||||
|
||||
class Updater(object):
|
||||
|
||||
- def __init__(self, lang='en', filename=os.path.expanduser('~/makfa.dump')):
|
||||
+ def __init__(self, lang='en', filename='/var/lib/makfa/makfa.dump'):
|
||||
self.db = {'order': [], 'entries': {}}
|
||||
url = 'http://jbovlaste.lojban.org/export/xml-export.html?lang=%s'
|
||||
tree = etree.parse(urllib.urlopen(url % lang))
|
||||
@@ -615,7 +615,7 @@ class Filter(object):
|
||||
|
||||
class Dictionary(object):
|
||||
|
||||
- def __init__(self, filename=os.path.expanduser('~/makfa.dump')):
|
||||
+ def __init__(self, filename='/var/lib/makfa/makfa.dump'):
|
||||
try:
|
||||
self._db = pickle.load(open(filename))
|
||||
except:
|
Loading…
Reference in New Issue
Block a user