From be1da17ab9a7bed60ead609cc93f26500ca67083 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 | 8 -------- jrnl/__main__.py | 9 --------- jrnl/commands.py | 7 +++---- jrnl/config.py | 2 +- jrnl/plugins/__init__.py | 4 ---- 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(+), 44 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 48140164..f2cf27af 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -18,7 +18,7 @@ import yaml from yaml.loader import SafeLoader 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 01b934e5..bb34ac3f 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -15,8 +15,7 @@ import tzlocal from . import Entry from . import Journal -from . import __title__ -from . import __version__ +from jrnl.__version__ import __version__ class DayOne(Journal.Journal): @@ -133,9 +132,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 550d580f..00000000 --- a/jrnl/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# 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 49497161..00000000 --- a/jrnl/__main__.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 32695204..d8d0bab0 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 8a3eb693..00000000 --- a/jrnl/plugins/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# 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 9ed0c70e..9dbaa395 100644 --- a/jrnl/plugins/exporter/dates.py +++ b/jrnl/plugins/exporter/dates.py @@ -6,7 +6,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 7bfe16f0..60005fd8 100644 --- a/jrnl/plugins/exporter/fancy.py +++ b/jrnl/plugins/exporter/fancy.py @@ -8,7 +8,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 ab714a0e..cb9a617f 100644 --- a/jrnl/plugins/exporter/json.py +++ b/jrnl/plugins/exporter/json.py @@ -7,7 +7,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 87a28393..3026b0b2 100644 --- a/jrnl/plugins/exporter/markdown.py +++ b/jrnl/plugins/exporter/markdown.py @@ -10,7 +10,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 f33ab999..f2a9d50b 100644 --- a/jrnl/plugins/exporter/tag.py +++ b/jrnl/plugins/exporter/tag.py @@ -6,7 +6,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 69bf0225..904593e0 100644 --- a/jrnl/plugins/exporter/xml.py +++ b/jrnl/plugins/exporter/xml.py @@ -7,7 +7,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 ff76790c..2054f344 100644 --- a/jrnl/plugins/exporter/yaml.py +++ b/jrnl/plugins/exporter/yaml.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/importer/jrnl.py b/jrnl/plugins/importer/jrnl.py index c403e4f0..07031cc3 100644 --- a/jrnl/plugins/importer/jrnl.py +++ b/jrnl/plugins/importer/jrnl.py @@ -6,7 +6,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