-
Notifications
You must be signed in to change notification settings - Fork 555
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
feat(bindings/python): Add repr for metadata #5783
feat(bindings/python): Add repr for metadata #5783
Conversation
… better print and debug Signed-off-by: yihong0618 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding unit test here. I think some simple assert is enough
Signed-off-by: yihong0618 <[email protected]>
Thanks and Done |
bindings/python/src/metadata.rs
Outdated
|
||
pub fn __repr__(&self) -> String { | ||
format!( | ||
"Metadata(content_disposition={}, content_length={}, content_md5={}, content_type={}, etag={}, mode={})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content_disposition
might be empty most of the time, so I don't think it's worth printing in repr
. How about this instead:
"Metadata(mode={}, content_length={}, content_type={}, etag={})"
We arrange the metadata by importance and ignore less frequently used metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool will drop this, you are right.
and FYI last_modified maybe needed here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool will update this patch after last_modified Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and lerned that, thanks
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
bindings/python/src/metadata.rs
Outdated
let rfc3339 = dt.to_rfc3339_opts(SecondsFormat::Micros, false); | ||
if let Some(pos) = rfc3339.find('.') { | ||
let (base, tz) = rfc3339.split_at(pos + 1); | ||
let tz_pos = tz.find('+').or_else(|| tz.find('-')).unwrap_or(tz.len()); | ||
let (micros, tz_suffix) = tz.split_at(tz_pos); | ||
|
||
let micros = format!("{:0<6}", micros); | ||
format!("{}{}{}", base, micros, tz_suffix) | ||
} else { | ||
rfc3339 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print last_modified
in this way doesn't look good to me.
If we have a clear target format, maybe we can use DateTime::format
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will learn that
bindings/python/src/metadata.rs
Outdated
}; | ||
|
||
format!( | ||
"Metadata(content_length={}, content_md5={}, content_type={}, etag={}, mode={}, last_modified={})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe mode
is the most important metadata, and content_md5
can be removed since we don't encourage users to rely on it.
So the final list will be:
- mode
- content_length
- content_type
- last_modified
- etag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy
Signed-off-by: yihong0618 <[email protected]>
This is not a breaking change, right? I'm guessing we don't need the |
OK, and FYI, it kind of small change the behaviour of print... |
I'm not familiar with python. Does python ecosystem treat such changes as breaking changes? |
if user depend the repr maybe break them, but I think its fine since we do not have repr before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @yihong0618 for this work!
… better print and debug
Which issue does this PR close?
Closes #5768