Skip to content

Commit

Permalink
refactor: imports sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed May 10, 2023
1 parent 7bdfd79 commit 68a8c60
Show file tree
Hide file tree
Showing 34 changed files with 101 additions and 151 deletions.
11 changes: 3 additions & 8 deletions examples/clientIDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
#
# SPDX-License-Identifier: Apache-2.0

import pyrfc
from configparser import ConfigParser
from os import path

from pyrfc import (
ABAPApplicationError,
ABAPRuntimeError,
LogonError,
CommunicationError,
)
from configparser import ConfigParser
import pyrfc
from pyrfc import ABAPApplicationError, ABAPRuntimeError, CommunicationError, LogonError


def initial_screen():
Expand Down
12 changes: 3 additions & 9 deletions examples/clientPrintDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
#
# SPDX-License-Identifier: Apache-2.0

from os import path
from configparser import ConfigParser
import sys
from configparser import ConfigParser
from os import path

from pyrfc import (
Connection,
ABAPApplicationError,
ABAPRuntimeError,
LogonError,
CommunicationError,
)
from pyrfc import ABAPApplicationError, ABAPRuntimeError, CommunicationError, Connection, LogonError


def parameter_key_function(parameter):
Expand Down
16 changes: 5 additions & 11 deletions examples/clientStfcStructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
#
# SPDX-License-Identifier: Apache-2.0

from os import (
path,
)
from pyrfc import Connection
from pprint import (
pprint,
)
from configparser import (
ConfigParser,
)

import datetime
from configparser import ConfigParser
from os import path
from pprint import pprint

from pyrfc import Connection

