-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mtime.value
with format string support
#2721
Comments
The result should be expected to be a usable type (datetime, int, float). Makes things easier to implement and it does not involve a potential unnecessary conversion or type check. I'm guessing you've been trying to use the code from In your example above, "status[date]" by itself is already a datetime object, but the |
As I understand it, the current implementation accepts 2 options:
You've identified that the format string can introduce a new option:
If further checks and conversions are to be avoided, it looks like we need a way of eliminating this option. How do you feel about some of these potential solutions?
Of course, you know this codebase better than I ever will, so I'm open to any other ideas you might have. |
I added a third argument to This makes it possible to have it do nothing and return the value as is by using an identity function formatter.parse("{status[date]}", None, util.identity)
formatter.parse("{content[0:6]:R22/2022/D%Y%m%d/}", None, util.identity)
It doesn't have to be a
That would have been even easier than my solution, but I noticed it a bit too late, oh well. A user would specify
or something like that, where |
I'm currently working on implementing
mtime.value
with support for format strings and was hoping to gather thoughts and implementation details before I open a PR.Some use cases:
mtime.key
currently cannot do, I also have a workaround for this):Some concerns I have:
mtime.key
andmtime.value
logically cannot be used simultaneously. In this case, should an exception be thrown (perhaps a new exception would be required), or should one take precedence over the other?datetime
by default, so that:D<format>/
isn't required? Or should users be expected to ensure the result will already be a validdatetime
?Of course, this will likely become less necessary if/when extractors all provide the same standardized set of metadata keys (
filename
,url
,date
,tags
etc.).The text was updated successfully, but these errors were encountered: