OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Commit Details
| Date: | 2010-09-10 18:04:22 (2 years 8 months ago) |
|---|---|
| Author: | Alan Post |
| Commit: | f4fa2d50aaba9aed1fa0936052bb59d293f6ec0d |
| Message: | Create package for makfa, the Lojban dictionary. {.i lo vi se finti ku vasru la makfa poi jbovlaste} |
| Files: |
makfa/Makefile (1 diff) makfa/patches/00-pickle.patch (1 diff) makfa/patches/01-path.patch (1 diff) |
Change Details
| makfa/Makefile | ||
|---|---|---|
| 1 | # | |
| 2 | # Copyright (C) 2010 qi-hardware.com | |
| 3 | # | |
| 4 | # This is free software, licensed under the GNU General Public License v2. | |
| 5 | # See /LICENSE for more information. | |
| 6 | # | |
| 7 | ||
| 8 | include $(TOPDIR)/rules.mk | |
| 9 | ||
| 10 | PKG_NAME:=makfa | |
| 11 | PKG_VERSION:=20091212 | |
| 12 | PKG_REV:=e6c80dc33aa94358e767d34cbb5c1e003485db62 | |
| 13 | PKG_RELEASE:=1 | |
| 14 | ||
| 15 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |
| 16 | PKG_SOURCE_URL:=git://github.com/lojban/makfa-cli | |
| 17 | PKG_SOURCE_PROTO:=git | |
| 18 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) | |
| 19 | PKG_SOURCE_VERSION:=$(PKG_REV) | |
| 20 | ||
| 21 | include $(INCLUDE_DIR)/package.mk | |
| 22 | ||
| 23 | define Package/makfa | |
| 24 | SECTION:=education | |
| 25 | CATEGORY:=Education | |
| 26 | TITLE:=Lojban Dictionary | |
| 27 | URL:=http://gittub.com/lojban/makfa-cli | |
| 28 | endef | |
| 29 | ||
| 30 | define Build/Configure | |
| 31 | endef | |
| 32 | ||
| 33 | # Since the Ben NanoNote does not have internet access, build the dictionary | |
| 34 | # on the host machine and copy it into the package. | |
| 35 | # | |
| 36 | define Build/Compile | |
| 37 | $(PYTHON) $(PKG_BUILD_DIR)/makfa update en $(PKG_BUILD_DIR)/makfa.dump | |
| 38 | endef | |
| 39 | ||
| 40 | define Package/makfa/install | |
| 41 | $(INSTALL_DIR) \ | |
| 42 | $(1)/var/lib/$(PKG_NAME) \ | |
| 43 | $(1)/usr/bin | |
| 44 | ||
| 45 | $(INSTALL_BIN) \ | |
| 46 | $(PKG_BUILD_DIR)/makfa \ | |
| 47 | $(1)/usr/bin/ | |
| 48 | ||
| 49 | $(INSTALL_DATA) \ | |
| 50 | $(PKG_BUILD_DIR)/makfa.dump \ | |
| 51 | $(1)/var/lib/$(PKG_NAME)/ | |
| 52 | endef | |
| 53 | ||
| 54 | $(eval $(call BuildPackage,makfa)) | |
| makfa/patches/00-pickle.patch | ||
|---|---|---|
| 1 | diff --git a/makfa b/makfa | |
| 2 | index af7a8b7..488007e 100755 | |
| 3 | --- a/makfa | |
| 4 | @@ -296,19 +296,16 @@ class Update(object): | |
| 5 | """Update dictionary.""" | |
| 6 | ||
| 7 | def __init__(self): | |
| 8 | - self.parser = OptionParser(usage='makfa update [language]', | |
| 9 | + self.parser = OptionParser(usage='makfa update [language] [filename]', | |
| 10 | description=self.__class__.__doc__) | |
| 11 | ||
| 12 | def parse(self, argv): | |
| 13 | options, args = self.parser.parse_args(argv) | |
| 14 | print 'Updating dictionary...' | |
| 15 | - if args: | |
| 16 | - try: | |
| 17 | - Updater(args[0]) | |
| 18 | - except SyntaxError: | |
| 19 | - print 'Invalid language code.' | |
| 20 | - else: | |
| 21 | - Updater() | |
| 22 | + try: | |
| 23 | + Updater(*args) | |
| 24 | + except SyntaxError: | |
| 25 | + print 'Invalid language code.' | |
| 26 | ||
| 27 | ||
| 28 | class Find(object): | |
| 29 | @@ -488,7 +485,7 @@ class Type(Command): | |
| 30 | ||
| 31 | class Updater(object): | |
| 32 | ||
| 33 | - def __init__(self, lang='en'): | |
| 34 | + def __init__(self, lang='en', filename=os.path.expanduser('~/makfa.dump')): | |
| 35 | self.db = {'order': [], 'entries': {}} | |
| 36 | url = 'http://jbovlaste.lojban.org/export/xml-export.html?lang=%s' | |
| 37 | tree = etree.parse(urllib.urlopen(url % lang)) | |
| 38 | @@ -506,7 +503,7 @@ class Updater(object): | |
| 39 | self.db['entries'][word]['places'][place] = [] | |
| 40 | self.db['entries'][word]['places'][place]. \ | |
| 41 | append((valsi.get('word'), sense)) | |
| 42 | - pickle.dump(self.db, open(os.path.expanduser('~/.makfa.dump'), 'w'), -1) | |
| 43 | + pickle.dump(self.db, open(filename, 'w'), -1) | |
| 44 | ||
| 45 | def _save(self, valsi): | |
| 46 | word = valsi.get('word') | |
| 47 | @@ -618,12 +615,12 @@ class Filter(object): | |
| 48 | ||
| 49 | class Dictionary(object): | |
| 50 | ||
| 51 | - def __init__(self): | |
| 52 | + def __init__(self, filename=os.path.expanduser('~/makfa.dump')): | |
| 53 | try: | |
| 54 | - self._db = pickle.load(open(os.path.expanduser('~/.makfa.dump'))) | |
| 55 | + self._db = pickle.load(open(filename)) | |
| 56 | except: | |
| 57 | print >>sys.stderr, '(Fetching dictionary, this may take a minute.)' | |
| 58 | - self._db = Updater().db | |
| 59 | + self._db = Updater(filename=filename).db | |
| 60 | self._longest = max(map(len, self)) | |
| 61 | ||
| 62 | def definition(self, entry): | |
| makfa/patches/01-path.patch | ||
|---|---|---|
| 1 | diff --git a/makfa b/makfa | |
| 2 | index 488007e..a19a5c8 100755 | |
| 3 | --- a/makfa | |
| 4 | @@ -485,7 +485,7 @@ class Type(Command): | |
| 5 | ||
| 6 | class Updater(object): | |
| 7 | ||
| 8 | - def __init__(self, lang='en', filename=os.path.expanduser('~/makfa.dump')): | |
| 9 | + def __init__(self, lang='en', filename='/var/lib/makfa/makfa.dump'): | |
| 10 | self.db = {'order': [], 'entries': {}} | |
| 11 | url = 'http://jbovlaste.lojban.org/export/xml-export.html?lang=%s' | |
| 12 | tree = etree.parse(urllib.urlopen(url % lang)) | |
| 13 | @@ -615,7 +615,7 @@ class Filter(object): | |
| 14 | ||
| 15 | class Dictionary(object): | |
| 16 | ||
| 17 | - def __init__(self, filename=os.path.expanduser('~/makfa.dump')): | |
| 18 | + def __init__(self, filename='/var/lib/makfa/makfa.dump'): | |
| 19 | try: | |
| 20 | self._db = pickle.load(open(filename)) | |
| 21 | except: | |
