Skip to content

Commit 1988135

Browse files
committed
black codebase
1 parent 067adf8 commit 1988135

File tree

40 files changed

+136
-168
lines changed

40 files changed

+136
-168
lines changed

jumpscale/clients/_bcdb/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from jumpscale.core.base import StoredFactory
22
from .client import HTTPClient
33

4+
45
def export_module_as():
56

67
return StoredFactory(HTTPClient)

jumpscale/clients/_bcdb/client.py

+19-30
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,36 @@
77
from urllib.parse import quote_plus
88
import requests_unixsocket
99
from jumpscale.core.base import fields
10+
11+
1012
class Object(NamedTuple):
1113
id: int
1214
data: bytes
1315
tags: dict
1416

1517
@property
1618
def acl(self):
17-
return int(self.tags[':acl']) if ':acl' in self.tags else None
19+
return int(self.tags[":acl"]) if ":acl" in self.tags else None
1820

1921
@property
2022
def size(self):
21-
return int(self.tags[':size']) if ':size' in self.tags else 0
23+
return int(self.tags[":size"]) if ":size" in self.tags else 0
2224

2325
@property
2426
def created(self):
25-
return int(self.tags[':created']) if ':created' in self.tags else 0
27+
return int(self.tags[":created"]) if ":created" in self.tags else 0
2628

2729
@property
2830
def updated(self):
29-
return int(self.tags[':updated']) if ':updated' in self.tags else 0
30-
31+
return int(self.tags[":updated"]) if ":updated" in self.tags else 0
3132

3233

3334
class HTTPClient(BaseClient):
3435
sock = fields.String(default="/tmp/bcdb.sock")
36+
3537
def __init__(self, *args, **kwargs):
3638
super().__init__(*args, **kwargs)
37-
url = 'http+unix://%s/' % quote_plus(self.sock)
39+
url = "http+unix://%s/" % quote_plus(self.sock)
3840
self.__session = requests_unixsocket.Session()
3941
self.__url = url
4042

@@ -47,7 +49,7 @@ def headers(self, **args):
4749
for k, v in args.items():
4850
if v is None:
4951
continue
50-
k = k.replace('_', '-').lower()
52+
k = k.replace("_", "-").lower()
5153
output[k] = str(v)
5254

5355
return output
@@ -88,10 +90,7 @@ def create(self, perm, users):
8890
:returns: newly created key
8991
"""
9092

91-
data = {
92-
"perm": perm,
93-
'users': users
94-
}
93+
data = {"perm": perm, "users": users}
9594

9695
return self.session.post(self.url(), json=data, headers=self.headers()).json()
9796

@@ -104,9 +103,7 @@ def set(self, key, perm):
104103
:returns: new object id
105104
"""
106105

107-
data = {
108-
'perm': perm
109-
}
106+
data = {"perm": perm}
110107

111108
self.session.put(self.url(key), json=data, headers=self.headers())
112109

@@ -129,9 +126,7 @@ def grant(self, key, users):
129126
:returns: updated id
130127
"""
131128

132-
data = {
133-
'users': users
134-
}
129+
data = {"users": users}
135130

136131
return self.session.post(self.url(f"{key}/grant"), json=data, headers=self.headers()).json()
137132

@@ -144,9 +139,7 @@ def revoke(self, key, users):
144139
:returns: updated id
145140
"""
146141

147-
data = {
148-
'users': users
149-
}
142+
data = {"users": users}
150143

151144
return self.session.post(self.url(f"{key}/revoke"), json=data, headers=self.headers()).json()
152145

