divejson 0.35.0__tar.gz → 0.35.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. {divejson-0.35.0 → divejson-0.35.2}/CHANGELOG.md +24 -0
  2. {divejson-0.35.0 → divejson-0.35.2}/PKG-INFO +1 -1
  3. divejson-0.35.2/SPEC_REF +1 -0
  4. {divejson-0.35.0 → divejson-0.35.2}/divejson/__init__.py +1 -1
  5. {divejson-0.35.0 → divejson-0.35.2}/divejson/fit.py +65 -34
  6. {divejson-0.35.0 → divejson-0.35.2}/divejson/shearwater_db.py +7 -4
  7. {divejson-0.35.0 → divejson-0.35.2}/divejson/shearwater_xml.py +4 -2
  8. {divejson-0.35.0 → divejson-0.35.2}/divejson/ssrf.py +44 -8
  9. {divejson-0.35.0 → divejson-0.35.2}/divejson/xmlsource.py +68 -28
  10. {divejson-0.35.0 → divejson-0.35.2}/docs/converting.md +8 -5
  11. {divejson-0.35.0 → divejson-0.35.2}/docs/fit-mapping.md +84 -65
  12. {divejson-0.35.0 → divejson-0.35.2}/docs/ssrf-mapping.md +2 -1
  13. {divejson-0.35.0 → divejson-0.35.2}/docs/uddf-mapping.md +1 -1
  14. {divejson-0.35.0 → divejson-0.35.2}/fixtures/README.md +20 -9
  15. divejson-0.35.2/fixtures/fit/garmin-connect-summary-first.divejson +42380 -0
  16. divejson-0.35.2/fixtures/fit/garmin-connect-summary-first.fit +0 -0
  17. {divejson-0.35.0 → divejson-0.35.2}/tests/test_fit_fixtures.py +37 -11
  18. {divejson-0.35.0 → divejson-0.35.2}/tests/test_fit_parsing.py +110 -9
  19. {divejson-0.35.0 → divejson-0.35.2}/tests/test_fit_units.py +58 -0
  20. {divejson-0.35.0 → divejson-0.35.2}/tests/test_shearwater_db.py +12 -0
  21. {divejson-0.35.0 → divejson-0.35.2}/tests/test_shearwater_xml.py +8 -0
  22. {divejson-0.35.0 → divejson-0.35.2}/tests/test_ssrf_units.py +20 -5
  23. {divejson-0.35.0 → divejson-0.35.2}/tests/test_xmlsource.py +47 -0
  24. divejson-0.35.0/SPEC_REF +0 -1
  25. {divejson-0.35.0 → divejson-0.35.2}/.github/scripts/release_bump.py +0 -0
  26. {divejson-0.35.0 → divejson-0.35.2}/.github/scripts/spec_pin.py +0 -0
  27. {divejson-0.35.0 → divejson-0.35.2}/.github/workflows/ci.yml +0 -0
  28. {divejson-0.35.0 → divejson-0.35.2}/.github/workflows/pr-title.yml +0 -0
  29. {divejson-0.35.0 → divejson-0.35.2}/.github/workflows/release-bump.yml +0 -0
  30. {divejson-0.35.0 → divejson-0.35.2}/.github/workflows/release.yml +0 -0
  31. {divejson-0.35.0 → divejson-0.35.2}/.gitignore +0 -0
  32. {divejson-0.35.0 → divejson-0.35.2}/CONTRIBUTING.md +0 -0
  33. {divejson-0.35.0 → divejson-0.35.2}/LICENSE +0 -0
  34. {divejson-0.35.0 → divejson-0.35.2}/README.md +0 -0
  35. {divejson-0.35.0 → divejson-0.35.2}/divejson/cli.py +0 -0
  36. {divejson-0.35.0 → divejson-0.35.2}/divejson/codes.py +0 -0
  37. {divejson-0.35.0 → divejson-0.35.2}/divejson/conform.py +0 -0
  38. {divejson-0.35.0 → divejson-0.35.2}/divejson/converter.py +0 -0
  39. {divejson-0.35.0 → divejson-0.35.2}/divejson/py.typed +0 -0
  40. {divejson-0.35.0 → divejson-0.35.2}/divejson/registry.py +0 -0
  41. {divejson-0.35.0 → divejson-0.35.2}/divejson/series.py +0 -0
  42. {divejson-0.35.0 → divejson-0.35.2}/divejson/suunto_json.py +0 -0
  43. {divejson-0.35.0 → divejson-0.35.2}/divejson/suunto_xml.py +0 -0
  44. {divejson-0.35.0 → divejson-0.35.2}/divejson/uddf.py +0 -0
  45. {divejson-0.35.0 → divejson-0.35.2}/divejson/uddf_write.py +0 -0
  46. {divejson-0.35.0 → divejson-0.35.2}/divejson/validate.py +0 -0
  47. {divejson-0.35.0 → divejson-0.35.2}/docs/shearwater-db-mapping.md +0 -0
  48. {divejson-0.35.0 → divejson-0.35.2}/docs/shearwater-xml-mapping.md +0 -0
  49. {divejson-0.35.0 → divejson-0.35.2}/docs/suunto-json-mapping.md +0 -0
  50. {divejson-0.35.0 → divejson-0.35.2}/docs/suunto-xml-mapping.md +0 -0
  51. {divejson-0.35.0 → divejson-0.35.2}/docs/uddf-writing.md +0 -0
  52. {divejson-0.35.0 → divejson-0.35.2}/docs/writing.md +0 -0
  53. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/ocean-heart-rate.divejson +0 -0
  54. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/ocean-heart-rate.fit +0 -0
  55. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/ocean-poor-first-fix.divejson +0 -0
  56. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/ocean-poor-first-fix.fit +0 -0
  57. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/suunto-d5.divejson +0 -0
  58. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/suunto-d5.fit +0 -0
  59. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/suunto-ocean-2026.divejson +0 -0
  60. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/suunto-ocean-2026.fit +0 -0
  61. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/suunto-ocean.divejson +0 -0
  62. {divejson-0.35.0 → divejson-0.35.2}/fixtures/fit/suunto-ocean.fit +0 -0
  63. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/accommodation-dangling-reference.divejson +0 -0
  64. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/address-without-country.divejson +0 -0
  65. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/agency-other-missing.divejson +0 -0
  66. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/avg-depth-exceeds-max.divejson +0 -0
  67. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/bad-version.divejson +0 -0
  68. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/bbox-missing-corner.divejson +0 -0
  69. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/bbox-south-exceeds-north.divejson +0 -0
  70. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/bbox-without-position.divejson +0 -0
  71. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/boat-name-empty.divejson +0 -0
  72. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/boat-name-too-long.divejson +0 -0
  73. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/channel-length-mismatch.divejson +0 -0
  74. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/contact-position-incomplete.divejson +0 -0
  75. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/contact-roles-repeated.divejson +0 -0
  76. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/course-agency-other-without-agency.divejson +0 -0
  77. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/course-dates-reversed.divejson +0 -0
  78. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/current-unknown.divejson +0 -0
  79. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/cylinder-gear-dangling-reference.divejson +0 -0
  80. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/cylinder-gear-repeated.divejson +0 -0
  81. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/dangling-reference.divejson +0 -0
  82. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/deco-model-gf-order.divejson +0 -0
  83. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/device-empty-member.divejson +0 -0
  84. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/dive-duration.divejson +0 -0
  85. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/dive-profile-outside-recording.divejson +0 -0
  86. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/dive-readout-outside-recording.divejson +0 -0
  87. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/diver-email-too-long.divejson +0 -0
  88. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/diver-name-too-long.divejson +0 -0
  89. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/diver-username.divejson +0 -0
  90. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/duplicate-file-uuid-across-recordings.divejson +0 -0
  91. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/duplicate-file-uuid-portrait.divejson +0 -0
  92. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/duplicate-json-member.divejson +0 -0
  93. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/duplicate-uuid.divejson +0 -0
  94. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/emergency-contact-without-name.divejson +0 -0
  95. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/entry-type-unknown.divejson +0 -0
  96. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/event-without-type-or-label.divejson +0 -0
  97. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-identifier-empty.divejson +0 -0
  98. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-identifier-too-long.divejson +0 -0
  99. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-openstreetmap-form.divejson +0 -0
  100. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-registry-not-a-key.divejson +0 -0
  101. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-wikidata-form.divejson +0 -0
  102. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-without-identifier.divejson +0 -0
  103. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-without-registry.divejson +0 -0
  104. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-id-worms-form.divejson +0 -0
  105. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-ids-repeated-with-extensions.divejson +0 -0
  106. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/external-ids-repeated.divejson +0 -0
  107. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/gear-dive-time-negative.divejson +0 -0
  108. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/gear-material-unknown.divejson +0 -0
  109. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/gear-type-unknown.divejson +0 -0
  110. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/gear-volume-not-positive.divejson +0 -0
  111. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/gear-working-pressure-too-high.divejson +0 -0
  112. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/heart-rate-zero.divejson +0 -0
  113. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/instructor-dangling-reference.divejson +0 -0
  114. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/insurance-without-provider.divejson +0 -0
  115. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/location-full-name.divejson +0 -0
  116. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/missing-format.divejson +0 -0
  117. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/naive-exported-at.divejson +0 -0
  118. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/non-increasing-samples.divejson +0 -0
  119. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/null-member.divejson +0 -0
  120. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/oxygen-helium-sum.divejson +0 -0
  121. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/person-dangling-reference.divejson +0 -0
  122. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/person-referenced-twice.divejson +0 -0
  123. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/position-incomplete.divejson +0 -0
  124. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/pressure-order.divejson +0 -0
  125. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/profile-duration-short.divejson +0 -0
  126. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/rating-out-of-range.divejson +0 -0
  127. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/recording-without-content.divejson +0 -0
  128. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/schedule-interval-hours-not-positive.divejson +0 -0
  129. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/schedule-without-interval.divejson +0 -0
  130. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/sighting-count-and-abundance.divejson +0 -0
  131. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/sighting-dangling-reference.divejson +0 -0
  132. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/sighting-species-repeated.divejson +0 -0
  133. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-altitude-too-high.divejson +0 -0
  134. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-altitude-too-low.divejson +0 -0
  135. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-bbox-south-exceeds-north.divejson +0 -0
  136. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-depth-from-negative.divejson +0 -0
  137. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-depth-reversed.divejson +0 -0
  138. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-depth-to-negative.divejson +0 -0
  139. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-entry-type-unknown.divejson +0 -0
  140. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-entry-types-repeated.divejson +0 -0
  141. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-other-name-empty.divejson +0 -0
  142. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-other-name-repeats-name.divejson +0 -0
  143. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-other-name-too-long.divejson +0 -0
  144. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-other-names-repeated-by-case.divejson +0 -0
  145. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-other-names-repeated.divejson +0 -0
  146. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-tag-empty.divejson +0 -0
  147. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-tag-too-long.divejson +0 -0
  148. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-tags-repeated-by-case.divejson +0 -0
  149. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-tags-repeated.divejson +0 -0
  150. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/site-water-type-unknown.divejson +0 -0
  151. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/species-aphia-id.divejson +0 -0
  152. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/species-external-ids-empty.divejson +0 -0
  153. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/species-external-ids-repeated-with-extensions.divejson +0 -0
  154. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/species-no-identity.divejson +0 -0
  155. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/species-two-worms-entries.divejson +0 -0
  156. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/species-wikidata-qid.divejson +0 -0
  157. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/tag-empty.divejson +0 -0
  158. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/tag-too-long.divejson +0 -0
  159. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/tags-repeated-by-case.divejson +0 -0
  160. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/tags-repeated-by-whitespace.divejson +0 -0
  161. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/tags-repeated.divejson +0 -0
  162. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/trailing-newline-datetime.divejson +0 -0
  163. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/trip-dates-reversed.divejson +0 -0
  164. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/type-unknown.divejson +0 -0
  165. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/undefined-member.divejson +0 -0
  166. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/water-type-en13319.divejson +0 -0
  167. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/waves-unknown.divejson +0 -0
  168. {divejson-0.35.0 → divejson-0.35.2}/fixtures/invalid/weather-unknown.divejson +0 -0
  169. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_db/perdix3-deco-dive-11.db +0 -0
  170. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_db/perdix3-deco-dive-11.divejson +0 -0
  171. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_db/perdix3-dives-1-and-8.db +0 -0
  172. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_db/perdix3-dives-1-and-8.divejson +0 -0
  173. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_xml/perdix3-deco-dive-11.divejson +0 -0
  174. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_xml/perdix3-deco-dive-11.xml +0 -0
  175. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_xml/perdix3-dive-8.divejson +0 -0
  176. {divejson-0.35.0 → divejson-0.35.2}/fixtures/shearwater_xml/perdix3-dive-8.xml +0 -0
  177. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/people.divejson +0 -0
  178. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/people.ssrf +0 -0
  179. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/refusals.divejson +0 -0
  180. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/refusals.ssrf +0 -0
  181. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/sites.divejson +0 -0
  182. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/sites.ssrf +0 -0
  183. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/subsurface.divejson +0 -0
  184. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/subsurface.ssrf +0 -0
  185. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/trip-grouping.divejson +0 -0
  186. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/trip-grouping.ssrf +0 -0
  187. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/two-computers.divejson +0 -0
  188. {divejson-0.35.0 → divejson-0.35.2}/fixtures/ssrf/two-computers.ssrf +0 -0
  189. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/d5-deco-max-depth.divejson +0 -0
  190. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/d5-deco-max-depth.json +0 -0
  191. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/d5-deep-stop-broken.divejson +0 -0
  192. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/d5-deep-stop-broken.json +0 -0
  193. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/d5-stop-alarms.divejson +0 -0
  194. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/d5-stop-alarms.json +0 -0
  195. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/header-only.divejson +0 -0
  196. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/header-only.json +0 -0
  197. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/not-a-dive.divejson +0 -0
  198. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/not-a-dive.json +0 -0
  199. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-deco-ppo2.divejson +0 -0
  200. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-deco-ppo2.json +0 -0
  201. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-heart-rate.divejson +0 -0
  202. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-heart-rate.json +0 -0
  203. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-poor-first-fix.divejson +0 -0
  204. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-poor-first-fix.json +0 -0
  205. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-tank-pressure.divejson +0 -0
  206. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/ocean-tank-pressure.json +0 -0
  207. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/purged-regulator.divejson +0 -0
  208. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/purged-regulator.json +0 -0
  209. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/suunto-d5.divejson +0 -0
  210. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/suunto-d5.json +0 -0
  211. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/suunto-ocean-2026.divejson +0 -0
  212. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/suunto-ocean-2026.json +0 -0
  213. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/suunto-ocean.divejson +0 -0
  214. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_json/suunto-ocean.json +0 -0
  215. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/freedive.divejson +0 -0
  216. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/freedive.xml +0 -0
  217. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/nitrox-deco.divejson +0 -0
  218. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/nitrox-deco.xml +0 -0
  219. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/refusals.divejson +0 -0
  220. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/refusals.xml +0 -0
  221. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/suunto-d5.divejson +0 -0
  222. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/suunto-d5.xml +0 -0
  223. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/unlabelled-pressure.divejson +0 -0
  224. {divejson-0.35.0 → divejson-0.35.2}/fixtures/suunto_xml/unlabelled-pressure.xml +0 -0
  225. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/conditions.divejson +0 -0
  226. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/conditions.uddf +0 -0
  227. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/contacts.divejson +0 -0
  228. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/contacts.uddf +0 -0
  229. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/divelogs.divejson +0 -0
  230. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/divelogs.uddf +0 -0
  231. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/gear.divejson +0 -0
  232. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/gear.uddf +0 -0
  233. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/legacy-writer.divejson +0 -0
  234. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/legacy-writer.uddf +0 -0
  235. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/mix-only-cylinder.divejson +0 -0
  236. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/mix-only-cylinder.uddf +0 -0
  237. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/opendiving.divejson +0 -0
  238. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/opendiving.uddf +0 -0
  239. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/owner-profile-only.divejson +0 -0
  240. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/owner-profile-only.uddf +0 -0
  241. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/people.divejson +0 -0
  242. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/people.uddf +0 -0
  243. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/shearwater-cloud-cns.divejson +0 -0
  244. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/shearwater-cloud-cns.uddf +0 -0
  245. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/shearwater-cloud.divejson +0 -0
  246. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/shearwater-cloud.uddf +0 -0
  247. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/sites.divejson +0 -0
  248. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/sites.uddf +0 -0
  249. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/subsurface.divejson +0 -0
  250. {divejson-0.35.0 → divejson-0.35.2}/fixtures/uddf/subsurface.uddf +0 -0
  251. {divejson-0.35.0 → divejson-0.35.2}/fixtures/valid/demo-logbook.divejson +0 -0
  252. {divejson-0.35.0 → divejson-0.35.2}/fixtures/valid/minimal.divejson +0 -0
  253. {divejson-0.35.0 → divejson-0.35.2}/fixtures/valid/technical-dive.divejson +0 -0
  254. {divejson-0.35.0 → divejson-0.35.2}/fixtures/valid/two-computers.divejson +0 -0
  255. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/contacts.divejson +0 -0
  256. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/contacts.uddf +0 -0
  257. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/opendiving.divejson +0 -0
  258. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/opendiving.uddf +0 -0
  259. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/owner-profile-only.divejson +0 -0
  260. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/owner-profile-only.uddf +0 -0
  261. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/people.divejson +0 -0
  262. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/people.uddf +0 -0
  263. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/technical-dive.divejson +0 -0
  264. {divejson-0.35.0 → divejson-0.35.2}/fixtures/write/uddf/technical-dive.uddf +0 -0
  265. {divejson-0.35.0 → divejson-0.35.2}/pyproject.toml +0 -0
  266. {divejson-0.35.0 → divejson-0.35.2}/schema/1.0/divejson.schema.json +0 -0
  267. {divejson-0.35.0 → divejson-0.35.2}/tests/fitbuild.py +0 -0
  268. {divejson-0.35.0 → divejson-0.35.2}/tests/fixtures/README.md +0 -0
  269. {divejson-0.35.0 → divejson-0.35.2}/tests/fixtures/uddf_3.2.2.xsd +0 -0
  270. {divejson-0.35.0 → divejson-0.35.2}/tests/helpers.py +0 -0
  271. {divejson-0.35.0 → divejson-0.35.2}/tests/shearwaterbuild.py +0 -0
  272. {divejson-0.35.0 → divejson-0.35.2}/tests/test_cli.py +0 -0
  273. {divejson-0.35.0 → divejson-0.35.2}/tests/test_conform.py +0 -0
  274. {divejson-0.35.0 → divejson-0.35.2}/tests/test_converter.py +0 -0
  275. {divejson-0.35.0 → divejson-0.35.2}/tests/test_findings.py +0 -0
  276. {divejson-0.35.0 → divejson-0.35.2}/tests/test_package.py +0 -0
  277. {divejson-0.35.0 → divejson-0.35.2}/tests/test_registry.py +0 -0
  278. {divejson-0.35.0 → divejson-0.35.2}/tests/test_release_bump.py +0 -0
  279. {divejson-0.35.0 → divejson-0.35.2}/tests/test_series.py +0 -0
  280. {divejson-0.35.0 → divejson-0.35.2}/tests/test_sources.py +0 -0
  281. {divejson-0.35.0 → divejson-0.35.2}/tests/test_spec_pin.py +0 -0
  282. {divejson-0.35.0 → divejson-0.35.2}/tests/test_ssrf_fixtures.py +0 -0
  283. {divejson-0.35.0 → divejson-0.35.2}/tests/test_ssrf_parsing.py +0 -0
  284. {divejson-0.35.0 → divejson-0.35.2}/tests/test_suunto_json_fixtures.py +0 -0
  285. {divejson-0.35.0 → divejson-0.35.2}/tests/test_suunto_json_parsing.py +0 -0
  286. {divejson-0.35.0 → divejson-0.35.2}/tests/test_suunto_json_units.py +0 -0
  287. {divejson-0.35.0 → divejson-0.35.2}/tests/test_suunto_xml_fixtures.py +0 -0
  288. {divejson-0.35.0 → divejson-0.35.2}/tests/test_suunto_xml_parsing.py +0 -0
  289. {divejson-0.35.0 → divejson-0.35.2}/tests/test_suunto_xml_units.py +0 -0
  290. {divejson-0.35.0 → divejson-0.35.2}/tests/test_uddf_fixtures.py +0 -0
  291. {divejson-0.35.0 → divejson-0.35.2}/tests/test_uddf_parsing.py +0 -0
  292. {divejson-0.35.0 → divejson-0.35.2}/tests/test_uddf_units.py +0 -0
  293. {divejson-0.35.0 → divejson-0.35.2}/tests/test_uddf_write_fixtures.py +0 -0
  294. {divejson-0.35.0 → divejson-0.35.2}/tests/test_uddf_writing.py +0 -0
  295. {divejson-0.35.0 → divejson-0.35.2}/tests/test_validate.py +0 -0
