diff --git a/Package & Installer/Dictionary Short Description.rtf b/Potchana Installer/Dictionary Short Description.rtf similarity index 100% rename from Package & Installer/Dictionary Short Description.rtf rename to Potchana Installer/Dictionary Short Description.rtf diff --git a/Package & Installer/Introduction.rtfd/TXT.rtf b/Potchana Installer/Introduction.rtfd/TXT.rtf similarity index 100% rename from Package & Installer/Introduction.rtfd/TXT.rtf rename to Potchana Installer/Introduction.rtfd/TXT.rtf diff --git a/Package & Installer/License.rtf b/Potchana Installer/License.rtf similarity index 100% rename from Package & Installer/License.rtf rename to Potchana Installer/License.rtf diff --git a/Potchana Installer/Potchana Installer 0.1.pkg b/Potchana Installer/Potchana Installer 0.1.pkg deleted file mode 100644 index 0d2cea8..0000000 Binary files a/Potchana Installer/Potchana Installer 0.1.pkg and /dev/null differ diff --git a/Potchana Installer/Potchana Installer 0.2.pkg b/Potchana Installer/Potchana Installer 0.2.pkg deleted file mode 100644 index 7f51c17..0000000 Binary files a/Potchana Installer/Potchana Installer 0.2.pkg and /dev/null differ diff --git a/Potchana Installer/Potchana Installer.pkgproj b/Potchana Installer/Potchana Installer.pkgproj index e970243..371b2f4 100755 --- a/Potchana Installer/Potchana Installer.pkgproj +++ b/Potchana Installer/Potchana Installer.pkgproj @@ -473,7 +473,7 @@ PACKAGE_FILES DEFAULT_INSTALL_LOCATION - / + /Library/Dictionaries HIERARCHY CHILDREN @@ -4784,7 +4784,7 @@ PACKAGE_FILES DEFAULT_INSTALL_LOCATION - /Library + /Library/Dictionaries HIERARCHY CHILDREN @@ -7129,6 +7129,11 @@ VERSION 4 + PACKAGE_SCRIPTS + + RESOURCES + + PACKAGE_SETTINGS AUTHENTICATION @@ -7155,7 +7160,7 @@ PACKAGE_FILES DEFAULT_INSTALL_LOCATION - / + /Library/Dictionaries HIERARCHY CHILDREN @@ -8247,9 +8252,9 @@ This dictionary was created by TumCivil. For more informations please visits: ht VALUE PATH - /Users/iFluke/Documents/Github/potchana/Package & Installer/Introduction.rtfd + Introduction.rtfd PATH_TYPE - 0 + 1 @@ -8266,9 +8271,9 @@ This dictionary was created by TumCivil. For more informations please visits: ht VALUE PATH - /Users/iFluke/Documents/Github/potchana/Package & Installer/License.rtf + License.rtf PATH_TYPE - 0 + 1 @@ -8324,13 +8329,6 @@ This dictionary was created by TumCivil. For more informations please visits: ht PATH_TYPE 1 - CERTIFICATE - - NAME - Developer ID Installer: Thunpisit Amnuaikiatloet (7S69HUYJ5S) - PATH - /Users/iFluke/Library/Keychains/login.keychain - EXCLUDED_FILES diff --git a/PotchanaBuild/PotchanaBuild.pkgproj b/PotchanaBuild/PotchanaBuild.pkgproj deleted file mode 100755 index 2520e7a..0000000 --- a/PotchanaBuild/PotchanaBuild.pkgproj +++ /dev/null @@ -1,240 +0,0 @@ - - - - - PACKAGES - - - PACKAGE_SETTINGS - - AUTHENTICATION - 1 - CONCLUSION_ACTION - 0 - IDENTIFIER - com.mygreatcompany.pkg.PotchanaBuild - NAME - PotchanaBuild - OVERWRITE_PERMISSIONS - - VERSION - 1.0 - - UUID - E793C21A-5C58-47C7-9B7D-A3448FC77E76 - - - PROJECT - - PROJECT_COMMENTS - - NOTES - - - - PROJECT_PRESENTATION - - TITLE - - LOCALIZATIONS - - - LANGUAGE - English - VALUE - PotchanaBuild - - - - - PROJECT_SETTINGS - - ADVANCED_OPTIONS - - BUILD_FORMAT - 0 - BUILD_PATH - - PATH - build - PATH_TYPE - 1 - - EXCLUDED_FILES - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - .DS_Store - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Remove .DS_Store files - PROXY_TOOLTIP - Remove ".DS_Store" files created by the Finder. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - .pbdevelopment - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Remove .pbdevelopment files - PROXY_TOOLTIP - Remove ".pbdevelopment" files created by ProjectBuilder or Xcode. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - CVS - TYPE - 1 - - - REGULAR_EXPRESSION - - STRING - .cvsignore - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - .cvspass - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - .svn - TYPE - 1 - - - REGULAR_EXPRESSION - - STRING - .git - TYPE - 1 - - - REGULAR_EXPRESSION - - STRING - .gitignore - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Remove SCM metadata - PROXY_TOOLTIP - Remove helper files and folders used by the CVS, SVN or Git Source Code Management systems. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - classes.nib - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - designable.db - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - info.nib - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Optimize nib files - PROXY_TOOLTIP - Remove "classes.nib", "info.nib" and "designable.nib" files within .nib bundles. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - Resources Disabled - TYPE - 1 - - - PROTECTED - - PROXY_NAME - Remove Resources Disabled folders - PROXY_TOOLTIP - Remove "Resources Disabled" folders. - STATE - - - - SEPARATOR - - - - NAME - PotchanaBuild - - - TYPE - 0 - VERSION - 2 - - diff --git a/playground.ipynb b/playground.ipynb index 01c10b2..d1355e0 100644 --- a/playground.ipynb +++ b/playground.ipynb @@ -2,12 +2,561 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], - "source": [] + "source": [ + "from glob import glob\n", + "import os\n", + "import sh" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "def get_target():\n", + " zips_1 = glob('RawDictionary/StarDict/*/*.zip')\n", + " zips_2 = glob('RawDictionary/StarDict/*/*.ZIP')\n", + " zips = zips_2+zips_1\n", + " return zips\n", + "\n", + "def cmd_ops(zip_stardict):\n", + " sh.unzip(zip_stardict)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "zips = get_target()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['RawDictionary/StarDict/en-th/VolubilisEnTh-2.4.2.zip.ZIP',\n 'RawDictionary/StarDict/en-th/VolubilisThEn-2.4.2.zip.ZIP',\n 'RawDictionary/StarDict/fr-th/VolubilisThFr-2.4.2.zip.ZIP',\n 'RawDictionary/StarDict/en-th/LexitronEnTh-2.4.2.zip',\n 'RawDictionary/StarDict/en-th/LexitronThEn-2.4.2.zip',\n 'RawDictionary/StarDict/en-th/NontriEnTh-2.4.2.zip',\n 'RawDictionary/StarDict/en-th/PlantsEnTh-2.4.2.zip',\n 'RawDictionary/StarDict/en-th/PlantsThEn-2.4.2.zip',\n 'RawDictionary/StarDict/en-th/SEASiteThEn-2.4.2.zip',\n 'RawDictionary/StarDict/en-th/TumCivilEnTh-2.4.2.zip',\n 'RawDictionary/StarDict/fr-th/DicoThaiFrTh-2.4.2.zip',\n 'RawDictionary/StarDict/fr-th/DicoThaiThFr-2.4.2.zip',\n 'RawDictionary/StarDict/other/BuddhistTermsPiTh-2.4.2.zip',\n 'RawDictionary/StarDict/other/DeutshThai-2.4.2.zip',\n 'RawDictionary/StarDict/other/Dict2UThZh-2.4.2.zip',\n 'RawDictionary/StarDict/other/Dict2UZhTh-2.4.2.zip',\n 'RawDictionary/StarDict/other/English2Lao-2.4.2.zip',\n 'RawDictionary/StarDict/other/JTDicJaTh-2.4.2.zip',\n 'RawDictionary/StarDict/other/JTDicThJa-2.4.2.zip',\n 'RawDictionary/StarDict/other/KDTKoTh-2.4.2.zip',\n 'RawDictionary/StarDict/other/KDTThKo-2.4.2.zip',\n 'RawDictionary/StarDict/other/Lao2English-2.4.2.zip',\n 'RawDictionary/StarDict/other/MahaSilaLoLo-2.4.2.zip',\n 'RawDictionary/StarDict/ru-th/PhoneticThai-2.4.2.zip',\n 'RawDictionary/StarDict/ru-th/RussianThai-2.4.2.zip',\n 'RawDictionary/StarDict/ru-th/ThaiRussian-2.4.2.zip',\n 'RawDictionary/StarDict/th-th/AbbrevThTh-2.4.2.zip',\n 'RawDictionary/StarDict/th-th/NickNamesThTh-2.4.2.zip',\n 'RawDictionary/StarDict/th-th/RoyalInstituteThTh-2.4.2.zip']" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "zips" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "log = sh.unzip(zips[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Archive: RawDictionary/StarDict/en-th/VolubilisEnTh-2.4.2.zip.ZIP\n creating: VolubilisEnTh-2.4.2/\n inflating: VolubilisEnTh-2.4.2/VolubilisEnTh.bmp \n inflating: VolubilisEnTh-2.4.2/VolubilisEnTh.dict.dz \n inflating: VolubilisEnTh-2.4.2/VolubilisEnTh.idx.gz \n inflating: VolubilisEnTh-2.4.2/VolubilisEnTh.ifo " + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "log" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "from zipfile import ZipFile\n", + "\n", + "folder, zipfile = os.path.split(zips[0])\n", + "\n", + "zip_ref = ZipFile(zips[0], 'r')\n", + "zip_ref.extractall(folder)\n", + "zip_ref.close()" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('RawDictionary/StarDict/en-th', 'VolubilisEnTh-2.4.2.zip.ZIP')" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "folder,zipfile" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], + "source": [ + "import re" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['VolubilisEnTh-2.4.2', '', '']" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "re.split(r'.zip',zipfile, maxsplit=10,flags=re.IGNORECASE)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['RawDictionary/StarDict/en-th/VolubilisEnTh-2.4.2']" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c=[x for x in glob(folder+'/*') if os.path.isdir(x) and not 'not use' in x];c" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [ + "sample = glob(_[0]+'/*.ifo') + glob(_[0]+'/*.IFO')" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "no `Reader` class found in Stardict plugin, falling back to indirect mode\n\nWriting to file \"/Users/heim/Developer/Potchana/RawDictionary/StarDict/en-th/VolubilisEnTh-2.4.2/VolubilisEnTh.xml\"\n\nRunning time of convert: 402.1 seconds\nWriting file \"xml\" done." + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sh.python('pyglossary/pyglossary.pyw',sample[0],'xml')" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['RawDictionary/StarDict/en-th/VolubilisEnTh-2.4.2/VolubilisEnTh']" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "d=[x for x in glob(c[0]+'/*') if os.path.isdir(x)]\n", + "d" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"\"\"/Developer/Extras/Dictionary Development Kit\"/bin\"/build_dict.sh\" \"VolubilisEnTh\" \"VolubilisEnTh.xml\" \"VolubilisEnTh.css\" \"VolubilisEnTh.plist\"\n- Building VolubilisEnTh.dictionary.\n- Checking source.\n- Cleaning objects directory.\n- Preparing dictionary template.\n- Preprocessing dictionary sources.\n- Extracting index data.\n- Preparing dictionary bundle.\n- Adding body data.\n- Preparing index data.\n- Building key_text index.\n- Building reference index.\n- Fixing dictionary property.\n- Copying CSS.\n- Finished building ./objects/VolubilisEnTh.dictionary.\necho \"Done.\"\nDone." + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sh.make('-C',d[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['RawDictionary/StarDict/en-th/VolubilisEnTh-2.4.2/VolubilisEnTh/objects/VolubilisEnTh.dictionary']" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = glob('**/*.dictionary',recursive=True);a" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "import shutil" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'CompiledDictionary/VolubilisEnTh.dictionary'" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "shutil.move(a[0],'CompiledDictionary')" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'/var/folders/89/0z3my29s2j5039v_x3nbl5140000gn/T'" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tempfile.gettempdir()" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [], + "source": [ + "import tempfile" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [], + "source": [ + "def cmd_ops(zip_stardict):\n", + " folder, zipfile = os.path.split(zip_stardict)\n", + "\n", + " folder_unzip_to = tempfile.gettempdir()\n", + "\n", + " zip_ref = ZipFile(zip_stardict, 'r')\n", + " zip_ref.extractall(folder_unzip_to)\n", + " zip_ref.close()\n", + "\n", + " # VolubilisEnTh-2.4.2.zip.ZIP -> VolubilisEnTh-2.4.2\n", + " folder_unzip = re.split(r'.zip', zipfile, maxsplit=10, flags=re.IGNORECASE)[0]\n", + "\n", + " folder_in_extracted = os.path.join(folder_unzip_to, folder_unzip)\n", + " if os.path.exists(folder_in_extracted):\n", + " raise Exception('unzip folder not found')\n", + "\n", + " file_ifo = glob(folder_in_extracted + '/*.ifo') + glob(folder_in_extracted + '/*.IFO')\n", + " if len(file_ifo) > 1:\n", + " raise Exception('found more than 1 ifo')\n", + " elif len(file_ifo) == 0:\n", + " raise Exception('no ifp file found')\n", + "\n", + " # convert using pyglossary\n", + " sh.python('pyglossary/pyglossary.pyw', file_ifo, 'xml')\n", + "\n", + " # VolubilisEnTh-2.4.2 -> VolubilisEnTh\n", + " folder_converted = re.split(r'-',folder_unzip,maxsplit=10)[0]\n", + " path_make = os.path.join(folder_in_extracted,folder_converted)\n", + "\n", + " sh.make('-C', path_make)\n", + "\n", + " compiledDict = glob(folder_unzip_to + '/**/*.dictionary', recursive=True)\n", + " shutil.move(compiledDict, 'CompiledDictionary')" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "ename": "Exception", + "evalue": "unzip folder not found", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mException\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcmd_ops\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mzips\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mcmd_ops\u001b[0;34m(zip_stardict)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mfolder_in_extracted\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfolder_unzip_to\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfolder_unzip\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexists\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfolder_in_extracted\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'unzip folder not found'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0mfile_ifo\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mglob\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfolder_in_extracted\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m'/*.ifo'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mglob\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfolder_in_extracted\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m'/*.IFO'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mException\u001b[0m: unzip folder not found" + ], + "output_type": "error" + } + ], + "source": [ + "cmd_ops(zips[6])" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'folder_unzip_to' is not defined", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfolder_in_extracted\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfolder_unzip_to\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfolder_unzip\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'folder_unzip_to' is not defined" + ], + "output_type": "error" + } + ], + "source": [ + "folder_in_extracted = os.path.join(folder_unzip_to, folder_unzip)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "no `Reader` class found in Stardict plugin, falling back to indirect mode\n\nWriting to file \"/private/var/folders/89/0z3my29s2j5039v_x3nbl5140000gn/T/PlantsThEn-2.4.2/PlantsThEn.xml\"\n\nRunning time of convert: 0.1 seconds\nWriting file \"xml\" done." + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sh.python('pyglossary/pyglossary.pyw', r'/private/var/folders/89/0z3my29s2j5039v_x3nbl5140000gn/T/PlantsThEn-2.4.2/PlantsThEn.ifo', 'xml')" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "no `Reader` class found in Stardict plugin, falling back to indirect mode\n\nWriting to file \"/private/var/folders/89/0z3my29s2j5039v_x3nbl5140000gn/T/PlantsThEn-2.4.2/PlantsThEn.xml\"\n\nRunning time of convert: 0.1 seconds\nWriting file \"xml\" done." + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "_" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'/Users/heim/anaconda3/envs/35/bin/python'" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sh.which('python')" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "plist_info = glob('CompiledDictionary/**/Info.plist',recursive=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [], + "source": [ + "import plistlib as plist" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [], + "source": [ + "with open(plist_info[0],mode='rb') as file:\n", + " a = plist.load(file)" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'CFBundleDevelopmentRegion': 'English',\n 'CFBundleDisplayName': 'Plant Names (En-Th)',\n 'CFBundleIdentifier': 'PlantsEnTh',\n 'CFBundleInfoDictionaryVersion': '6.0',\n 'CFBundleName': 'PlantsEnTh',\n 'CFBundleShortVersionString': '1.0',\n 'DCSBuildToolVersion': 3,\n 'DCSDictionaryCSS': 'DefaultStyle.css',\n 'DCSDictionaryCopyright': '.',\n 'DCSDictionaryDefaultPrefs': {},\n 'DCSDictionaryManufacturerName': '(c) V-I-C, 2010-2011.',\n 'DCSDictionaryPrefsHTML': '',\n 'DCSDictionaryXSL': '',\n 'IDXDictionaryIndexes': [{'IDXIndexAccessMethod': 'com.apple.TrieAccessMethod',\n 'IDXIndexBigEndian': False,\n 'IDXIndexDataFields': {'IDXExternalDataFields': [{'IDXDataFieldName': 'DCSExternalBodyID',\n 'IDXDataSize': 4,\n 'IDXIndexName': 'DCSBodyDataIndex'}],\n 'IDXFixedDataFields': [{'IDXDataFieldName': 'DCSPrivateFlag',\n 'IDXDataSize': 2}],\n 'IDXVariableDataFields': [{'IDXDataFieldName': 'DCSKeyword',\n 'IDXDataSizeLength': 2},\n {'IDXDataFieldName': 'DCSHeadword', 'IDXDataSizeLength': 2},\n {'IDXDataFieldName': 'DCSEntryTitle', 'IDXDataSizeLength': 2},\n {'IDXDataFieldName': 'DCSAnchor', 'IDXDataSizeLength': 2},\n {'IDXDataFieldName': 'DCSYomiWord', 'IDXDataSizeLength': 2}]},\n 'IDXIndexDataSizeLength': 2,\n 'IDXIndexKeyMatchingMethods': ['IDXExactMatch',\n 'IDXPrefixMatch',\n 'IDXCommonPrefixMatch',\n 'IDXWildcardMatch',\n 'IDXAllMatch'],\n 'IDXIndexName': 'DCSKeywordIndex',\n 'IDXIndexPath': 'KeyText.index',\n 'IDXIndexSupportDataID': False,\n 'IDXIndexWritable': False,\n 'TrieAuxiliaryDataOptions': {'IDXIndexPath': 'KeyText.data'}},\n {'IDXIndexAccessMethod': 'com.apple.TrieAccessMethod',\n 'IDXIndexBigEndian': False,\n 'IDXIndexDataFields': {'IDXExternalDataFields': [{'IDXDataFieldName': 'DCSExternalBodyID',\n 'IDXDataSize': 4,\n 'IDXIndexName': 'DCSBodyDataIndex'}]},\n 'IDXIndexDataSizeLength': 2,\n 'IDXIndexKeyMatchingMethods': ['IDXExactMatch'],\n 'IDXIndexName': 'DCSReferenceIndex',\n 'IDXIndexPath': 'EntryID.index',\n 'IDXIndexSupportDataID': False,\n 'IDXIndexWritable': False,\n 'TrieAuxiliaryDataOptions': {'IDXIndexPath': 'EntryID.data'}},\n {'HeapDataCompressionType': 1,\n 'IDXIndexAccessMethod': 'com.apple.HeapAccessMethod',\n 'IDXIndexBigEndian': False,\n 'IDXIndexDataFields': {'IDXVariableDataFields': [{'IDXDataFieldName': 'DCSBodyData',\n 'IDXDataSizeLength': 4}]},\n 'IDXIndexName': 'DCSBodyDataIndex',\n 'IDXIndexPath': 'Body.data',\n 'IDXIndexSupportDataID': True,\n 'IDXIndexWritable': False}],\n 'IDXDictionaryVersion': 1}" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [], + "source": [ + "a['DCSDictionaryManufacturerName'] = 'Codustry Laboratory'" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Plant Names (En-Th)
this original dictionary is from https://sites.google.com/site/thaidictproject/
Developed Jun 2017 by Codustry Laboratory: Potchana Project.
'" + ] + }, + "execution_count": 84, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ORIGIN_URL = 'https://sites.google.com/site/thaidictproject/'\n", + "a['DCSDictionaryCopyright'] = a['CFBundleDisplayName'] + \"
this original dictionary is from {}
Developed Jun 2017 by {}
\".format(\n", + " ORIGIN_URL,\n", + " a['DCSDictionaryManufacturerName'] + ': Potchana Project.'\n", + ")\n", + "a['DCSDictionaryCopyright']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "" + ] } ], "metadata": { @@ -19,7 +568,7 @@ "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 2.0 }, "file_extension": ".py", "mimetype": "text/x-python",