Uh oh!
There was an error while loading. Please reload this page.
Add loading image from filename. - #2778
Conversation
dhermes
left a comment
There was a problem hiding this comment.
Mostly looks good (the benefit of tiny PRs!) though the constructor needs to be sorted out before I can sign off
| >>> client = vision.Client(project='my-project', credentials=creds) | ||
| Creating an :class:`~google.cloud.vision.image.Image` object. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| Creating an :class:`~google.cloud.vision.image.Image` object. | ||
| ------------------------------------------------------------- | ||
| The :class:`~google.cloud.vision.image.Image` object is used to load your image |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| data from sources such as a Google Cloud Storage URI, raw bytes, or a file. | ||
| **From a Google Cloud Storage URI** |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| Image Properties | ||
| ~~~~~~~~~~~~~~~~ | ||
| ---------------- |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self._source = source_uri | ||
| else: | ||
| self._content = _bytes_to_unicode(b64encode(_to_bytes(content))) | ||
| if filename: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| with open(filename, 'rb') as file_obj: | ||
| content = file_obj.read() | ||
| if content: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| """ | ||
| def __init__(self, client, content=None, source_uri=None): | ||
| def __init__(self, client, content=None, filename=None, source_uri=None): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| pip install --quiet --upgrade {toxinidir}/../core | ||
| deps = | ||
| {toxinidir}/../core | ||
| mock |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| image = self._make_one(CLIENT_MOCK, content=IMAGE_CONTENT) | ||
| _AS_DICT = { | ||
| _as_dict = { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| image = self._make_one(CLIENT_MOCK, source_uri=IMAGE_SOURCE) | ||
| _AS_DICT = { | ||
| _as_dict = { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| """ | ||
| def __init__(self, client, content=None, source_uri=None): | ||
| def __init__(self, client, content=None, filename=None, source_uri=None): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def __init__(self, client, content=None, source_uri=None): | ||
| def __init__(self, client, content=None, filename=None, source_uri=None): | ||
| sources = set(source for source in (content, filename, source_uri) | ||
| if source is not None) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| if len(sources) != 1: | ||
| raise ValueError( | ||
| 'Specify exactly one of \'content\', \'filename\', or' | ||
| '\'source_uri\'.') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self._content = _bytes_to_unicode(b64encode(_to_bytes(content))) | ||
| if filename is not None: | ||
| with open(filename, 'rb') as file_obj: | ||
| content = file_obj.read() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| pip install --quiet --upgrade {toxinidir}/../core | ||
| deps = | ||
| {toxinidir}/../core | ||
| mock |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daspecster
commented
Dec 1, 2016
Thanks @dhermes! I cancelled travis and rerun after squashing. |
b77ed78 to
0bc1c4bCompare…e-support Add loading image from filename.
Add loading image from filename.
Towards #2753
Adding support to pass in a filename when instantiating an
Image.