Skip to content

Commit 904713f

Browse files
committed
moving from 80 char lines to 79 char lines
1 parent 8dc6c95 commit 904713f

17 files changed

Lines changed: 98 additions & 74 deletions

examples/discovery_v1.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import watson_developer_cloud
33
import os, json
44

5-
discovery = watson_developer_cloud.DiscoveryV1('2016-11-07',
6-
username='YOUR SERVICE USERNAME',
7-
password='YOUR SERVICE PASSWORD')
5+
discovery = watson_developer_cloud.DiscoveryV1(
6+
'2016-11-07',
7+
username='YOUR SERVICE USERNAME',
8+
password='YOUR SERVICE PASSWORD')
89

910
environments = discovery.get_environments()
1011
news_environments = [x for x in environments['environments'] if

examples/document_conversion_v1.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
with open(join(dirname(__file__), '../resources/example.html'),
1313
'r') as document:
1414
config = {'conversion_target': DocumentConversionV1.NORMALIZED_HTML}
15-
print(document_conversion.convert_document(document=document, config=config,
16-
media_type='text/html')
17-
.content)
15+
print(document_conversion.convert_document(
16+
document=document, config=config, media_type='text/html').content)
1817

1918
# Example with JSON
2019
with open(join(dirname(__file__), '../resources/example.html'),
@@ -26,8 +25,8 @@
2625

2726
# Examples of index_document API
2827
print(
29-
"########## Example of a dry run of index_document with only a document "
30-
"##########")
28+
"########## Example of a dry run of index_document with only a document "
29+
"##########")
3130
with open(join(dirname(__file__), '../resources/example.html'),
3231
'r') as document:
3332
config = {
@@ -40,8 +39,8 @@
4039
indent=2))
4140

4241
print(
43-
"########## Example of a dry run of index_document with only metadata "
44-
"##########")
42+
"########## Example of a dry run of index_document with only metadata "
43+
"##########")
4544
config = {
4645
'retrieve_and_rank': {
4746
'dry_run': 'true'
@@ -53,12 +52,14 @@
5352
]
5453
}
5554
print(
56-
json.dumps(document_conversion.index_document(config=config, metadata=metadata),
57-
indent=2))
55+
json.dumps(
56+
document_conversion.index_document(config=config, metadata=metadata),
57+
indent=2))
5858

5959
print(
60-
"########## Example of a dry run of index_document with document and metadata "
61-
"##########")
60+
"########## Example of a dry run of index_document with document and "
61+
"metadata "
62+
"##########")
6263
with open(join(dirname(__file__), '../resources/example.html'),
6364
'r') as document:
6465
config = {
@@ -76,9 +77,10 @@
7677
metadata=metadata), indent=2))
7778

7879
print(
79-
"########## Example of a dry run of index_document with document, metadata, "
80-
"and additional config for conversion"
81-
"##########")
80+
"########## Example of a dry run of index_document with document, "
81+
"metadata, "
82+
"and additional config for conversion"
83+
"##########")
8284
with open(join(dirname(__file__), '../resources/example.html'),
8385
'r') as document:
8486
config = {

examples/language_translator_v2.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
password='YOUR SERVICE PASSWORD')
88

99
# create new custom model
10-
# with open('../resources/language_translator_model.tmx', 'rb') as custom_model:
10+
# with open('../resources/language_translator_model.tmx', 'rb') as \
11+
# custom_model:
1112
# print(json.dumps(language_translator.create_model(
1213
# base_model_id='en-fr', name='test_glossary',
13-
# forced_glossary=custom_model), indent=2))
14+
# forced_glossary=custom_model), indent=2))
1415

1516
print(json.dumps(language_translator.get_models(), indent=2))
1617

@@ -26,9 +27,10 @@
2627
target='en'), indent=2,
2728
ensure_ascii=False))
2829

29-
print(json.dumps(language_translator.translate('Messi is the best ever',
30-
model_id='en-es-conversational'),
31-
indent=2))
30+
print(json.dumps(
31+
language_translator.translate('Messi is the best ever',
32+
model_id='en-es-conversational'),
33+
indent=2))
3234

3335
print(json.dumps(language_translator.identify('Hello how are you?'), indent=2))
3436

examples/personality_insights_v2.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@
1212
print(json.dumps(personality_insights.profile(
1313
text=personality_text.read()), indent=2))
1414

15-
# with open(join(dirname(__file__),
16-
# '../resources/personality.txt') as personality_text:
15+
# with open(join(dirname(__file__), '../resources/personality.txt')) as \
16+
# personality_text:
1717
# personality_insights_json = {"contentItems": [
1818
# {"id": "245160944223793152", "userid": "bob", "sourceid": "twitter",
19-
# "created": 1427720427,
20-
# "updated": 1427720427, "contenttype": "text/plain", "charset": "UTF-8",
21-
# "language": "en-us",
22-
# "content": personality_text.read(), "parentid": "", "reply": "false",
23-
# "forward": "false"}]}
24-
# print(json.dumps(personality_insights.profile(text=personality_insights_json),
25-
# indent=2))
19+
# "created": 1427720427, "updated": 1427720427,
20+
# "contenttype": "text/plain", "charset": "UTF-8",
21+
# "language": "en-us", "content": personality_text.read(),
22+
# "parentid": "", "reply": "false", "forward": "false"}]}
23+
# print(json.dumps(personality_insights.profile(
24+
# text=personality_insights_json), indent=2))
2625
#
27-
# with open(join(dirname(__file__),
28-
# '../resources/personality.es.txt') as personality_text:
29-
# print(json.dumps(personality_insights.profile(text=personality_text.read(),
30-
# language='es'), indent=2))
26+
# with open(join(dirname(__file__), '../resources/personality.es.txt')) as \
27+
# personality_text:
28+
# print(json.dumps(personality_insights.profile(
29+
# text=personality_text.read(), language='es'), indent=2))

