-
Notifications
You must be signed in to change notification settings - Fork 949
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
get_all_worksheet_values feature #1180
base: master
Are you sure you want to change the base?
Conversation
Hi thank you for your contribution, I'll have a proper look at the code when I have some free time (very soon). I looked at it quickly and I see some changes to be done. I'll come back with a complete review. |
Thanks for the review. I resolved your comments and fixed the docstrings for the code I added. Cheers |
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.
took me some time but I finally found the time to review your PR.
They are some small adjustments that need to be addressed.
if skip_worksheet_titles is None: | ||
skip_worksheet_titles = [] | ||
|
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.
if you set it to []
empty list when it's not set, then just set the default value to []
in the argument in the method definition.
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 suppose the initial solution was right, because usage of a mutable object as default argument can follow wrong behaviour. You can see example of such problem there
|
||
ranges = [] | ||
|
||
for worksheet in self.worksheets().worksheets(): |
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.
that won't work, it should be only self.worksheets()
|
||
for worksheet in self.worksheets().worksheets(): | ||
if worksheet.title not in skip_worksheet_titles: | ||
ranges.append(worksheet.title) |
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.
Here we should protect the worksheet title using the util function absolute_range_name
@@ -27,6 +27,8 @@ | |||
URL_KEY_V1_RE = re.compile(r"key=([^&#]+)") | |||
URL_KEY_V2_RE = re.compile(r"/spreadsheets/d/([a-zA-Z0-9-_]+)") | |||
|
|||
TITLE_RANGE_RE = re.compile(r"'(.*?)'!.*") |
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 won't always work, here we can have 2 cases:
- names with a
'
so they start with a'
but they may have multiple'
surrounding the actual name - no
'
at starts or end. so it's a single string with only characters.
The regex should be improved to match all possible titles.
Addresses #1002.
The function returns a dict of all the worksheet values, mapped by the worksheet name/title.
I have not written tests for this function yet.