Skip to content

Commit 1d79ba2

Browse files
committed
LITE-27556 Add black
* Double quotes replaced with single quotes
1 parent 92164e8 commit 1d79ba2

File tree

105 files changed

+2792
-1547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2792
-1547
lines changed

connect/cli/ccli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def main():
1717
_ignore_openpyxl_warnings()
1818
try:
1919
import uvloop
20+
2021
uvloop.install()
2122
except ImportError:
2223
pass
@@ -45,6 +46,7 @@ def _ignore_openpyxl_warnings():
4546
To avoid losing data validation, it should be re-created each time the file is saved by the cli.
4647
"""
4748
import warnings
49+
4850
warnings.filterwarnings('ignore', category=UserWarning, module='openpyxl.worksheet._reader')
4951

5052

connect/cli/core/base.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def invoke(self, ctx):
2323
class CCliGroup(click.Group):
2424
def command(self, *args, **kwargs):
2525
from click.decorators import command
26+
2627
kwargs['cls'] = CCliCommand
2728

2829
def decorator(f):
@@ -34,6 +35,7 @@ def decorator(f):
3435

3536
def group(self, *args, **kwargs):
3637
from click.decorators import group
38+
3739
kwargs['cls'] = CCliGroup
3840

3941
def decorator(f):
@@ -45,7 +47,7 @@ def decorator(f):
4547

4648

4749
def group(name=None, **attrs):
48-
attrs.setdefault("cls", CCliGroup)
50+
attrs.setdefault('cls', CCliGroup)
4951
return click.command(name, **attrs)
5052

5153

@@ -65,10 +67,13 @@ def print_version(ctx, param, value):
6567
is_eager=True,
6668
callback=print_version,
6769
)
68-
@click.option('-c', '--config-dir',
69-
default=os.path.join(os.path.expanduser('~'), '.ccli'),
70-
type=click.Path(file_okay=False),
71-
help='set the config directory.')
70+
@click.option(
71+
'-c',
72+
'--config-dir',
73+
default=os.path.join(os.path.expanduser('~'), '.ccli'),
74+
type=click.Path(file_okay=False),
75+
help='set the config directory.',
76+
)
7277
@click.option(
7378
'-s',
7479
'--silent',

connect/cli/core/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def load(self, config_dir):
8686
data = json.load(f)
8787
active_account_id = data['active']
8888
for account_data in data['accounts']:
89-
9089
account = Account(
9190
**account_data,
9291
client=ConnectClient(

connect/cli/core/terminal.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def update(
8989

9090

9191
class Console(_Console):
92-
9392
def __init__(self, *args, **kwargs):
9493
super().__init__(*args, **kwargs)
9594
self._skip_confirm = False
@@ -133,7 +132,7 @@ def page_size(self, value):
133132
def progress(self):
134133
return Progress(
135134
SpinnerColumn(),
136-
TextColumn("[progress.description]{task.description:<80}"),
135+
TextColumn('[progress.description]{task.description:<80}'),
137136
BarColumn(style='cyan', finished_style='green3'),
138137
MofNCompleteColumn(),
139138
TaskProgressColumn(),
@@ -159,7 +158,8 @@ def confirm(
159158

160159
self.print()
161160
prompt = Confirm(
162-
message, console=self,
161+
message,
162+
console=self,
163163
)
164164

165165
result = prompt(default=False)
@@ -236,10 +236,11 @@ def table(
236236
if not (columns and rows):
237237
return
238238

239-
chunks = [
240-
rows[i:i + self.page_size]
241-
for i in range(0, len(rows), self.page_size)
242-
] if not self.skip_confirm else [rows]
239+
chunks = (
240+
[rows[i : i + self.page_size] for i in range(0, len(rows), self.page_size)]
241+
if not self.skip_confirm
242+
else [rows]
243+
)
243244

244245
for chunk_count, chunk in enumerate(chunks):
245246
table = Table(

connect/cli/core/utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ def validate_output_options(output_path, output_file, default_dir_name, default_
6969

7070
output_path = output_path or os.getcwd()
7171
if not os.path.exists(output_path):
72-
raise click.ClickException("Output Path does not exist")
72+
raise click.ClickException('Output Path does not exist')
7373

7474
output_path = os.path.join(output_path, default_dir_name)
7575
if not os.path.exists(output_path):
7676
os.mkdir(output_path)
7777
elif not os.path.isdir(output_path): # pragma: no branch
7878
raise click.ClickException(
7979
f"Exists a file with name '{os.path.basename(output_path)}' but a directory is "
80-
"expected, please rename it",
80+
'expected, please rename it',
8181
)
8282

8383
output_file = os.path.join(output_path, output_file or f'{default_file_name}.xlsx')
@@ -88,12 +88,10 @@ def validate_output_options(output_path, output_file, default_dir_name, default_
8888
def field_to_check_mark(predicate, false_value=''):
8989
"""Change the value of a field to a check mark base on a predicate.
9090
91-
:param predicate: bool value / expression.
92-
:param false_value: customizable value if predicate evaluates to false.
93-
"""
94-
return (
95-
'\u2713' if predicate else false_value
96-
)
91+
:param predicate: bool value / expression.
92+
:param false_value: customizable value if predicate evaluates to false.
93+
"""
94+
return '\u2713' if predicate else false_value
9795