imp = {
"RFCINT1": 0x7F, # INT1: Integer value (1 byte)
Expand Down
8 changes: 2 additions & 6 deletions examples/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0

from os import (
path,
)
from configparser import (
ConfigParser,
)
from configparser import ConfigParser
from os import path

cp = ConfigParser()
cp.read(
Expand Down
1 change: 1 addition & 0 deletions examples/server/bgrfc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import sys

from pyrfc import Connection

client = Connection(dest=sys.argv[1])
Expand Down
4 changes: 2 additions & 2 deletions examples/server/bgrfc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# SPDX-License-Identifier: Apache-2.0

import sys
from backends import BACKEND

from pyrfc import Server, RCStatus, UnitState, UnitCallType
from backends import BACKEND
from tlog import TLog

from pyrfc import RCStatus, Server, UnitCallType, UnitState

backend_dest = sys.argv[1]

Expand Down
1 change: 1 addition & 0 deletions examples/server/bgrfc_unit_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import sys

from pyrfc import Connection

with Connection(dest=sys.argv[1]) as client:
Expand Down
4 changes: 1 addition & 3 deletions examples/server/error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from pyrfc import (
ABAPRuntimeError,
)
from pyrfc import ABAPRuntimeError

errorInfo = {
"code": 4,
Expand Down
3 changes: 2 additions & 1 deletion examples/server/server_app_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
# SPDX-License-Identifier: Apache-2.0

from pyrfc import Server
from threading import Thread

from pyrfc import Server


def my_stfc_connection(request_context=None, REQUTEXT=""):
"""Server function my_stfc_connection with the signature of ABAP function module STFC_CONNECTION."""
Expand Down
6 changes: 4 additions & 2 deletions examples/server/server_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#
# SPDX-License-Identifier: Apache-2.0

from backends import BACKEND
import sys
from pyrfc import Server, ExternalRuntimeError

from backends import BACKEND

from pyrfc import ExternalRuntimeError, Server

backend_dest = sys.argv[1]

Expand Down
2 changes: 1 addition & 1 deletion examples/server/tlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import uuid
from contextlib import suppress
from datetime import datetime
from pyrfc import UnitState

from pyrfc import UnitState

# default dbpath
DBPATH = "./examples/server/tlog.log"
Expand Down
5 changes: 1 addition & 4 deletions examples/serverFunctionDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

from pyrfc import (
FunctionDescription,
TypeDescription,
)
from pyrfc import FunctionDescription, TypeDescription

animals = TypeDescription(
"ANIMALS",
Expand Down
5 changes: 1 addition & 4 deletions examples/serverStfcConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

import os

from pyrfc import (
Server,
set_ini_file_directory,
)
from pyrfc import Server, set_ini_file_directory


def my_stfc_connection(
Expand Down
1 change: 1 addition & 0 deletions examples/timeout/timeout_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import sys

from pyrfc import Connection, RFCError

client = Connection(dest=sys.argv[1], config={"timeout": 20})
Expand Down
1 change: 1 addition & 0 deletions examples/timeout/timeout_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import sys

from pyrfc import Connection, RFCError

client = Connection(dest=sys.argv[1], config={"timeout": 5})
Expand Down
43 changes: 21 additions & 22 deletions src/pyrfc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

"""pyrfc package."""

from contextlib import suppress
import importlib.metadata
import os

from contextlib import suppress

__version__ = importlib.metadata.version("pyrfc")
__version_info__ = tuple(__version__.split("."))
Expand All @@ -17,40 +16,40 @@
with suppress(Exception):
os.add_dll_directory(os.path.join(os.environ["SAPNWRFC_HOME"], "lib"))

from pyrfc._exception import ( # noqa F401
RFCError,
RFCLibError,
CommunicationError,
LogonError,
from pyrfc._exception import CommunicationError # noqa F401
from pyrfc._exception import (
ABAPApplicationError,
ABAPRuntimeError,
ExternalAuthorizationError,
ExternalApplicationError,
ExternalAuthorizationError,
ExternalRuntimeError,
LogonError,
RFCError,
RFCLibError,
)

try:
from pyrfc._cyrfc import ( # noqa F401
get_nwrfclib_version,
reload_ini_file,
set_ini_file_directory,
set_cryptolib_path,
set_locale_radix,
language_iso_to_sap,
language_sap_to_iso,
cancel_connection,
from pyrfc._cyrfc import RCStatus # noqa F401
from pyrfc._cyrfc import (
Connection,
ConnectionParameters,
Decimal,
Throughput,
TypeDescription,
FunctionDescription,
RfcFieldType,
RfcParameterDirection,
Server,
Throughput,
TypeDescription,
UnitCallType,
UnitState,
RCStatus,
RfcParameterDirection,
RfcFieldType,
cancel_connection,
get_nwrfclib_version,
language_iso_to_sap,
language_sap_to_iso,
reload_ini_file,
set_cryptolib_path,
set_ini_file_directory,
set_locale_radix,
)
except Exception as ex:
# PyRFC module could not be loaded
Expand Down
9 changes: 5 additions & 4 deletions src/pyrfc/_cyrfc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@

""" The _pyrfc C-extension module """

from libc.stdlib cimport malloc, free
from libc.stdint cimport uintptr_t
from libc.stdlib cimport free, malloc

import socket
from collections.abc import Iterable
from datetime import date, time, datetime
from datetime import date, datetime, time
from decimal import Decimal
from enum import Enum, auto
from locale import localeconv
from os.path import isfile, join
from sys import exc_info, platform
import socket
from threading import Thread, Timer

from pyrfc.csapnwrfc cimport *

from pyrfc._exception import *
from pyrfc._utils import enum_names, enum_values


################################################################################
# Configuration options
################################################################################
Expand Down
1 change: 1 addition & 0 deletions src/pyrfc/_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
""":mod:`pyrfc`-specific exception classes."""

from enum import Enum, auto

from pyrfc._utils import enum_values


Expand Down
3 changes: 2 additions & 1 deletion tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# SPDX-License-Identifier: Apache-2.0

import datetime
from configparser import ConfigParser
import platform
from configparser import ConfigParser

from pyrfc import set_ini_file_directory

COPA = ConfigParser()
Expand Down
5 changes: 2 additions & 3 deletions tests/function_description_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import sys

from pyrfc import Connection

parameter_keys = [
Expand Down Expand Up @@ -90,9 +91,7 @@ def main(func_name):
# from data.func_desc_BAPISDORDER_GETDETAILEDLIST import FUNC_DESC_BAPISDORDER_GETDETAILEDLIST
# from data.func_desc_BS01_SALESORDER_GETDETAIL import FUNC_DESC_BS01_SALESORDER_GETDETAIL

from data.func_desc_STFC_STRUCTURE import ( # noqa: E402 WPS131
FUNC_DESC_STFC_STRUCTURE,
)
from data.func_desc_STFC_STRUCTURE import FUNC_DESC_STFC_STRUCTURE # noqa: E402 WPS131

with Connection(dest="MME") as client:
func_desc = client.get_function_description(func_name)
Expand Down
6 changes: 2 additions & 4 deletions tests/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# SPDX-License-Identifier: Apache-2.0

import os
from pyrfc import (
Server,
set_ini_file_directory,
)

from pyrfc import Server, set_ini_file_directory


# server function
Expand Down
2 changes: 1 addition & 1 deletion tests/stfc-mrfc/test_function_group_mrfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# Some of them are used as well.

import unittest
from pyrfc import Connection

from pyrfc import Connection
from tests.config import PARAMS as params


Expand Down
2 changes: 1 addition & 1 deletion tests/stfc-mrfc/test_function_group_stfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import datetime
import unittest
from pyrfc import Connection

from pyrfc import Connection
from tests.config import PARAMS as params


Expand Down
6 changes: 3 additions & 3 deletions tests/test_client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#
# SPDX-License-Identifier: Apache-2.0

from tests.config import CONFIG_SECTIONS as config_sections

import datetime
from pyrfc import Connection, RFCError

import pytest

from pyrfc import Connection, RFCError
from tests.config import CONFIG_SECTIONS as config_sections


class TestConnection:
def test_config_rstrip_false(self):
Expand Down
Loading

0 comments on commit 68a8c60

Please sign in to comment.