Skip to content

Commit

Permalink
v2.2.0 (#28)
Browse files Browse the repository at this point in the history
* First step in making warn-on-modify messages optional (#11)

* Split core application into flextoolslib. (#27)

* Restructure files for making a Python library

* Use relative imports now.

* Add build/configuration files

* Update icons path

* Change to import flextools library

Also removed from __future__ imports.

* Move batch files into FlexTools folder

* Move version info to __init__.py

* Derive paths according to new structure

* requirements.txt is now used for building, not runtime

* Moved main UI to UIMain.py

FLExTools.py is still the entry point. It initialises everything and launches the UI.

* Log exceptions from flexlibs when opening a project

* Specify flexlibs 1.1.6 for FW 9.1.15/16 support

* Add some Chinese support files

I don't know why these weren't on github already.

* Reconfigure script files for new flextoolslib library

* Clean out tests

* Add makezip.py to build the FlexTools app zip file

* Specify Python 3.6-3.8

* Package "flextools" --> "flextoolslib"

* Give FlexTools a separate version from flextoolslib

* Update ListProjects.py

* New setup for running and updating FlexTools

* Use date naming for flextoolslib version number.

* Move version # to RunFlexTools.py

* Fix import order for MessageBox()

* Put TestAModule core code into flextoolslib.misc

* Add ListProjects.vbs

* Also update flexlibs with InstallOrUpdate

* Better handling of flextools.log

* Update history.txt

* Updated help files

* Add more example modules to Examples collection

* Build updates

New versions of libraries:
cdfutils 1.0.4
flexlibs 1.1.6

* Change to global config (FTConfig)

Includes adding Modules and Collections paths to the ini file for easy site customisation.

* Tidy FlexToolsCommands.vbs

* Warning --> Info if module doesn't modify (#11)

* Put version number in Version.py

* Use new global FTConfig

* First library version: 2023.1.31

* Exclude flextools.ini from zip file

* Update history.txt

* Upload flextoolslib with twine
  • Loading branch information
cdfarrow authored Jan 31, 2023
1 parent bdb9d6e commit da1cce9
Show file tree
Hide file tree
Showing 94 changed files with 2,536 additions and 1,536 deletions.
10 changes: 0 additions & 10 deletions FlexTools.bat

This file was deleted.

9 changes: 0 additions & 9 deletions FlexTools.vbs

This file was deleted.

18 changes: 16 additions & 2 deletions FlexTools/Collections/Examples.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
[Reports.Text Statistics]
[Reports.Project Information]
_order = 1

[Reports.Lexicon Statistics]
[Reports.Text Statistics]
_order = 2

[Reports.Lexicon Statistics]
_order = 3

[Utilities.Approve Spelling of Numbers]
_order = 4

[Reports.Lexeme Usage in Corpus]
_order = 5

[Examples.Example - Check Punctuation]
_order = 6

[Export.Dump All Headwords To File]
_order = 7
16 changes: 0 additions & 16 deletions FlexTools/FTPaths.py

This file was deleted.

7 changes: 7 additions & 0 deletions FlexTools/FlexTools.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
' Run the FlexTools application

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "scripts\FlexToolsCommands.vbs RUN", 0, True

WshShell = Null
7 changes: 7 additions & 0 deletions FlexTools/FlexTools_Debug.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
' Run FlexTools with debug logging enabled

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "scripts\FlexToolsCommands.vbs DEBUG", 0, True

WshShell = Null
8 changes: 8 additions & 0 deletions FlexTools/InstallOrUpdate.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
' Run the FlexTools installer (pip) for first install or to update
' to a later version.

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "scripts\FlexToolsCommands.vbs INSTALL", 0, True

WshShell = Null
7 changes: 7 additions & 0 deletions FlexTools/ListProjects.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
' Run the FlexTools application

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "scripts\FlexToolsCommands.vbs LIST", 0, True

WshShell = Null
9 changes: 9 additions & 0 deletions FlexTools/Modules/Chinese/Doc/Building packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
How to build Chinese Tools packages
-----------------------------------

1. Create Full ZIP for archiving.
1. Delete all .pyc and .log files from the Chinese tree
2. Create ZIP file with Chinese.pth + Chinese\
3. Name it "ChineseTools-MASTER-<date>.zip" (date in YYYY-MM-DD format)


Binary file not shown.
10 changes: 4 additions & 6 deletions FlexTools/Modules/Chinese/Generate_Reversal_Sort_Field_Only.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Chinese.Generate Reversal Sort Field Only
# - A FlexTools Module -
#
# Finds the Chinese Reversal Index and uses the Hanzi field to generate the Pinyin Numbered
# field, and then uses those to populate the Sort field. See documentation below for the Writing System
# Finds the Chinese Reversal Index and uses the Hanzi field to
# generate the Pinyin Numbered field, and then uses those to populate
# the Sort field. See documentation below for the Writing System
# codes.
#
# C D Farrow
Expand All @@ -13,10 +14,7 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals
from __future__ import print_function
from FTModuleClass import *

from flextoolslib import *

#----------------------------------------------------------------
# Documentation for the user:
Expand Down
2 changes: 1 addition & 1 deletion FlexTools/Modules/Chinese/Update_Pinyin_Fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import unicodedata

from FTModuleClass import *
from flextoolslib import *

import site
site.addsitedir(r"Lib")
Expand Down
2 changes: 1 addition & 1 deletion FlexTools/Modules/Chinese/Update_Reversal_Sort_Field.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from __future__ import unicode_literals
from builtins import str

from FTModuleClass import *
from flextoolslib import *

import site
site.addsitedir(r"Lib")
Expand Down
2 changes: 1 addition & 1 deletion FlexTools/Modules/Chinese/Update_Tonenumber_Fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from __future__ import unicode_literals
from builtins import str

from FTModuleClass import *
from flextoolslib import *

import site
site.addsitedir(r"Lib")
Expand Down
110 changes: 110 additions & 0 deletions FlexTools/Modules/Chinese/__test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# -*- coding: utf-8 -*-
#
# ChineseUtilities
#
# Craig Farrow
# May 2011
#
#
#

from __future__ import unicode_literals
from __future__ import print_function
from builtins import str

import codecs
import re

import os, sys

class SortStringDB(dict):
FNAME = 'ch2sort.txt'
def __init__(self):
dict.__init__(self)
self.loaded = False

def __load(self):
if self.loaded: return
self.loaded = True # Set True even if fail to load file
# This stack-frame code is all that I've found to work from
# Idle, command-line AND Python.NET
# (Use of __file__ failed for Idle)
mypath = os.path.dirname(sys._getframe().f_code.co_filename)
fname = os.path.join(mypath, self.FNAME)
print(fname)
try:
f = codecs.open(fname, encoding="gb18030")
except IOError:
return

for line in f.readlines():
line = line.strip("\n\r")
parts = line.split("\t")
if len(parts) == 2:
self[parts[0]] = parts[1]
else:
ambiguities = {}
hz = parts.pop(0)
while (parts):
py = parts.pop(0)
sortKey = parts.pop(0)
ambiguities[py] = sortKey
self[hz] = ambiguities

f.close()

def Lookup(self, hz, py):
self.__load()
try:
sortInfo = self[hz]
except KeyError:
return "[HZ not in DB: %s]" % repr(hz)
if type(sortInfo) == str:
if sortInfo.startswith(py):
return "(" + sortInfo + ")"
else:
return "[PY mismatch]"
else:
try:
match = sortInfo[py]
return "(" + match + ")"
except KeyError:
return "[PY invalid]"

Sorter = SortStringDB()

def PinyinTonenumSplit(pinyin):
pinyin = re.sub(" ", "", pinyin)
return re.findall("[^1-5]*[1-5]", pinyin)

def ChineseSortString(hz, py):
global Sorter
if not hz or not py:
return ""
hzList = [x for x in hz]
pyList = PinyinTonenumSplit(py)
if len(hzList) != len(pyList):
return "[PY different length]"

return ";".join([Sorter.Lookup(h,p) for h, p in zip(hzList, pyList)])


if __name__ == "__main__":
if sys.stdout.encoding == None:
sys.stdout = codecs.getwriter("utf-8")(sys.stdout)

testSet = [
("路", "lu4"),
("你好", "ni3hao3"),
("中国", "zhong1 guo2"),
("录音", "lu4yin1"),
("录", ""),
("孩子", "hai2zi5"),
]

for t in testSet:
print(t[0], t[1], ChineseSortString(t[0], t[1]))




5 changes: 1 addition & 4 deletions FlexTools/Modules/Duplicates/Find_Duplicate_Definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals
from builtins import str

from FTModuleClass import *
from flextoolslib import *

import re
from types import *
Expand Down
7 changes: 1 addition & 6 deletions FlexTools/Modules/Duplicates/Find_Duplicate_Entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals
from flextoolslib import *

from FTModuleClass import *
from SIL.LCModel import *
from SIL.LCModel import MoMorphTypeTags

Expand All @@ -27,10 +26,6 @@
from collections import defaultdict
from types import *



# from SIL.FieldWorks.FDO import MoMorphTypeTags

#----------------------------------------------------------------
# Documentation that the user sees:

Expand Down
3 changes: 1 addition & 2 deletions FlexTools/Modules/Duplicates/Merge_Entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
# Platforms: Python.NET
#

from __future__ import unicode_literals
from flextoolslib import *

from FTModuleClass import *
from SIL.LCModel import *
from SIL.LCModel.Core.KernelInterfaces import ITsString, ITsStrBldr

Expand Down
4 changes: 1 addition & 3 deletions FlexTools/Modules/Duplicates/Merge_Senses.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
# Platforms: Python.NET
#

from __future__ import unicode_literals
from flextoolslib import *

from FTModuleClass import *
from SIL.LCModel import *
from SIL.LCModel.Core.KernelInterfaces import ITsString, ITsStrBldr

Expand All @@ -22,7 +21,6 @@
from collections import defaultdict
from types import *


#----------------------------------------------------------------
# Documentation that the user sees:

Expand Down
4 changes: 1 addition & 3 deletions FlexTools/Modules/Examples/Example_Check_Punctuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals

from FTModuleClass import *
from flextoolslib import *

import re
from types import *
Expand Down
4 changes: 1 addition & 3 deletions FlexTools/Modules/Examples/Example_Programming_Errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# Platforms: Python .NET
#

from __future__ import unicode_literals

from FTModuleClass import *
from flextoolslib import *

import logging
logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion FlexTools/Modules/Examples/__Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Platforms: Python .NET and IronPython
#

from FTModuleClass import *
from flextoolslib import *


#----------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions FlexTools/Modules/Export/Dump_All_Headwords_To_File.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals

from FTModuleClass import *
from flextoolslib import *
import io

#----------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions FlexTools/Modules/Export/Dump_Published_Headwords_To_File.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals

from FTModuleClass import *
from flextoolslib import *
import io

#----------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions FlexTools/Modules/Export/Dump_SemanticDomains_To_File.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# Platforms: Python .NET and IronPython
#

from __future__ import unicode_literals

from FTModuleClass import *
from flextoolslib import *
import io

#----------------------------------------------------------------
Expand Down
Loading

0 comments on commit da1cce9

Please sign in to comment.