From e0536e7e5e9d0af045c12c1a7b68fa14fab40e42 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 26 Jun 2021 14:54:26 -0700 Subject: [PATCH] Remove __init__.py files (#1275) 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 143dc4a4e..f8aca6a96 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -18,7 +18,7 @@ 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 6e1b83454..72864c14d 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -17,8 +17,7 @@ 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 @@ def write(self): 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 8f4dc3ec3..000000000 --- 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 e977369fa..000000000 --- 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 8da644995..90c01b5af 100644 --- a/jrnl/commands.py +++ b/jrnl/commands.py @@ -16,7 +16,7 @@ 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 da2df2cce..bbf850dcb 100644 --- a/jrnl/config.py +++ b/jrnl/config.py @@ -6,7 +6,7 @@ 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 4c1f6f367..000000000 --- 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 68cb5d55c..8e5725b8f 100644 --- a/jrnl/plugins/exporter/dates.py +++ b/jrnl/plugins/exporter/dates.py @@ -7,7 +7,7 @@ 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 034145c86..1261bd0c5 100644 --- a/jrnl/plugins/exporter/fancy.py +++ b/jrnl/plugins/exporter/fancy.py @@ -9,7 +9,7 @@ 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 624a3c170..d53a85884 100644 --- a/jrnl/plugins/exporter/json.py +++ b/jrnl/plugins/exporter/json.py @@ -8,7 +8,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/markdown.py b/jrnl/plugins/exporter/markdown.py index 3638a1274..39d67f2e7 100644 --- a/jrnl/plugins/exporter/markdown.py +++ b/jrnl/plugins/exporter/markdown.py @@ -11,7 +11,7 @@ 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 e44eb8726..9a83341c2 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 c9c21a8ad..9ebf057a3 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 a8cf932d2..d009d01cb 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 20339922d..7f3e6fcdc 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 7d7f279ce..062af453b 100644 --- a/jrnl/plugins/exporter/xml.py +++ b/jrnl/plugins/exporter/xml.py @@ -8,7 +8,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/yaml.py b/jrnl/plugins/exporter/yaml.py index cbfb5b315..03c77ab1b 100644 --- a/jrnl/plugins/exporter/yaml.py +++ b/jrnl/plugins/exporter/yaml.py @@ -12,7 +12,7 @@ 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 b8da9df43..27c332543 100644 --- a/jrnl/plugins/importer/jrnl.py +++ b/jrnl/plugins/importer/jrnl.py @@ -7,7 +7,7 @@ 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 158f8de3f..e9eb83f1a 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -5,7 +5,7 @@ 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