Skip to content
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

Не работает фильтр полей fields #4

Closed
Necrobsd opened this issue Sep 13, 2018 · 6 comments
Closed

Не работает фильтр полей fields #4

Necrobsd opened this issue Sep 13, 2018 · 6 comments
Labels
bug Suspected or confirmed bug language-russian Issue на русском

Comments

@Necrobsd
Copy link

Делаю запрос:
y.listdir('/path', fields='name, type')
А в ответ приходят все поля. В чем может быть проблема? Я неправильно указываю список полей?
Версия yadisk 1.2.11

@ivknv
Copy link
Owner

ivknv commented Sep 13, 2018

Параметр fields должен быть массивом (или чем-нибудь подобным):

y.listdir('/path', fields=["name", "type"])

@Necrobsd
Copy link
Author

В таком случае получаю ошибку:
list(y.listdir('/path', fields=["name"])) Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/alex/.pyenv/versions/backup/lib/python3.5/site-packages/yadisk/functions/resources.py", line 292, in _listdir for child in result.embedded.items: AttributeError: 'NoneType' object has no attribute 'items'

@ivknv
Copy link
Owner

ivknv commented Sep 13, 2018

Эта ошибка возникает потому что таких полей в ответе нет (хотя это и баг, поправлю как-нибудь).
Судя по всему, вместо "name" и "type" должно быть "embedded.name" и "embedded.type", тогда всё работает как надо:

y.listdir('/path', fields=["embedded.name", "embedded.type"])

@Necrobsd
Copy link
Author

Увы. Пришли также все поля.
Запрос:
list(y.listdir('app:/', fields=["embedded.name","embedded.type"]))
Ответ:
[<ResourceObject{'file': None, 'embedded': None, 'modified': datetime.datetime(2018, 9, 13, 13, 40, 26, tzinfo=datetime.timezone.utc), 'created': datetime.datetime(2018, 9, 13, 13, 40, 26, tzinfo=datetime.timezone.utc), 'exif': <EXIFObject{'date_time': None}>, 'md5': None, 'share': None, 'type': 'dir', 'custom_properties': None, 'revision': 1536846026647000, 'mime_type': None, 'comment_ids': <CommentIDsObject{'private_resource': '547528787:7f3b52d024474ce38b76ee0c262cdca90f02f06277724ea18d429aa747a8c5ae', 'public_resource': '547528787:7f3b52d024474ce38b76ee0c262cdca90f02f06277724ea18d429aa747a8c5ae'}>, 'public_url': None, 'antivirus_status': None, 'name': '2018_09_13__23_40_23_diff', 'path': 'disk:/Приложения/uploader/2018_09_13__23_40_23_diff', 'media_type': None, 'size': None, 'preview': None, 'resource_id': '547528787:7f3b52d024474ce38b76ee0c262cdca90f02f06277724ea18d429aa747a8c5ae', 'sha256': None, 'public_key': None}>]

@ivknv
Copy link
Owner

ivknv commented Sep 13, 2018

ОК, теперь должно быть правильно.
Ещё один баг вскрылся :)

y.listdir('app:/', fields=["embedded.offset", "embedded.limit", "embedded.total",
                           "embedded.items.name", "embedded.items.type"])

"embedded.offset", "embedded.limit", "embedded.total" нужны, чтобы не было другой ошибки :).

@ivknv
Copy link
Owner

ivknv commented Sep 17, 2018

Попробуйте последнюю версию с гитхаба:

pip install git+https://github.com/ivknv/yadisk

Заодно проверьте версию установленной библиотеки, теперь должно быть 1.2.12:

import yadisk

print(yadisk.__version__) # 1.2.12

В последней версии всё должно работать как нужно (никакие embedded больше не нужны):

y.listdir('/path', fields=["name", "type"])

@ivknv ivknv closed this as completed Oct 11, 2018
@ivknv ivknv added bug Suspected or confirmed bug language-russian Issue на русском labels Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Suspected or confirmed bug language-russian Issue на русском
Projects
None yet
Development

No branches or pull requests

2 participants