Hello community, here is the log from the commit of package python-pdd for openSUSE:Factory checked in at 2019-04-30 13:01:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pdd (Old) and /work/SRC/openSUSE:Factory/.python-pdd.new.5536 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-pdd" Tue Apr 30 13:01:02 2019 rev:2 rq:697446 version:1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pdd/python-pdd.changes 2019-04-04 14:13:45.549337898 +0200 +++ /work/SRC/openSUSE:Factory/.python-pdd.new.5536/python-pdd.changes 2019-04-30 13:01:06.098161238 +0200 @@ -1,0 +2,9 @@ +Wed Apr 24 09:21:19 UTC 2019 - pgajdos@suse.com + +- version update to 1.4 + - Command piggybacking with countdown timer + - Show current time for timers + - Disable showing epoch time on `pdd` +- run the test suite + +------------------------------------------------------------------- Old: ---- pdd-1.3.1.tar.gz New: ---- pdd-1.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pdd.spec ++++++ --- /var/tmp/diff_new_pack.VK8MD2/_old 2019-04-30 13:01:07.202160908 +0200 +++ /var/tmp/diff_new_pack.VK8MD2/_new 2019-04-30 13:01:07.202160908 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-pdd # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,29 +12,32 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + # pdd is not available for Python 2 %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pdd -Version: 1.3.1 +Version: 1.4 Release: 0 -License: GPL-3.0 Summary: Tiny date, time diff calculator with timers -Url: https://github.com/jarun/pdd +License: GPL-3.0-only Group: Development/Languages/Python +Url: https://github.com/jarun/pdd Source: https://files.pythonhosted.org/packages/source/p/pdd/pdd-%{version}.tar.gz -BuildRequires: python-rpm-macros BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} +BuildRequires: python-rpm-macros # SECTION test requirements -BuildRequires: %{python_module python-dateutil} BuildRequires: %{python_module pytest} +BuildRequires: %{python_module python-dateutil} # /SECTION BuildRequires: fdupes Requires: python-python-dateutil +Requires: python-setuptools BuildArch: noarch %python_subpackages @@ -46,12 +49,19 @@ %setup -q -n pdd-%{version} %build +# this seems to be fixed in github (there is pdd instead of pdd.py, +# what setup.py expects, if I have not missed anything) +mv pdd.py pdd %python_build %install %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +%check +chmod 755 pdd +%pytest test.py + %files %{python_files} %doc README.md CHANGELOG %license LICENSE ++++++ pdd-1.3.1.tar.gz -> pdd-1.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/CHANGELOG new/pdd-1.4/CHANGELOG --- old/pdd-1.3.1/CHANGELOG 2018-08-08 18:16:59.000000000 +0200 +++ new/pdd-1.4/CHANGELOG 2019-04-04 13:18:23.000000000 +0200 @@ -1,3 +1,13 @@ +pdd v1.4 +2019-04-04 + +- Support hiding cursor on OSX +- Command piggybacking with countdown timer +- Show current time for timers +- Disable showing epoch time on `pdd` + +------------------------------------------------------------------------------- + pdd v1.3.1 2018-08-08 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/MANIFEST.in new/pdd-1.4/MANIFEST.in --- old/pdd-1.3.1/MANIFEST.in 2018-08-08 18:16:59.000000000 +0200 +++ new/pdd-1.4/MANIFEST.in 2019-04-04 13:18:23.000000000 +0200 @@ -1 +1,2 @@ include CHANGELOG LICENSE +include test.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/PKG-INFO new/pdd-1.4/PKG-INFO --- old/pdd-1.3.1/PKG-INFO 2018-08-08 18:17:40.000000000 +0200 +++ new/pdd-1.4/PKG-INFO 2019-04-04 13:19:33.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pdd -Version: 1.3.1 +Version: 1.4 Summary: Tiny date, time diff calculator with timers Home-page: https://github.com/jarun/pdd Author: Arun Prakash Jana @@ -18,8 +18,9 @@ </p> <p align="center"> + <a href="https://repology.org/metapackage/pdd"><img src="https://repology.org/badge/tiny-repos/pdd.svg" alt="Availability"></a> <a href="https://github.com/jarun/pdd/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-GPLv3-yellow.svg?maxAge=2592000" alt="License" /></a> - <a href="https://travis-ci.org/jarun/pdd"><img src="https://travis-ci.org/jarun/pdd.svg?branch=master" alt="Build Status" /></a> + <a href="https://circleci.com/gh/jarun/workflows/pdd"><img src="https://img.shields.io/circleci/project/github/jarun/pdd.svg" alt="Build Status" /></a> </p> <p align="center"> @@ -33,8 +34,7 @@ *Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.* <p align="center"> - <a href="https://saythanks.io/to/jarun"><img src="https://img.shields.io/badge/say-thanks!-ff69b4.svg" /></a> - <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-green.svg" alt="Donate via PayPal!" /></a> + <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-1eb0fc.svg" alt="Donate via PayPal!" /></a> </p> ### Table of Contents @@ -58,7 +58,7 @@ - calculate date and time difference - calculate diff from *today* and *now* - add, subtract duration (timeslice) to/from date (time) - - countdown timer + - countdown timer with command piggybacking - custom resolution stopwatch - non-verbose mode for background timers - show current date, time and timezone @@ -79,14 +79,16 @@ #### From a package manager - - [AUR](https://aur.archlinux.org/packages/pdd/) (`pacman -S pdd`) + - [AUR](https://aur.archlinux.org/packages/pdd/) (`yay -S pdd`) - [Debian](https://packages.debian.org/search?keywords=pdd&searchon=names&exact=1) (`apt-get install pdd`) - [Fedora](https://apps.fedoraproject.org/packages/pdd) (`dnf install pdd`) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/pkgs/tools/misc/pdd) (`nix-env -i pdd`) - [PyPI](https://pypi.org/project/pdd) (`pip3 install pdd`) + - [Raspbian Testing](https://archive.raspbian.org/raspbian/pool/main/p/pdd/) (`apt-get install pdd`) + - [Termux](https://termux.com/) (`pip3 install pdd`) - [Ubuntu](https://packages.ubuntu.com/search?keywords=pdd&searchon=names&exact=1) (`apt-get install pdd`) - [Ubuntu PPA](https://launchpad.net/~twodopeshaggy/+archive/ubuntu/jarun/) (`apt-get install pdd`) - - [Void Linux](https://github.com/voidlinux/void-packages/tree/master/srcpkgs/pdd) (`xbps-install -S pdd`) + - [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/pdd) (`xbps-install -S pdd`) #### Release packages @@ -110,17 +112,19 @@ `pdd` is a standalone utility. From the containing directory, run: - $ ./pdd.py + $ chmod +x pdd + $ ./pdd ### Usage #### cmdline options ``` - usage: pdd.py [-h] [-d yyyy mmm dd [yyyy mmm dd | y m d]] - [-t hh:mm:ss [hh:mm:ss | h:m:s]] [--add] [--sub] - [--day yyyy mmm dd] [-c hh:mm:ss] [-s [resolution]] [-q] - [keywords [keywords ...]] + usage: pdd [-h] [-d yyyy mmm dd [yyyy mmm dd | y m d]] + [-t hh:mm:ss [hh:mm:ss | h:m:s]] [--add] [--sub] + [--day yyyy mmm dd] [-c hh:mm:ss] [-r command] [-s [resolution]] + [-q] + [keywords [keywords ...]] Tiny date, time difference calculator with timers. @@ -137,7 +141,8 @@ --sub subtract from date (/today) or time (/now) --day yyyy mmm dd show day of the week on a date -c hh:mm:ss start a countdown timer - -s [resolution] start a stopwatch (default resolution: ms) + -r command run command when countdown timer reaches 0 + -s [resolution] start a stopwatch [default resolution: 3 (ms)] -q quiet mode for background timer/stopwatch ``` @@ -219,6 +224,11 @@ $ pdd -qc 3:0:0 & To see the final counter run `fg` and press <kbd>Ctrl-C</kbd>. + 17. Run a command when countdown timer reaches 0 + + $ pdd -c 00:00:5 -r 'ps -aux' + $ pdd -c 00:00:5 -r 'notify-send pdd "timer expired"' + ### Copyright Copyright © 2017 [Arun Prakash Jana](https://github.com/jarun) @@ -227,6 +237,7 @@ Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console +Classifier: Intended Audience :: Developers Classifier: Intended Audience :: End Users/Desktop Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Natural Language :: English @@ -236,6 +247,7 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Utilities +Requires-Python: >=3.5 Description-Content-Type: text/markdown Provides-Extra: packaging Provides-Extra: tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/README.md new/pdd-1.4/README.md --- old/pdd-1.3.1/README.md 2018-08-08 18:16:59.000000000 +0200 +++ new/pdd-1.4/README.md 2019-04-04 13:18:23.000000000 +0200 @@ -10,8 +10,9 @@ </p> <p align="center"> +<a href="https://repology.org/metapackage/pdd"><img src="https://repology.org/badge/tiny-repos/pdd.svg" alt="Availability"></a> <a href="https://github.com/jarun/pdd/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-GPLv3-yellow.svg?maxAge=2592000" alt="License" /></a> -<a href="https://travis-ci.org/jarun/pdd"><img src="https://travis-ci.org/jarun/pdd.svg?branch=master" alt="Build Status" /></a> +<a href="https://circleci.com/gh/jarun/workflows/pdd"><img src="https://img.shields.io/circleci/project/github/jarun/pdd.svg" alt="Build Status" /></a> </p> <p align="center"> @@ -25,8 +26,7 @@ *Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.* <p align="center"> -<a href="https://saythanks.io/to/jarun"><img src="https://img.shields.io/badge/say-thanks!-ff69b4.svg" /></a> -<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-green.svg" alt="Donate via PayPal!" /></a> +<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-1eb0fc.svg" alt="Donate via PayPal!" /></a> </p> ### Table of Contents @@ -50,7 +50,7 @@ - calculate date and time difference - calculate diff from *today* and *now* - add, subtract duration (timeslice) to/from date (time) -- countdown timer +- countdown timer with command piggybacking - custom resolution stopwatch - non-verbose mode for background timers - show current date, time and timezone @@ -71,14 +71,16 @@ #### From a package manager -- [AUR](https://aur.archlinux.org/packages/pdd/) (`pacman -S pdd`) +- [AUR](https://aur.archlinux.org/packages/pdd/) (`yay -S pdd`) - [Debian](https://packages.debian.org/search?keywords=pdd&searchon=names&exact=1) (`apt-get install pdd`) - [Fedora](https://apps.fedoraproject.org/packages/pdd) (`dnf install pdd`) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/pkgs/tools/misc/pdd) (`nix-env -i pdd`) - [PyPI](https://pypi.org/project/pdd) (`pip3 install pdd`) +- [Raspbian Testing](https://archive.raspbian.org/raspbian/pool/main/p/pdd/) (`apt-get install pdd`) +- [Termux](https://termux.com/) (`pip3 install pdd`) - [Ubuntu](https://packages.ubuntu.com/search?keywords=pdd&searchon=names&exact=1) (`apt-get install pdd`) - [Ubuntu PPA](https://launchpad.net/~twodopeshaggy/+archive/ubuntu/jarun/) (`apt-get install pdd`) -- [Void Linux](https://github.com/voidlinux/void-packages/tree/master/srcpkgs/pdd) (`xbps-install -S pdd`) +- [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/pdd) (`xbps-install -S pdd`) #### Release packages @@ -102,17 +104,19 @@ `pdd` is a standalone utility. From the containing directory, run: - $ ./pdd.py + $ chmod +x pdd + $ ./pdd ### Usage #### cmdline options ``` -usage: pdd.py [-h] [-d yyyy mmm dd [yyyy mmm dd | y m d]] - [-t hh:mm:ss [hh:mm:ss | h:m:s]] [--add] [--sub] - [--day yyyy mmm dd] [-c hh:mm:ss] [-s [resolution]] [-q] - [keywords [keywords ...]] +usage: pdd [-h] [-d yyyy mmm dd [yyyy mmm dd | y m d]] + [-t hh:mm:ss [hh:mm:ss | h:m:s]] [--add] [--sub] + [--day yyyy mmm dd] [-c hh:mm:ss] [-r command] [-s [resolution]] + [-q] + [keywords [keywords ...]] Tiny date, time difference calculator with timers. @@ -129,7 +133,8 @@ --sub subtract from date (/today) or time (/now) --day yyyy mmm dd show day of the week on a date -c hh:mm:ss start a countdown timer - -s [resolution] start a stopwatch (default resolution: ms) + -r command run command when countdown timer reaches 0 + -s [resolution] start a stopwatch [default resolution: 3 (ms)] -q quiet mode for background timer/stopwatch ``` @@ -211,6 +216,11 @@ $ pdd -qc 3:0:0 & To see the final counter run `fg` and press <kbd>Ctrl-C</kbd>. +17. Run a command when countdown timer reaches 0 + + $ pdd -c 00:00:5 -r 'ps -aux' + $ pdd -c 00:00:5 -r 'notify-send pdd "timer expired"' + ### Copyright Copyright © 2017 [Arun Prakash Jana](https://github.com/jarun) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/pdd.egg-info/PKG-INFO new/pdd-1.4/pdd.egg-info/PKG-INFO --- old/pdd-1.3.1/pdd.egg-info/PKG-INFO 2018-08-08 18:17:40.000000000 +0200 +++ new/pdd-1.4/pdd.egg-info/PKG-INFO 2019-04-04 13:19:33.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pdd -Version: 1.3.1 +Version: 1.4 Summary: Tiny date, time diff calculator with timers Home-page: https://github.com/jarun/pdd Author: Arun Prakash Jana @@ -18,8 +18,9 @@ </p> <p align="center"> + <a href="https://repology.org/metapackage/pdd"><img src="https://repology.org/badge/tiny-repos/pdd.svg" alt="Availability"></a> <a href="https://github.com/jarun/pdd/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-GPLv3-yellow.svg?maxAge=2592000" alt="License" /></a> - <a href="https://travis-ci.org/jarun/pdd"><img src="https://travis-ci.org/jarun/pdd.svg?branch=master" alt="Build Status" /></a> + <a href="https://circleci.com/gh/jarun/workflows/pdd"><img src="https://img.shields.io/circleci/project/github/jarun/pdd.svg" alt="Build Status" /></a> </p> <p align="center"> @@ -33,8 +34,7 @@ *Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.* <p align="center"> - <a href="https://saythanks.io/to/jarun"><img src="https://img.shields.io/badge/say-thanks!-ff69b4.svg" /></a> - <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-green.svg" alt="Donate via PayPal!" /></a> + <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-1eb0fc.svg" alt="Donate via PayPal!" /></a> </p> ### Table of Contents @@ -58,7 +58,7 @@ - calculate date and time difference - calculate diff from *today* and *now* - add, subtract duration (timeslice) to/from date (time) - - countdown timer + - countdown timer with command piggybacking - custom resolution stopwatch - non-verbose mode for background timers - show current date, time and timezone @@ -79,14 +79,16 @@ #### From a package manager - - [AUR](https://aur.archlinux.org/packages/pdd/) (`pacman -S pdd`) + - [AUR](https://aur.archlinux.org/packages/pdd/) (`yay -S pdd`) - [Debian](https://packages.debian.org/search?keywords=pdd&searchon=names&exact=1) (`apt-get install pdd`) - [Fedora](https://apps.fedoraproject.org/packages/pdd) (`dnf install pdd`) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/pkgs/tools/misc/pdd) (`nix-env -i pdd`) - [PyPI](https://pypi.org/project/pdd) (`pip3 install pdd`) + - [Raspbian Testing](https://archive.raspbian.org/raspbian/pool/main/p/pdd/) (`apt-get install pdd`) + - [Termux](https://termux.com/) (`pip3 install pdd`) - [Ubuntu](https://packages.ubuntu.com/search?keywords=pdd&searchon=names&exact=1) (`apt-get install pdd`) - [Ubuntu PPA](https://launchpad.net/~twodopeshaggy/+archive/ubuntu/jarun/) (`apt-get install pdd`) - - [Void Linux](https://github.com/voidlinux/void-packages/tree/master/srcpkgs/pdd) (`xbps-install -S pdd`) + - [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/pdd) (`xbps-install -S pdd`) #### Release packages @@ -110,17 +112,19 @@ `pdd` is a standalone utility. From the containing directory, run: - $ ./pdd.py + $ chmod +x pdd + $ ./pdd ### Usage #### cmdline options ``` - usage: pdd.py [-h] [-d yyyy mmm dd [yyyy mmm dd | y m d]] - [-t hh:mm:ss [hh:mm:ss | h:m:s]] [--add] [--sub] - [--day yyyy mmm dd] [-c hh:mm:ss] [-s [resolution]] [-q] - [keywords [keywords ...]] + usage: pdd [-h] [-d yyyy mmm dd [yyyy mmm dd | y m d]] + [-t hh:mm:ss [hh:mm:ss | h:m:s]] [--add] [--sub] + [--day yyyy mmm dd] [-c hh:mm:ss] [-r command] [-s [resolution]] + [-q] + [keywords [keywords ...]] Tiny date, time difference calculator with timers. @@ -137,7 +141,8 @@ --sub subtract from date (/today) or time (/now) --day yyyy mmm dd show day of the week on a date -c hh:mm:ss start a countdown timer - -s [resolution] start a stopwatch (default resolution: ms) + -r command run command when countdown timer reaches 0 + -s [resolution] start a stopwatch [default resolution: 3 (ms)] -q quiet mode for background timer/stopwatch ``` @@ -219,6 +224,11 @@ $ pdd -qc 3:0:0 & To see the final counter run `fg` and press <kbd>Ctrl-C</kbd>. + 17. Run a command when countdown timer reaches 0 + + $ pdd -c 00:00:5 -r 'ps -aux' + $ pdd -c 00:00:5 -r 'notify-send pdd "timer expired"' + ### Copyright Copyright © 2017 [Arun Prakash Jana](https://github.com/jarun) @@ -227,6 +237,7 @@ Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console +Classifier: Intended Audience :: Developers Classifier: Intended Audience :: End Users/Desktop Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Natural Language :: English @@ -236,6 +247,7 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Utilities +Requires-Python: >=3.5 Description-Content-Type: text/markdown Provides-Extra: packaging Provides-Extra: tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/pdd.egg-info/SOURCES.txt new/pdd-1.4/pdd.egg-info/SOURCES.txt --- old/pdd-1.3.1/pdd.egg-info/SOURCES.txt 2018-08-08 18:17:40.000000000 +0200 +++ new/pdd-1.4/pdd.egg-info/SOURCES.txt 2019-04-04 13:19:33.000000000 +0200 @@ -4,6 +4,7 @@ README.md pdd.py setup.py +test.py pdd.egg-info/PKG-INFO pdd.egg-info/SOURCES.txt pdd.egg-info/dependency_links.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/pdd.py new/pdd-1.4/pdd.py --- old/pdd-1.3.1/pdd.py 2018-08-08 18:16:59.000000000 +0200 +++ new/pdd-1.4/pdd.py 2019-04-04 13:19:33.000000000 +0200 @@ -21,10 +21,13 @@ import calendar as cal from datetime import date from datetime import datetime -from dateutil.relativedelta import relativedelta import os +import shlex +import subprocess import sys import time +from dateutil.relativedelta import relativedelta + if os.name == 'nt': import ctypes @@ -32,11 +35,11 @@ _fields_ = [("size", ctypes.c_int), ("visible", ctypes.c_byte)] -# Globals +# Global variables monthdict = {name.lower(): num for num, name in enumerate(cal.month_abbr) if num} -_VERSION_ = '1.3.1' # current program version +_VERSION_ = '1.4' # current program version def is_int(arg): @@ -68,7 +71,7 @@ def showdatediff(d0, d1): '''Show absolute difference between two dates''' - if (d0 < d1): + if d0 < d1: d0, d1 = d1, d0 delta = d0 - d1 @@ -169,26 +172,199 @@ print('%ds' % (t0 - t1)) -def cursor_off(): - if os.name != 'nt': - os.system('setterm -cursor off') +def showdate(): + t = time.localtime() + + if os.name == 'nt' and sys.version_info < (3, 6): + # No tm_zone in Python < v3.6 on Windows + print('%s %02d %s %d %02d:%02d:%02d' % ( + cal.day_abbr[t.tm_wday], + t.tm_year, cal.month_abbr[t.tm_mon], t.tm_mday, + t.tm_hour, t.tm_min, t.tm_sec)) else: + print('%s %02d %s %d %02d:%02d:%02d %s' % ( + cal.day_abbr[t.tm_wday], + t.tm_year, cal.month_abbr[t.tm_mon], t.tm_mday, + t.tm_hour, t.tm_min, t.tm_sec, t.tm_zone)) + + +def cursor_off(): + if os.name == 'nt': ci = _CursorInfo() handle = ctypes.windll.kernel32.GetStdHandle(-11) ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci)) ci.visible = False ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci)) + elif sys.platform == 'darwin': + os.system('tput civis') + else: + os.system('setterm -cursor off') def cursor_on(): - if os.name != 'nt': - os.system('setterm -cursor on') - else: + if os.name == 'nt': ci = _CursorInfo() handle = ctypes.windll.kernel32.GetStdHandle(-11) ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci)) ci.visible = True ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci)) + elif sys.platform == 'darwin': + os.system('tput cnorm') + else: + os.system('setterm -cursor on') + + +def calc_date(args): + d0 = getdate(args.date[:3]) + + if args.add: + if not validargs(args.date[3], args.date[4], args.date[5]): + raise ValueError('negative value') + + d0 += getreldate(args.date[3:]) + print('%s %04d %s %02d' % ( + cal.day_abbr[d0.weekday()], d0.year, cal.month_abbr[d0.month], d0.day)) + elif args.sub: + if not validargs(args.date[3], args.date[4], args.date[5]): + raise ValueError('negative value') + + d0 -= getreldate(args.date[3:]) + print('%s %04d %s %02d' % ( + cal.day_abbr[d0.weekday()], d0.year, cal.month_abbr[d0.month], d0.day)) + else: + d1 = getdate(args.date[3:]) + showdatediff(d0, d1) + + +def calc_time(args): + h, m, s = gettime(args.time[0]) + h, m, s = gethms(h, m, s) + if not validdata(h, m, s): + raise ValueError('negative value') + t0 = h * 3600 + m * 60 + s + + h, m, s = gettime(args.time[1]) + h, m, s = gethms(h, m, s) + if not validdata(h, m, s): + raise ValueError('negative value') + t1 = h * 3600 + m * 60 + s + + if args.add: + showtimesum(t0, t1) + elif args.sub: + showtimesub(t0, t1) + else: + showtimediff(t0, t1) + + +def show_day(day): + d = getdate(day) + print('%s' % cal.day_abbr[d.weekday()]) + + +def calc_misc(args): + if len(args.keywords) == 3: + # Show date diff from today + today = datetime.now().date() + + if args.add: + if not validargs(args.keywords[0], args.keywords[1], + args.keywords[1]): + raise ValueError('negative value') + + today += getreldate(args.keywords) + print('%s %04d %s %02d' % ( + cal.day_abbr[today.weekday()], today.year, cal.month_abbr[today.month], today.day)) + elif args.sub: + if not validargs(args.keywords[0], args.keywords[1], args.keywords[2]): + raise ValueError('negative value') + + today -= getreldate(args.keywords) + print('%s %04d %s %02d' % ( + cal.day_abbr[today.weekday()], today.year, cal.month_abbr[today.month], today.day)) + else: + d0 = getdate(args.keywords) + showdatediff(today, d0) + elif len(args.keywords) == 1: + # Show time diff from now + h, m, s = gettime(args.keywords[0]) + h, m, s = gethms(h, m, s) + if not validdata(h, m, s): + raise ValueError('negative value') + t0 = h * 3600 + m * 60 + s + + now = datetime.now().time() + secs = now.hour * 3600 + now.minute * 60 + now.second + + if args.add: + showtimesum(t0, secs) + elif args.sub: + showtimesub(secs, t0) + else: + showtimediff(t0, secs) + else: + print('keywords can be [dd mmm yyyy] OR [hh:mm:ss]') + + +def run_countdown_timer(args): + h, m, s = gettime(args.timer[0]) + h, m, s = gethms(h, m, s) + if not validdata(h, m, s): + raise ValueError('negative value') + + if args.quiet is False: + cursor_off() + + try: + while True: + if args.quiet is False: + print('\r\x1b[7m{0:02d}h {1:02d}m {2:02d}s\x1b[0m'.format(h, m, s), end='') + s = s - 1 + if s == -1: + s = 59 + m = m - 1 + if m == -1: + m = 59 + h = h - 1 + if h == -1: + h = m = s = 0 + break + time.sleep(1) + except KeyboardInterrupt: + pass + finally: + print('\r\x1b[7m{0:02d}h {1:02d}m {2:02d}s\x1b[0m '.format(h, m, s), end='\b\b\n', flush=True) + print('stop: ', end='') + showdate() + if args.quiet is False: + cursor_on() + if args.run: + # subprocess.call(''.join(args.run).split()) + subprocess.call(shlex.split(''.join(args.run))) + + +def run_stopwatch(args): + print('start: ', end='') + showdate() + + n = args.stopwatch + res = 10 ** (-n) + t0 = time.time() + # os.system('clear') + if args.quiet is False: + cursor_off() + + try: + while True: + t1 = time.time() + if args.quiet is False: + print('\r\x1b[7m{1:.{0}f}s\x1b[0m'.format(n, t1 - t0), end='') + time.sleep(res) + except KeyboardInterrupt: + print('\r\x1b[7m{1:.{0}f}s\x1b[0m '.format(n, t1 - t0), end='\b\b\n', flush=True) + finally: + if args.quiet is False: + cursor_on() class ExtendedArgumentParser(argparse.ArgumentParser): @@ -228,7 +404,7 @@ ''' argparser = ExtendedArgumentParser( - description='Tiny date, time difference calculator with timers.') + description='Tiny date, time difference calculator with timers.') addarg = argparser.add_argument addarg('-d', dest='date', nargs=6, metavar=('yyyy', 'mmm', 'dd', '[yyyy', 'mmm', 'dd | y m d]'), @@ -244,30 +420,17 @@ help='show day of the week on a date') addarg('-c', dest='timer', nargs=1, metavar=('hh:mm:ss'), help='start a countdown timer') + addarg('-r', dest='run', nargs=1, metavar=('command'), + help='run command when countdown timer reaches 0') addarg('-s', dest='stopwatch', nargs='?', type=int, const=3, choices=range(1, 10), - metavar=('resolution'), help='start a stopwatch (default resolution: ms)') + metavar=('resolution'), help='start a stopwatch [default resolution: 3 (ms)]') addarg('-q', dest='quiet', action='store_true', help='quiet mode for background timer/stopwatch') addarg('keywords', nargs='*', help='diff/add/subtract from today or now') # Show `date` and exit if no arguments if len(sys.argv) < 2: - t = time.localtime() - - if os.name == 'nt' and sys.version_info < (3,6): - # No tm_zone in Python < v3.6 on Windows - print('%s %02d %s %d %02d:%02d:%02d' % ( - cal.day_abbr[t.tm_wday], - t.tm_year, cal.month_abbr[t.tm_mon], t.tm_mday, - t.tm_hour, t.tm_min, t.tm_sec)) - print(time.time()) - else: - print('%s %02d %s %d %02d:%02d:%02d %s' % ( - cal.day_abbr[t.tm_wday], - t.tm_year, cal.month_abbr[t.tm_mon], t.tm_mday, - t.tm_hour, t.tm_min, t.tm_sec, t.tm_zone)) - print(time.time()) - + showdate() sys.exit(0) return argparser.parse_args(args, namespace) @@ -280,157 +443,32 @@ print('error: cannot add and subtract simultaneously') sys.exit(1) - # Handle date add, sub or show date diff - if args.date is not None: - try: - d0 = getdate(args.date[:3]) - - if args.add: - if not validargs(args.date[3], args.date[4], args.date[5]): - raise ValueError('negative value') - - d0 += getreldate(args.date[3:]) - print('%s %04d %s %02d' % (cal.day_abbr[d0.weekday()], d0.year, cal.month_abbr[d0.month], d0.day)) - elif args.sub: - if not validargs(args.date[3], args.date[4], args.date[5]): - raise ValueError('negative value') - - d0 -= getreldate(args.date[3:]) - print('%s %04d %s %02d' % (cal.day_abbr[d0.weekday()], d0.year, cal.month_abbr[d0.month], d0.day)) - else: - d1 = getdate(args.date[3:]) - showdatediff(d0, d1) - except (ValueError, KeyError) as e: - print('error: ' + str(e)) - - # Handle time add, sub or show time diff - if args.time is not None: - try: - h, m, s = gettime(args.time[0]) - h, m, s = gethms(h, m, s) - if not validdata(h, m, s): - raise ValueError('negative value') - t0 = h * 3600 + m * 60 + s - - h, m, s = gettime(args.time[1]) - h, m, s = gethms(h, m, s) - if not validdata(h, m, s): - raise ValueError('negative value') - t1 = h * 3600 + m * 60 + s - - if args.add: - showtimesum(t0, t1) - elif args.sub: - showtimesub(t0, t1) - else: - showtimediff(t0, t1) - except (ValueError, TypeError) as e: - print('error: ' + str(e)) - - # Show day of the week on the given date - if args.day is not None: - try: - d = getdate(args.day) - print('%s' % cal.day_abbr[d.weekday()]) - except (ValueError, KeyError) as e: - print('error: ' + str(e)) - - if len(args.keywords): - try: - if len(args.keywords) == 3: - # Show date diff from today - today = datetime.now().date() - - if args.add: - if not validargs(args.keywords[0], args.keywords[1], - args.keywords[1]): - raise ValueError('negative value') - - today += getreldate(args.keywords) - print('%s %04d %s %02d' % (cal.day_abbr[today.weekday()], today.year, cal.month_abbr[today.month], today.day)) - elif args.sub: - if not validargs(args.keywords[0], args.keywords[1], args.keywords[2]): - raise ValueError('negative value') - - today -= getreldate(args.keywords) - print('%s %04d %s %02d' % (cal.day_abbr[today.weekday()], today.year, cal.month_abbr[today.month], today.day)) - else: - d0 = getdate(args.keywords) - showdatediff(today, d0) - elif len(args.keywords) == 1: - # Show time diff from now - h, m, s = gettime(args.keywords[0]) - h, m, s = gethms(h, m, s) - if not validdata(h, m, s): - raise ValueError('negative value') - t0 = h * 3600 + m * 60 + s - - now = datetime.now().time() - secs = now.hour * 3600 + now.minute * 60 + now.second - - if args.add: - showtimesum(t0, secs) - elif args.sub: - showtimesub(secs, t0) - else: - showtimediff(t0, secs) - else: - print('keywords can be [dd mmm yyyy] OR [hh:mm:ss]') - except (ValueError) as e: - print('error: ' + str(e)) + try: + # Handle date add, sub or show date diff + if args.date is not None: + calc_date(args) + + # Handle time add, sub or show time diff + if args.time is not None: + calc_time(args) + + # Show day of the week on the given date + if args.day is not None: + show_day(args.day) + + # Diff/add/subtract from today or now + if args.keywords: + calc_misc(args) + except (ValueError, TypeError, KeyError) as e: + print('error: ' + str(e)) # Countdown timer if args.timer is not None: - h, m, s = gettime(args.timer[0]) - h, m, s = gethms(h, m, s) - if not validdata(h, m, s): - raise ValueError('negative value') - - if args.quiet is False: - cursor_off() - - try: - while True: - if args.quiet is False: - print('\r\x1b[7m{0:02d}h {1:02d}m {2:02d}s\x1b[0m'.format(h, m, s), end='') - s = s - 1 - if s == -1: - s = 59 - m = m - 1 - if m == -1: - m = 59 - h = h - 1 - if h == -1: - h = m = s = 0 - break - time.sleep(1) - except KeyboardInterrupt: - pass - finally: - print('\r\x1b[7m{0:02d}h {1:02d}m {2:02d}s\x1b[0m '.format(h, m, s), end='\b\b\n', flush=True) - if args.quiet is False: - cursor_on() + run_countdown_timer(args) # Stopwatch if args.stopwatch: - n = args.stopwatch - res = 10 ** (-n) - t0 = time.time() - # os.system('clear') - if args.quiet is False: - cursor_off() - - try: - while True: - t1 = time.time() - if args.quiet is False: - print('\r\x1b[7m{1:.{0}f}s\x1b[0m'.format(n, t1 - t0), end='') - time.sleep(res) - except KeyboardInterrupt: - print('\r\x1b[7m{1:.{0}f}s\x1b[0m '.format(n, t1 - t0), end='\b\b\n', flush=True) - finally: - if args.quiet is False: - cursor_on() + run_stopwatch(args) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/setup.py new/pdd-1.4/setup.py --- old/pdd-1.3.1/setup.py 2018-07-02 09:42:18.000000000 +0200 +++ new/pdd-1.4/setup.py 2019-04-04 13:18:23.000000000 +0200 @@ -1,13 +1,12 @@ #!/usr/bin/env python3 import re +import shutil import sys from setuptools import setup, find_packages -if sys.version_info < (3, 5): - print('ERROR: pdd requires at least Python 3.5 to run.') - sys.exit(1) +shutil.copyfile('pdd', 'pdd.py') with open('pdd.py', encoding='utf-8') as f: version = re.search('_VERSION_ = \'([^\']+)\'', f.read()).group(1) @@ -27,6 +26,7 @@ author_email='engineerarun@gmail.com', url='https://github.com/jarun/pdd', license='GPLv3', + python_requires='>=3.5', # requires pip>=9.0.0 platforms=['any'], py_modules=['pdd'], install_requires=['python-dateutil'], @@ -44,6 +44,7 @@ classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', + 'Intended Audience :: Developers', 'Intended Audience :: End Users/Desktop', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 'Natural Language :: English', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pdd-1.3.1/test.py new/pdd-1.4/test.py --- old/pdd-1.3.1/test.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pdd-1.4/test.py 2019-04-04 13:18:23.000000000 +0200 @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +''' +pdd test script + +Author: Arun Prakash Jana +Email : engineerarun@gmail.com +Home : https://github.com/jarun/pdd + +NOTES: + +1. Before raising a PR, + a. add relevant test cases + b. run `python3 -m pytest test.py +''' +import pytest +import subprocess + +test = [ + ('./pdd', '-d', '1983', 'jul', '3', '2014', '1', '15'), # 1 + ('./pdd', '-d', '2014', '1', '15', '1983', 'jul', '03'), # 2 + ('./pdd', '-t', '45:50', '6:17:33'), # 3 + ('./pdd', '-t', '6:17:33', '45:50'), # 4 + ('./pdd', '-t', '5:80:75', '6:17:33'), # 5 + ('./pdd', '-t', '6:17:33', '5:80:75'), # 6 + ('./pdd', '-d', '2000', 'FEB', '28', '3', '2', '1', '--add'), # 7 + ('./pdd', '-d', '2000', 'FEB', '28', '1', '2', '3', '--add'), # 8 + ('./pdd', '-t', '47:71:37', '1:2:63', '--add'), # 9 + ('./pdd', '-d', '2000', 'Mar', '01', '0', '0', '1', '--sub'), # 10 + ('./pdd', '-d', '2000', 'Mar', '1', '1', '1', '1', '--sub'), # 11 + ('./pdd', '-t', '00:00:00', '0:0:1', '--sub'), # 12 + ('./pdd', '-t', '25:61:61', '0:0:0', '--sub'), # 13 + ('./pdd', '-t', '0:0:0', '1:1:1', '--sub'), # 14 + ('./pdd', '-t', '0:0:0', '25:61:61', '--sub'), # 15 +] + +res = [ + b'30y 6m 12d\n11154d\n', # 1 + b'30y 6m 12d\n11154d\n', # 2 + b'05:31:43\n19903s\n', # 3 + b'05:31:43\n19903s\n', # 4 + b'00:03:42\n222s\n', # 5 + b'00:03:42\n222s\n', # 6 + b'Tue 2003 Apr 29\n', # 7 + b'Tue 2001 May 01\n', # 8 + b'2 day(s) later, 01:14:40\n177280s\n', # 9 + b'Tue 2000 Feb 29\n', # 10 + b'Sun 1999 Jan 31\n', # 11 + b'1 day(s) earlier, 23:59:59\n-1s\n', # 12 + b'02:02:01\n93721s\n', # 13 + b'1 day(s) earlier, 22:58:59\n-3661s\n', # 14 + b'2 day(s) earlier, 21:57:59\n-93721s\n', # 15 +] + + +@pytest.mark.parametrize('item, res', zip(test, res)) +def test_output(item, res): + try: + out = subprocess.check_output(item, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + # print(e.output) + assert e.output == res + else: + assert out == res