From 415bed31e1b095824b49e9f09a597c23b80fb057 Mon Sep 17 00:00:00 2001 From: mmolenda Date: Tue, 28 Jul 2020 14:05:46 +0200 Subject: [PATCH] Fixing imports (#93) Fixing imports --- .github/workflows/python-app.yml | 2 ++ missal1962/apiv3.py | 14 +++++----- missal1962/app.py | 10 +++---- missal1962/cli.py | 6 ++--- missal1962/constants/__init__.py | 4 +-- missal1962/constants/la/blocks.py | 2 +- missal1962/constants/la/translation.py | 2 +- missal1962/constants/pl/translation.py | 2 +- missal1962/controller.py | 12 ++++----- missal1962/ical.py | 2 +- missal1962/kalendar/factory.py | 8 +++--- missal1962/kalendar/models.py | 32 +++++++++++------------ missal1962/kalendar/rules.py | 36 +++++++++++++------------- missal1962/propers/models.py | 4 +-- missal1962/propers/parser.py | 24 ++++++++--------- missal1962/utils.py | 4 +-- missal1962/views.py | 12 ++++----- tests/conftest.py | 6 ++--- tests/test_apiv3.py | 2 +- tests/test_calendar.py | 6 ++--- tests/test_propers.py | 12 ++++----- 21 files changed, 102 insertions(+), 100 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index da8e6ab3..266b0be1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -20,6 +20,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 + - name: Set PYTHONPATH + run: echo '::set-env name=PYTHONPATH::/home/runner/work/Missal1962/Missal1962/missal1962' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/missal1962/apiv3.py b/missal1962/apiv3.py index 9c83f742..b38a8ae4 100644 --- a/missal1962/apiv3.py +++ b/missal1962/apiv3.py @@ -8,13 +8,13 @@ from flask import jsonify, Blueprint -from missal1962 import __version__ -from missal1962 import controller -from missal1962.constants import TRANSLATION -from missal1962.constants.common import LANGUAGES, LANGUAGE_ENGLISH -from missal1962.exceptions import InvalidInput, ProperNotFound, SupplementNotFound, SectionNotFound -from missal1962.kalendar.models import Day, Calendar -from missal1962.utils import format_day_propers, get_supplement, format_proper_sections, get_pregenerated_proper +import __version__ +import controller +from constants import TRANSLATION +from constants.common import LANGUAGES, LANGUAGE_ENGLISH +from exceptions import InvalidInput, ProperNotFound, SupplementNotFound, SectionNotFound +from kalendar.models import Day, Calendar +from utils import format_day_propers, get_supplement, format_proper_sections, get_pregenerated_proper logging.basicConfig( stream=sys.stdout, diff --git a/missal1962/app.py b/missal1962/app.py index 29cfc916..5457f731 100644 --- a/missal1962/app.py +++ b/missal1962/app.py @@ -5,11 +5,11 @@ from flask_babel import Babel from werkzeug.routing import BaseConverter, ValidationError -from missal1962.__version__ import __version__ -from missal1962.apiv3 import api as apiv3 -from missal1962.filters import slugify, asterisks2em, newline2br -from missal1962.constants.common import LANGUAGES -from missal1962.views import views +from __version__ import __version__ +from apiv3 import api as apiv3 +from filters import slugify, asterisks2em, newline2br +from constants.common import LANGUAGES +from views import views logging.basicConfig( stream=sys.stdout, diff --git a/missal1962/cli.py b/missal1962/cli.py index b7d651e2..db0efb94 100755 --- a/missal1962/cli.py +++ b/missal1962/cli.py @@ -9,9 +9,9 @@ import click -from missal1962 import controller -from missal1962.kalendar.models import Calendar, Day -from missal1962.propers.models import Proper +import controller +from kalendar.models import Calendar, Day +from propers.models import Proper logging.basicConfig( diff --git a/missal1962/constants/__init__.py b/missal1962/constants/__init__.py index e438630e..8724ccb5 100644 --- a/missal1962/constants/__init__.py +++ b/missal1962/constants/__init__.py @@ -9,5 +9,5 @@ BLOCKS = {} for lang in langs: - TRANSLATION[lang] = importlib.import_module(f'missal1962.constants.{lang}.translation') - BLOCKS[lang] = importlib.import_module(f'missal1962.constants.{lang}.blocks') + TRANSLATION[lang] = importlib.import_module(f'constants.{lang}.translation') + BLOCKS[lang] = importlib.import_module(f'constants.{lang}.blocks') diff --git a/missal1962/constants/la/blocks.py b/missal1962/constants/la/blocks.py index 2194e72d..36300c51 100644 --- a/missal1962/constants/la/blocks.py +++ b/missal1962/constants/la/blocks.py @@ -1,6 +1,6 @@ import itertools -from missal1962.constants import common as constants +from constants import common as constants POST_EPIPHANY = ( (constants.TEMPORA_EPI1_0,), diff --git a/missal1962/constants/la/translation.py b/missal1962/constants/la/translation.py index 8728a393..fb201153 100644 --- a/missal1962/constants/la/translation.py +++ b/missal1962/constants/la/translation.py @@ -1,6 +1,6 @@ import re -from missal1962.constants import common as constants +from constants import common as constants TITLES = { constants.TEMPORA_EPI1_0: 'Sanctæ Familiæ Jesu Mariæ Joseph', diff --git a/missal1962/constants/pl/translation.py b/missal1962/constants/pl/translation.py index cbe13707..9ca0e24f 100644 --- a/missal1962/constants/pl/translation.py +++ b/missal1962/constants/pl/translation.py @@ -1,6 +1,6 @@ import re -from missal1962.constants import common as constants +from constants import common as constants TITLES = { constants.TEMPORA_EPI1_0: 'Uroczystość Świętej Rodziny Jezusa, Maryi i Józefa', diff --git a/missal1962/controller.py b/missal1962/controller.py index 1df7f5a3..9bb20260 100644 --- a/missal1962/controller.py +++ b/missal1962/controller.py @@ -4,12 +4,12 @@ from functools import lru_cache from typing import List, Tuple -from missal1962 import ical -from missal1962.kalendar.factory import MissalFactory -from missal1962.kalendar.models import Calendar, Day -from missal1962.propers.models import Proper, ProperConfig -from missal1962.propers.parser import ProperParser -from missal1962.utils import get_custom_preface +import ical +from kalendar.factory import MissalFactory +from kalendar.models import Calendar, Day +from propers.models import Proper, ProperConfig +from propers.parser import ProperParser +from utils import get_custom_preface no_cache = bool(os.environ.get('MISSAL_NO_CACHE')) diff --git a/missal1962/ical.py b/missal1962/ical.py index cfadf701..cf8695a6 100644 --- a/missal1962/ical.py +++ b/missal1962/ical.py @@ -2,7 +2,7 @@ from icalendar import Calendar, Event from typing import Dict -from missal1962.kalendar.models import Day +from kalendar.models import Day class IcalBuilder: diff --git a/missal1962/kalendar/factory.py b/missal1962/kalendar/factory.py index a756a086..993f5f45 100644 --- a/missal1962/kalendar/factory.py +++ b/missal1962/kalendar/factory.py @@ -6,10 +6,10 @@ from dateutil.easter import easter -from missal1962.constants import BLOCKS -from missal1962.constants.common import TEMPORA_NAT2_0, SANCTI_10_DUr, LANGUAGE_ENGLISH -from missal1962.kalendar.models import Calendar, Observance -from missal1962.kalendar.rules import rules +from constants import BLOCKS +from constants.common import TEMPORA_NAT2_0, SANCTI_10_DUr, LANGUAGE_ENGLISH +from kalendar.models import Calendar, Observance +from kalendar.rules import rules class MissalFactory: diff --git a/missal1962/kalendar/models.py b/missal1962/kalendar/models.py index 4a405cf7..7bc937c5 100644 --- a/missal1962/kalendar/models.py +++ b/missal1962/kalendar/models.py @@ -7,21 +7,21 @@ from datetime import date, timedelta from typing import ItemsView, List, Tuple, Union -from missal1962.constants.common import (TEMPORA_C_10A, TEMPORA_C_10B, TEMPORA_C_10C, TEMPORA_C_10PASC, TEMPORA_C_10T, - TABLE_OF_PRECEDENCE, TEMPORA_EPI1_0, - TEMPORA_EPI1_0A, TEMPORA_PENT01_0, - TEMPORA_RANK_MAP, TYPE_TEMPORA, WEEKDAY_MAPPING, PATTERN_EASTER, - PATTERN_PRE_LENTEN, - PATTERN_LENT, GRADUALE_PASCHAL, TRACTUS, GRADUALE, - CUSTOM_INTER_READING_SECTIONS, - SUNDAY, PATTERN_POST_EPIPHANY_SUNDAY, TEMPORA_PENT23_0, INTROIT, OFFERTORIUM, - COMMUNIO, - TEMPORA_NAT2_0, SANCTI_01_01, PREFATIO_COMMUNIS, TEMPORA_PASC5_0, - TEMPORA_PASC5_4, - TEMPORA_PENT01_0A) -from missal1962.propers.models import Proper, ProperConfig -from missal1962.propers.parser import ProperParser -from missal1962.utils import get_custom_preface, match +from constants.common import (TEMPORA_C_10A, TEMPORA_C_10B, TEMPORA_C_10C, TEMPORA_C_10PASC, TEMPORA_C_10T, + TABLE_OF_PRECEDENCE, TEMPORA_EPI1_0, + TEMPORA_EPI1_0A, TEMPORA_PENT01_0, + TEMPORA_RANK_MAP, TYPE_TEMPORA, WEEKDAY_MAPPING, PATTERN_EASTER, + PATTERN_PRE_LENTEN, + PATTERN_LENT, GRADUALE_PASCHAL, TRACTUS, GRADUALE, + CUSTOM_INTER_READING_SECTIONS, + SUNDAY, PATTERN_POST_EPIPHANY_SUNDAY, TEMPORA_PENT23_0, INTROIT, OFFERTORIUM, + COMMUNIO, + TEMPORA_NAT2_0, SANCTI_01_01, PREFATIO_COMMUNIS, TEMPORA_PASC5_0, + TEMPORA_PASC5_4, + TEMPORA_PENT01_0A) +from propers.models import Proper, ProperConfig +from propers.parser import ProperParser +from utils import get_custom_preface, match log = logging.getLogger(__name__) @@ -67,7 +67,7 @@ def __init__(self, observance_id: str, date_: date, lang: str): """ self.date = date_ self.lang = lang - translation = importlib.import_module(f'missal1962.constants.{lang}.translation') + translation = importlib.import_module(f'constants.{lang}.translation') flexibility, name, rank, color = observance_id.split(':') self.flexibility: str = flexibility self.name: str = name diff --git a/missal1962/kalendar/rules.py b/missal1962/kalendar/rules.py index 499076a3..409add2d 100644 --- a/missal1962/kalendar/rules.py +++ b/missal1962/kalendar/rules.py @@ -18,24 +18,24 @@ from datetime import date, timedelta from typing import List -from missal1962.constants.common import (TEMPORA_C_10A, TEMPORA_C_10B, TEMPORA_C_10C, TEMPORA_C_10PASC, TEMPORA_C_10T, - EMBER_DAYS, - FEASTS_OF_JESUS_CLASS_1_AND_2, PATTERN_ADVENT, - PATTERN_CLASS_1, PATTERN_EASTER, - PATTERN_SANCTI_CLASS_1_OR_2, - PATTERN_SANCTI_CLASS_2, PATTERN_TEMPORA, - PATTERN_TEMPORA_SUNDAY, - PATTERN_TEMPORA_SUNDAY_CLASS_2, SANCTI_01_13, - SANCTI_02_24, SANCTI_02_27, SANCTI_11_02_1, - SANCTI_12_24, SANCTI_12_25_1, - TEMPORA_EPI1_0, TEMPORA_PASC0_0, TEMPORA_QUAD6_1, - TEMPORA_QUAD6_2, TEMPORA_QUAD6_3, - TEMPORA_QUAD6_4, TEMPORA_QUAD6_5, - TEMPORA_QUAD6_6, TEMPORA_QUADP3_3, - SANCTI_09_29, PATTERN_SANCTI_CLASS_4, PATTERN_LENT, PATTERN_SANCTI, SUNDAY, - PATTERN_TEMPORA_CLASS_4) -from missal1962.kalendar.models import Calendar, Observance -from missal1962.utils import match +from constants.common import (TEMPORA_C_10A, TEMPORA_C_10B, TEMPORA_C_10C, TEMPORA_C_10PASC, TEMPORA_C_10T, + EMBER_DAYS, + FEASTS_OF_JESUS_CLASS_1_AND_2, PATTERN_ADVENT, + PATTERN_CLASS_1, PATTERN_EASTER, + PATTERN_SANCTI_CLASS_1_OR_2, + PATTERN_SANCTI_CLASS_2, PATTERN_TEMPORA, + PATTERN_TEMPORA_SUNDAY, + PATTERN_TEMPORA_SUNDAY_CLASS_2, SANCTI_01_13, + SANCTI_02_24, SANCTI_02_27, SANCTI_11_02_1, + SANCTI_12_24, SANCTI_12_25_1, + TEMPORA_EPI1_0, TEMPORA_PASC0_0, TEMPORA_QUAD6_1, + TEMPORA_QUAD6_2, TEMPORA_QUAD6_3, + TEMPORA_QUAD6_4, TEMPORA_QUAD6_5, + TEMPORA_QUAD6_6, TEMPORA_QUADP3_3, + SANCTI_09_29, PATTERN_SANCTI_CLASS_4, PATTERN_LENT, PATTERN_SANCTI, SUNDAY, + PATTERN_TEMPORA_CLASS_4) +from kalendar.models import Calendar, Observance +from utils import match def rule_nativity_has_multiple_masses( diff --git a/missal1962/propers/models.py b/missal1962/propers/models.py index 7e75280e..a8b4b12a 100644 --- a/missal1962/propers/models.py +++ b/missal1962/propers/models.py @@ -1,9 +1,9 @@ from copy import copy from typing import ItemsView, KeysView, List, Union, ValuesView -from missal1962.constants.common import VISIBLE_SECTIONS, GRADUALE, TRACTUS, GRADUALE_PASCHAL, COMMEMORATED_ORATIO, \ +from constants.common import VISIBLE_SECTIONS, GRADUALE, TRACTUS, GRADUALE_PASCHAL, COMMEMORATED_ORATIO, \ COMMEMORATED_SECRETA, COMMEMORATED_POSTCOMMUNIO, POSTCOMMUNIO, SECRETA, ORATIO, COMMEMORATION -from missal1962.exceptions import ProperNotFound +from exceptions import ProperNotFound class ParsedSource: diff --git a/missal1962/propers/parser.py b/missal1962/propers/parser.py index 99b6ec87..cf0eeced 100644 --- a/missal1962/propers/parser.py +++ b/missal1962/propers/parser.py @@ -3,18 +3,18 @@ import re from typing import Tuple, Union -import missal1962.utils as utils -from missal1962.exceptions import InvalidInput, ProperNotFound - -from missal1962.constants import TRANSLATION -from missal1962.constants.common import (CUSTOM_DIVOFF_DIR, DIVOFF_DIR, LANGUAGE_LATIN, DIVOFF_LANG_MAP, - REFERENCE_REGEX, - SECTION_REGEX, EXCLUDE_SECTIONS_IDX, ASTERISK, PATTERN_COMMEMORATION, - PREFATIO_COMMUNIS, - VISIBLE_SECTIONS, TRACTUS, GRADUALE, GRADUALE_PASCHAL, PATTERN_ALLELUIA, - PREFATIO_OMIT, - OBSERVANCES_WITHOUT_OWN_PROPER, PATTERN_TRACT) -from missal1962.propers.models import Proper, Section, ProperConfig, ParsedSource +import utils as utils +from exceptions import InvalidInput, ProperNotFound + +from constants import TRANSLATION +from constants.common import (CUSTOM_DIVOFF_DIR, DIVOFF_DIR, LANGUAGE_LATIN, DIVOFF_LANG_MAP, + REFERENCE_REGEX, + SECTION_REGEX, EXCLUDE_SECTIONS_IDX, ASTERISK, PATTERN_COMMEMORATION, + PREFATIO_COMMUNIS, + VISIBLE_SECTIONS, TRACTUS, GRADUALE, GRADUALE_PASCHAL, PATTERN_ALLELUIA, + PREFATIO_OMIT, + OBSERVANCES_WITHOUT_OWN_PROPER, PATTERN_TRACT) +from propers.models import Proper, Section, ProperConfig, ParsedSource log = logging.getLogger(__name__) diff --git a/missal1962/utils.py b/missal1962/utils.py index 58a72d21..7b4fb900 100644 --- a/missal1962/utils.py +++ b/missal1962/utils.py @@ -6,8 +6,8 @@ import mistune import yaml -from missal1962.constants.common import CUSTOM_PREFACES, PROPERS_DIR, SUPPLEMENT_DIR -from missal1962.exceptions import SupplementNotFound, SectionNotFound +from constants.common import CUSTOM_PREFACES, PROPERS_DIR, SUPPLEMENT_DIR +from exceptions import SupplementNotFound, SectionNotFound def match(observances: Union[str, 'Observance', List[Union[str, 'Observance']]], # noqa: F821 diff --git a/missal1962/views.py b/missal1962/views.py index 1257f786..faea7c7b 100644 --- a/missal1962/views.py +++ b/missal1962/views.py @@ -14,12 +14,12 @@ from flask_babel import _ from jinja2 import TemplateNotFound -from missal1962 import controller -from missal1962.constants import TRANSLATION, BLOCKS -from missal1962.constants.common import LANGUAGES, LANGUAGE_ENGLISH, SUPPLEMENT_DIR -from missal1962.exceptions import SupplementNotFound -from missal1962.kalendar.models import Day -from missal1962.utils import format_day_propers, get_supplement, format_propers +import controller +from constants import TRANSLATION, BLOCKS +from constants.common import LANGUAGES, LANGUAGE_ENGLISH, SUPPLEMENT_DIR +from exceptions import SupplementNotFound +from kalendar.models import Day +from utils import format_day_propers, get_supplement, format_propers logging.basicConfig( stream=sys.stdout, diff --git a/tests/conftest.py b/tests/conftest.py index a03c6c1f..c9495675 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,9 +2,9 @@ import pytest -from missal1962 import app -from missal1962.constants.common import LANGUAGE_LATIN -from missal1962.kalendar.factory import MissalFactory +import app +from constants.common import LANGUAGE_LATIN +from kalendar.factory import MissalFactory HERE = os.path.abspath(os.path.dirname(__file__)) diff --git a/tests/test_apiv3.py b/tests/test_apiv3.py index f82e32c2..e99d4628 100644 --- a/tests/test_apiv3.py +++ b/tests/test_apiv3.py @@ -5,7 +5,7 @@ import pytest from .conftest import HERE -from missal1962.constants.common import LANGUAGES +from constants.common import LANGUAGES def test_api_calendar(client): diff --git a/tests/test_calendar.py b/tests/test_calendar.py index d5ce3d3c..8b90f3f6 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -5,9 +5,9 @@ import pytest -from missal1962.constants import common as c -from missal1962.kalendar.models import Observance -from missal1962.utils import match +from constants import common as c +from kalendar.models import Observance +from utils import match from tests.conftest import get_missal, HERE language = 'pl' diff --git a/tests/test_propers.py b/tests/test_propers.py index 79da9e4e..2d14ec30 100644 --- a/tests/test_propers.py +++ b/tests/test_propers.py @@ -1,16 +1,16 @@ import json from datetime import date -from missal1962.constants.common import * -from missal1962.exceptions import InvalidInput, ProperNotFound +from constants.common import * +from exceptions import InvalidInput, ProperNotFound import pytest import re -from missal1962.constants import common as c -from missal1962.kalendar.models import Observance -from missal1962.propers.models import ProperConfig -from missal1962.propers.parser import ProperParser +from constants import common as c +from kalendar.models import Observance +from propers.models import ProperConfig +from propers.parser import ProperParser from tests.conftest import get_missal, HERE language = 'pl'