-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from neocl/dev
Version 0.1a3 is ready
- Loading branch information
Showing
27 changed files
with
673 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include README.rst | ||
include CHANGES.md | ||
include LICENSE | ||
recursive-include jamdict/scripts/ *.sql | ||
recursive-include jamdict/data/ *.sql | ||
recursive-include jamdict/data/ *.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Copy JMDict dictionary file (JMdict_e.xml) here | ||
Copy dictionary files (JMdict_e.xml, kanjidic2.xml, kradfile, etc.) here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,26 +44,14 @@ | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
|
||
__author__ = "Le Tuan Anh" | ||
__email__ = "[email protected]" | ||
__copyright__ = "Copyright 2016, jamdict" | ||
__credits__ = [] | ||
__license__ = "MIT License" | ||
__description__ = "Python library for manipulating Jim Breen's JMdict & KanjiDic2" | ||
__url__ = "https://github.com/neocl/jamdict" | ||
__maintainer__ = "Le Tuan Anh" | ||
__version_major__ = "0.1" | ||
__version__ = "{}a1".format(__version_major__) | ||
__version_long__ = "{} - Alpha".format(__version_major__) | ||
__status__ = "Prototype" | ||
|
||
######################################################################## | ||
|
||
from .__version__ import __author__, __email__, __copyright__, __maintainer__ | ||
from .__version__ import __credits__, __license__, __description__, __url__ | ||
from .__version__ import __version_major__, __version_long__, __version__, __status__ | ||
|
||
from .jmdict_sqlite import JMDictSQLite | ||
from .kanjidic2_sqlite import KanjiDic2SQLite | ||
from .util import Jamdict, JMDictXML, KanjiDic2XML | ||
|
||
######################################################################## | ||
|
||
__all__ = ['Jamdict', 'JMDictSQLite', 'JMDictXML', 'KanjiDic2SQLite', 'KanjiDic2XML'] | ||
__all__ = ['Jamdict', 'JMDictSQLite', 'JMDictXML', 'KanjiDic2SQLite', 'KanjiDic2XML', | ||
"__version__", "__author__", "__description__", "__copyright__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# jamdict's package version information | ||
__author__ = "Le Tuan Anh" | ||
__email__ = "[email protected]" | ||
__copyright__ = "Copyright (c) 2016, Le Tuan Anh" | ||
__credits__ = [] | ||
__license__ = "MIT License" | ||
__description__ = "Python library for manipulating Jim Breen's JMdict & KanjiDic2" | ||
__url__ = "https://github.com/neocl/jamdict" | ||
__maintainer__ = "Le Tuan Anh" | ||
__version_major__ = "0.1" | ||
__version__ = "{}a3".format(__version_major__) | ||
__version_long__ = "{} - Alpha".format(__version_major__) | ||
__status__ = "Prototype" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
''' | ||
Jamdict configuration management | ||
Latest version can be found at https://github.com/neocl/jamdict | ||
@author: Le Tuan Anh <[email protected]> | ||
@license: MIT | ||
''' | ||
|
||
# Copyright (c) 2016, Le Tuan Anh <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
######################################################################## | ||
|
||
import os | ||
import logging | ||
|
||
from chirptext import AppConfig | ||
from chirptext.io import read_file, write_file | ||
|
||
# ---------------------------------------------------------------------- | ||
# Configuration | ||
# ---------------------------------------------------------------------- | ||
|
||
MY_DIR = os.path.dirname(__file__) | ||
CONFIG_TEMPLATE = os.path.join(MY_DIR, 'data', 'config_template.json') | ||
__jamdict_home = os.environ.get('JAMDICT_HOME', MY_DIR) | ||
__app_config = AppConfig('jamdict', mode=AppConfig.JSON, working_dir=__jamdict_home) | ||
|
||
|
||
def getLogger(): | ||
return logging.getLogger(__name__) | ||
|
||
|
||
def _get_config_manager(): | ||
''' Internal function for retrieving application config manager object | ||
Don't use this directly, use read_config() method instead | ||
''' | ||
return __app_config | ||
|
||
|
||
def read_config(): | ||
if not __app_config.config and not __app_config.locate_config(): | ||
# need to create a config | ||
config_dir = os.path.expanduser('~/.jamdict/') | ||
if not os.path.exists(config_dir): | ||
os.makedirs(config_dir) | ||
cfg_loc = os.path.join(config_dir, 'config.json') | ||
default_config = read_file(CONFIG_TEMPLATE) | ||
getLogger().warning("Jamdict configuration file could not be found. A new configuration file will be generated at {}".format(cfg_loc)) | ||
getLogger().debug("Default config: {}".format(default_config)) | ||
write_file(cfg_loc, default_config) | ||
# read config | ||
config = __app_config.config | ||
return config | ||
|
||
|
||
def home_dir(): | ||
_config = read_config() | ||
return _config.get('JAMDICT_HOME', '.') | ||
|
||
|
||
def data_dir(): | ||
_config = read_config() | ||
_data_dir = _config.get('JAMDICT_DATA', '{JAMDICT_HOME}/data').format(JAMDICT_HOME=home_dir()) | ||
return _data_dir | ||
|
||
|
||
def get_file(file_key): | ||
_config = read_config() | ||
_data_dir = data_dir() | ||
return _config.get(file_key).format(JAMDICT_DATA=_data_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"JAMDICT_HOME": "~/.jamdict", | ||
"JAMDICT_DATA": "{JAMDICT_HOME}/data", | ||
"JAMDICT_DB": "{JAMDICT_DATA}/jamdict.db", | ||
"JMDICT_XML": "{JAMDICT_DATA}/JMdict_e.gz", | ||
"KD2_XML": "{JAMDICT_DATA}/kanjidic2.xml.gz", | ||
"KRADFILE": "{JAMDICT_DATA}/kradfile-u.gz" | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.