Skip to content

Commit

Permalink
fix BOM markers and carriage returns
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicprice committed Jan 29, 2023
1 parent da4a76a commit c1c5449
Show file tree
Hide file tree
Showing 23 changed files with 824 additions and 824 deletions.
186 changes: 93 additions & 93 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
cmake_minimum_required(VERSION 3.13)
project(endplay)

# Global settings
# ===============

if (NOT CMAKE_BUILD_TYPE)
message(WARNING "CMAKE_BUILD_TYPE not specified; defaulting to 'Release'")
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)

set(ENDPLAY_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/endplay")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" ENDPLAY_VERSION)
string(REGEX REPLACE "\n$" "" ENDPLAY_VERSION "${ENDPLAY_VERSION}")
string(TIMESTAMP ENDPLAY_BUILD_TIME)

# Detect compiler
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CC_CLANG 1)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CC_GCC 1)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CC_MSVC 1)
else()
message(WARNING "The compiler you are using hasn't been tested for building this library.")
endif()

# Pretend to use SETUPTOOLS_BUILD variable to stop it complaining
if (SETUPTOOLS_BUILD)
message(STATUS "Call to CMake was invocated by setuptools")
endif()

if (COMPILE_32_BITS)
add_compile_options("-m32")
add_link_options("-m32")
endif()

# Configure config.py with version number
# =======================================
configure_file("${ENDPLAY_ROOT_DIR}/config.py.in" "config.py" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/config.py" DESTINATION "endplay")


# _dds library
# ============

# Compile the source files for the DDS library together into a shared library file
set(DDS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs/dds/")
set(DDS_SOURCE
dds.cpp dump.cpp ABsearch.cpp
ABstats.cpp CalcTables.cpp DealerPar.cpp
File.cpp Init.cpp LaterTricks.cpp
Memory.cpp Moves.cpp Par.cpp
PlayAnalyser.cpp PBN.cpp QuickTricks.cpp
Scheduler.cpp SolveBoard.cpp SolverIF.cpp
System.cpp ThreadMgr.cpp Timer.cpp
TimerGroup.cpp TimerList.cpp TimeStat.cpp
TimeStatList.cpp TransTableS.cpp TransTableL.cpp)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DDS_SOURCE ${DDS_SOURCE} exports.def dds.rc)
endif()
list(TRANSFORM DDS_SOURCE PREPEND "${DDS_ROOT_DIR}/src/")

add_library(dds SHARED ${DDS_SOURCE})
target_compile_definitions(dds PRIVATE "DDS_THREADS_STL")
target_include_directories(dds PRIVATE "${DDS_ROOT_DIR}/src")
# Compiler specific flags
if (CC_GCC)
target_compile_options(dds PRIVATE "-Wno-format-overflow")
elseif (CC_MSVC)
target_compile_definitions(dds PRIVATE "_CRT_SECURE_NO_WARNINGS")
target_compile_options(dds PRIVATE "/wd4267")
endif()

# Copy some macro definitions from the c header file into the
# __init__.py for the package
file(READ "${DDS_ROOT_DIR}/include/dll.h" DDS_DLL_H)
string(REGEX MATCH "#define MAXNOOFBOARDS [0-9]+" DDS_MAXNOOFBOARDS "${DDS_DLL_H}")
string(REGEX MATCH "[0-9]+" DDS_MAXNOOFBOARDS "${DDS_MAXNOOFBOARDS}")
string(REGEX MATCH "#define MAXNOOFTABLES [0-9]+" DDS_MAXNOOFTABLES "${DDS_DLL_H}")
string(REGEX MATCH "[0-9]+" DDS_MAXNOOFTABLES "${DDS_MAXNOOFTABLES}")
set(DDS_LIBRARY_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}dds${CMAKE_SHARED_LIBRARY_SUFFIX}")
configure_file("${ENDPLAY_ROOT_DIR}/_dds/__init__.py.in" "_dds/__init__.py" @ONLY)

# Install both bits into the right places in the package
if (CC_MSVC)
# .dll is a runtime component
install(TARGETS dds RUNTIME DESTINATION "endplay/_dds")
else()
install(TARGETS dds DESTINATION "endplay/_dds")
endif()

cmake_minimum_required(VERSION 3.13)
project(endplay)

# Global settings
# ===============

if (NOT CMAKE_BUILD_TYPE)
message(WARNING "CMAKE_BUILD_TYPE not specified; defaulting to 'Release'")
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)

set(ENDPLAY_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/endplay")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" ENDPLAY_VERSION)
string(REGEX REPLACE "\n$" "" ENDPLAY_VERSION "${ENDPLAY_VERSION}")
string(TIMESTAMP ENDPLAY_BUILD_TIME)

# Detect compiler
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CC_CLANG 1)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CC_GCC 1)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CC_MSVC 1)
else()
message(WARNING "The compiler you are using hasn't been tested for building this library.")
endif()

# Pretend to use SETUPTOOLS_BUILD variable to stop it complaining
if (SETUPTOOLS_BUILD)
message(STATUS "Call to CMake was invocated by setuptools")
endif()

if (COMPILE_32_BITS)
add_compile_options("-m32")
add_link_options("-m32")
endif()

# Configure config.py with version number
# =======================================
configure_file("${ENDPLAY_ROOT_DIR}/config.py.in" "config.py" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/config.py" DESTINATION "endplay")


# _dds library
# ============

# Compile the source files for the DDS library together into a shared library file
set(DDS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs/dds/")
set(DDS_SOURCE
dds.cpp dump.cpp ABsearch.cpp
ABstats.cpp CalcTables.cpp DealerPar.cpp
File.cpp Init.cpp LaterTricks.cpp
Memory.cpp Moves.cpp Par.cpp
PlayAnalyser.cpp PBN.cpp QuickTricks.cpp
Scheduler.cpp SolveBoard.cpp SolverIF.cpp
System.cpp ThreadMgr.cpp Timer.cpp
TimerGroup.cpp TimerList.cpp TimeStat.cpp
TimeStatList.cpp TransTableS.cpp TransTableL.cpp)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DDS_SOURCE ${DDS_SOURCE} exports.def dds.rc)
endif()
list(TRANSFORM DDS_SOURCE PREPEND "${DDS_ROOT_DIR}/src/")

add_library(dds SHARED ${DDS_SOURCE})
target_compile_definitions(dds PRIVATE "DDS_THREADS_STL")
target_include_directories(dds PRIVATE "${DDS_ROOT_DIR}/src")
# Compiler specific flags
if (CC_GCC)
target_compile_options(dds PRIVATE "-Wno-format-overflow")
elseif (CC_MSVC)
target_compile_definitions(dds PRIVATE "_CRT_SECURE_NO_WARNINGS")
target_compile_options(dds PRIVATE "/wd4267")
endif()

# Copy some macro definitions from the c header file into the
# __init__.py for the package
file(READ "${DDS_ROOT_DIR}/include/dll.h" DDS_DLL_H)
string(REGEX MATCH "#define MAXNOOFBOARDS [0-9]+" DDS_MAXNOOFBOARDS "${DDS_DLL_H}")
string(REGEX MATCH "[0-9]+" DDS_MAXNOOFBOARDS "${DDS_MAXNOOFBOARDS}")
string(REGEX MATCH "#define MAXNOOFTABLES [0-9]+" DDS_MAXNOOFTABLES "${DDS_DLL_H}")
string(REGEX MATCH "[0-9]+" DDS_MAXNOOFTABLES "${DDS_MAXNOOFTABLES}")
set(DDS_LIBRARY_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}dds${CMAKE_SHARED_LIBRARY_SUFFIX}")
configure_file("${ENDPLAY_ROOT_DIR}/_dds/__init__.py.in" "_dds/__init__.py" @ONLY)

# Install both bits into the right places in the package
if (CC_MSVC)
# .dll is a runtime component
install(TARGETS dds RUNTIME DESTINATION "endplay/_dds")
else()
install(TARGETS dds DESTINATION "endplay/_dds")
endif()

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_dds/__init__.py" DESTINATION "endplay/_dds/")
28 changes: 14 additions & 14 deletions src/endplay/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Endplay - A bridge tools library with generating, analysing and scoring.
Released under the MIT licence (see the LICENCE file provided with this distribution)
"""

import endplay._dds as _dds
from endplay.dds import *
from endplay.dealer import *
from endplay.interact import *
from endplay.parsers import *
from endplay.evaluate import *
from endplay.types import *
from endplay.config import \
__version__, __version_info__, __author__, \
"""
Endplay - A bridge tools library with generating, analysing and scoring.
Released under the MIT licence (see the LICENCE file provided with this distribution)
"""

import endplay._dds as _dds
from endplay.dds import *
from endplay.dealer import *
from endplay.interact import *
from endplay.parsers import *
from endplay.evaluate import *
from endplay.types import *
from endplay.config import \
__version__, __version_info__, __author__, \
__buildtime__, suppress_unicode
92 changes: 46 additions & 46 deletions src/endplay/config.py.in
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
"""
Configuration and versioning information
"""
__all__ = ["__version__", "__version_info__", "__author__", "use_unicode", "suppress_unicode"]
from contextlib import ContextDecorator
# Packages metadata, used by setuptools etc
__version__ = """@ENDPLAY_VERSION@""".strip()
"""Version of the library as a string"""
__version_info__ = tuple(int(i) if i.isdigit() else i for i in __version__.replace("-", ".").split("."))
"""Version of the library as a tuple of integers"""
__author__ = "Dominic Price"
"""Author of the library"""
__buildtime__ = """@ENDPLAY_BUILD_TIME@""".strip()
use_unicode = True
"""If set to False, the library will only print characters in the ASCII range"""
class suppress_unicode(ContextDecorator):
"""
Context manager to temporarily ensure that unicode output is turned off,
for example when writing to a file which expects suit symbols to be
SDHC.
Example usage::
print(Denom.hearts.abbr) # prints ♥ (assuming config.use_unicode=True)
with suppress_unicode():
print(Denom.hearts.abbr) # prints H
print(Denom.hearts.abbr) # prints ♥
"""
def __enter__(self):
global use_unicode
self.use_unicode = use_unicode
use_unicode = False
return self
def __exit__(self, *exc):
global use_unicode
use_unicode = self.use_unicode
return False
"""
Configuration and versioning information
"""

__all__ = ["__version__", "__version_info__", "__author__", "use_unicode", "suppress_unicode"]

from contextlib import ContextDecorator

# Packages metadata, used by setuptools etc
__version__ = """@ENDPLAY_VERSION@""".strip()
"""Version of the library as a string"""

__version_info__ = tuple(int(i) if i.isdigit() else i for i in __version__.replace("-", ".").split("."))
"""Version of the library as a tuple of integers"""

__author__ = "Dominic Price"
"""Author of the library"""

__buildtime__ = """@ENDPLAY_BUILD_TIME@""".strip()

use_unicode = True
"""If set to False, the library will only print characters in the ASCII range"""

class suppress_unicode(ContextDecorator):
"""
Context manager to temporarily ensure that unicode output is turned off,
for example when writing to a file which expects suit symbols to be
SDHC.

Example usage::

print(Denom.hearts.abbr) # prints ♥ (assuming config.use_unicode=True)
with suppress_unicode():
print(Denom.hearts.abbr) # prints H
print(Denom.hearts.abbr) # prints ♥
"""
def __enter__(self):
global use_unicode
self.use_unicode = use_unicode
use_unicode = False
return self

def __exit__(self, *exc):
global use_unicode
use_unicode = self.use_unicode
return False
34 changes: 17 additions & 17 deletions src/endplay/dds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""
Higher-level wrappers around Bo Haglund's dds wrapper, using the
Python types defined in `endplay.types` and which use sensible
defaults for the internal state such as threading indexes.
"""

__all__ = [
'solve_board', 'solve_all_boards', 'calc_dd_table',
'calc_all_tables', 'analyse_play', 'analyse_all_plays', 'par',
'analyse_start', 'analyse_all_starts'
]

import endplay._dds as _dds
from endplay.dds.solve import solve_board, solve_all_boards
from endplay.dds.ddtable import calc_dd_table, calc_all_tables
from endplay.dds.analyse import analyse_play, analyse_all_plays, analyse_start, analyse_all_starts
from endplay.dds.parscore import par
"""
Higher-level wrappers around Bo Haglund's dds wrapper, using the
Python types defined in `endplay.types` and which use sensible
defaults for the internal state such as threading indexes.
"""

__all__ = [
'solve_board', 'solve_all_boards', 'calc_dd_table',
'calc_all_tables', 'analyse_play', 'analyse_all_plays', 'par',
'analyse_start', 'analyse_all_starts'
]

import endplay._dds as _dds
from endplay.dds.solve import solve_board, solve_all_boards
from endplay.dds.ddtable import calc_dd_table, calc_all_tables
from endplay.dds.analyse import analyse_play, analyse_all_plays, analyse_start, analyse_all_starts
from endplay.dds.parscore import par
2 changes: 1 addition & 1 deletion src/endplay/dds/analyse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
Analysis functions from the DDS library, which calculate the double dummy
number of tricks available given a play history.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dds/parscore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
Par contract and scoring function
"""

Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dds/solve.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
Solving functions from the DDS library, which calculate the double dummy
results for playing each card in a player's hand.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dealer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
The endplay.dealer program is a reimplementation of Hans van Staveren's dealer program
which can be used to generate hands for partnerships bidding training or for
generating statistics that can be used to design conventions, or win postmortems.
Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dealer/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
The Actions classes provide a common interface for producing different
types of output from a dealer script. When a script is run, an appropriate
Actions object is constructed, and any time output is requested one of the
Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dealer/actions/latex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
Actions class for producing LaTeX output.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dealer/actions/terminal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
Actions class for producing plaintext output.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/endplay/dealer/constraint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
Engine for converting dealer-syntax expressions into evaluatable
Python functions. You should not need to use this directly unless
you are developing your own functions, as most functions accept
Expand Down
Loading

0 comments on commit c1c5449

Please sign in to comment.