@@ -7,6 +7,30 @@ this file is about the package, whose version moves independently.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.35.2
11
+
12
+ - **Garmin Connect FIT exports keep their samples when the session precedes them.**
13
+ The reader carries the native no-decompression time and time to surface in seconds,
14
+ ppO₂ in hundredths of a bar and CNS in tenths of a percent. Events keep their own
15
+ timestamps on the samples' recording origin, including between samples and after the
16
+ last sample, without extending the profile duration. A summary-first export with
17
+ multiple sessions is refused with a request to export each dive separately, rather
18
+ than silently losing samples or mixing untimed gas definitions. The anonymised Garmin
19
+ Connect fixture covers both gases, the four channels, gas switches and dive alerts.
20
+
21
+ ## 0.35.1
22
+
23
+ - **Reading a measurement takes linear time in every reader.** Subsurface's measured
24
+ attributes and the figures typed into a Shearwater Cloud logbook were split with patterns
25
+ that backtrack quadratically on a long run of letters or digits; both are now scanned
26
+ without backtracking, and a value over 64 characters is not a number and is dropped and
27
+ reported as one. The Shearwater Cloud XML sniff's start-tag pattern is linear too.
28
+ - **A `<!DOCTYPE>` is refused before the parser reads anything.** The refusal used to come
29
+ from the parser's own hook, which surfaces only after the whole buffer has been parsed —
30
+ entity references in the content included. The prolog is now scanned first, and the
31
+ document is fed in 64 KiB pieces behind it. The scan, like the sniff's `root_name`, reads
32
+ UTF-16 without a byte-order mark, as the parser does.
33
+
10
34
  ## 0.35.0
