chesscalc 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. chesscalc-2.0.0/LICENCE +15 -0
  2. chesscalc-2.0.0/PKG-INFO +113 -0
  3. chesscalc-2.0.0/README +77 -0
  4. chesscalc-2.0.0/chesscalc/__init__.py +71 -0
  5. chesscalc-2.0.0/chesscalc/apsw/__init__.py +5 -0
  6. chesscalc-2.0.0/chesscalc/apsw/database.py +46 -0
  7. chesscalc-2.0.0/chesscalc/apsw/database_du.py +35 -0
  8. chesscalc-2.0.0/chesscalc/basecore/__init__.py +5 -0
  9. chesscalc-2.0.0/chesscalc/basecore/database.py +66 -0
  10. chesscalc-2.0.0/chesscalc/berkeleydb/__init__.py +5 -0
  11. chesscalc-2.0.0/chesscalc/berkeleydb/database.py +73 -0
  12. chesscalc-2.0.0/chesscalc/berkeleydb/database_du.py +63 -0
  13. chesscalc-2.0.0/chesscalc/calculate.py +79 -0
  14. chesscalc-2.0.0/chesscalc/core/__init__.py +5 -0
  15. chesscalc-2.0.0/chesscalc/core/apply_identities.py +219 -0
  16. chesscalc-2.0.0/chesscalc/core/calculate.py +838 -0
  17. chesscalc-2.0.0/chesscalc/core/configuration.py +24 -0
  18. chesscalc-2.0.0/chesscalc/core/constants.py +98 -0
  19. chesscalc-2.0.0/chesscalc/core/delete_games.py +725 -0
  20. chesscalc-2.0.0/chesscalc/core/eventrecord.py +305 -0
  21. chesscalc-2.0.0/chesscalc/core/export.py +288 -0
  22. chesscalc-2.0.0/chesscalc/core/filespec.py +391 -0
  23. chesscalc-2.0.0/chesscalc/core/gamerecord.py +741 -0
  24. chesscalc-2.0.0/chesscalc/core/identify_event.py +124 -0
  25. chesscalc-2.0.0/chesscalc/core/identify_item.py +406 -0
  26. chesscalc-2.0.0/chesscalc/core/identify_mode.py +108 -0
  27. chesscalc-2.0.0/chesscalc/core/identify_person.py +769 -0
  28. chesscalc-2.0.0/chesscalc/core/identify_playertype.py +107 -0
  29. chesscalc-2.0.0/chesscalc/core/identify_termination.py +108 -0
  30. chesscalc-2.0.0/chesscalc/core/identify_timecontrol.py +101 -0
  31. chesscalc-2.0.0/chesscalc/core/identity.py +285 -0
  32. chesscalc-2.0.0/chesscalc/core/mirror_identities.py +220 -0
  33. chesscalc-2.0.0/chesscalc/core/moderecord.py +265 -0
  34. chesscalc-2.0.0/chesscalc/core/name_lookup.py +236 -0
  35. chesscalc-2.0.0/chesscalc/core/person.py +81 -0
  36. chesscalc-2.0.0/chesscalc/core/pgnheaders.py +138 -0
  37. chesscalc-2.0.0/chesscalc/core/playerrecord.py +444 -0
  38. chesscalc-2.0.0/chesscalc/core/playertyperecord.py +270 -0
  39. chesscalc-2.0.0/chesscalc/core/population.py +179 -0
  40. chesscalc-2.0.0/chesscalc/core/selectorrecord.py +107 -0
  41. chesscalc-2.0.0/chesscalc/core/tab_from_selection.py +176 -0
  42. chesscalc-2.0.0/chesscalc/core/terminationrecord.py +274 -0
  43. chesscalc-2.0.0/chesscalc/core/timecontrolrecord.py +269 -0
  44. chesscalc-2.0.0/chesscalc/core/update_rule.py +155 -0
  45. chesscalc-2.0.0/chesscalc/core/utilities.py +37 -0
  46. chesscalc-2.0.0/chesscalc/db/__init__.py +5 -0
  47. chesscalc-2.0.0/chesscalc/db/database.py +73 -0
  48. chesscalc-2.0.0/chesscalc/db/database_du.py +63 -0
  49. chesscalc-2.0.0/chesscalc/db_tkinter/__init__.py +5 -0
  50. chesscalc-2.0.0/chesscalc/db_tkinter/database.py +61 -0
  51. chesscalc-2.0.0/chesscalc/db_tkinter/database_du.py +45 -0
  52. chesscalc-2.0.0/chesscalc/dpt/__init__.py +5 -0
  53. chesscalc-2.0.0/chesscalc/dpt/database.py +81 -0
  54. chesscalc-2.0.0/chesscalc/dpt/database_du.py +31 -0
  55. chesscalc-2.0.0/chesscalc/dpt/dptnofistat.py +65 -0
  56. chesscalc-2.0.0/chesscalc/gui/__init__.py +5 -0
  57. chesscalc-2.0.0/chesscalc/gui/calculator.py +2728 -0
  58. chesscalc-2.0.0/chesscalc/gui/events.py +386 -0
  59. chesscalc-2.0.0/chesscalc/gui/eventsgrid.py +32 -0
  60. chesscalc-2.0.0/chesscalc/gui/eventspec.py +79 -0
  61. chesscalc-2.0.0/chesscalc/gui/eventsrow.py +77 -0
  62. chesscalc-2.0.0/chesscalc/gui/games.py +119 -0
  63. chesscalc-2.0.0/chesscalc/gui/gamesgrid.py +32 -0
  64. chesscalc-2.0.0/chesscalc/gui/gamesrow.py +126 -0
  65. chesscalc-2.0.0/chesscalc/gui/gridlocator.py +65 -0
  66. chesscalc-2.0.0/chesscalc/gui/help_.py +30 -0
  67. chesscalc-2.0.0/chesscalc/gui/modes.py +269 -0
  68. chesscalc-2.0.0/chesscalc/gui/modesgrid.py +32 -0
  69. chesscalc-2.0.0/chesscalc/gui/modesrow.py +68 -0
  70. chesscalc-2.0.0/chesscalc/gui/performancedu.py +998 -0
  71. chesscalc-2.0.0/chesscalc/gui/persons.py +403 -0
  72. chesscalc-2.0.0/chesscalc/gui/personsgrid.py +32 -0
  73. chesscalc-2.0.0/chesscalc/gui/personsrow.py +94 -0
  74. chesscalc-2.0.0/chesscalc/gui/players.py +330 -0
  75. chesscalc-2.0.0/chesscalc/gui/playersgrid.py +32 -0
  76. chesscalc-2.0.0/chesscalc/gui/playersrow.py +88 -0
  77. chesscalc-2.0.0/chesscalc/gui/playertypes.py +269 -0
  78. chesscalc-2.0.0/chesscalc/gui/playertypesgrid.py +32 -0
  79. chesscalc-2.0.0/chesscalc/gui/playertypesrow.py +67 -0
  80. chesscalc-2.0.0/chesscalc/gui/report.py +56 -0
  81. chesscalc-2.0.0/chesscalc/gui/reportapply.py +457 -0
  82. chesscalc-2.0.0/chesscalc/gui/reportmirror.py +252 -0
  83. chesscalc-2.0.0/chesscalc/gui/reportremovepgn.py +23 -0
  84. chesscalc-2.0.0/chesscalc/gui/rule.py +1489 -0
  85. chesscalc-2.0.0/chesscalc/gui/ruleedit.py +55 -0
  86. chesscalc-2.0.0/chesscalc/gui/ruleinsert.py +38 -0
  87. chesscalc-2.0.0/chesscalc/gui/ruleshow.py +75 -0
  88. chesscalc-2.0.0/chesscalc/gui/selectors.py +70 -0
  89. chesscalc-2.0.0/chesscalc/gui/selectorsgrid.py +32 -0
  90. chesscalc-2.0.0/chesscalc/gui/selectorsrow.py +85 -0
  91. chesscalc-2.0.0/chesscalc/gui/terminations.py +271 -0
  92. chesscalc-2.0.0/chesscalc/gui/terminationsgrid.py +32 -0
  93. chesscalc-2.0.0/chesscalc/gui/terminationsrow.py +68 -0
  94. chesscalc-2.0.0/chesscalc/gui/timecontrols.py +265 -0
  95. chesscalc-2.0.0/chesscalc/gui/timecontrolsgrid.py +32 -0
  96. chesscalc-2.0.0/chesscalc/gui/timecontrolsrow.py +68 -0
  97. chesscalc-2.0.0/chesscalc/help_/__init__.py +30 -0
  98. chesscalc-2.0.0/chesscalc/help_/aboutcalculator.txt +16 -0
  99. chesscalc-2.0.0/chesscalc/help_/calculator.txt +110 -0
  100. chesscalc-2.0.0/chesscalc/legacy/__init__.py +5 -0
  101. chesscalc-2.0.0/chesscalc/legacy/core/__init__.py +5 -0
  102. chesscalc-2.0.0/chesscalc/legacy/core/performances.py +1000 -0
  103. chesscalc-2.0.0/chesscalc/legacy/gui/__init__.py +5 -0
  104. chesscalc-2.0.0/chesscalc/legacy/gui/performance.py +279 -0
  105. chesscalc-2.0.0/chesscalc/legacy/gui/population.py +533 -0
  106. chesscalc-2.0.0/chesscalc/legacy/gui/prediction.py +419 -0
  107. chesscalc-2.0.0/chesscalc/lmdb/__init__.py +5 -0
  108. chesscalc-2.0.0/chesscalc/lmdb/database.py +56 -0
  109. chesscalc-2.0.0/chesscalc/lmdb/database_du.py +64 -0
  110. chesscalc-2.0.0/chesscalc/shared/alldu.py +815 -0
  111. chesscalc-2.0.0/chesscalc/shared/dbdu.py +44 -0
  112. chesscalc-2.0.0/chesscalc/shared/litedu.py +83 -0
  113. chesscalc-2.0.0/chesscalc/shared/rundu.py +93 -0
  114. chesscalc-2.0.0/chesscalc/shared/task.py +41 -0
  115. chesscalc-2.0.0/chesscalc/sqlite/__init__.py +5 -0
  116. chesscalc-2.0.0/chesscalc/sqlite/database.py +50 -0
  117. chesscalc-2.0.0/chesscalc/sqlite/database_du.py +35 -0
  118. chesscalc-2.0.0/chesscalc/unqlite/__init__.py +5 -0
  119. chesscalc-2.0.0/chesscalc/unqlite/database.py +46 -0
  120. chesscalc-2.0.0/chesscalc/unqlite/database_du.py +35 -0
  121. chesscalc-2.0.0/chesscalc/vedis/__init__.py +5 -0
  122. chesscalc-2.0.0/chesscalc/vedis/database.py +46 -0
  123. chesscalc-2.0.0/chesscalc/vedis/database_du.py +35 -0
  124. chesscalc-2.0.0/chesscalc.egg-info/PKG-INFO +113 -0
  125. chesscalc-2.0.0/chesscalc.egg-info/SOURCES.txt +128 -0
  126. chesscalc-2.0.0/chesscalc.egg-info/dependency_links.txt +1 -0
  127. chesscalc-2.0.0/chesscalc.egg-info/requires.txt +4 -0
  128. chesscalc-2.0.0/chesscalc.egg-info/top_level.txt +1 -0
  129. chesscalc-2.0.0/pyproject.toml +67 -0
  130. chesscalc-2.0.0/setup.cfg +4 -0
