-
Notifications
You must be signed in to change notification settings - Fork 40
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
Allow user to specify non-14-digit datetimes in URI #301
Comments
Memento endpoint should return only the closest memento. What you are describing here should be implemented as datetime-based slicing on TimeMap. There are plans to support similar functionality in MemGator too. |
Correct, this ticket appeals to the slicing feature of the |
I think I am confused with the purposes of In my opinion, sliced TimeMaps should be served at |
It's really a wrapper to the generic
There is definitely some duplicate code and redundant functionality, which stems from progressively adding the functionality. The sliced TimeMap functionality also needs to serve the web UI when a 404 for a URI-M is encountered (see screenshots in #286). I think the We also have |
The current state of resolution is odd. With the 5mementos sample WARC, |
Resolving unspecified date fields to the earlier possibility seems like the most logical resolution, e.g., the aforementioned request for the URI-R at the date |
This is done in MemGator as following: var regs = map[string]*regexp.Regexp{
"dttmstr": regexp.MustCompile(`^(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?$`),
}
func paddedTime(dttmstr string) (dttm *time.Time, err error) {
m := regs["dttmstr"].FindStringSubmatch(dttmstr)
dts := m[1]
dts += (m[2] + "01")[:2]
dts += (m[3] + "01")[:2]
dts += (m[4] + "00")[:2]
dts += (m[5] + "00")[:2]
dts += (m[6] + "00")[:2]
var dtm time.Time
dtm, err = time.Parse("20060102150405", dts)
dttm = &dtm
return
} |
@ibnesayeed Thanks for supplying this logic. Do you want to try to adapt this to ipwb? If not, I can use it as inspiration for an implementation. |
Also, for reference, this should be written/called in/from |
Though it's a little out-of-scope of this ticket, we may also want to tweak the regex to be stricter to the date component bound, e.g., reject months > 12. |
I can look into it.
This can be better done by parsing the datetime and throwing invalid datetime exception. |
Is liberal use of exceptions common practice in Python? This pattern seems to be your approach to a few of our problems and I am curious as to whether it is inspired by another language or influenced by other Python examples.
I will assign this ticket to you in this case. If you'd rather not, let me know and I can take care of it. |
https://github.com/webrecorder/warcio/blob/master/warcio/timeutils.py also has some useful test cases for this, e.g., inclusion of letters, bad month, padding, etc. |
This is actually very Pythonic to use exceptions in situations like this. Some other languages encourage using exceptions too, but I am not necessarily applying any cross-language influence here. In some ways exceptions fall under a few mantras of Python programming that include 1) explicit is better than implicit, 2) errors should never pass silently, unless explicitly silenced, and 3) easier to ask for forgiveness than permission. Practically speaking, when something unexpected happens, the function would not know what to return (and the return value in case of unexpected failure could be meaningless other than detecting a failure). So, one may chose to return |
I have updated the checkboxes of tasks as per #586. For the remaining one task with more precise datetime (in milliseconds or nanoseconds) we can open a new ticket. |
@ibnesayeed #283 covers the more-precise date requirement. Your contribution to this ticket meets the criteria to close it. |
e.g., GET on
/2016/http://example.com
would return only list of mementos with interpreted date (all from the year of 2016). Currently a non-14-digit date simply returns an interface with all mementos for the URI-R listed as well as an abbreviated TimeMap in the link header.The text was updated successfully, but these errors were encountered: