Skip to content

Commit

Permalink
LOCALE_US and LOCALE_FR are gathered in a new mathmakerlib/constants.…
Browse files Browse the repository at this point in the history
…py module.
  • Loading branch information
nicolashainaux committed Jun 20, 2018
1 parent 3c95b30 commit 4ddbf08
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions mathmakerlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

from . import required, exceptions, config
from . import required, exceptions, config, constants
from . import locale_patch, calculus, core, geometry, LaTeX

__all__ = ['required', 'config', 'LaTeX', 'exceptions',
__all__ = ['required', 'config', 'LaTeX', 'exceptions', 'constants',
'locale_patch', 'core', 'calculus', 'geometry']

__version_info__ = (0, 7, 0)
Expand Down
25 changes: 25 additions & 0 deletions mathmakerlib/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-

# Mathmaker Lib offers lualatex-printable mathematical objects.
# Copyright 2006-2017 Nicolas Hainaux <nh.techn@gmail.com>

# This file is part of Mathmaker Lib.

# Mathmaker Lib is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.

# Mathmaker Lib is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
LOCALE_FR = 'fr' if sys.platform.startswith('win') else 'fr_FR.UTF-8'
3 changes: 1 addition & 2 deletions mathmakerlib/geometry/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys
from math import atan2, degrees

from mathmakerlib import required, config
Expand All @@ -36,8 +35,8 @@
from mathmakerlib.geometry.vector import Vector
from mathmakerlib.geometry.bipoint import Bipoint
from mathmakerlib.calculus.number import Number, is_number
from mathmakerlib.constants import LOCALE_US

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
AVAILABLE_NAMING_MODES = ['from_endpoints', 'from_armspoints', 'from_vertex']


Expand Down
5 changes: 1 addition & 4 deletions tests/02_core/locale_patch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys
import locale
import pytest

from mathmakerlib import locale_patch

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
LOCALE_FR = 'fr' if sys.platform.startswith('win') else 'fr_FR.UTF-8'
from mathmakerlib.constants import LOCALE_US, LOCALE_FR


def test_errors():
Expand Down
5 changes: 1 addition & 4 deletions tests/03_calculus/04_number_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys
import locale
import pytest
from copy import copy, deepcopy
Expand All @@ -31,9 +30,7 @@
from mathmakerlib.calculus import move_fracdigits_to
from mathmakerlib.calculus import remove_fracdigits_from
from mathmakerlib.calculus import fix_fracdigits

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
LOCALE_FR = 'fr' if sys.platform.startswith('win') else 'fr_FR.UTF-8'
from mathmakerlib.constants import LOCALE_US, LOCALE_FR


def test_Number_inheritance():
Expand Down
5 changes: 1 addition & 4 deletions tests/04_geometry/10_polygon_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys
import locale
import pytest

from mathmakerlib import required, config
from mathmakerlib.calculus import Number
from mathmakerlib.geometry import Point, Polygon, AngleDecoration
from mathmakerlib.geometry import shoelace_formula

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
LOCALE_FR = 'fr' if sys.platform.startswith('win') else 'fr_FR.UTF-8'
from mathmakerlib.constants import LOCALE_US, LOCALE_FR


@pytest.fixture()
Expand Down
5 changes: 1 addition & 4 deletions tests/04_geometry/11_triangle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys
import locale
import pytest

from mathmakerlib.calculus import Number
from mathmakerlib.geometry import Point, Triangle, AngleDecoration

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
LOCALE_FR = 'fr' if sys.platform.startswith('win') else 'fr_FR.UTF-8'
from mathmakerlib.constants import LOCALE_US, LOCALE_FR


def test_instanciation_errors():
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sys
import locale

LOCALE_US = 'en' if sys.platform.startswith('win') else 'en_US.UTF-8'
from mathmakerlib.constants import LOCALE_US

locale.setlocale(locale.LC_ALL, locale=LOCALE_US)

0 comments on commit 4ddbf08

Please sign in to comment.