11
35
 
12
36
  - **The readers carry the diver's heart rate, and the UDDF writer sends it back as a pulse
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: divejson
3
- Version: 0.35.0
3
+ Version: 0.35.2
4
4
  Summary: Validator, converters and conformance runner for DiveJSON, an open dive-log interchange format
5
5
  Project-URL: Homepage, https://divejson.org
6
6
  Project-URL: Repository, https://github.com/divejson/divejson-py
@@ -0,0 +1 @@
1
+ 7e31b341fb636414fe1cfc543e13fa518545dbb9
@@ -25,7 +25,7 @@ specification commit named in the repository's ``SPEC_REF``, so that an installe
25
25
  resolves its own schema and needs no checkout of anything.
26
26
  """
27
27
 
28
- __version__ = "0.35.0"
28
+ __version__ = "0.35.2"
29
29
 
30
30
  SPEC_VERSION = "1.0"
31
31
 
@@ -110,6 +110,18 @@ _READING_LABELS: dict[str, str] = {
110
110
  "ceiling": "decompression ceiling",
111
111
  "temperature": "water temperature",
112
112
  "heart_rate": "heart rate",
113
+ "ndl": "no-decompression time",
114
+ "tts": "time to surface",
115
+ "ppo2": "ppO₂ reading",
116
+ "cns": "CNS reading",
117
+ }
118
+
119
+ HUNDREDTHS_PER_BAR = Decimal(100)
120
+ SAMPLED_READOUTS: dict[str, tuple[str, Decimal]] = {
121
+ "ndl": ("ndl_time", Decimal(1)),
122
+ "tts": ("time_to_surface", Decimal(1)),
123
+ "ppo2": ("po2", HUNDREDTHS_PER_BAR),
124
+ "cns": ("cns_load", TENTHS_PER_UNIT),
113
125
  }
114
126
 
115
127
  # uuid5(NAMESPACE_URL, "https://divejson.org/ns/fit"). Fixed forever: changing it would
@@ -200,16 +212,17 @@ SALINITIES = {"fresh": "fresh", "salt": "salt", "en13319": "en13319"}
200
212
  # shared enum carries — have to come out as nothing rather than be forced into a type of
201
213
  # this format's.
202
214
  #
203
- # `timer` is the deliberate omission. It is the only `event` any file in hand writes, and
204
- # its start/stop pair says where the dive begins and ends, which §6.4's `started_at` and
205
- # the profile's own axis already say twice over.
215
+ # `timer` is the deliberate omission. Its start/stop pair says where the dive begins and
216
+ # ends, which §6.4's `started_at` and the profile's own axis already say twice over. It is
217
+ # the only `event` the Suunto fixtures write; the Garmin Connect pair also carries gas
218
+ # switches and dive alerts.
206
219
  #
207
220
  # **`dive_alert` maps to `None`**, which here means an event with no `type` at all and the
208
221
  # device's wording as its `label` — §6.6's spelling of an unclassified event. The alert
209
222
  # names are deliberately *not* mapped onto §6.6's vocabulary, though several of them plainly
210
- # line up with it: no FIT file in hand carries a `dive_alert` of any kind, and this corpus
211
- # does not adopt a mapping no pair exercises. The Suunto app JSON reader has that table
212
- # because its files have the alerts.
223
+ # line up with it. The Garmin Connect pair exercises their native labels; a mapping onto
224
+ # this format's event types remains unadopted. The Suunto app JSON reader has that table
225
+ # because its files exercise that mapping.
213
226
  EVENT_TYPES: dict[str, str | None] = {
214
227
  "dive_gas_switched": "gas_switch",
215
228
  "user_marker": "bookmark",
@@ -328,17 +341,17 @@ class _Point:
328
341
  `tank_update` at one timestamp are one sample rather than two, the later of which the
329
342
  axis would drop.
330
343
 
331
- `eq=False` so a point stays hashable and compares by identity. A dataclass that
332
- generates `__eq__` sets `__hash__` to `None`, and these are used as dictionary keys —
333
- an event finds its place by looking its own instant's point up in the axis. Identity
334
- is also the comparison that means anything here: two instants that happened to record
335
- the same depth are still two samples.
344
+ `eq=False` keeps points distinct when two instants happen to record the same readings.
336
345
  """
337
346
 
338
347
  depth: Decimal | None = None
339
348
  ceiling: Decimal | None = None
340
349
  temperature: Decimal | None = None
341
350
  heart_rate: Decimal | None = None
351
+ ndl: Decimal | None = None
352
+ tts: Decimal | None = None
353
+ ppo2: Decimal | None = None
354
+ cns: Decimal | None = None
342
355
  latitude: Decimal | None = None
343
356
  longitude: Decimal | None = None
344
357
  # `gps_accuracy`, the receiver's stated horizontal error in metres, off the `record`
@@ -351,16 +364,16 @@ class _Point:
351
364
  class _Scan:
352
365
  """Everything one pass over a FIT file keeps.
353
366
 
354
- A FIT file is a stream whose summary messages come *after* the samples they summarise,
355
- so there is no cheap way to read a header: the file is decoded once and this is what
356
- survives it. Summaries are kept as frames, of which there are a handful; the sample
357
- stream is reduced to `_Point`s as it goes past.
367
+ Summaries can precede or follow the samples, so the file is decoded once and this is
368
+ what survives it. Summaries are kept as frames; the sample stream is reduced to
369
+ `_Point`s as it goes past.
358
370
  """
359
371
 
360
372
  protocol: str | None = None
361
373
  file_id: fitdecode.FitDataMessage | None = None
362
374
  session: fitdecode.FitDataMessage | None = None
363
375
  sessions: int = 0
376
+ summary_first: bool = False
364
377
  activity: fitdecode.FitDataMessage | None = None
365
378
  settings: fitdecode.FitDataMessage | None = None
366
379
  summaries: list[fitdecode.FitDataMessage] = field(default_factory=list)
@@ -429,11 +442,23 @@ def _collect(scan: _Scan, frame: fitdecode.FitDataMessage) -> None:
429
442
  `dive_summary` and `tank_summary` sit **above** that cut, because both are written
430
443
  after the session they describe and gating them on it would discard every one. They
431
444
  are bounded at the second session instead.
445
+
446
+ Garmin Connect can put the session before all samples. That single-session ordering
447
+ keeps the following stream. Multiple summary-first sessions are refused: untimed gas
448
+ definitions cannot be assigned to a dive reliably, and silently dropping or mixing
449
+ their samples would produce a misleading logbook.
432
450
  """
433
451
  name = frame.name
434
452
  if name == "file_id":
435
453
  scan.file_id = scan.file_id or frame
436
454
  elif name == "session":
455
+ if scan.sessions == 0:
456
+ scan.summary_first = not (scan.points or scan.undated)
457
+ elif scan.summary_first:
458
+ raise MalformedFitError(
459
+ "this FIT file puts a session summary before its samples and contains multiple sessions; "
460
+ "their samples and gas lists cannot be separated reliably, so export each dive as a separate FIT file"
461
+ )
437
462
  scan.sessions += 1
438
463
  scan.session = scan.session or frame
439
464
  elif name == "activity":
@@ -449,7 +474,7 @@ def _collect(scan: _Scan, frame: fitdecode.FitDataMessage) -> None:
449
474
  elif name == "tank_summary":
450
475
  if scan.sessions < 2:
451
476
  scan.tanks.append(frame)
452
- elif scan.session is not None:
477
+ elif scan.session is not None and not scan.summary_first:
453
478
  return
454
479
  elif name == "dive_gas":
455
480
  scan.gases.append(frame)
@@ -506,6 +531,8 @@ def _collect_record(scan: _Scan, frame: fitdecode.FitDataMessage) -> None:
506
531
  _set(scan, point, "temperature", _number(_native(frame, "temperature")))
507
532
  # Beats per minute already, which is the channel's unit.
508
533
  _set(scan, point, "heart_rate", _number(_native(frame, "heart_rate")))
534
+ for channel, (source, _) in SAMPLED_READOUTS.items():
535
+ _set(scan, point, channel, _number(_native(frame, source)))
509
536
  unfixed = point.latitude is None
510
537
  _set(scan, point, "latitude", _degrees(_native(frame, "position_lat")))
511
538
  _set(scan, point, "longitude", _degrees(_native(frame, "position_long")))
@@ -1452,6 +1479,11 @@ class _Converter:
1452
1479
 
1453
1480
  # -- the profile -------------------------------------------------------------
1454
1481
 
1482
+ def time_origin(self) -> datetime | None:
1483
+ """The shared origin for elapsed sample and event timestamps."""
1484
+ start = _native(self.scan.session, "start_time")
1485
+ return start if isinstance(start, datetime) else min(self.scan.points, default=None)
1486
+
1455
1487
  def axis(self, where: str) -> SampleAxis:
1456
1488
  """The dive's time axis, offered every instant the file recorded a reading at.
1457
1489
 
@@ -1474,11 +1506,10 @@ class _Converter:
1474
1506
  code="readings_at_one_instant",
1475
1507
  member=f"{RECORDING}/profile",
1476
1508
  )
1477
- if not self.scan.points:
1509
+ origin = self.time_origin()
1510
+ if origin is None:
1478
1511
  return axis
1479
1512
 
1480
- start = _native(self.scan.session, "start_time")
1481
- origin = start if isinstance(start, datetime) else min(self.scan.points)
1482
1513
  for at, point in self.scan.points.items():
1483
1514
  axis.offer(milliseconds(Decimal(str((at - origin).total_seconds()))), point)
1484
1515
  return axis
@@ -1506,6 +1537,7 @@ class _Converter:
1506
1537
  ceiling = Channel("ceiling")
1507
1538
  temperature = Channel("temperature")
1508
1539
  heart_rate = Channel("heart_rate")
1540
+ readouts = {name: Channel(name) for name in SAMPLED_READOUTS}
1509
1541
  pressures = {sensor: Channel("pressures") for sensor in sensors}
1510
1542
  for at, point in samples.ordered():
1511
1543
  if point.depth is not None:
