-
Notifications
You must be signed in to change notification settings - Fork 328
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
Select archive #226
Select archive #226
Conversation
… select the granularity
Not sure do we need to introduce separate functions for that, dubbing so much code. Maybe you can introduce |
I agree, there is way too much duplicated code introduced by this patch |
1 similar comment
Implemented the suggested changes in the last commit |
whisper.py
Outdated
@@ -872,23 +872,31 @@ def info(path): | |||
return None | |||
|
|||
|
|||
def fetch(path, fromTime, untilTime=None, now=None): | |||
def fetch(path, fromTime, untilTime=None, now=None, archiveToSelect=None): | |||
"""fetch(path,fromTime,untilTime=None) |
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.
Change docstring also, please
@@ -920,13 +928,21 @@ def file_fetch(fh, fromTime, untilTime, now=None): | |||
untilTime = now | |||
|
|||
diff = now - fromTime |
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.
Looking much better, this line could now be inside the if block.
Implemented the suggested changes in the last commit |
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.
This is starting to look good, I'd like to see some tests for the archiveToSelect
parameter before we merge it.
whisper.py
Outdated
|
||
#Parse granularity | ||
if archiveToSelect: | ||
retentionStr = str(archiveToSelect)+":1s" |
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.
This can be slightly more efficient if you specify ":1", I'd also move this down into file_fetch
so that the archiveToSelect
parameter has the same semantics in both functions.
whisper.py
Outdated
if archiveToSelect and archive['secondsPerPoint'] == archiveToSelect: | ||
break | ||
elif archiveToSelect: | ||
archive = None |
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.
This might be easier to read as a nested if:
if archiveToSelect:
if archive['secondsPerPoint'] == archiveToSelect:
break
archive = None
else:
if archive['retention'] >= diff:
break
Last commit implements the changes that you suggest and add a test for fetch with archiveToSelect parameter |
whisper.py
Outdated
|
||
return __archive_fetch(fh, archive, fromTime, untilTime) | ||
|
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.
Please replace the blank line removed here, then I think this will be good to merge
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.
Looking good
Backport of 'Select archive #226' to 1.0.x
Introduces one new function to override the default fetch algorithm.
In this new algorithm the user can pass the file that he wants to get data from instead of getting the one with the highest precission