From c3c8ba2908d18ac5a14a4d59d2b155af14d7f718 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 18:47:20 -0800 Subject: [PATCH 01/11] Updated pyproject.toml to poetry --- pyproject.toml | 50 +++++++++++++++++++-------------------------- wavinfo/__init__.py | 3 --- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 500d65e..a566528 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,16 @@ -[build-system] -requires = ["flit_core >=3.2,<4"] -build-backend = "flit_core.buildapi" +# https://python-poetry.org/docs/pyproject/ -[project] +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry] name = "wavinfo" -authors = [{name = "Jamie Hardt", email = "jamiehardt@me.com"}] +version = "3.0.1" +description = "Probe WAVE files for all metadata" +authors = ["Jamie Hardt "] +license = "MIT" readme = "README.md" -dynamic = ["version", "description"] -requires-python = "~=3.8" classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: MIT License', @@ -20,9 +23,10 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13" ] -dependencies = [ - "lxml ~= 5.3.0" -] +homepage = "https://github.com/iluvcapra/wavinfo" +repository = "https://github.com/iluvcapra/wavinfo.git" +documentation = "https://wavinfo.readthedocs.io/" +urls.Tracker = 'https://github.com/iluvcapra/wavinfo/issues' keywords = [ 'waveform', 'metadata', @@ -35,29 +39,17 @@ keywords = [ 'broadcast' ] -[tool.flit.module] -name = "wavinfo" +[tool.poetry.extras] +doc = ['sphinx', 'sphinx_rtd_theme'] -[project.optional-dependencies] -doc = [ - 'sphinx >= 5.3.0', - 'sphinx_rtd_theme >= 1.1.1', -] - -[project.urls] -Home = "https://github.com/iluvcapra/wavinfo" -Documentation = "https://wavinfo.readthedocs.io/" -Source = "https://github.com/iluvcapra/wavinfo.git" -Issues = 'https://github.com/iluvcapra/wavinfo/issues' - -[project.entry_points.console_scripts] +[tool.poetry.scripts] wavinfo = 'wavinfo.__main__:main' -[project.scripts] -wavinfo = "wavinfo.__main__:main" +[[tool.poetry.packages]] +include = "data" -[tool.flit.external-data] -directory = "data" +[tool.poetry.dependencies] +lxml = "~= 5.3.0" [tool.pyright] typeCheckingMode = "basic" diff --git a/wavinfo/__init__.py b/wavinfo/__init__.py index f8d7de0..d5bbfaf 100644 --- a/wavinfo/__init__.py +++ b/wavinfo/__init__.py @@ -4,6 +4,3 @@ Probe WAVE Files for iXML, Broadcast-WAVE and other metadata. from .wave_reader import WavInfoReader from .riff_parser import WavInfoEOFError - -__version__ = '3.0.0' -__short_version__ = '3.0.0' From 8b402f310cdf77a36d25ecb9b6324ca938eb5fb9 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 19:15:16 -0800 Subject: [PATCH 02/11] Changes for poetry --- pyproject.toml | 9 ++++++--- wavinfo/__main__.py | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a566528..6e96730 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,9 @@ keywords = [ 'film', 'broadcast' ] +include = [ + { path = "data/", format = ["sdist", "wheel"] }, +] [tool.poetry.extras] doc = ['sphinx', 'sphinx_rtd_theme'] @@ -45,11 +48,11 @@ doc = ['sphinx', 'sphinx_rtd_theme'] [tool.poetry.scripts] wavinfo = 'wavinfo.__main__:main' -[[tool.poetry.packages]] -include = "data" - [tool.poetry.dependencies] +python = "^3.8" lxml = "~= 5.3.0" +sphinx_rtd_theme = {version= '>= 1.1.1', optional=true} +sphinx = {version= '>= 5.3.0', optional=true} [tool.pyright] typeCheckingMode = "basic" diff --git a/wavinfo/__main__.py b/wavinfo/__main__.py index 0fd7428..8980dd3 100644 --- a/wavinfo/__main__.py +++ b/wavinfo/__main__.py @@ -1,6 +1,5 @@ import datetime from . import WavInfoReader -from . import __version__ from optparse import OptionParser import sys @@ -53,7 +52,7 @@ def main(): ret_dict = { 'filename': arg, 'run_date': datetime.datetime.now().isoformat(), - 'application': "wavinfo " + __version__, + # 'application': "wavinfo " + __version__, 'scopes': {} } for scope, name, value in this_file.walk(): From e60723afcfcc3ca62f17ee68bb6836798829c8ab Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 20:20:19 -0800 Subject: [PATCH 03/11] Added version detection back to output --- wavinfo/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wavinfo/__main__.py b/wavinfo/__main__.py index 8980dd3..25d97cb 100644 --- a/wavinfo/__main__.py +++ b/wavinfo/__main__.py @@ -7,6 +7,11 @@ import json from enum import Enum +import importlib.metadata + +version = importlib.metadata.version('wavinfo') + + class MyJSONEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, Enum): @@ -52,7 +57,7 @@ def main(): ret_dict = { 'filename': arg, 'run_date': datetime.datetime.now().isoformat(), - # 'application': "wavinfo " + __version__, + 'application': "wavinfo " + version, 'scopes': {} } for scope, name, value in this_file.walk(): From a66049b4255e1708f0ae996d34b565c5e4a74f03 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 20:23:52 -0800 Subject: [PATCH 04/11] Added `poetry.lock` to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a9c6ddc..186fd5f 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,5 @@ venv_docs/ .DS_Store .vscode/ + +poetry.lock From c249ce058d1cfc5743617fb5f8f4b0bb72d6f110 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 20:56:20 -0800 Subject: [PATCH 05/11] Reorganized man files to fall inside module --- pyproject.toml | 3 -- wavinfo/__main__.py | 41 ++++++++++++++++++---- {data/share => wavinfo}/man/man1/wavinfo.1 | 0 {data/share => wavinfo}/man/man7/wavinfo.7 | 0 4 files changed, 34 insertions(+), 10 deletions(-) rename {data/share => wavinfo}/man/man1/wavinfo.1 (100%) rename {data/share => wavinfo}/man/man7/wavinfo.7 (100%) diff --git a/pyproject.toml b/pyproject.toml index 6e96730..19e7eda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,9 +38,6 @@ keywords = [ 'film', 'broadcast' ] -include = [ - { path = "data/", format = ["sdist", "wheel"] }, -] [tool.poetry.extras] doc = ['sphinx', 'sphinx_rtd_theme'] diff --git a/wavinfo/__main__.py b/wavinfo/__main__.py index 25d97cb..fbf95db 100644 --- a/wavinfo/__main__.py +++ b/wavinfo/__main__.py @@ -1,16 +1,12 @@ -import datetime from . import WavInfoReader +import datetime from optparse import OptionParser -import sys +import sys, os import json from enum import Enum - - import importlib.metadata -version = importlib.metadata.version('wavinfo') - class MyJSONEncoder(json.JSONEncoder): def default(self, o): @@ -25,10 +21,22 @@ class MissingDataError(RuntimeError): def main(): + version = importlib.metadata.version('wavinfo') + manpath = os.path.dirname(__file__) + "/man" parser = OptionParser() parser.usage = 'wavinfo (--adm | --ixml) +' + parser.add_option('--install-manpages', + help="Install manual pages for wavinfo", + default=False, + action='store_true') + + parser.add_option('--man', + help="Read the manual", + default=False, + action='store_true') + parser.add_option('--adm', dest='adm', help='Output ADM XML', default=False, @@ -40,6 +48,25 @@ def main(): action='store_true') (options, args) = parser.parse_args(sys.argv) + + if options.install_manpages: + print("Installing manpages...") + print(f"Docfiles at {__file__}") + return + + if options.man: + print("Which man page?") + print("1) wavinfo usage") + print("7) General info on Wave file metadata") + m = input("?> ") + + if m.startswith("1"): + os.system(f"man -M {manpath} 1 wavinfo") + elif m.startswith("7"): + os.system(f"man -M {manpath} 7 wavinfo") + + return + for arg in args[1:]: try: this_file = WavInfoReader(path=arg) @@ -57,7 +84,7 @@ def main(): ret_dict = { 'filename': arg, 'run_date': datetime.datetime.now().isoformat(), - 'application': "wavinfo " + version, + 'application': f"wavinfo {version}", 'scopes': {} } for scope, name, value in this_file.walk(): diff --git a/data/share/man/man1/wavinfo.1 b/wavinfo/man/man1/wavinfo.1 similarity index 100% rename from data/share/man/man1/wavinfo.1 rename to wavinfo/man/man1/wavinfo.1 diff --git a/data/share/man/man7/wavinfo.7 b/wavinfo/man/man7/wavinfo.7 similarity index 100% rename from data/share/man/man7/wavinfo.7 rename to wavinfo/man/man7/wavinfo.7 From 82129cee075d1d7ee3159025cc28ebd8debd01c3 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 20:59:15 -0800 Subject: [PATCH 06/11] Clarified a man item --- wavinfo/man/man1/wavinfo.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wavinfo/man/man1/wavinfo.1 b/wavinfo/man/man1/wavinfo.1 index 58fd7d6..0fe5382 100644 --- a/wavinfo/man/man1/wavinfo.1 +++ b/wavinfo/man/man1/wavinfo.1 @@ -17,7 +17,7 @@ With no options, will emit a JSON (Javascript Object Notation) object containing all detected metadata. .IP "\-\-adm" -Output any Audio Definition Model (ADM) metadata in +Output Audio Definition Model (ADM) XML metadata in .BR FILE . .IP "\-\-ixml" Output any iXML metdata in From 77ce1e3bc0a477bd3bc1c12bbc8a5fff044fa1c4 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 21:00:05 -0800 Subject: [PATCH 07/11] Removing "--install-manpages" for now --- wavinfo/__main__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wavinfo/__main__.py b/wavinfo/__main__.py index fbf95db..f0e3e8d 100644 --- a/wavinfo/__main__.py +++ b/wavinfo/__main__.py @@ -27,10 +27,10 @@ def main(): parser.usage = 'wavinfo (--adm | --ixml) +' - parser.add_option('--install-manpages', - help="Install manual pages for wavinfo", - default=False, - action='store_true') + # parser.add_option('--install-manpages', + # help="Install manual pages for wavinfo", + # default=False, + # action='store_true') parser.add_option('--man', help="Read the manual", @@ -49,10 +49,10 @@ def main(): (options, args) = parser.parse_args(sys.argv) - if options.install_manpages: - print("Installing manpages...") - print(f"Docfiles at {__file__}") - return + # if options.install_manpages: + # print("Installing manpages...") + # print(f"Docfiles at {__file__}") + # return if options.man: print("Which man page?") From 29ca62b970da0660b325ec6fbba23ac8f09b8057 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 21:02:40 -0800 Subject: [PATCH 08/11] Autopep8 --- wavinfo/__main__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wavinfo/__main__.py b/wavinfo/__main__.py index f0e3e8d..3b70851 100644 --- a/wavinfo/__main__.py +++ b/wavinfo/__main__.py @@ -2,7 +2,8 @@ from . import WavInfoReader import datetime from optparse import OptionParser -import sys, os +import sys +import os import json from enum import Enum import importlib.metadata @@ -27,16 +28,16 @@ def main(): parser.usage = 'wavinfo (--adm | --ixml) +' - # parser.add_option('--install-manpages', + # parser.add_option('--install-manpages', # help="Install manual pages for wavinfo", # default=False, # action='store_true') - parser.add_option('--man', + parser.add_option('--man', help="Read the manual", default=False, action='store_true') - + parser.add_option('--adm', dest='adm', help='Output ADM XML', default=False, @@ -53,7 +54,7 @@ def main(): # print("Installing manpages...") # print(f"Docfiles at {__file__}") # return - + if options.man: print("Which man page?") print("1) wavinfo usage") @@ -86,7 +87,7 @@ def main(): 'run_date': datetime.datetime.now().isoformat(), 'application': f"wavinfo {version}", 'scopes': {} - } + } for scope, name, value in this_file.walk(): if scope not in ret_dict['scopes'].keys(): ret_dict['scopes'][scope] = {} From 28e0532994fac1b0482315c775853e311c6b1482 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 23 Nov 2024 21:22:06 -0800 Subject: [PATCH 09/11] Made the man opening code cleaner --- wavinfo/__main__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wavinfo/__main__.py b/wavinfo/__main__.py index 3b70851..bd077ad 100644 --- a/wavinfo/__main__.py +++ b/wavinfo/__main__.py @@ -34,7 +34,7 @@ def main(): # action='store_true') parser.add_option('--man', - help="Read the manual", + help="Read the manual and exit.", default=False, action='store_true') @@ -56,16 +56,17 @@ def main(): # return if options.man: + import shlex print("Which man page?") print("1) wavinfo usage") print("7) General info on Wave file metadata") m = input("?> ") - if m.startswith("1"): - os.system(f"man -M {manpath} 1 wavinfo") - elif m.startswith("7"): - os.system(f"man -M {manpath} 7 wavinfo") + args = ["man", "-M", manpath, "1", "wavinfo"] + if m.startswith("7"): + args[3] = "7" + os.system(shlex.join(args)) return for arg in args[1:]: From b8617a35e2f6fbf1b26beeb1fa7769fcf1c347c3 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Mon, 25 Nov 2024 10:41:05 -0800 Subject: [PATCH 10/11] Fixing doc dependencies I think --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 19e7eda..a4a19f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,8 +48,8 @@ wavinfo = 'wavinfo.__main__:main' [tool.poetry.dependencies] python = "^3.8" lxml = "~= 5.3.0" -sphinx_rtd_theme = {version= '>= 1.1.1', optional=true} -sphinx = {version= '>= 5.3.0', optional=true} +sphinx_rtd_theme = {version= '>= 1.1.1', optional=true, extras=['doc']} +sphinx = {version= '>= 5.3.0', optional=true, extras=['doc']} [tool.pyright] typeCheckingMode = "basic" From c6f66b2d6e2f1c4bb6586b551fed96885e139376 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Mon, 25 Nov 2024 10:48:58 -0800 Subject: [PATCH 11/11] Changes to fix docs --- docs/source/conf.py | 9 +++++---- docs/source/references.rst | 2 +- pyproject.toml | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 083c8fe..f540b15 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,24 +12,25 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import importlib import os import sys sys.path.insert(0, os.path.abspath('../..')) sys.path.insert(0, os.path.abspath("../../..")) print(sys.path) -import wavinfo +import importlib # -- Project information ----------------------------------------------------- project = u'wavinfo' -copyright = u'2018-2023, Jamie Hardt' +copyright = u'2018-2024, Jamie Hardt' author = u'Jamie Hardt' # The short X.Y version -version = wavinfo.__short_version__ +version = "3.1" # The full version, including alpha/beta/rc tags -release = wavinfo.__version__ +release = importlib.metadata.version("wavinfo") # -- General configuration --------------------------------------------------- diff --git a/docs/source/references.rst b/docs/source/references.rst index 4006cb2..0825069 100644 --- a/docs/source/references.rst +++ b/docs/source/references.rst @@ -39,7 +39,7 @@ iXML Sampler Metadata ---------------- -* `RecordingBlogs.com — Sample chunk (of a Wave file)`_ +* `RecordingBlogs.com — Sample chunk (of a Wave file) `_ RIFF Metadata ------------- diff --git a/pyproject.toml b/pyproject.toml index a4a19f5..19e7eda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,8 +48,8 @@ wavinfo = 'wavinfo.__main__:main' [tool.poetry.dependencies] python = "^3.8" lxml = "~= 5.3.0" -sphinx_rtd_theme = {version= '>= 1.1.1', optional=true, extras=['doc']} -sphinx = {version= '>= 5.3.0', optional=true, extras=['doc']} +sphinx_rtd_theme = {version= '>= 1.1.1', optional=true} +sphinx = {version= '>= 5.3.0', optional=true} [tool.pyright] typeCheckingMode = "basic"