epy.reverse_fstring

epy.reverse_fstring#

etils.epy.reverse_fstring(pattern: str, string: str) dict[str, str] | None[source]#

Reverse f-string.

Example:

epy.reverse_fstring(
    '/home/{user}/projects/{project}',
    '/home/conchylicultor/projects/menhir'
) == {
    'user': 'conchylicultor',
    'project': 'menhir',
}
Parameters:
  • pattern – The f-string pattern (can only contained named group)

  • string – The string to search

Returns:

The extracted info