9896

9997
def iter_entry_points(group, name=None):

connect/cli/plugins/customer/commands.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def cmd_export_customers(config, output_path, output_file):
5757
name='sync',
5858
short_help='Synchronize customers from an excel file.',
5959
)
60-
6160
@click.argument('input_file', metavar='input_file', nargs=1, required=True) # noqa: E304
6261
@pass_config
6362
def cmd_sync_customers(config, input_file):
@@ -70,7 +69,7 @@ def cmd_sync_customers(config, input_file):
7069
client=config.active.client,
7170
account_id=acc_id,
7271
)
73-
warnings.filterwarnings("ignore", category=UserWarning)
72+
warnings.filterwarnings('ignore', category=UserWarning)
7473
synchronizer.open(input_file, 'Customers')
7574
synchronizer.sync()
7675
synchronizer.save(input_file)

connect/cli/plugins/customer/export.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
def dump_customers(client, account_id, output_file, output_path=None): # noqa: CCR001
1515
output_file = validate_output_options(
16-
output_path, output_file, default_dir_name=account_id, default_file_name='customers',
16+
output_path,
17+
output_file,
18+
default_dir_name=account_id,
19+
default_file_name='customers',
1720
)
1821
try:
1922
wb = Workbook()
@@ -26,7 +29,11 @@ def dump_customers(client, account_id, output_file, output_path=None): # noqa:
2629
with console.progress() as progress:
2730
task = progress.add_task('Processing customer', total=count)
2831
for customer in customers:
29-
progress.update(task, description=f'Processing customer {customer["id"]}', advance=1)
32+
progress.update(
33+
task,
34+
description=f'Processing customer {customer["id"]}',
35+
advance=1,
36+
)
3037
_fill_customer_row(wb['Customers'], row_idx, customer)
3138
row_idx += 1
3239
progress.update(task, completed=count)
@@ -83,7 +90,9 @@ def _fill_customer_row(ws, row_idx, customer):
8390
ws.cell(row_idx, 18, value=customer['contact_info']['contact'].get('last_name', '-'))
8491
ws.cell(row_idx, 19, value=customer['contact_info']['contact'].get('email', '-'))
8592
ws.cell(
86-
row_idx, 20, value=_get_phone_number(
93+
row_idx,
94+
20,
95+
value=_get_phone_number(
8796
customer['contact_info']['contact'].get(
8897
'phone_number',
8998
'-',
@@ -113,7 +122,7 @@ def _get_phone_number(number):
113122
def _prepare_worksheet(ws):
114123
color = Color('d3d3d3')
115124
fill = PatternFill('solid', color)
116-
cels = ws['A1': 'T1']
125+
cels = ws['A1':'T1']
117126
for cel in cels[0]:
118127
if cel.column_letter in ['J', 'K', 'L']:
119128
ws.column_dimensions[cel.column_letter].width = 50
@@ -136,7 +145,7 @@ def _add_countries(ws):
136145
ws.column_dimensions['A'].width = 15
137146
ws.column_dimensions['A'].auto_size = True
138147
ws.column_dimensions['B'].width = 50
139-
cels = ws['A1': 'B1']
148+
cels = ws['A1':'B1']
140149
for cel in cels[0]:
141150
cel.fill = fill
142151
cel.value = col_headers[cel.column_letter]

connect/cli/plugins/customer/sync.py

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _open_workbook(self, input_file):
5757

5858
@staticmethod
5959
def _validate_worksheet_sheet(ws):
60-
cels = ws['A1': 'T1']
60+
cels = ws['A1':'T1']
6161
for cel in cels[0]:
6262
if cel.value != COL_HEADERS[cel.column_letter]:
6363
raise ClickException(
@@ -90,27 +90,30 @@ def sync(self): # noqa: CCR001
9090
self.stats.error(row_errors, row_idx)
9191
continue
9292
if data.parent_search_criteria and not data.parent_search_value:
93-
self.stats.error("Parent search value is needed if criteria is set", row_idx)
93+
self.stats.error('Parent search value is needed if criteria is set', row_idx)
9494
continue
9595
if data.hub_id and (data.hub_id != '' or data.hub_id != '-'):
9696
if data.hub_id not in self.hubs:
97-
self.stats.error(f"Accounts on hub {data.hub_id} can not be modified", row_idx)
97+
self.stats.error(
98+
f'Accounts on hub {data.hub_id} can not be modified',
99+
row_idx,
100+
)
98101
continue
99102
name = f'{data.technical_contact_first_name} {data.technical_contact_last_name}'
100103
model = {
101-
"type": data.type,
102-
"name": data.company_name if data.company_name else name,
103-
"contact_info": {
104-
"address_line1": data.address_line_1,
105-
"address_line2": data.address_line_2,
106-
"city": data.city,
107-
"country": data.country,
108-
"postal_code": data.zip,
109-
"state": data.state,
110-
"contact": {
111-
"first_name": data.technical_contact_first_name,
112-
"last_name": data.technical_contact_last_name,
113-
"email": data.technical_contact_email,
104+
'type': data.type,
105+
'name': data.company_name if data.company_name else name,
106+
'contact_info': {
107+
'address_line1': data.address_line_1,
108+
'address_line2': data.address_line_2,
109+
'city': data.city,
110+
'country': data.country,
111+
'postal_code': data.zip,
112+
'state': data.state,
113+
'contact': {
114+
'first_name': data.technical_contact_first_name,
115+
'last_name': data.technical_contact_last_name,
116+
'email': data.technical_contact_email,
114117
},
115118
},
116119
}
@@ -124,9 +127,9 @@ def sync(self): # noqa: CCR001
124127
try:
125128
phone = phonenumbers.parse(data.technical_contact_phone, data.country)
126129
phone_number = {
127-
"country_code": f'+{str(phone.country_code)}',
128-
"area_code": '',
129-
"extension": str(phone.extension) if phone.extension else '-',
130+
'country_code': f'+{str(phone.country_code)}',
131+
'area_code': '',
132+
'extension': str(phone.extension) if phone.extension else '-',
130133
'phone_number': str(phone.national_number),
131134
}
132135
model['contact_info']['contact']['phone_number'] = phone_number
@@ -137,7 +140,9 @@ def sync(self): # noqa: CCR001
137140
if data.parent_search_criteria == 'id':
138141
if data.parent_search_value not in parent_id:
139142
try:
140-
pacc = self._client.ns('tier').accounts[data.parent_search_value].get()
143+
pacc = (
144+
self._client.ns('tier').accounts[data.parent_search_value].get()
145+
)
141146
parent_id.append(pacc['id'])
142147
except ClientError:
143148
self.stats.error(
@@ -167,7 +172,8 @@ def sync(self): # noqa: CCR001
167172
parent_external_id[data.parent_search_value] = pacc[0]['id']
168173
except ClientError:
169174
self.stats.error(
170-
'Error when obtaining parent data from Connect', row_idx,
175+
'Error when obtaining parent data from Connect',
176+
row_idx,
171177
)
172178
continue
173179
model['parent']['id'] = parent_external_id[data.parent_search_value]
@@ -191,7 +197,8 @@ def sync(self): # noqa: CCR001
191197
parent_uuid[data.parent_search_value] = pacc[0]['id']
192198
except ClientError:
193199
self.stats.error(
194-
'Error when obtaining parent data from Connect', row_idx,
200+
'Error when obtaining parent data from Connect',
201+
row_idx,
195202
)
196203
continue
197204
model['parent']['id'] = parent_uuid[data.parent_search_value]
@@ -200,7 +207,8 @@ def sync(self): # noqa: CCR001
200207
account = self._client.ns('tier').accounts.create(model)
201208
except ClientError as e:
202209
self.stats.error(
203-
f'Error when creating account: {str(e)}', row_idx,
210+
f'Error when creating account: {str(e)}',
211+
row_idx,
204212
)
205213
continue
206214
self.stats.created()
@@ -211,7 +219,8 @@ def sync(self): # noqa: CCR001
211219
account = self._client.ns('tier').accounts[data.id].update(model)
212220
except ClientError as e:
213221
self.stats.error(
214-
f'Error when updating account: {str(e)}', row_idx,
222+
f'Error when updating account: {str(e)}',
223+
row_idx,
215224
)
216225
continue
217226
self.stats.updated()
@@ -235,23 +244,25 @@ def _validate_row(self, row):
235244
errors.append(f'Customer type must be customer or reseller, not {row.type}')
236245
return errors
237246
if not all(
238-
[
239-
row.address_line_1,
240-
row.city,
241-
row.state,
242-
row.zip,
243-
row.technical_contact_first_name,
244-
row.technical_contact_last_name,
245-
row.technical_contact_email,
246-
],
247+
[
248+
row.address_line_1,
249+
row.city,
250+
row.state,
251+
row.zip,
252+
row.technical_contact_first_name,
253+
row.technical_contact_last_name,
254+
row.technical_contact_email,
255+
],
247256
):
248257
errors.append('Address line 1, city, state and zip are mandatory')
249258
return errors
250259
if row.action == 'create' and row.id is not None:
251260
errors.append(f'Create action must not have account id, is set to {row.id}')
252261
return errors
253-
if row.action == 'create' and row.type == 'customer' and (
254-
row.parent_search_criteria == '' or row.parent_search_criteria == '-'
262+
if (
263+
row.action == 'create'
264+
and row.type == 'customer'
265+
and (row.parent_search_criteria == '' or row.parent_search_criteria == '-')
255266
):
256267
errors.append('Customers requires a parent account')
257268
return errors

connect/cli/plugins/locale/commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def cmd_list_locales(config, query):
4141
],
4242
rows=[
4343
(
44-
resource["id"],
45-
resource["name"],
46-
field_to_check_mark(resource["auto_translation"], false_value='\u2716'),
47-
resource["stats"]["translations"] or '-',
44+
resource['id'],
45+
resource['name'],
46+
field_to_check_mark(resource['auto_translation'], false_value='\u2716'),
47+
resource['stats']['translations'] or '-',
4848
)
4949
for resource in query_locales
5050
],

0 commit comments

Comments
 (0)