From 9bd14c4575d7d549d6ec890748931959542ec904 Mon Sep 17 00:00:00 2001 From: Carey Metcalfe Date: Sun, 14 Jan 2024 09:50:09 -0500 Subject: [PATCH 1/3] Fix typo in api docs (#145) * Fix typo in api docs * Fix test that checked warning output --- docs/api.rst | 2 +- tests/test.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 8d64e0f..e5db642 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -76,7 +76,7 @@ The ``FitFile`` Object try: fitfile = FitFile('/path.to/fitfile.fit') fitfile.parse() - except FitParseError, e: + except FitParseError as e: print "Error while parsing .FIT file: %s" % e sys.exit(1) diff --git a/tests/test.py b/tests/test.py index 886f21f..77082fb 100755 --- a/tests/test.py +++ b/tests/test.py @@ -74,6 +74,7 @@ def testfile(filename): class FitFileTestCase(unittest.TestCase): + def test_basic_file_with_one_record(self, endian='<'): f = FitFile(generate_fitfile(endian=endian)) f.parse() @@ -414,7 +415,11 @@ def test_mismatched_field_size(self): with warnings.catch_warnings(record=True) as w: f.parse() assert w - assert all("falling back to byte encoding" in str(x) for x in w) + assert all( + "falling back to byte encoding" in str(x) + for x in w + if x.category == UserWarning + ) self.assertEqual(len(f.messages), 11293) def test_unterminated_file(self): From 0ae62ab46856be418922b6e6cc72e16e7debcf96 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Sun, 19 Jan 2025 17:38:37 -0500 Subject: [PATCH 2/3] License bump. Happy New Year! --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 387b0b0..901fe39 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ MIT License -Copyright (c) 2011-2022, David Cooper -Copyright (c) 2017-2022, Carey Metcalfe +Copyright (c) 2011-2025, David Cooper +Copyright (c) 2017-2025, Carey Metcalfe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 142578c9474d190d2c45e55172d99d41d41d8a27 Mon Sep 17 00:00:00 2001 From: roboes Date: Sat, 25 Jan 2025 16:44:46 +0100 Subject: [PATCH 3/3] Update datetime module as datetime.datetime.utcfromtimestamp() is deprecated --- fitparse/processors.py | 4 ++-- tests/test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fitparse/processors.py b/fitparse/processors.py index 6848584..34b36ba 100644 --- a/fitparse/processors.py +++ b/fitparse/processors.py @@ -70,7 +70,7 @@ def process_type_bool(self, field_data): def process_type_date_time(self, field_data): value = field_data.value if value is not None and value >= 0x10000000: - field_data.value = datetime.datetime.utcfromtimestamp(UTC_REFERENCE + value) + field_data.value = datetime.datetime.fromtimestamp(timestamp=(UTC_REFERENCE + value), tz=datetime.timezone.utc).replace(tzinfo=None) field_data.units = None # Units were 's', set to None def process_type_local_date_time(self, field_data): @@ -78,7 +78,7 @@ def process_type_local_date_time(self, field_data): # NOTE: This value was created on the device using it's local timezone. # Unless we know that timezone, this value won't be correct. However, if we # assume UTC, at least it'll be consistent. - field_data.value = datetime.datetime.utcfromtimestamp(UTC_REFERENCE + field_data.value) + field_data.value = datetime.datetime.fromtimestamp(timestamp=(UTC_REFERENCE + field_data.value), tz=datetime.timezone.utc).replace(tzinfo=None) field_data.units = None def process_type_localtime_into_day(self, field_data): diff --git a/tests/test.py b/tests/test.py index 77082fb..e4851d5 100755 --- a/tests/test.py +++ b/tests/test.py @@ -66,7 +66,7 @@ def generate_fitfile(data=None, endian='<'): def secs_to_dt(secs): - return datetime.datetime.utcfromtimestamp(secs + UTC_REFERENCE) + return datetime.datetime.fromtimestamp(timestamp=(secs + UTC_REFERENCE), tz=datetime.timezone.utc).replace(tzinfo=None) def testfile(filename):