Skip to content

Commit

Permalink
chore: reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
gjedlicska committed Nov 27, 2023
1 parent 3578592 commit 4dc1481
Show file tree
Hide file tree
Showing 32 changed files with 303 additions and 183 deletions.
47 changes: 37 additions & 10 deletions src/specklepy/api/host_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,44 @@
from enum import Enum
from unicodedata import name

# following imports seem to be unnecessary, but they need to stay
# following imports seem to be unnecessary, but they need to stay
# to not break the scripts using these functions as non-core
from specklepy.core.api.host_applications import (HostApplication, HostAppVersion,
get_host_app_from_string,
_app_name_host_app_mapping,
RHINO,GRASSHOPPER,REVIT,DYNAMO,UNITY,GSA,
CIVIL,AUTOCAD,MICROSTATION,OPENROADS,
OPENRAIL,OPENBUILDINGS,ETABS,SAP2000,CSIBRIDGE,
SAFE,TEKLASTRUCTURES,DXF,EXCEL,UNREAL,POWERBI,
BLENDER,QGIS,ARCGIS,SKETCHUP,ARCHICAD,TOPSOLID,
PYTHON,NET,OTHER)
from specklepy.core.api.host_applications import (
HostApplication,
HostAppVersion,
get_host_app_from_string,
_app_name_host_app_mapping,
RHINO,
GRASSHOPPER,
REVIT,
DYNAMO,
UNITY,
GSA,
CIVIL,
AUTOCAD,
MICROSTATION,
OPENROADS,
OPENRAIL,
OPENBUILDINGS,
ETABS,
SAP2000,
CSIBRIDGE,
SAFE,
TEKLASTRUCTURES,
DXF,
EXCEL,
UNREAL,
POWERBI,
BLENDER,
QGIS,
ARCGIS,
SKETCHUP,
ARCHICAD,
TOPSOLID,
PYTHON,
NET,
OTHER,
)

if __name__ == "__main__":
print(HostAppVersion.v)
23 changes: 17 additions & 6 deletions src/specklepy/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@

from pydantic import BaseModel, Field

# following imports seem to be unnecessary, but they need to stay
# following imports seem to be unnecessary, but they need to stay
# to not break the scripts using these functions as non-core
from specklepy.core.api.models import (Collaborator, Commit,
Commits, Object, Branch, Branches,
Stream, Streams, User, LimitedUser,
PendingStreamCollaborator, Activity,
ActivityCollection, ServerInfo)
from specklepy.core.api.models import (
Collaborator,
Commit,
Commits,
Object,
Branch,
Branches,
Stream,
Streams,
User,
LimitedUser,
PendingStreamCollaborator,
Activity,
ActivityCollection,
ServerInfo,
)
11 changes: 7 additions & 4 deletions src/specklepy/api/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from specklepy.transports.abstract_transport import AbstractTransport
from specklepy.transports.sqlite import SQLiteTransport

from specklepy.core.api.operations import (send as core_send,
receive as _untracked_receive,
serialize as core_serialize,
deserialize as core_deserialize)
from specklepy.core.api.operations import (
send as core_send,
receive as _untracked_receive,
serialize as core_serialize,
deserialize as core_deserialize,
)


