Skip to content

Conversation

@janbridley
Copy link
Collaborator

@janbridley janbridley commented Dec 21, 2024

This PR is a total refactor of the current interface, with a significantly improved parser in additional to the wrapping CifFile class. The class builds an iterator out of lines from the file, combining multiline data entries into single, parseable blocks. The table reader is more robust as well, with more careful regex allowing for fewer assumptions about non-delimiting whitespaces. The previous parse and unitcells modules have been combined as class methods, with patterns being retained to store the myriad string cleaning operations. Files are read and processed lazily, so this should be more memory efficient as well.

Motivation and Context

Per request from several PR's, this interface is more pythonic and only traverses the file once. Multiple operations on the same file are effectively free (requiring only a dict or list lookup), where the previous code would have to open and read the file each time.

Resolves #5

Types of Changes

  • Documentation update
  • Bug fix
  • New feature
  • Breaking change1

1The change breaks (or has the potential to break) existing functionality and should be merged into the breaking branch

Checklist:

  • I am familiar with the Development Guidelines
  • The changes introduced by this pull request are covered by existing or newly introduced tests.
  • I have updated the changelog and added my name to the credits.

@janbridley janbridley marked this pull request as ready for review December 30, 2024 14:00
@janbridley
Copy link
Collaborator Author

This PR is ready for review, and I'd appreciate a quick look through the API and docs. It's fairly simple and very well tested but any feedback would be appreciated!

@janbridley janbridley requested a review from joaander January 6, 2025 15:22
@janbridley
Copy link
Collaborator Author

I am going to go ahead and merge this so others can use the package as is - if anyone has time to review afterward I'd still appreciate it!

@janbridley janbridley merged commit a01ea2e into main Jan 13, 2025
8 checks passed
@janbridley janbridley deleted the admin/object-oriented branch December 8, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add function that reads multiline key-value pairs

2 participants