Skip to content

Commit 3a7a809

Browse files
committed
Release 7.2: Support custom timestamp formats (#19, #23)
1 parent 704aff8 commit 3a7a809

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

CHANGELOG.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,47 @@ to `semantic versioning`_.
1111
.. _Keep a Changelog: http://keepachangelog.com/
1212
.. _semantic versioning: http://semver.org/
1313

14+
`Release 7.2`_ (2020-02-14)
15+
---------------------------
16+
17+
Merged pull request `#23`_ which makes it possible to customize the regular
18+
expression that's used to match timestamps in filenames using a new command
19+
line option ``rotate-backups --timestamp-pattern``.
20+
21+
The pull request wasn't exactly complete (the code couldn't have run as
22+
written, although it showed the general idea clear enough) so I decided to
23+
treat `#23`_ as more of a feature suggestion. However there was no reason no to
24+
merge the pull request and use it as a base for my changes, hence why I decided
25+
to do so despite rewriting the code.
26+
27+
Changes from the pull request:
28+
29+
- Renamed ``timestamp`` to :attr:`~rotate_backups.RotateBackups.timestamp_pattern`
30+
to make it less ambiguous.
31+
32+
- Added validation that custom patterns provided by callers define
33+
named capture groups corresponding to the required date components
34+
(year, month and day).
35+
36+
- Rewrote the mapping from capture groups to :class:`datetime.datetime`
37+
arguments as follows:
38+
39+
- Previously positional :class:`datetime.datetime` arguments were used
40+
which depended on the order of capture groups in the hard coded
41+
regular expression pattern to function correctly.
42+
43+
- Now that users can define their own patterns, this is no longer a
44+
reasonable approach. As such the code now constructs and passes a
45+
dictionary of keyword arguments to :class:`datetime.datetime`.
46+
47+
- Updated the documentation and the command line interface usage message to
48+
describe the new command line option and configuration file option.
49+
50+
- Added tests for the new behavior.
51+
52+
.. _Release 7.2: https://github.com/xolox/python-rotate-backups/compare/7.1...7.2
53+
.. _#23: https://github.com/xolox/python-rotate-backups/pull/23
54+
1455
`Release 7.1`_ (2020-02-13)
1556
---------------------------
1657

rotate_backups/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from verboselogs import VerboseLogger
4545

4646
# Semi-standard module versioning.
47-
__version__ = '7.1'
47+
__version__ = '7.2'
4848

4949
# Initialize a logger for this module.
5050
logger = VerboseLogger(__name__)
@@ -458,8 +458,8 @@ def timestamp_pattern(self):
458458
:func:`re.compile()` documentation for details).
459459
460460
The regular expression pattern is expected to be a Python compatible
461-
regular expression that contains the named capture groups 'year',
462-
'month', 'day', 'hour', 'minute' and 'second'.
461+
regular expression that defines the named capture groups 'year',
462+
'month' and 'day' and optionally 'hour', 'minute' and 'second'.
463463
464464
String values are automatically coerced to compiled regular expressions
465465
by calling :func:`~humanfriendly.coerce_pattern()`, in this case only

0 commit comments

Comments
 (0)