def send(
Expand Down Expand Up @@ -74,6 +76,7 @@ def serialize(base: Base, write_transports: List[AbstractTransport] = []) -> str
metrics.track(metrics.SDK, custom_props={"name": "Serialize"})
return core_serialize(base, write_transports)


def deserialize(
obj_string: str, read_transport: Optional[AbstractTransport] = None
) -> Base:
Expand Down
13 changes: 6 additions & 7 deletions src/specklepy/api/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from specklepy.serialization.base_object_serializer import BaseObjectSerializer
from specklepy.transports.sqlite import SQLiteTransport

# following imports seem to be unnecessary, but they need to stay
# following imports seem to be unnecessary, but they need to stay
# to not break the scripts using these functions as non-core
from specklepy.core.api.resource import ResourceBase as CoreResourceBase

Expand All @@ -29,10 +29,9 @@ def __init__(
server_version: Optional[Tuple[Any, ...]] = None,
) -> None:
super().__init__(
account = account,
basepath = basepath,
client = client,
name = name,
server_version = server_version
account=account,
basepath=basepath,
client=client,
name=name,
server_version=server_version,
)

4 changes: 3 additions & 1 deletion src/specklepy/api/resources/active_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def get_all_pending_invites(self) -> List[PendingStreamCollaborator]:
List[PendingStreamCollaborator]
-- a list of pending invites for the current user
"""
metrics.track(metrics.SDK, self.account, {"name": "User Active Invites All Get"})
metrics.track(
metrics.SDK, self.account, {"name": "User Active Invites All Get"}
)
return super().get_all_pending_invites()

def get_pending_invite(
Expand Down
1 change: 0 additions & 1 deletion src/specklepy/api/resources/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ def create(self, stream_id: str, objects: List[Dict]) -> str:
"""
metrics.track(metrics.SDK, self.account, {"name": "Object Create"})
return super().create(stream_id, objects)

5 changes: 2 additions & 3 deletions src/specklepy/api/resources/other_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def search(
)

metrics.track(metrics.SDK, self.account, {"name": "Other User Search"})
return super().search(search_query, limit)
return super().search(search_query, limit)

def activity(
self,
Expand Down Expand Up @@ -83,5 +83,4 @@ def activity(
cursor {datetime} -- timestamp cursor for pagination
"""
metrics.track(metrics.SDK, self.account, {"name": "Other User Activity"})
return super().activity(user_id, limit, action_type, before, after, cursor)

return super().activity(user_id, limit, action_type, before, after, cursor)
2 changes: 1 addition & 1 deletion src/specklepy/api/resources/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def revoke_token(self, token: str) -> bool:
bool -- True if the token was successfully deleted
"""
metrics.track(metrics.SDK, self.account, {"name": "Server Revoke Token"})
return super().revoke_token(token)
return super().revoke_token(token)
7 changes: 5 additions & 2 deletions src/specklepy/api/resources/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ def update_permission(self, stream_id: str, user_id: str, role: str):
Returns:
bool -- True if the operation was successful
"""
metrics.track(metrics.SDK, self.account, {"name": "Stream Permission Update", "role": role})
metrics.track(
metrics.SDK,
self.account,
{"name": "Stream Permission Update", "role": role},
)
return super().update_permission(stream_id, user_id, role)

def revoke_permission(self, stream_id: str, user_id: str):
Expand Down Expand Up @@ -301,4 +305,3 @@ def activity(
"""
metrics.track(metrics.SDK, self.account, {"name": "Stream Activity"})
return super().activity(stream_id, action_type, limit, before, after, cursor)

9 changes: 7 additions & 2 deletions src/specklepy/api/resources/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from specklepy.logging import metrics
from specklepy.core.api.resources.subscriptions import Resource as CoreResource


def check_wsclient(function):
@wraps(function)
async def check_wsclient_wrapper(self, *args, **kwargs):
Expand Down Expand Up @@ -64,7 +65,9 @@ async def stream_updated(self, id: str, callback: Optional[Callable] = None):
Returns:
Stream -- the update stream
"""
metrics.track(metrics.SDK, self.account, {"name": "Subscription Stream Updated"})
metrics.track(
metrics.SDK, self.account, {"name": "Subscription Stream Updated"}
)
return super().stream_updated(id, callback)

@check_wsclient
Expand All @@ -83,7 +86,9 @@ async def stream_removed(self, callback: Optional[Callable] = None):
Returns:
dict -- dict containing 'id' of stream removed and optionally 'revokedBy'
"""
metrics.track(metrics.SDK, self.account, {"name": "Subscription Stream Removed"})
metrics.track(
metrics.SDK, self.account, {"name": "Subscription Stream Removed"}
)
return super().stream_removed(callback)

@check_wsclient
Expand Down
15 changes: 7 additions & 8 deletions src/specklepy/api/resources/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get(self, id: Optional[str] = None) -> User:
"""
metrics.track(metrics.SDK, self.account, {"name": "User Get_deprecated"})
return super().get(id)

@deprecated(version=DEPRECATION_VERSION, reason=DEPRECATION_TEXT)
def search(
self, search_query: str, limit: int = 25
Expand Down Expand Up @@ -83,7 +83,7 @@ def update(
Returns:
bool -- True if your profile was updated successfully
"""
#metrics.track(metrics.USER, self.account, {"name": "update"})
# metrics.track(metrics.USER, self.account, {"name": "update"})
metrics.track(metrics.SDK, self.account, {"name": "User Update_deprecated"})
return super().update(name, company, bio, avatar)

Expand Down Expand Up @@ -118,7 +118,6 @@ def activity(
"""
metrics.track(metrics.SDK, self.account, {"name": "User Activity_deprecated"})
return super().activity(user_id, limit, action_type, before, after, cursor)


@deprecated(version=DEPRECATION_VERSION, reason=DEPRECATION_TEXT)
def get_all_pending_invites(self) -> List[PendingStreamCollaborator]:
Expand All @@ -130,10 +129,11 @@ def get_all_pending_invites(self) -> List[PendingStreamCollaborator]:
List[PendingStreamCollaborator]
-- a list of pending invites for the current user
"""
#metrics.track(metrics.INVITE, self.account, {"name": "get"})
metrics.track(metrics.SDK, self.account, {"name": "User GetAllInvites_deprecated"})
# metrics.track(metrics.INVITE, self.account, {"name": "get"})
metrics.track(
metrics.SDK, self.account, {"name": "User GetAllInvites_deprecated"}
)
return super().get_all_pending_invites()


@deprecated(version=DEPRECATION_VERSION, reason=DEPRECATION_TEXT)
def get_pending_invite(
Expand All @@ -152,7 +152,6 @@ def get_pending_invite(
PendingStreamCollaborator
-- the invite for the given stream (or None if it isn't found)
"""
#metrics.track(metrics.INVITE, self.account, {"name": "get"})
# metrics.track(metrics.INVITE, self.account, {"name": "get"})
metrics.track(metrics.SDK, self.account, {"name": "User GetInvite_deprecated"})
return super().get_pending_invite(stream_id, token)

9 changes: 6 additions & 3 deletions src/specklepy/api/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from specklepy.transports.server.server import ServerTransport

from specklepy.logging import metrics
from specklepy.core.api.wrapper import StreamWrapper as CoreStreamWrapper
from specklepy.core.api.wrapper import StreamWrapper as CoreStreamWrapper


class StreamWrapper(CoreStreamWrapper):
"""
Expand Down Expand Up @@ -51,7 +52,7 @@ class StreamWrapper(CoreStreamWrapper):
_account: Account = None

def __init__(self, url: str) -> None:
super().__init__(url = url)
super().__init__(url=url)

def get_account(self, token: str = None) -> Account:
"""
Expand Down Expand Up @@ -90,5 +91,7 @@ def get_transport(self, token: str = None) -> ServerTransport:
ServerTransport -- constructed for this stream
with a pre-authenticated client
"""
metrics.track(metrics.SDK, custom_props={"name": "Stream Wrapper Get Transport"})
metrics.track(
metrics.SDK, custom_props={"name": "Stream Wrapper Get Transport"}
)
return super().get_transport(token)
2 changes: 1 addition & 1 deletion src/specklepy/core/api/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def get_default_account(base_path: Optional[str] = None) -> Optional[Account]:
if not default:
default = accounts[0]
default.isDefault = True
#metrics.initialise_tracker(default)
# metrics.initialise_tracker(default)

return default

Expand Down
2 changes: 1 addition & 1 deletion src/specklepy/core/api/operations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

#from specklepy.logging import metrics
# from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException
from specklepy.objects.base import Base
from specklepy.serialization.base_object_serializer import BaseObjectSerializer
Expand Down
6 changes: 5 additions & 1 deletion src/specklepy/core/api/resources/active_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

from gql import gql

from specklepy.core.api.models import ActivityCollection, PendingStreamCollaborator, User
from specklepy.core.api.models import (
ActivityCollection,
PendingStreamCollaborator,
User,
)
from specklepy.core.api.resource import ResourceBase
from specklepy.logging.exceptions import SpeckleException

Expand Down
9 changes: 6 additions & 3 deletions src/specklepy/core/api/resources/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from deprecated import deprecated
from gql import gql

from specklepy.core.api.models import ActivityCollection, PendingStreamCollaborator, Stream
from specklepy.core.api.models import (
ActivityCollection,
PendingStreamCollaborator,
Stream,
)
from specklepy.core.api.resource import ResourceBase
from specklepy.logging.exceptions import SpeckleException, UnsupportedException

Expand Down Expand Up @@ -504,11 +508,10 @@ def invite_batch(

user_invites = [
{"streamId": stream_id, "message": message, "userId": user_id}
for user_id in (user_ids if user_ids is not None else [])
for user_id in (user_ids if user_ids is not None else [])
if user_id is not None
]


params = {"input": [*email_invites, *user_invites]}

return self.make_request(
Expand Down
6 changes: 5 additions & 1 deletion src/specklepy/core/api/resources/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from deprecated import deprecated
from gql import gql

from specklepy.core.api.models import ActivityCollection, PendingStreamCollaborator, User
from specklepy.core.api.models import (
ActivityCollection,
PendingStreamCollaborator,
User,
)
from specklepy.core.api.resource import ResourceBase

from specklepy.logging.exceptions import SpeckleException
Expand Down
4 changes: 2 additions & 2 deletions src/specklepy/logging/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
RECEIVE = "Receive"
SEND = "Send"

# not in use since 2.15
# not in use since 2.15
ACCOUNTS = "Get Local Accounts"
BRANCH = "Branch Action"
CLIENT = "Speckle Client"
Expand Down Expand Up @@ -142,7 +142,7 @@ def set_last_server(self, server: str):

def hash(self, value: str):
inputList = value.lower().split("://")
input = inputList[len(inputList)-1].split("/")[0].split('?')[0]
input = inputList[len(inputList) - 1].split("/")[0].split("?")[0]
return hashlib.md5(input.encode("utf-8")).hexdigest().upper()

def _send_tracking_requests(self):
Expand Down
4 changes: 1 addition & 3 deletions src/specklepy/objects/GIS/CRS.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class CRS(Base, speckle_type="Objects.GIS.CRS"):
name: Optional[str] = None
authority_id: Optional[str] = None
wkt: Optional[str] = None
units_native: Optional[str] = None
units_native: Optional[str] = None
offset_x: Optional[float] = None
offset_y: Optional[float] = None
rotation: Optional[float] = None


Loading

0 comments on commit 4dc1481

Please sign in to comment.