diff --git a/CHANGELOG b/CHANGELOG index b4a70693..b845b4b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,11 @@ jc changelog -20231128 v1.23.7 +20231128 v1.24.0 - Add `deb-packages-index` parser for Debian/Ubuntu Package Index files - Add `debconf-show` command parser - Add `swapon` command parser - Add `tune2fs` command parser +- Remove `iso-datetime` parser (use `datetime-iso` instead) - Update timezone change in Github Actions for node v16 requirement - Refactor `acpi` command parser for code cleanup - Fix `iptables` parser for cases where the `target` field is blank in a rule diff --git a/jc/lib.py b/jc/lib.py index 37b7c02d..cb4a6ee0 100644 --- a/jc/lib.py +++ b/jc/lib.py @@ -71,7 +71,6 @@ parsers: List[str] = [ 'ip-address', 'iptables', 'ip-route', - 'iso-datetime', 'iw-scan', 'iwconfig', 'jar-manifest', diff --git a/jc/parsers/iso_datetime.py b/jc/parsers/iso_datetime.py deleted file mode 100644 index b4294e9e..00000000 --- a/jc/parsers/iso_datetime.py +++ /dev/null @@ -1,46 +0,0 @@ -"""jc - JSON Convert ISO 8601 Datetime string parser - -This parser has been renamed to datetime-iso (cli) or datetime_iso (module). - -This parser will be removed in a future version, so please start using -the new parser name. -""" -from jc.parsers import datetime_iso -import jc.utils - - -class info(): - """Provides parser metadata (version, author, etc.)""" - version = '1.1' - description = 'Deprecated - please use datetime-iso' - author = 'Kelly Brazil' - author_email = 'kellyjonbrazil@gmail.com' - details = 'Deprecated - please use datetime-iso' - compatible = ['linux', 'aix', 'freebsd', 'darwin', 'win32', 'cygwin'] - tags = ['standard', 'string'] - deprecated = True - - -__version__ = info.version - - -def parse(data, raw=False, quiet=False): - """ - This parser is deprecated and calls datetime_iso. Please use datetime_iso - directly. This parser will be removed in the future. - - Parameters: - - data: (string) text data to parse - raw: (boolean) unprocessed output if True - quiet: (boolean) suppress warning messages if True - - Returns: - - Dictionary. Raw or processed structured data. - """ - jc.utils.warning_message([ - 'iso-datetime parser is deprecated. Please use datetime-iso instead.' - ]) - - return datetime_iso.parse(data, raw=raw, quiet=quiet) diff --git a/tests/test_iso_datetime.py b/tests/test_iso_datetime.py deleted file mode 100644 index dd381694..00000000 --- a/tests/test_iso_datetime.py +++ /dev/null @@ -1,60 +0,0 @@ -import unittest -import json -import jc.parsers.iso_datetime - - -class MyTests(unittest.TestCase): - def test_iso_datetime_nodata(self): - """ - Test 'iso_datetime' with no data - """ - self.assertEqual(jc.parsers.iso_datetime.parse('', quiet=True), {}) - - - def test_iso_datetime_z(self): - """ - Test ISO datetime string with Z timezone - """ - data = r'2007-04-05T14:30Z' - expected = json.loads(r'''{"year":2007,"month":"Apr","month_num":4,"day":5,"weekday":"Thu","weekday_num":4,"hour":2,"hour_24":14,"minute":30,"second":0,"microsecond":0,"period":"PM","utc_offset":"+0000","day_of_year":95,"week_of_year":14,"iso":"2007-04-05T14:30:00+00:00","timestamp":1175783400}''') - self.assertEqual(jc.parsers.iso_datetime.parse(data, quiet=True), expected) - - - def test_iso_datetime_microseconds(self): - """ - Test ISO datetime string with Z timezone - """ - data = r'2007-04-05T14:30.555Z' - expected = json.loads(r'''{"year":2007,"month":"Apr","month_num":4,"day":5,"weekday":"Thu","weekday_num":4,"hour":2,"hour_24":14,"minute":0,"second":30,"microsecond":555000,"period":"PM","utc_offset":"+0000","day_of_year":95,"week_of_year":14,"iso":"2007-04-05T14:00:30.555000+00:00","timestamp":1175781630}''') - self.assertEqual(jc.parsers.iso_datetime.parse(data, quiet=True), expected) - - - def test_iso_datetime_plus_offset(self): - """ - Test ISO datetime string with + offset - """ - data = r'2007-04-05T14:30+03:30' - expected = json.loads(r'''{"year":2007,"month":"Apr","month_num":4,"day":5,"weekday":"Thu","weekday_num":4,"hour":2,"hour_24":14,"minute":30,"second":0,"microsecond":0,"period":"PM","utc_offset":"+0330","day_of_year":95,"week_of_year":14,"iso":"2007-04-05T14:30:00+03:30","timestamp":1175770800}''') - self.assertEqual(jc.parsers.iso_datetime.parse(data, quiet=True), expected) - - - def test_iso_datetime_negative_offset(self): - """ - Test ISO datetime string with - offset - """ - data = r'2007-04-05T14:30-03:30' - expected = json.loads(r'''{"year":2007,"month":"Apr","month_num":4,"day":5,"weekday":"Thu","weekday_num":4,"hour":2,"hour_24":14,"minute":30,"second":0,"microsecond":0,"period":"PM","utc_offset":"-0330","day_of_year":95,"week_of_year":14,"iso":"2007-04-05T14:30:00-03:30","timestamp":1175796000}''') - self.assertEqual(jc.parsers.iso_datetime.parse(data, quiet=True), expected) - - - def test_iso_datetime_nocolon_offset(self): - """ - Test ISO datetime string with no colon offset - """ - data = r'2007-04-05T14:30+0300' - expected = json.loads(r'''{"year":2007,"month":"Apr","month_num":4,"day":5,"weekday":"Thu","weekday_num":4,"hour":2,"hour_24":14,"minute":30,"second":0,"microsecond":0,"period":"PM","utc_offset":"+0300","day_of_year":95,"week_of_year":14,"iso":"2007-04-05T14:30:00+03:00","timestamp":1175772600}''') - self.assertEqual(jc.parsers.iso_datetime.parse(data, quiet=True), expected) - - -if __name__ == '__main__': - unittest.main()