@@ -1516,14 +1548,18 @@ class _Converter:
1516
1548
  temperature.record(at, rounded(point.temperature * HUNDREDTHS_PER_DEGREE))
1517
1549
  if point.heart_rate is not None:
1518
1550
  heart_rate.record(at, rounded(point.heart_rate))
1551
+ for name, channel in readouts.items():
1552
+ value = getattr(point, name)
1553
+ if value is not None:
1554
+ channel.record(at, rounded(value * SAMPLED_READOUTS[name][1]))
1519
1555
  for sensor, bar in point.pressures.items():
1520
1556
  if sensor in pressures and 0 <= bar <= MAX_CYLINDER_PRESSURE:
1521
1557
  pressures[sensor].record(at, rounded(bar * TENTHS_PER_UNIT))
1522
1558
 
1523
- events = self.read_events(samples, where)
1559
+ events = self.read_events(where)
1524
1560
  numbered = [(number, pressures[sensor]) for number, sensor in enumerate(sensors) if sensor in pressures]
1525
1561
  profile = samples.profile(
1526
- {"depth": depth, "ceiling": ceiling, "temperature": temperature, "heart_rate": heart_rate},
1562
+ {"depth": depth, "ceiling": ceiling, "temperature": temperature, "heart_rate": heart_rate, **readouts},
1527
1563
  pressures=numbered,
1528
1564
  events=events,
1529
1565
  )
@@ -1535,7 +1571,7 @@ class _Converter:
1535
1571
  cylinder["gas_number"] = number
1536
1572
  return profile
1537
1573
 
1538
- def read_events(self, samples: SampleAxis, where: str) -> list[dict[str, Any]]:
1574
+ def read_events(self, where: str) -> list[dict[str, Any]]:
1539
1575
  """The `event` messages that describe the dive, as §6.5 events.
1540
1576
 
1541
1577
  The one that needs work is `dive_gas_switched`, whose `data` field holds the
@@ -1549,8 +1585,9 @@ class _Converter:
1549
1585
  happened, and saying "a gas switch, to something this file does not describe" is
1550
1586
  honest where guessing a position would not be.
1551
1587
 
1552
- **Untested against a real file**: the only `event` any file in hand writes is
1553
- `timer`, which this table deliberately does not carry.
1588
+ The Garmin Connect fixture carries gas switches and labelled dive alerts.
1589
+ Bookmarks still have no device fixture; the Suunto fixtures carry only `timer`,
1590
+ which this table deliberately does not carry.
1554
1591
  """
1555
1592
  if not self.scan.events:
1556
1593
  return []
@@ -1559,11 +1596,7 @@ class _Converter:
1559
1596
  for number, index in enumerate(_native_raw(gas, "message_index") for gas in self.gases)
1560
1597
  if isinstance(index, int) and not isinstance(index, bool)
1561
1598
  }
1562
- # The axis is what decided which instants have a place and where each landed, so
1563
- # an event asks it rather than recomputing from the session's start time: a sample
1564
- # the axis dropped for sharing its millisecond with an earlier one is an instant the
1565
- # profile does not reach, and an event there has nowhere to go either.
1566
- places = {point: at for at, point in samples.ordered()}
1599
+ origin = self.time_origin()
1567
1600
 
1568
1601
  events: list[dict[str, Any]] = []
1569
1602
  for frame in self.scan.events:
@@ -1576,13 +1609,11 @@ class _Converter:
1576
1609
  at = _native(frame, "timestamp")
1577
1610
  if not isinstance(at, datetime):
1578
1611
  continue
1579
- point = self.scan.points.get(at)
1580
- placed = places.get(point) if point is not None else None
1581
- if placed is None:
1612
+ placed = milliseconds(Decimal(str((at - origin).total_seconds()))) if origin is not None else None
1613
+ if placed is None or placed < 0:
1582
1614
  self.note(
1583
1615
  where,
1584
- "An event is recorded at an instant the dive's profile does not reach, so it has no place in "
1585
- "it and is left out.",
1616
+ "An event has no recording time origin or occurs before the recording began, so it is left out.",
1586
1617
  "dropped",
1587
1618
  code="event_outside_profile",
1588
1619
  member=f"{RECORDING}/profile/events",
@@ -299,8 +299,11 @@ DETAIL_COLUMNS_MAPPED = frozenset(
299
299
  *NO_PLACE_COLUMNS,
300
300
  }
301
301
  )
302
- # A figure as a diver types one: a number, and whatever follows it.
303
- _FIGURE = re.compile(r"\A([+-]?\d+(?:\.\d+)?)\s*(\S.*)?\Z")
302
+ # A figure as a diver types one: a number, and whatever follows it. Possessive, because
303
+ # a number that gave digits back would be retried against the rest of the line once per
304
+ # digit; and refused past `_FIGURE_LENGTH`, which no figure a diver types comes near.
305
+ _FIGURE = re.compile(r"\A([+-]?\d++(?:\.\d++)?+)\s*+(.*)\Z")
306
+ _FIGURE_LENGTH = 64
304
307
 
305
308
 
306
309
  class ShearwaterDbError(ConverterError):
@@ -1789,11 +1792,11 @@ def _typed(value: Any) -> str:
1789
1792
  def _figure(typed: str) -> tuple[Decimal, str] | None:
1790
1793
  """A typed figure as its number and whatever unit follows it, or nothing for one that is
1791
1794
  not a number this package can carry."""
1792
- match = _FIGURE.match(typed)
1795
+ match = _FIGURE.match(typed) if len(typed) <= _FIGURE_LENGTH else None
1793
1796
  number = None if match is None else decimal_of(match[1])
1794
1797
  if match is None or number is None:
1795
1798
  return None
1796
- return number, (match[2] or "").strip()
1799
+ return number, match[2].strip()
1797
1800
 
1798
1801
 
1799
1802
  def _scaled(value: Any, scale: int) -> int | None:
@@ -92,8 +92,10 @@ ROOT = "dive"
92
92
 
93
93
  # The root's start tag and the first child the sniff asks for. `<dive>` is a name the DM5
94
94
  # export's root has too, there in a datacontract namespace; this root declares none of its
95
- # own and carries a `version`, and its first element child is `<diveLog>`.
96
- _START_TAG = re.compile(r"<(?:[\w.-]+:)?dive(\s[^>]*)?>", re.IGNORECASE)
95
+ # own and carries a `version`, and its first element child is `<diveLog>`. The attributes
96
+ # stop at a `<` as well as a `>`, which no start tag can hold, so a search tried at every
97
+ # `<dive` reads each stretch of the head once rather than once per tag.
98
+ _START_TAG = re.compile(r"<(?:[\w.-]+:)?dive(\s[^<>]*)?>", re.IGNORECASE)
97
99
  _DEFAULT_NAMESPACE = re.compile(r"\sxmlns\s*=")