@@ -156,8 +149,7 @@ def list(self):
156149
157150
:returns: acl list
158151
"""
159-
response = self.session.get(
160-
self.url(), headers=self.headers())
152+
response = self.session.get(self.url(), headers=self.headers())
161153

162154
# this should instead read response "stream" and parse each object individually
163155
content = response.text
@@ -219,9 +211,7 @@ def get(self, key):
219211
return Object(
220212
id=key,
221213
data=response.content,
222-
tags=json.loads(
223-
response.headers.get('x-tags', 'null')
224-
),
214+
tags=json.loads(response.headers.get("x-tags", "null")),
225215
)
226216

227217
def delete(self, key):
@@ -251,19 +241,18 @@ def find(self, **kwargs):
251241
# due to a bug in the warp router (server side)
252242
# this call does not match if no queries are supplied
253243
# hence we add a dummy query that is ignred by the server
254-
kwargs = {'_': ''}
244+
kwargs = {"_": ""}
255245

256246
# this should instead read response "stream" and parse each object individually
257-
response = self.session.get(
258-
self.url(), params=kwargs, headers=self.headers())
247+
response = self.session.get(self.url(), params=kwargs, headers=self.headers())
259248

260249
content = response.text
261250
dec = json.JSONDecoder()
262251
while content:
263252
obj, idx = dec.raw_decode(content)
264253
yield Object(
265-
id=obj['id'],
266-
tags=obj['tags'],
254+
id=obj["id"],
255+
tags=obj["tags"],
267256
data=None,
268257
)
269258

jumpscale/clients/btc_alpha/btc_alpha.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ def get_wallets(self, **kwargs):
6565
return self._query("get", "v1/wallets/", params=kwargs, auth=True)
6666

6767
def get_own_sell_orders(self, **kwargs):
68-
""" Returns own sell orders """
68+
"""Returns own sell orders"""
6969
kwargs["type"] = "sell"
7070
return self._query("get", "v1/orders/own/", params=kwargs, auth=True)
7171

7272
def get_own_buy_orders(self, **kwargs):
73-
""" Returns own buy orders """
73+
"""Returns own buy orders"""
7474
kwargs["type"] = "buy"
7575
return self._query("get", "v1/orders/own/", params=kwargs, auth=True)
7676

@@ -89,7 +89,7 @@ def create_sell_order(self, pair, amount, price):
8989
return self._query("post", "v1/order/", data=data, auth=True)
9090

9191
def create_buy_order(self, pair, amount, price):
92-
""" Create buy order """
92+
"""Create buy order"""
9393
data = {"pair": pair, "amount": amount, "price": price, "type": "buy"}
9494
return self._query("post", "v1/order/", data=data, auth=True)
9595

jumpscale/clients/currencylayer/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""
32
JS-NG> fake = j.clients.currencylayer.new('fake')
43
JS-NG> fake.cur2id_print()
@@ -712,4 +711,5 @@
712711
def export_module_as():
713712
from jumpscale.core.base import StoredFactory
714713
from .currencylayer import CurrencyLayerClient
714+
715715
return StoredFactory(CurrencyLayerClient)

jumpscale/clients/currencylayer/currencies.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,5 @@
172172
}
173173

174174

175-
CURRNECIES_IDS = dict(zip(range(1, len(CURRENCIES)+1), CURRENCIES.keys()))
176-
IDS_CURRENCIES = dict(zip(CURRENCIES.keys(), range(1, len(CURRENCIES)+1)))
175+
CURRNECIES_IDS = dict(zip(range(1, len(CURRENCIES) + 1), CURRENCIES.keys()))
176+
IDS_CURRENCIES = dict(zip(CURRENCIES.keys(), range(1, len(CURRENCIES) + 1)))

jumpscale/clients/digitalocean/digitalocean.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def get_image(self, name):
522522
raise j.exceptions.Base("did not find image:%s" % name)
523523

524524
def get_image_names(self, name=""):
525-
""" Return all the image or images with a specified name
525+
"""Return all the image or images with a specified name
526526
e.g
527527
dg.get_image_names() -> ['centos 6.9 x32 20180130', 'centos 6.9 x64 20180602',...]
528528
dg.get_image_names("centos") -> ['centos 6.9 x32 20180130', 'centos 6.9 x64 20180602']

jumpscale/clients/gedis/gedis.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ def list_actors(self) -> list:
125125
return self.execute("core", "list_actors", die=True).result
126126

127127
def reload(self):
128-
"""Reload actors
129-
"""
128+
"""Reload actors"""
130129
self._load_actors(force_reload=True)
131130

132131
def execute(self, actor_name: str, actor_method: str, *args, die: bool = False, **kwargs) -> ActorResult:

jumpscale/clients/github/milestone.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, repo, githubObj=None):
2323

2424
def load(self):
2525
self._ddict = {}
26-
#self._ddict["deadline"] = j.data.time.any2HRDateTime(self.api.due_on)
26+
# self._ddict["deadline"] = j.data.time.any2HRDateTime(self.api.due_on)
2727
self._ddict["id"] = self.api.id
2828
self._ddict["url"] = self.api.url
2929
self._ddict["title"] = self.api.title
@@ -46,8 +46,6 @@ def ddict(self):
4646
self.load()
4747
return self._ddict
4848

49-
50-
5149
# synonym to let the tags of super class work
5250
@property
5351
def body(self):

jumpscale/clients/kraken/kraken.py

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class Price(Base):
4040

4141

4242
class KrakenClient(Client):
43-
4443
def __init__(self, *args, **kwargs):
4544
super().__init__(*args, **kwargs)
4645
self._session = requests.Session()

jumpscale/clients/mail/mail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def is_ssl(self):
2828
return self.smtp_port in [465, 587]
2929

3030
def send(self, recipients, sender="", subject="", message="", files=None, mimetype=None):
31-
""" Send an email to the recipients from the sender containing the message required and any attached files given by the paths in files
31+
"""Send an email to the recipients from the sender containing the message required and any attached files given by the paths in files
3232
:param recipients: Recipients of the message
3333
:type recipients: mixed, str or list
3434
:param sender: Sender of the email

jumpscale/clients/sendgrid/sendgrid.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def build_attachment(self, filepath, typ="application/pdf"):
2222
data = io.BytesIO()
2323
with open(filepath, "rb") as f:
2424
while True:
25-
d = f.read(2 ** 20)
25+
d = f.read(2**20)
2626
if not d:
2727
break
2828
data.write(d)
@@ -50,4 +50,3 @@ def send(self, sender, subject, html_content="<strong>Email</strong>", recipient
5050
print(response.headers)
5151
except HTTPError as e:
5252
raise e
53-

jumpscale/clients/stellar/stellar.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def _change_trustline(self, asset_code, issuer, limit=None, secret=None):
395395
network_passphrase=_NETWORK_PASSPHRASES[self.network.value],
396396
base_fee=base_fee,
397397
)
398-
.append_change_trust_op(Asset(asset_code,issuer), limit=limit)
398+
.append_change_trust_op(Asset(asset_code, issuer), limit=limit)
399399
.set_timeout(30)
400400
.build()
401401
)
@@ -540,7 +540,7 @@ def _transfer(
540540
transaction_builder.append_payment_op(
541541
destination=destination_address,
542542
amount=str(amount),
543-
asset=self._get_asset(asset_code,issuer),
543+
asset=self._get_asset(asset_code, issuer),
544544
source=source_account.account.account_id,
545545
)
546546
transaction_builder.set_timeout(timeout)

jumpscale/clients/syncthing/syncthing.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ def delete_device(self, name):
101101
return self.set_config(self.config)
102102

103103
def add_folder(
104-
self, name, path, ignore_perms=False, read_only=False, rescan_intervals=10, devices=None, overwrite=False,
104+
self,
105+
name,
106+
path,
107+
ignore_perms=False,
108+
read_only=False,
109+
rescan_intervals=10,
110+
devices=None,
111+
overwrite=False,
105112
):
106113
folders = self.get_folders()
107114
idx = self._get_folder(name)

jumpscale/clients/taiga/models.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,12 @@ def as_yaml(self):
746746
"email": self.owner["email"],
747747
}
748748
members = [
749-
{"name": member.full_name, "id": member.id, "role": member.role_name,} for member in self.list_memberships()
749+
{
750+
"name": member.full_name,
751+
"id": member.id,
752+
"role": member.role_name,
753+
}
754+
for member in self.list_memberships()
750755
]
751756
other_membership = {
752757
"i_am_owner": self.i_am_owner,

jumpscale/clients/taiga/taiga.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,10 @@ def validate_custom_fields(self, attributes):
741741
duration = value.get("duration", 1)
742742
amount = value.get("amount", 0)
743743
currency = value.get("currency", "eur")
744-
start_date = value.get("start_date", f"{dateutil.utils.today().month}:{dateutil.utils.today().year}",)
744+
start_date = value.get(
745+
"start_date",
746+
f"{dateutil.utils.today().month}:{dateutil.utils.today().year}",
747+
)
745748
confidence = value.get("confidence", 100)
746749
user = value.get("user")
747750
part = value.get("part", "0%")
@@ -899,7 +902,10 @@ def _create_new_circle(
899902
return p
900903

901904
def create_new_project_circle(
902-
self, name, description="", **attrs,
905+
self,
906+
name,
907+
description="",
908+
**attrs,
903909
):
904910
"""Creates a new project circle.
905911
@@ -1269,21 +1275,27 @@ def import_circle(self, yaml_obj):
12691275
# Funnel Circle
12701276
if yaml_obj["basic_info"]["name"].lower() == "funnel":
12711277
circle = self.create_new_funnel_circle(
1272-
yaml_obj["basic_info"]["name"], yaml_obj["basic_info"]["description"],
1278+
yaml_obj["basic_info"]["name"],
1279+
yaml_obj["basic_info"]["description"],
12731280
)
12741281
# Team Circle
12751282
elif yaml_obj["basic_info"]["name"].lower() == "team":
12761283
circle = self.create_new_team_circle(
1277-
yaml_obj["basic_info"]["name"], yaml_obj["basic_info"]["description"],
1284+
yaml_obj["basic_info"]["name"],
1285+
yaml_obj["basic_info"]["description"],
12781286
)
12791287
# Project Circle
12801288
elif yaml_obj["basic_info"]["name"].lower() == "project":
12811289
circle = self.create_new_project_circle(
1282-
yaml_obj["basic_info"]["name"], yaml_obj["basic_info"]["description"],
1290+
yaml_obj["basic_info"]["name"],
1291+
yaml_obj["basic_info"]["description"],
12831292
)
12841293
# Any Other Circle
12851294
else:
1286-
circle = self._create_new_circle(yaml_obj["basic_info"]["name"], yaml_obj["basic_info"]["description"],)
1295+
circle = self._create_new_circle(
1296+
yaml_obj["basic_info"]["name"],
1297+
yaml_obj["basic_info"]["description"],
1298+
)
12871299
circle.is_backlog_activated = yaml_obj["modules"]["is_backlog_activated"]
12881300
circle.is_issues_activated = yaml_obj["modules"]["is_issues_activated"]
12891301
circle.is_kanban_activated = yaml_obj["modules"]["is_kanban_activated"]

jumpscale/clients/zerotier/zerotier.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ def _update_authorization(self, authorize):
5656
self.raw_data["config"]["authorized"] = authorize
5757

5858
def authorize(self):
59-
"""Authorize member to the zerotier network
60-
"""
59+
"""Authorize member to the zerotier network"""
6160
self._update_authorization(True)
6261

6362
def unauthorize(self):
64-
"""Unauthorize member to the zerotier network
65-
"""
63+
"""Unauthorize member to the zerotier network"""
6664
self._update_authorization(False)
6765

6866
def __repr__(self):

jumpscale/data/treemanager/treemanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _string_repr(self):
175175

176176

177177
class Tree:
178-
""""
178+
""" "
179179
A class to represent a tree
180180
"""
181181

0 commit comments

Comments
 (0)