@@ -0,0 +1,15 @@
1
+ Licence for chesscalc package
2
+ Copyright (c) 2012, Roger Marsh
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+
8
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
+
10
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+
12
+ Neither the name of the owner nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13
+
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: chesscalc
3
+ Version: 2.0.0
4
+ Summary: Calculate player performances in chess games.
5
+ Author-email: Roger Marsh <roger.marsh@solentware.co.uk>
6
+ License: Licence for chesscalc package
7
+ Copyright (c) 2012, Roger Marsh
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
11
+
12
+
13
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14
+
15
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
+
17
+ Neither the name of the owner nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
18
+
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21
+
22
+ Project-URL: Homepage, http://www.solentware.co.uk
23
+ Project-URL: Repository, https://github.com/RogerMarsh/chesscalc.git
24
+ Project-URL: Bug Tracker, https://github.com/RogerMarsh/chesscalc/issues
25
+ Classifier: License :: OSI Approved :: BSD License
26
+ Classifier: Programming Language :: Python :: 3.8
27
+ Classifier: Programming Language :: Python :: 3.9
28
+ Classifier: Programming Language :: Python :: 3.10
29
+ Classifier: Programming Language :: Python :: 3.11
30
+ Classifier: Operating System :: OS Independent
31
+ Classifier: Topic :: Games/Entertainment :: Board Games
32
+ Classifier: Intended Audience :: End Users/Desktop
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Development Status :: 3 - Alpha
35
+ License-File: LICENCE
36
+
37
+ =====================================================
38
+ Calculate player performances from chess game results
39
+ =====================================================
40
+
41
+ .. contents::
42
+
43
+
44
+ Description
45
+ ===========
46
+
47
+ This package provides methods to calculate player performances.
48
+
49
+ Calculate player performances from results of games imported from `PGN`_ format files.
50
+
51
+ Provide facilities to resolve player identities where inconsistencies exist in the PGN Tag Values for games involving the same player.
52
+
53
+ Provide facilties to resolve inconsistent identities, time controls or playing modes for example, derived from other PGN Tag Values.
54
+
55
+
56
+ Installation Instructions
57
+ =========================
58
+
59
+ This package is not available on PyPI, or any other package index, but can be installed by typing
60
+
61
+ python -m pip install --user --trusted-host solentware.co.uk --find-links http://solentware.co.uk/wheels.html chesscalc
62
+
63
+ at the command prompt.
64
+
65
+ See `Python`_ and `pip`_ documentation for alternatives and platform-specific points.
66
+
67
+ Then run 'python -m pip check' to identify other packages which need to be installed.
68
+
69
+
70
+ Run
71
+ ===
72
+
73
+ The command to run this package is:
74
+
75
+ python -m chesscalc.calculate
76
+
77
+ You may need to give the path and version of Python depending on your system's configuration:
78
+
79
+ <path to python>/python<version> -m chesscalc.calculate
80
+
81
+ For example
82
+
83
+ C:\\Python33\\python -m chesscalc.calculate
84
+
85
+ on Microsoft Windows or
86
+
87
+ python3.3 -m chesscalc.calculate
88
+
89
+ on Unix-like systems.
90
+
91
+ Or use the facilities of your desktop (Microsoft Windows, GNOME, KDE, ...) to set up a convenient way of starting calculate.
92
+
93
+
94
+ Notes
95
+ =====
96
+
97
+ ChessCalc makes no attempt to ease the problems arising from not using PGN Tags in the way envisaged in the PGN specification. For example:
98
+
99
+ Not using the WhiteType and BlackType tags to indicate human or algorithmic players.
100
+
101
+ Not using the TimeControl tag to indicate the time controls. This determines if the game is standard, rapid, or blitz (using English Chess Federation terms); or some other distinctions.
102
+
103
+ Not using the Mode tag to indicate Online or Over The Board play.
104
+
105
+ ChessCalc does use the WhiteTeam and BlackTeam tags which appear in PGN files published by `TWIC`_. At time of writing I have not seen these PGN tags elsewhere.
106
+
107
+ The legacy sub-package contains some of the implementation prior to version 2.0.0 but this will be removed in the future.
108
+
109
+
110
+ .. _Python: https://python.org
111
+ .. _pip: https://packaging.python.org/installing
112
+ .. _PGN: https://www.chessclub.com/help/PGN-spec
113
+ .. _TWIC: https://theweekinchess.com
chesscalc-2.0.0/README ADDED
@@ -0,0 +1,77 @@
1
+ =====================================================
2
+ Calculate player performances from chess game results
3
+ =====================================================
4
+
5
+ .. contents::
6
+
7
+
8
+ Description
9
+ ===========
10
+
11
+ This package provides methods to calculate player performances.
12
+
13
+ Calculate player performances from results of games imported from `PGN`_ format files.
14
+
15
+ Provide facilities to resolve player identities where inconsistencies exist in the PGN Tag Values for games involving the same player.
16
+
17
+ Provide facilties to resolve inconsistent identities, time controls or playing modes for example, derived from other PGN Tag Values.
18
+
19
+
20
+ Installation Instructions
21
+ =========================
22
+
23
+ This package is not available on PyPI, or any other package index, but can be installed by typing
24
+
25
+ python -m pip install --user --trusted-host solentware.co.uk --find-links http://solentware.co.uk/wheels.html chesscalc
26
+
27
+ at the command prompt.
28
+
29
+ See `Python`_ and `pip`_ documentation for alternatives and platform-specific points.
30
+
31
+ Then run 'python -m pip check' to identify other packages which need to be installed.
32
+
33
+
34
+ Run
35
+ ===
36
+
37
+ The command to run this package is:
38
+
39
+ python -m chesscalc.calculate
40
+
41
+ You may need to give the path and version of Python depending on your system's configuration:
42
+
43
+ <path to python>/python<version> -m chesscalc.calculate
44
+
45
+ For example
46
+
47
+ C:\\Python33\\python -m chesscalc.calculate
48
+
49
+ on Microsoft Windows or
50
+
51
+ python3.3 -m chesscalc.calculate
52
+
53
+ on Unix-like systems.
54
+
55
+ Or use the facilities of your desktop (Microsoft Windows, GNOME, KDE, ...) to set up a convenient way of starting calculate.
56
+
57
+
58
+ Notes
59
+ =====
60
+
61
+ ChessCalc makes no attempt to ease the problems arising from not using PGN Tags in the way envisaged in the PGN specification. For example:
62
+
63
+ Not using the WhiteType and BlackType tags to indicate human or algorithmic players.
64
+
65
+ Not using the TimeControl tag to indicate the time controls. This determines if the game is standard, rapid, or blitz (using English Chess Federation terms); or some other distinctions.
66
+
67
+ Not using the Mode tag to indicate Online or Over The Board play.
68
+
69
+ ChessCalc does use the WhiteTeam and BlackTeam tags which appear in PGN files published by `TWIC`_. At time of writing I have not seen these PGN tags elsewhere.
70
+
71
+ The legacy sub-package contains some of the implementation prior to version 2.0.0 but this will be removed in the future.
72
+
73
+
74
+ .. _Python: https://python.org
75
+ .. _pip: https://packaging.python.org/installing
76
+ .. _PGN: https://www.chessclub.com/help/PGN-spec
77
+ .. _TWIC: https://theweekinchess.com
@@ -0,0 +1,71 @@
1
+ # __init__.py
2
+ # Copyright 2008 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Calculate player's performances on a set of games.
6
+
7
+ Performances are calculated by iteration where each player starts with 0 as
8
+ their performance. The scale used is +50 for a win, -50 for a loss, and 0 for
9
+ a draw, relative to the opponents performance. English Chess Federation (ECF)
10
+ grades have the same scale.
11
+
12
+ The performances are not grades because the results of calculations in previous
13
+ runs are not used in this calculation.
14
+
15
+ """
16
+ import os
17
+ import datetime
18
+ import traceback
19
+
20
+ import solentware_base.core.constants as sb_c_constants
21
+
22
+ APPLICATION_NAME = "ChessPerfCalc"
23
+ ERROR_LOG = "ErrorLog"
24
+ REPORT_DIRECTORY = "_reports"
25
+
26
+ # Map database module names to application module
27
+ APPLICATION_DATABASE_MODULE = {
28
+ sb_c_constants.BERKELEYDB_MODULE: __name__ + ".berkeleydb.database",
29
+ sb_c_constants.BSDDB3_MODULE: __name__ + ".db.database",
30
+ sb_c_constants.SQLITE3_MODULE: __name__ + ".sqlite.database",
31
+ sb_c_constants.APSW_MODULE: __name__ + ".apsw.database",
32
+ sb_c_constants.DPT_MODULE: __name__ + ".dpt.database",
33
+ sb_c_constants.UNQLITE_MODULE: __name__ + ".unqlite.database",
34
+ sb_c_constants.VEDIS_MODULE: __name__ + ".vedis.database",
35
+ sb_c_constants.DB_TCL_MODULE: __name__ + ".db_tkinter.database",
36
+ sb_c_constants.LMDB_MODULE: __name__ + ".lmdb.database",
37
+ }
38
+
39
+ del sb_c_constants
40
+
41
+
42
+ def write_error_to_log(directory):
43
+ """Write the exception to the error log with a time stamp.
44
+
45
+ Consider using the ExceptionHandler.report_exception(...) method if
46
+ the write_error_to_log() call is in an instance of a subclass of the
47
+ solentware_bind.gui.exceptionhandler.ExceptionHandler class.
48
+
49
+ """
50
+ with open(
51
+ os.path.join(directory, ERROR_LOG),
52
+ "a",
53
+ encoding="utf-8",
54
+ ) as file:
55
+ file.write(
56
+ "".join(
57
+ (
58
+ "\n\n\n",
59
+ " ".join(
60
+ (
61
+ APPLICATION_NAME,
62
+ "exception report at",
63
+ datetime.datetime.now().isoformat(),
64
+ )
65
+ ),
66
+ "\n\n",
67
+ traceback.format_exc(),
68
+ "\n\n",
69
+ )
70
+ )
71
+ )
@@ -0,0 +1,5 @@
1
+ # __init__.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Identify apsw as a sub-package in chesscalc."""
@@ -0,0 +1,46 @@
1
+ # database.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Chess Performance Calculation database using Sqlite3 via apsw."""
6
+
7
+ from solentware_base import apsw_database
8
+
9
+ from ..core.filespec import FileSpec
10
+ from ..basecore import database
11
+
12
+
13
+ class Database(database.Database, apsw_database.Database):
14
+ """Methods and data structures to create, open, and close database."""
15
+
16
+ _deferred_update_process = "chesscalc.apsw.database_du"
17
+
18
+ def __init__(
19
+ self,
20
+ sqlite3file,
21
+ use_specification_items=None,
22
+ dpt_records=None,
23
+ **kargs,
24
+ ):
25
+ """Define database specification then delegate."""
26
+ names = FileSpec(
27
+ use_specification_items=use_specification_items,
28
+ dpt_records=dpt_records,
29
+ )
30
+
31
+ super().__init__(
32
+ names,
33
+ sqlite3file,
34
+ use_specification_items=use_specification_items,
35
+ **kargs,
36
+ )
37
+
38
+ def delete_database(self):
39
+ """Close and delete the open chess results database."""
40
+ return super().delete_database(
41
+ (
42
+ self.database_file,
43
+ "-".join((self.database_file, "lock")),
44
+ "-".join((self.database_file, "journal")),
45
+ )
46
+ )
@@ -0,0 +1,35 @@
1
+ # database_du.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Chess performance database deferred update using Sqlite 3 via apsw."""
6
+
7
+ from solentware_base import apswdu_database
8
+ from solentware_base import apsw_database
9
+
10
+ from ..shared import litedu
11
+ from ..shared import alldu
12
+
13
+
14
+ class ApswDatabaseduError(Exception):
15
+ """Exception class for apsw.database_du module."""
16
+
17
+
18
+ class Database(alldu.Alldu, litedu.Litedu, apswdu_database.Database):
19
+ """Provide custom deferred update for chess performance database."""
20
+
21
+ def __init__(self, sqlite3file, **kargs):
22
+ """Delegate with ApswDatabaseduError as exception class."""
23
+ super().__init__(sqlite3file, ApswDatabaseduError, **kargs)
24
+
25
+
26
+ class DatabaseSU(alldu.Alldu, litedu.Litedu, apsw_database.Database):
27
+ """Provide custom deferred update for chess performance database."""
28
+
29
+ def __init__(self, sqlite3file, **kargs):
30
+ """Delegate with ApswDatabaseduError as exception class."""
31
+ super().__init__(sqlite3file, ApswDatabaseduError, **kargs)
32
+
33
+ # Class structure implies this is not an override at present.
34
+ def deferred_update_housekeeping(self):
35
+ """Override to do nothing."""
@@ -0,0 +1,5 @@
1
+ # __init__.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Identify basecore as a sub-package in chesscalc."""
@@ -0,0 +1,66 @@
1
+ # database.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Database methods common to all database engine interfaces."""
6
+
7
+ import os
8
+ import shutil
9
+
10
+ from .. import APPLICATION_NAME, ERROR_LOG, REPORT_DIRECTORY
11
+
12
+
13
+ class Database:
14
+ """Provide methods common to all database engine interfaces."""
15
+
16
+ # Non *_du database actions are done in separate threads by default,
17
+ # not the main thread. Override with 'can_use_thread = False' in
18
+ # subclasses if necessary.
19
+ # For SQLite3 the apsw interface is happy with the default, but the
20
+ # sqlite3 interface gives a sqlite3.programmingerror exception.
21
+ # For Berkeley DB the bsddb3 and berkeleydb interfaces are happy with
22
+ # the default, but the tcl via tkinter interface gives a RuntimeError
23
+ # exception.
24
+ can_use_thread = True
25
+
26
+ def use_deferred_update_process(self):
27
+ """Return path to deferred update module."""
28
+ return self._deferred_update_process
29
+
30
+ def open_database(self, files=None):
31
+ """Return '' to fit behaviour of dpt version of this method."""
32
+ super().open_database(files=files)
33
+ return ""
34
+
35
+ def delete_database(self, names):
36
+ """Delete database and return message about items not deleted."""
37
+ listnames = set(n for n in os.listdir(self.home_directory))
38
+ homenames = set(n for n in names if os.path.basename(n) in listnames)
39
+ for name in (ERROR_LOG, REPORT_DIRECTORY):
40
+ if name in listnames:
41
+ homenames.add(name)
42
+ if len(listnames - set(os.path.basename(h) for h in homenames)):
43
+ message = "".join(
44
+ (
45
+ "There is at least one file or folder in\n\n",
46
+ self.home_directory,
47
+ "\n\nwhich may not be part of the database. These items ",
48
+ "have not been deleted by ",
49
+ APPLICATION_NAME,
50
+ ".",
51
+ )
52
+ )
53
+ else:
54
+ message = None
55
+ self.close_database()
56
+ for hnm in homenames:
57
+ hnm = os.path.join(self.home_directory, hnm)
58
+ if os.path.isdir(hnm):
59
+ shutil.rmtree(hnm, ignore_errors=True)
60
+ else:
61
+ os.remove(hnm)
62
+ try:
63
+ os.rmdir(self.home_directory)
64
+ except (FileNotFoundError, OSError):
65
+ pass
66
+ return message
@@ -0,0 +1,5 @@
1
+ # __init__.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Identify berkeleydb as a sub-package in chesscalc."""
@@ -0,0 +1,73 @@
1
+ # database.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Chess Performance Calculation database using Berkeley DB via berkeleydb."""
6
+
7
+ from berkeleydb.db import (
8
+ # DB_BTREE,
9
+ # DB_HASH,
10
+ # DB_RECNO,
11
+ # DB_DUPSORT,
12
+ DB_CREATE,
13
+ DB_RECOVER,
14
+ DB_INIT_MPOOL,
15
+ DB_INIT_LOCK,
16
+ DB_INIT_LOG,
17
+ DB_INIT_TXN,
18
+ DB_PRIVATE,
19
+ )
20
+
21
+ from solentware_base import berkeleydb_database
22
+
23
+ from ..core.filespec import FileSpec
24
+ from ..basecore import database
25
+
26
+
27
+ class Database(database.Database, berkeleydb_database.Database):
28
+ """Methods and data structures to create, open, and close database."""
29
+
30
+ _deferred_update_process = "chesscalc.berkeleydb.database_du"
31
+
32
+ def __init__(
33
+ self,
34
+ DBfile,
35
+ use_specification_items=None,
36
+ dpt_records=None,
37
+ **kargs,
38
+ ):
39
+ """Define database specification and environment then delegate."""
40
+ dbnames = FileSpec(
41
+ use_specification_items=use_specification_items,
42
+ dpt_records=dpt_records,
43
+ )
44
+
45
+ environment = {
46
+ "flags": (
47
+ DB_CREATE
48
+ | DB_RECOVER
49
+ | DB_INIT_MPOOL
50
+ | DB_INIT_LOCK
51
+ | DB_INIT_LOG
52
+ | DB_INIT_TXN
53
+ | DB_PRIVATE
54
+ ),
55
+ }
56
+
57
+ super().__init__(
58
+ dbnames,
59
+ DBfile,
60
+ environment,
61
+ use_specification_items=use_specification_items,
62
+ **kargs,
63
+ )
64
+
65
+ def delete_database(self):
66
+ """Close and delete the open chess results database."""
67
+ return super().delete_database(
68
+ (
69
+ self.database_file,
70
+ "-".join((self.database_file, "lock")),
71
+ self.dbenv.get_lg_dir().decode(),
72
+ )
73
+ )
@@ -0,0 +1,63 @@
1
+ # database_du.py
2
+ # Copyright 2023 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Chess performance deferred update using Berkeley DB via berkeleydb."""
6
+
7
+ import berkeleydb.db
8
+
9
+ from solentware_base import berkeleydbdu_database
10
+ from solentware_base import berkeleydb_database
11
+
12
+ from ..shared import dbdu
13
+ from ..shared import alldu
14
+
15
+
16
+ class BerkeleydbDatabaseduError(Exception):
17
+ """Exception class for berkeleydb.database_du module."""
18
+
19
+
20
+ class Database(alldu.Alldu, dbdu.Dbdu, berkeleydbdu_database.Database):
21
+ """Provide custom deferred update for chess performance database."""
22
+
23
+ def __init__(self, DBfile, **kargs):
24
+ """Delegate with BerkeleydbDatabaseduError as exception class."""
25
+ super().__init__(
26
+ DBfile,
27
+ BerkeleydbDatabaseduError,
28
+ (
29
+ berkeleydb.db.DB_CREATE
30
+ | berkeleydb.db.DB_RECOVER
31
+ | berkeleydb.db.DB_INIT_MPOOL
32
+ | berkeleydb.db.DB_INIT_LOCK
33
+ | berkeleydb.db.DB_INIT_LOG
34
+ | berkeleydb.db.DB_INIT_TXN
35
+ | berkeleydb.db.DB_PRIVATE
36
+ ),
37
+ **kargs
38
+ )
39
+
40
+
41
+ class DatabaseSU(alldu.Alldu, dbdu.Dbdu, berkeleydb_database.Database):
42
+ """Provide custom deferred update for chess performance database."""
43
+
44
+ def __init__(self, DBfile, **kargs):
45
+ """Delegate with BerkeleydbDatabaseduError as exception class."""
46
+ super().__init__(
47
+ DBfile,
48
+ BerkeleydbDatabaseduError,
49
+ (
50
+ berkeleydb.db.DB_CREATE
51
+ | berkeleydb.db.DB_RECOVER
52
+ | berkeleydb.db.DB_INIT_MPOOL
53
+ | berkeleydb.db.DB_INIT_LOCK
54
+ | berkeleydb.db.DB_INIT_LOG
55
+ | berkeleydb.db.DB_INIT_TXN
56
+ | berkeleydb.db.DB_PRIVATE
57
+ ),
58
+ **kargs
59
+ )
60
+
61
+ # Class structure implies this is not an override at present.
62
+ def deferred_update_housekeeping(self):
63
+ """Override to do nothing."""
@@ -0,0 +1,79 @@
1
+ # calculate.py
2
+ # Copyright 2012 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Calculate performances from a file of chess game results."""
6
+
7
+ if __name__ == "__main__":
8
+ import multiprocessing
9
+
10
+ from . import APPLICATION_NAME
11
+
12
+ multiprocessing.set_start_method("spawn")
13
+ del multiprocessing
14
+
15
+ try:
16
+ from solentware_misc.gui.startstop import (
17
+ start_application_exception,
18
+ stop_application,
19
+ application_exception,
20
+ )
21
+ except Exception as error:
22
+ import tkinter.messagebox
23
+
24
+ try:
25
+ tkinter.messagebox.showerror(
26
+ title="Start Exception",
27
+ message=".\n\nThe reported exception is:\n\n".join(
28
+ (
29
+ " ".join(
30
+ (
31
+ "Unable to import",
32
+ "solentware_misc.gui.startstop module",
33
+ )
34
+ ),
35
+ str(error),
36
+ )
37
+ ),
38
+ )
39
+ except tkinter.TclError:
40
+ pass
41
+ raise SystemExit(
42
+ "Unable to import start application utilities"
43
+ ) from error
44
+ try:
45
+ from .gui.calculator import Calculator
46
+ except Exception as error:
47
+ start_application_exception(
48
+ error, appname=APPLICATION_NAME, action="import"
49
+ )
50
+ raise SystemExit(
51
+ " import ".join(("Unable to", APPLICATION_NAME))
52
+ ) from error
53
+ try:
54
+ app = Calculator()
55
+ except Exception as error:
56
+ start_application_exception(
57
+ error, appname=APPLICATION_NAME, action="initialise"
58
+ )
59
+ raise SystemExit(
60
+ " initialise ".join(("Unable to", APPLICATION_NAME))
61
+ ) from error
62
+ try:
63
+ app.widget.mainloop()
64
+ except SystemExit:
65
+ stop_application(app, app.widget)
66
+ raise
67
+ except Exception as error:
68
+ application_exception(
69
+ error,
70
+ app,
71
+ app.widget,
72
+ title="Chess Performace Calculator",
73
+ appname=APPLICATION_NAME,
74
+ )
75
+ raise SystemExit(
76
+ " reporting exception in ".join(
77
+ ("Exception while", APPLICATION_NAME)
78
+ )
79
+ ) from error
@@ -0,0 +1,5 @@
1
+ # __init__.py
2
+ # Copyright 2009 Roger Marsh
3
+ # Licence: See LICENCE (BSD licence)
4
+
5
+ """Identify core as a sub-package in chesscalc."""