4242import sys
4343import time
4444
45- from googleapiclient import discovery
46- from googleapiclient import errors
45+ import googleapiclient . discovery
46+ import googleapiclient . errors
4747
4848BATCH_SIZE = 10
4949
@@ -52,7 +52,7 @@ class VisionApi(object):
5252 """Construct and use the Cloud Vision API service."""
5353
5454 def __init__ (self ):
55- self .service = discovery .build ('vision' , 'v1' )
55+ self .service = googleapiclient . discovery .build ('vision' , 'v1' )
5656
5757 def detect_text (self , input_filenames , num_retries = 3 , max_results = 6 ):
5858 """Uses the Vision API to detect text in the given file."""
@@ -100,7 +100,7 @@ def detect_text(self, input_filenames, num_retries=3, max_results=6):
100100
101101 return text_response
102102
103- except errors .HttpError as e :
103+ except googleapiclient . errors .HttpError as e :
104104 logging .error ('Http Error for {}: {}' .format (filename , e ))
105105 except KeyError as e2 :
106106 logging .error ('Key error: {}' .format (e2 ))
@@ -110,7 +110,7 @@ class TextAnalyzer(object):
110110 """Construct and use the Google Natural Language API service."""
111111
112112 def __init__ (self , db_filename = None ):
113- self .service = discovery .build ('language' , 'v1' )
113+ self .service = googleapiclient . discovery .build ('language' , 'v1' )
114114
115115 # This list will store the entity information gleaned from the
116116 # image files.
@@ -143,7 +143,7 @@ def nl_detect(self, text):
143143 request = self .service .documents ().analyzeEntities (body = body )
144144 response = request .execute ()
145145 entities = response ['entities' ]
146- except errors .HttpError as e :
146+ except googleapiclient . errors .HttpError as e :
147147 logging .error ('Http Error: %s' % e )
148148 except KeyError as e2 :
149149 logging .error ('Key error: %s' % e2 )
0 commit comments