Skip to content

Conversation

Bibo-Joshi
Copy link
Member

@Bibo-Joshi Bibo-Joshi commented Nov 24, 2020

  • add ability to pass pathlib.Path objects instead of strings

@Bibo-Joshi Bibo-Joshi added the ⚙️ bot-api affected functionality: bot-api label Nov 24, 2020
@Bibo-Joshi Bibo-Joshi marked this pull request as ready for review November 24, 2020 21:05
@Bibo-Joshi
Copy link
Member Author

Theoretically this is ready for review.

  • pytest fails seem unrelated
  • don't know why coverage is "not affected". need to double check before merging

If I get to it before this is reviewed and merged, I'll try to add the file:// parsing logic. Otherwise it get's its own pr …

@Bibo-Joshi Bibo-Joshi requested a review from Poolitzer November 24, 2020 21:07
@Bibo-Joshi
Copy link
Member Author

Bibo-Joshi commented Nov 25, 2020

Update: @Poolitzer tested the local file get & download behaviour on local bot apis on both windows and ubuntu.

I just pushed a commit to also allow passing (relative) local paths to send files. Mock-tests succeed (at least locally for me), will double check on ubuntu in a moment.

@Bibo-Joshi
Copy link
Member Author

Tested send_document and send_media_group and both work.

@Bibo-Joshi Bibo-Joshi mentioned this pull request Nov 25, 2020
28 tasks
@Bibo-Joshi Bibo-Joshi added this to the 13.1 milestone Nov 26, 2020
@Bibo-Joshi Bibo-Joshi mentioned this pull request Nov 27, 2020
8 tasks
return False

path = Path(obj) if isinstance(obj, str) else obj
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need try except here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path('https://some-domain.org').is_file() throws an error instead of returning False

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe so we could do

try:
    path.is_file()
    return True
except Exception:
    return False

thats funny :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, path.is_file() can still return False if the passed string looks like a valid path but the file doesn't exist

Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small doc suggestions. Code looks good!

return False

path = Path(obj) if isinstance(obj, str) else obj
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe so we could do

try:
    path.is_file()
    return True
except Exception:
    return False

thats funny :D

Bibo-Joshi and others added 3 commits November 29, 2020 15:06
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
# Conflicts:
#	telegram/files/inputmedia.py
@Bibo-Joshi Bibo-Joshi merged commit 4359007 into api-5.0-master Nov 29, 2020
@Bibo-Joshi Bibo-Joshi deleted the api-5.0-local-bot-API-server branch November 29, 2020 14:22
@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚙️ bot-api affected functionality: bot-api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants