| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
Sorry, something went wrong.
| >>> client = vision.Client(project='my-project', credentials=creds) | ||
|
|
||
|
|
||
| Creating an :class:`~google.cloud.vision.image.Image` object. |
| Creating an :class:`~google.cloud.vision.image.Image` object. | ||
| ------------------------------------------------------------- | ||
|
|
||
| The :class:`~google.cloud.vision.image.Image` object is used to load your image |
| data from sources such as a Google Cloud Storage URI, raw bytes, or a file. | ||
|
|
||
|
|
||
| **From a Google Cloud Storage URI** |
|
|
||
| Image Properties | ||
| ~~~~~~~~~~~~~~~~ | ||
| ---------------- |
| self._source = source_uri | ||
| else: | ||
| self._content = _bytes_to_unicode(b64encode(_to_bytes(content))) | ||
| if filename: |
| with open(filename, 'rb') as file_obj: | ||
| content = file_obj.read() | ||
|
|
||
| if content: |
| """ | ||
|
|
||
| def __init__(self, client, content=None, source_uri=None): | ||
| def __init__(self, client, content=None, filename=None, source_uri=None): |
| pip install --quiet --upgrade {toxinidir}/../core | ||
| deps = | ||
| {toxinidir}/../core | ||
| mock |
| image = self._make_one(CLIENT_MOCK, content=IMAGE_CONTENT) | ||
|
|
||
| _AS_DICT = { | ||
| _as_dict = { |
| image = self._make_one(CLIENT_MOCK, source_uri=IMAGE_SOURCE) | ||
|
|
||
| _AS_DICT = { | ||
| _as_dict = { |
| """ | ||
|
|
||
| def __init__(self, client, content=None, source_uri=None): | ||
| def __init__(self, client, content=None, filename=None, source_uri=None): |
| 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) |
| if len(sources) != 1: | ||
| raise ValueError( | ||
| 'Specify exactly one of \'content\', \'filename\', or' | ||
| '\'source_uri\'.') |
| 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() |
| pip install --quiet --upgrade {toxinidir}/../core | ||
| deps = | ||
| {toxinidir}/../core | ||
| mock |
|
Thanks @dhermes! I cancelled travis and rerun after squashing. |
Sorry, something went wrong.
…e-support Add loading image from filename.
Add loading image from filename.
| Back | FazBrowse Home | New Git URL |
Towards #2753
Adding support to pass in a filename when instantiating an Image.