Skip to content

API 5.0 WP4.3: Handling of files in local mode #2223

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

Merged
merged 10 commits into from
Nov 29, 2020

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy