From 6c191f2a38692c278242b7bcf93e254658703041 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 26 Jun 2021 14:28:55 -0700 Subject: [PATCH] Remove __init__.py files Since we're implementing a plugin system that relies on implicit namespacing, we should remove these files so that they don't confuse and muddle our virtual envs (like the ones we use to run tests). Also, they're not longer needed as of Python 3.3. PEP 420 says: Allowing implicit namespace packages means that the requirement to provide an __init__.py file can be dropped completely... --- features/steps/core.py | 2 +- jrnl/DayOneJournal.py | 7 ++----- jrnl/__init__.py | 9 --------- jrnl/__main__.py | 10 ---------- jrnl/commands.py | 7 +++---- jrnl/config.py | 2 +- jrnl/plugins/__init__.py | 5 ----- jrnl/plugins/exporter/dates.py | 2 +- jrnl/plugins/exporter/fancy.py | 2 +- jrnl/plugins/exporter/json.py | 2 +- jrnl/plugins/exporter/markdown.py | 2 +- jrnl/plugins/exporter/pretty.py | 2 +- jrnl/plugins/exporter/short.py | 2 +- jrnl/plugins/exporter/tag.py | 2 +- jrnl/plugins/exporter/text.py | 2 +- jrnl/plugins/exporter/xml.py | 2 +- jrnl/plugins/exporter/yaml.py | 2 +- jrnl/plugins/importer/jrnl.py | 2 +- jrnl/upgrade.py | 2 +- 19 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 jrnl/__init__.py delete mode 100644 jrnl/__main__.py delete mode 100644 jrnl/plugins/__init__.py diff --git a/features/steps/core.py b/features/steps/core.py index 143dc4a4..f8aca6a9 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -18,7 +18,7 @@ import yaml from yaml.loader import FullLoader from jrnl import Journal -from jrnl import __version__ +from jrnl.__version__ import __version__ from jrnl import plugins from jrnl.args import parse_args from jrnl.behave_testing import _mock_getpass diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index 6e1b8345..72864c14 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -17,8 +17,7 @@ import tzlocal from . import Entry from . import Journal -from . import __title__ -from . import __version__ +from jrnl.__version__ import __version__ class DayOne(Journal.Journal): @@ -135,9 +134,7 @@ class DayOne(Journal.Journal): platform.system(), platform.release() ) if not hasattr(entry, "creator_software_agent"): - entry.creator_software_agent = "{}/{}".format( - __title__, __version__ - ) + entry.creator_software_agent = "jrnl/{}".format(__version__) fn = ( Path(self.config["journal"]) diff --git a/jrnl/__init__.py b/jrnl/__init__.py deleted file mode 100644 index 8f4dc3ec..00000000 --- a/jrnl/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2012-2021 jrnl contributors -# License: https://www.gnu.org/licenses/gpl-3.0.html - -try: - from .__version__ import __version__ -except ImportError: - __version__ = "source" -__title__ = "jrnl" diff --git a/jrnl/__main__.py b/jrnl/__main__.py deleted file mode 100644 index e977369f..00000000 --- a/jrnl/__main__.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2012-2021 jrnl contributors -# License: https://www.gnu.org/licenses/gpl-3.0.html - -import sys - -from .cli import cli - -if __name__ == "__main__": - sys.exit(cli()) diff --git a/jrnl/commands.py b/jrnl/commands.py index 8da64499..90c01b5a 100644 --- a/jrnl/commands.py +++ b/jrnl/commands.py @@ -16,7 +16,7 @@ import sys def preconfig_diagnostic(_): - from jrnl import __version__ + from jrnl.__version__ import __version__ print( f"jrnl: {__version__}\n" @@ -26,8 +26,7 @@ def preconfig_diagnostic(_): def preconfig_version(_): - from jrnl import __title__ - from jrnl import __version__ + from jrnl.__version__ import __version__ from jrnl.plugins.collector import ( IMPORT_FORMATS, EXPORT_FORMATS, @@ -35,7 +34,7 @@ def preconfig_version(_): get_importer, ) - version_str = f"""{__title__} version {__version__} + version_str = f"""jrnl version {__version__} Copyright (C) 2012-2021 jrnl contributors diff --git a/jrnl/config.py b/jrnl/config.py index da2df2cc..bbf850dc 100644 --- a/jrnl/config.py +++ b/jrnl/config.py @@ -6,7 +6,7 @@ import colorama import yaml import xdg.BaseDirectory -from . import __version__ +from jrnl.__version__ import __version__ from .exception import JrnlError from .color import ERROR_COLOR from .color import RESET_COLOR diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py deleted file mode 100644 index 4c1f6f36..00000000 --- a/jrnl/plugins/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 - -# Copyright (C) 2012-2021 jrnl contributors -# License: https://www.gnu.org/licenses/gpl-3.0.html diff --git a/jrnl/plugins/exporter/dates.py b/jrnl/plugins/exporter/dates.py index 68cb5d55..8e5725b8 100644 --- a/jrnl/plugins/exporter/dates.py +++ b/jrnl/plugins/exporter/dates.py @@ -7,7 +7,7 @@ from collections import Counter from jrnl.plugins.base import BaseExporter -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/fancy.py b/jrnl/plugins/exporter/fancy.py index 034145c8..1261bd0c 100644 --- a/jrnl/plugins/exporter/fancy.py +++ b/jrnl/plugins/exporter/fancy.py @@ -9,7 +9,7 @@ from textwrap import TextWrapper from jrnl.plugins.base import BaseExporter from jrnl.plugins.util import check_provided_linewrap_viability -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/json.py b/jrnl/plugins/exporter/json.py index 624a3c17..d53a8588 100644 --- a/jrnl/plugins/exporter/json.py +++ b/jrnl/plugins/exporter/json.py @@ -8,7 +8,7 @@ import json from jrnl.plugins.base import BaseExporter from jrnl.plugins.util import get_tags_count -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/markdown.py b/jrnl/plugins/exporter/markdown.py index 3638a127..39d67f2e 100644 --- a/jrnl/plugins/exporter/markdown.py +++ b/jrnl/plugins/exporter/markdown.py @@ -11,7 +11,7 @@ from jrnl.color import RESET_COLOR from jrnl.color import WARNING_COLOR from jrnl.plugins.base import BaseExporter -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/pretty.py b/jrnl/plugins/exporter/pretty.py index e44eb872..9a83341c 100644 --- a/jrnl/plugins/exporter/pretty.py +++ b/jrnl/plugins/exporter/pretty.py @@ -5,7 +5,7 @@ from jrnl.plugins.base import BaseExporter -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/short.py b/jrnl/plugins/exporter/short.py index c9c21a8a..9ebf057a 100644 --- a/jrnl/plugins/exporter/short.py +++ b/jrnl/plugins/exporter/short.py @@ -5,7 +5,7 @@ from jrnl.plugins.base import BaseExporter -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/tag.py b/jrnl/plugins/exporter/tag.py index a8cf932d..d009d01c 100644 --- a/jrnl/plugins/exporter/tag.py +++ b/jrnl/plugins/exporter/tag.py @@ -7,7 +7,7 @@ from jrnl.plugins.base import BaseExporter from jrnl.plugins.util import get_tags_count -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/text.py b/jrnl/plugins/exporter/text.py index 20339922..7f3e6fcd 100644 --- a/jrnl/plugins/exporter/text.py +++ b/jrnl/plugins/exporter/text.py @@ -5,7 +5,7 @@ from jrnl.plugins.base import BaseExporter -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/xml.py b/jrnl/plugins/exporter/xml.py index 7d7f279c..062af453 100644 --- a/jrnl/plugins/exporter/xml.py +++ b/jrnl/plugins/exporter/xml.py @@ -8,7 +8,7 @@ from xml.dom import minidom from jrnl.plugins.base import BaseExporter from jrnl.plugins.util import get_tags_count -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/exporter/yaml.py b/jrnl/plugins/exporter/yaml.py index cbfb5b31..03c77ab1 100644 --- a/jrnl/plugins/exporter/yaml.py +++ b/jrnl/plugins/exporter/yaml.py @@ -12,7 +12,7 @@ from jrnl.color import RESET_COLOR from jrnl.color import WARNING_COLOR from jrnl.plugins.base import BaseExporter -from ... import __version__ +from jrnl.__version__ import __version__ class Exporter(BaseExporter): diff --git a/jrnl/plugins/importer/jrnl.py b/jrnl/plugins/importer/jrnl.py index b8da9df4..27c33254 100644 --- a/jrnl/plugins/importer/jrnl.py +++ b/jrnl/plugins/importer/jrnl.py @@ -7,7 +7,7 @@ import sys from jrnl.plugins.base import BaseImporter -from ... import __version__ +from jrnl.__version__ import __version__ class Importer(BaseImporter): diff --git a/jrnl/upgrade.py b/jrnl/upgrade.py index 158f8de3..e9eb83f1 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -5,7 +5,7 @@ import os import sys from . import Journal -from . import __version__ +from jrnl.__version__ import __version__ from .EncryptedJournal import EncryptedJournal from .config import is_config_json from .config import load_config