98
100
  _VERSION = re.compile(r"\sversion\s*=")
99
101
  _DIVE_LOG = re.compile(r"<(?:[\w.-]+:)?diveLog[\s/>]")
@@ -51,6 +51,7 @@ and `drop_summary` are where it is made.
51
51
  from __future__ import annotations
52
52
 
53
53
  import re
54
+ import string
54
55
  import uuid as uuid_pkg
55
56
  import xml.etree.ElementTree as ET
56
57
  from collections.abc import Callable
@@ -114,10 +115,10 @@ MAX_CYLINDER_PRESSURE = Decimal(350)
114
115
  # guess at.
115
116
  _CLOCK = re.compile(r"\A(\d+):([0-5]\d)\Z")
116
117
 
117
- # A measurement splits into a number and the unit written after it. The unit is optional
118
- # because Subsurface writes some counts bare — `otu='31'`, `visibility='5'` — and the
119
- # number is whatever is left, checked by `decimal_of` rather than by this pattern.
120
- _MEASUREMENT = re.compile(r"\A(?P<number>\S+?)\s*(?P<unit>%|[A-Za-z][A-Za-z/]*)?\Z")
118
+ # A measurement splits into a number and the unit written after it — see `_measurement`.
119
+ # Nothing Subsurface writes comes near this length, and a value past it is not a number.
120
+ _MEASUREMENT_LENGTH = 64
121
+ _UNIT_CHARACTERS = frozenset(string.ascii_letters + "/")
121
122
 
122
123
  # A dive's `@date` and `@time`. Subsurface writes both to the digit, and the leniency here
123
124
  # is for the seconds alone: a hand-edited file missing them costs a dive otherwise, and
@@ -162,6 +163,41 @@ def _calendar_date(text: str) -> bool:
162
163
  return True
163
164
 
164
165
 
166
+ def _measurement(raw: str) -> tuple[str, str] | None:
167
+ """A measurement as its number and the unit written after it, or nothing.
168
+
169
+ The unit is optional because Subsurface writes some counts bare — `otu='31'`,
170
+ `visibility='5'` — so it is the longest closing `%` or run of letters and slashes that
171
+ opens on a letter, whitespace before it allowed. The number is everything in front: at
172
+ least one character and no whitespace, checked by `decimal_of` rather than here. Scanned
173
+ by hand because the pattern that says this backtracks quadratically on a long run of
174
+ letters, and refused past `_MEASUREMENT_LENGTH` so the work is bounded whatever the file.
175
+ """
176
+ if not raw or len(raw) > _MEASUREMENT_LENGTH:
177
+ return None
178
+ if raw.endswith("%"):
179
+ start = len(raw) - 1
180
+ else:
181
+ start = len(raw)
182
+ while start and raw[start - 1] in _UNIT_CHARACTERS:
183
+ start -= 1
184
+ while start < len(raw) and raw[start] == "/":
185
+ start += 1
186
+ number = raw[:start].rstrip()
187
+ if not number:
188
+ if start:
189
+ return None
190
+ # All of it reads as a unit, and the number needs a character: it takes the first,
191
+ # and the slashes after it, since a unit opens on a letter.
192
+ start = 1
193
+ while start < len(raw) and raw[start] == "/":
194
+ start += 1
195
+ number = raw[:start]
196
+ if any(character.isspace() for character in number):
197
+ return None
198
+ return number, raw[start:]
199
+
200
+
165
201
  # Every unit spelling this reader knows, against the way the number in front of it is read.
166
202
  # A measurement whose unit is not a key here is **dropped and reported** rather than read at
167
203
  # a guessed scale, which is `converting.md`'s refuse-rather-than-guess rule applied to the
@@ -274,14 +310,14 @@ class _Converter:
274
310
  # written in one unit produces one of these per record — 431 of them for a sample
275
311
  # channel — and `Conversion.grouped()` groups on the message, so a value in the
276
312
  # text would turn one habit of the file into hundreds of separate report lines.
277
- match = _MEASUREMENT.match(raw)
278
- if match is None:
313
+ split = _measurement(raw)
314
+ if split is None:
279
315
  self.note(
280
316
  where, f"{label} is not a number with a unit after it, and is left out.", "dropped",
281
317
  code="not_a_number", member=path,
282
318
  )
283
319
  return None
284
- found = match.group("unit") or ""
320
+ number, found = split
285
321
  if found != unit:
286
322
  self.note(
287
323
  where,
@@ -294,7 +330,7 @@ class _Converter:
294
330
  return None
295
331
  # `UNITS[unit]` on a unit this module never registered is a `KeyError`, which is the
296
332
  # point: it is this adapter asking for a scale nothing defines, not a source defect.
297
- value = UNITS[unit](match.group("number"))
333
+ value = UNITS[unit](number)
298
334
  if value is None:
299
335
  self.note(
300
336
  where,
@@ -10,9 +10,10 @@ document type declaration. `ElementTree` blocks external entities on its own but
10
10
  entity *amplification* only in recent libexpat — a several hundredfold blowup still parses
11
11
  on older ones, and that is a library-version property rather than a guarantee this
12
12
  package's `>=3.11` floor can make. Refusing the declaration is the guarantee, and it costs
13
- nothing real. Raising from the target's `doctype` hook aborts before expat has expanded a
14
- single entity reference in the content, which is what makes this a bound on amplification
15
- rather than a check performed after the damage.
13
+ nothing real. The prolog is scanned for one before expat is handed a byte, so nothing is
14
+ expanded at all: a refusal raised from expat's own `doctype` hook surfaces only once the
15
+ buffer that carried it has been parsed to its end, entity references included. That hook
16
+ stays, behind input fed in `_CHUNK`-sized pieces, for an encoding the scan misreads.
16
17
 
17
18
  **A tag is matched on its lowercased local name.** UDDF alone appears under four root
18
19
  shapes — two namespaces, no namespace at all, and an uppercase `<UDDF>` for 2.x — and
@@ -45,10 +46,19 @@ __all__ = [
45
46
  ]
46
47
 
47
48
  _NAME = re.compile(r"[^\s/>]+")
49
+ _DOCTYPE = re.compile(r"<!DOCTYPE\s+([^\s\[>]+)")
50
+
51
+ # What expat is fed at a time, so that a refusal from the `doctype` hook stops the parse
52
+ # within one piece of the declaration rather than at the end of the document.
53
+ _CHUNK = 64 * 1024
48
54
 
49
55
 
50
56
  class DoctypeRefusingTarget(ET.TreeBuilder):
51
- """A parse target that stops the parse the moment a DTD is declared.
57
+ """A parse target that refuses a DTD the prolog scan let through.
58
+
59
+ Its error surfaces only once expat has parsed the chunk that carried the declaration,
60
+ entity references in it included, so it is the backstop for an encoding the scan
61
+ misreads and not the refusal itself.
52
62
 
53
63
  The hook is on the *target* rather than on the parser: `XMLParser.parser`, which the
54
64
  equivalent expat handler would need, no longer exists on Python 3.14, while this one
@@ -56,10 +66,14 @@ class DoctypeRefusingTarget(ET.TreeBuilder):
56
66
  """
57
67
 
58
68
  def doctype(self, name: str, pubid: str | None, system: str | None) -> None:
59
- raise DoctypeRefusedError(
60
- f"the file declares <!DOCTYPE {name}>, and a file that declares a document type is not read, since one "
61
- "can pull in content from outside the file"
62
- )
69
+ raise _refused(name)
70
+
71
+
72
+ def _refused(name: str) -> DoctypeRefusedError:
73
+ return DoctypeRefusedError(
74
+ f"the file declares <!DOCTYPE {name}>, and a file that declares a document type is not read, since one "
75
+ "can pull in content from outside the file"
76
+ )
63
77
 
64
78
 
65
79
  def local_name(element: ET.Element) -> str:
@@ -131,9 +145,15 @@ def parse_xml(data: bytes, *, root: str, malformed: type[ConverterError]) -> ET.
131
145
  catching one format's errors still catches this one. A `<!DOCTYPE>` raises
132
146
  `DoctypeRefusedError` regardless, which is not any one format's refusal.
133
147
  """
148
+ prolog = _decoded(data)
149
+ position = _markup(prolog, 0)
150
+ declaration = _DOCTYPE.match(prolog, position) if position >= 0 else None
151
+ if declaration is not None:
152
+ raise _refused(declaration[1])
134
153
  parser = ET.XMLParser(target=DoctypeRefusingTarget())
135
154
  try:
136
- parser.feed(data)
155
+ for start in range(0, len(data), _CHUNK):
156
+ parser.feed(data[start : start + _CHUNK])
137
157
  found = parser.close()
138
158
  except DoctypeRefusedError:
139
159
  raise
@@ -154,36 +174,56 @@ def root_name(head: bytes) -> str | None:
154
174
  rather than refused here; refusing it is the *reader's* job, and a sniffer that raised
155
175
  would turn a hostile file into an error before anything had decided to read it.
156
176
 
157
- UTF-16 is decoded from its byte-order mark because Windows tools emit it; anything else
158
- is read as Latin-1, which never fails and is exactly right for the ASCII markup that
159
- precedes a root element whatever the declared encoding is.
177
+ The bytes are decoded as `_decoded` decodes them.
160
178
  """
161
- if head[:2] in (b"\xff\xfe", b"\xfe\xff"):
162
- text = head.decode("utf-16", errors="replace")
163
- else:
164
- text = head.removeprefix(b"\xef\xbb\xbf").decode("latin-1")
165
-
179
+ text = _decoded(head)
166
180
  position = 0
167
181
  while True:
168
- position = text.find("<", position)
182
+ position = _markup(text, position)
169
183
  if position < 0:
170
184
  return None
171
- rest = text[position:]
185
+ if text.startswith("<!", position):
186
+ position = _past_declaration(text, position)
187
+ if position < 0:
188
+ return None
189
+ continue
190
+ match = _NAME.match(text, position + 1)
191
+ return match.group().rpartition(":")[2].lower() if match else None
192
+
193
+
194
+ def _decoded(data: bytes) -> str:
195
+ """XML bytes as text good enough to walk the markup before the root element.
196
+
197
+ UTF-16 is recognised as expat recognises it — from a byte-order mark, which Windows
198
+ tools emit, or from a zero byte in the first two, which is how a `<` opens a UTF-16
199
+ file that has none. Anything else is read as Latin-1, which never fails and is exactly
200
+ right for the ASCII markup that precedes a root element whatever the declared encoding is.
201
+ """
202
+ if data[:2] in (b"\xff\xfe", b"\xfe\xff"):
203
+ return data.decode("utf-16", errors="replace")
204
+ if data[:1] == b"\x00":
205
+ return data.decode("utf-16-be", errors="replace")
206
+ if data[1:2] == b"\x00":
207
+ return data.decode("utf-16-le", errors="replace")
208
+ return data.removeprefix(b"\xef\xbb\xbf").decode("latin-1")
209
+
210
+
211
+ def _markup(text: str, position: int) -> int:
212
+ """The offset of the next `<` from `position` that opens neither a processing
213
+ instruction nor a comment — a declaration or an element — or -1."""
214
+ while True:
215
+ position = text.find("<", position)
216
+ if position < 0:
217
+ return -1
172
218
  for opening, closing in (("<?", "?>"), ("<!--", "-->")):
173
- if rest.startswith(opening):
219
+ if text.startswith(opening, position):
174
220
  end = text.find(closing, position + len(opening))
175
221
  if end < 0:
176
- return None
222
+ return -1
177
223
  position = end + len(closing)
178
224
  break
179
225
  else:
180
- if rest.startswith("<!"):
181
- position = _past_declaration(text, position)
182
- if position < 0:
183
- return None
184
- continue
185
- match = _NAME.match(text, position + 1)
186
- return match.group().rpartition(":")[2].lower() if match else None
226
+ return position
187
227
 
188
228
 
189
229
  def _past_declaration(text: str, position: int) -> int:
@@ -81,11 +81,14 @@ XML parser blocks external entities on its own, but it caps entity *amplificatio
81
81
  recent versions of the underlying library — a several-hundredfold blowup still parses on
82
82
  older ones, and that is a property of the library version rather than a guarantee the
83
83
  language makes. Refusing the declaration is the guarantee, it costs nothing real, and it
84
- saves taking on a hardening dependency for something one hook already settles.
85
-
86
- The refusal fires from the parser's doctype hook, which runs before a single entity
87
- reference in the content has been expanded. Every XML adapter shares one parse target, so
88
- the refusal is written once rather than per format.
84
+ saves taking on a hardening dependency for something one check already settles.
85
+
86
+ The refusal happens before the parser reads anything: the prolog is scanned for a
87
+ declaration first, and a document that carries one is never handed to the parser at all. A
88
+ refusal raised from inside the parser comes too late to bound anything, since a parser may
89
+ report the declaration only once it has worked through the input that carried it, entity
90
+ references included. Every XML adapter reads through one entry point, so the refusal is
91
+ written once rather than per format.
89
92
 
90
93
  ## Units and arithmetic
91
94