examples/visual_recognition_v3.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,20 @@
3535
print(json.dumps(visual_recognition.classify(images_url=test_url), indent=2))
3636

3737
print(
38-
json.dumps(visual_recognition.detect_faces(images_url=test_url), indent=2))
38+
json.dumps(visual_recognition.detect_faces(images_url=test_url), indent=2))
3939

4040
# print(json.dumps(visual_recognition.delete_classifier(classifier_id='YOUR
4141
# CLASSIFIER ID'), indent=2))
4242

4343
print(json.dumps(visual_recognition.list_classifiers(), indent=2))
4444

45-
with open(join(dirname(__file__), '../resources/text.png'), 'rb') as image_file:
45+
with open(join(dirname(__file__), '../resources/text.png'), 'rb')\
46+
as image_file:
4647
print(json.dumps(visual_recognition.recognize_text(images_file=image_file),
4748
indent=2))
4849

49-
with open(join(dirname(__file__), '../resources/face.jpg'), 'rb') as image_file:
50+
with open(join(dirname(__file__), '../resources/face.jpg'), 'rb')\
51+
as image_file:
5052
print(json.dumps(visual_recognition.detect_faces(images_file=image_file),
5153
indent=2))
5254

watson_developer_cloud/alchemy_data_news_v1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class AlchemyDataNewsV1(WatsonDeveloperCloudService):
2323
default_url = 'https://gateway-a.watsonplatform.net/calls'
2424

2525
def __init__(self, url=default_url, **kwargs):
26-
WatsonDeveloperCloudService.__init__(self, 'alchemy_api', url, **kwargs)
26+
WatsonDeveloperCloudService.__init__(self, 'alchemy_api', url,
27+
**kwargs)
2728

2829
def get_news_documents(self, start, end, max_results=10, query_fields=None,
2930
return_fields=None, time_slice=None,

watson_developer_cloud/alchemy_language_v1.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class AlchemyLanguageV1(WatsonDeveloperCloudService):
2323
default_url = 'https://gateway-a.watsonplatform.net/calls'
2424

2525
def __init__(self, url=default_url, **kwargs):
26-
WatsonDeveloperCloudService.__init__(self, 'alchemy_api', url, **kwargs)
26+
WatsonDeveloperCloudService.__init__(self, 'alchemy_api', url,
27+
**kwargs)
2728

2829
def author(self, html=None, url=None, language=None):
2930
params = {'language': language}
@@ -50,7 +51,8 @@ def keywords(self, html=None, text=None, url=None,
5051
if not max_items:
5152
max_items = max_keywords
5253
params = {
53-
'keywordExtractMode': 'strict' if strict_extract_mode else 'normal',
54+
'keywordExtractMode': 'strict' if strict_extract_mode else
55+
'normal',
5456
'sentiment': sentiment,
5557
'emotion': emotion,
5658
'showSourceText': show_source_text,
@@ -153,7 +155,8 @@ def language(self, html=None, text=None, url=None):
153155
return self._alchemy_html_request('GetLanguage', html=html, text=text,
154156
url=url)
155157

156-
def text(self, html=None, url=None, use_metadata=True, extract_links=False):
158+
def text(self, html=None, url=None, use_metadata=True,
159+
extract_links=False):
157160
params = {'useMetadata': use_metadata,
158161
'extractLinks': extract_links}
159162
return self._alchemy_html_request('GetText', html=html, url=url,

watson_developer_cloud/alchemy_vision_v1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class AlchemyVisionV1(WatsonDeveloperCloudService):
2525
default_url = 'https://gateway-a.watsonplatform.net/calls'
2626

2727
def __init__(self, url=default_url, **kwargs):
28-
WatsonDeveloperCloudService.__init__(self, 'alchemy_api', url, **kwargs)
28+
WatsonDeveloperCloudService.__init__(self, 'alchemy_api', url,
29+
**kwargs)
2930
print(
3031
'WARNING: The AlchemyVision service was deprecated, '
3132
'use VisualRecognitionV3 instead')

watson_developer_cloud/document_conversion_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def index_document(self, config, document=None, metadata=None,
5555
'one of those is'
5656
'required.')
5757
params = {'version': self.version}
58-
files = [
59-
('config', ('config.json', json.dumps(config), 'application/json'))]
58+
files = [('config', ('config.json', json.dumps(config),
59+
'application/json'))]
6060
if document is not None:
6161
filename = os.path.basename(document.name)
6262
file_tuple = (filename, document, media_type)\

watson_developer_cloud/language_translation_v2.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def create_model(self, base_model_id, name=None, forced_glossary=None,
5757
monolingual_corpus=None):
5858
if forced_glossary is None and parallel_corpus is None and \
5959
monolingual_corpus is None:
60-
raise WatsonInvalidArgument('A glossary or corpus must be provided')
60+
raise WatsonInvalidArgument(
61+
'A glossary or corpus must be provided')
6162
params = {'name': name,
6263
'base_model_id': base_model_id}
6364
files = {'forced_glossary': forced_glossary,
@@ -67,8 +68,8 @@ def create_model(self, base_model_id, name=None, forced_glossary=None,
6768
files=files, accept_json=True)
6869

6970
def get_model(self, model_id):
70-
return self.request(method='GET', url='/v2/models/{0}'.format(model_id),
71-
accept_json=True)
71+
return self.request(method='GET', url='/v2/models/{0}'
72+
.format(model_id), accept_json=True)
7273

7374
def delete_model(self, model_id):
7475
return self.request(method='DELETE',

0 commit comments

Comments
 (0)