Skip to content

Commit

Permalink
Rename models.py to config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vsivanandharao_expedia committed Jan 2, 2025
1 parent 818b5a3 commit 092eb73
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions pyarchitecture/cpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from typing import Dict

from pyarchitecture import models
from pyarchitecture import config
from pyarchitecture.cpu import main

LOGGER = logging.getLogger(__name__)
Expand All @@ -18,7 +18,7 @@ def _get_cpu_lib(user_input: str | os.PathLike) -> str:
user_input
or os.environ.get("cpu_lib")
or os.environ.get("CPU_LIB")
or models.default_cpu_lib()[models.OPERATING_SYSTEM]
or config.default_cpu_lib()[config.OPERATING_SYSTEM]
)


Expand Down
10 changes: 5 additions & 5 deletions pyarchitecture/cpu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import subprocess

from pyarchitecture.cpu import models
from pyarchitecture.cpu import config

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -36,11 +36,11 @@ def get_name(cpu_lib: str | os.PathLike) -> str | None:
Returns the processor information as a string.
"""
os_map = {
models.OperatingSystem.darwin: _darwin,
models.OperatingSystem.linux: _linux,
models.OperatingSystem.windows: _windows,
config.OperatingSystem.darwin: _darwin,
config.OperatingSystem.linux: _linux,
config.OperatingSystem.windows: _windows,
}
try:
return os_map[models.OPERATING_SYSTEM](cpu_lib)
return os_map[config.OPERATING_SYSTEM](cpu_lib)
except Exception as error:
LOGGER.error(error)
12 changes: 6 additions & 6 deletions pyarchitecture/disks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from typing import Dict, List

from pyarchitecture import models
from pyarchitecture import config
from pyarchitecture.disks import linux, macOS, windows

LOGGER = logging.getLogger(__name__)
Expand All @@ -18,7 +18,7 @@ def _get_disk_lib(user_input: str | os.PathLike) -> str:
user_input
or os.environ.get("disk_lib")
or os.environ.get("DISK_LIB")
or models.default_disk_lib()[models.OPERATING_SYSTEM]
or config.default_disk_lib()[config.OPERATING_SYSTEM]
)


Expand All @@ -35,9 +35,9 @@ def get_all_disks(disk_lib: str | os.PathLike = None) -> List[Dict[str, str]]:
library_path = _get_disk_lib(disk_lib)
if os.path.isfile(library_path):
os_map = {
models.OperatingSystem.darwin: macOS.drive_info,
models.OperatingSystem.linux: linux.drive_info,
models.OperatingSystem.windows: windows.drive_info,
config.OperatingSystem.darwin: macOS.drive_info,
config.OperatingSystem.linux: linux.drive_info,
config.OperatingSystem.windows: windows.drive_info,
}
return os_map[models.OperatingSystem(models.OPERATING_SYSTEM)](library_path)
return os_map[config.OperatingSystem(config.OPERATING_SYSTEM)](library_path)
LOGGER.error(f"Disk library {library_path!r} doesn't exist")
4 changes: 2 additions & 2 deletions pyarchitecture/gpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from typing import Dict, List

from pyarchitecture import models
from pyarchitecture import config
from pyarchitecture.gpu import main

LOGGER = logging.getLogger(__name__)
Expand All @@ -18,7 +18,7 @@ def _get_gpu_lib(user_input: str | os.PathLike) -> str:
user_input
or os.environ.get("gpu_lib")
or os.environ.get("GPU_LIB")
or models.default_gpu_lib()[models.OPERATING_SYSTEM]
or config.default_gpu_lib()[config.OPERATING_SYSTEM]
)


Expand Down
4 changes: 2 additions & 2 deletions pyarchitecture/gpu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess
from typing import Dict, List, Optional

from pyarchitecture import models
from pyarchitecture import config

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -119,6 +119,6 @@ def get_names(gpu_lib: str | os.PathLike) -> List[Dict[str, str]]:
"""Get list of GPU model and vendor information based on the operating system."""
fn_map = dict(linux=_linux, darwin=_darwin, windows=_windows)
try:
return fn_map[models.OPERATING_SYSTEM](gpu_lib)
return fn_map[config.OPERATING_SYSTEM](gpu_lib)
except (subprocess.SubprocessError, FileNotFoundError) as error:
LOGGER.debug(error)
12 changes: 6 additions & 6 deletions pyarchitecture/memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from typing import Dict

from pyarchitecture import models, squire
from pyarchitecture import config, squire
from pyarchitecture.memory import linux, macOS, windows

LOGGER = logging.getLogger(__name__)
Expand All @@ -18,7 +18,7 @@ def _get_mem_lib(user_input: str | os.PathLike) -> str:
user_input
or os.environ.get("mem_lib")
or os.environ.get("MEM_LIB")
or models.default_mem_lib()[models.OPERATING_SYSTEM]
or config.default_mem_lib()[config.OPERATING_SYSTEM]
or __file__ # placeholder for windows
)

Expand All @@ -37,13 +37,13 @@ def get_memory_info(
Returns the memory information as key-value pairs.
"""
os_map = {
models.OperatingSystem.darwin: macOS.get_memory_info,
models.OperatingSystem.linux: linux.get_memory_info,
models.OperatingSystem.windows: windows.get_memory_info,
config.OperatingSystem.darwin: macOS.get_memory_info,
config.OperatingSystem.linux: linux.get_memory_info,
config.OperatingSystem.windows: windows.get_memory_info,
}
library_path = _get_mem_lib(mem_lib)
if os.path.isfile(library_path):
raw_info = os_map[models.OPERATING_SYSTEM](library_path)
raw_info = os_map[config.OPERATING_SYSTEM](library_path)
if humanize:
return {k: squire.size_converter(v) for k, v in raw_info.items()}
return raw_info
Expand Down
8 changes: 4 additions & 4 deletions pyarchitecture/squire.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def convert_to_bytes(size_str: str) -> int:
# Find the last character, which should indicate the unit (B, K, M, G, T, P, E)
if size_str[-1] in units:
# Extract the numeric value and unit
numeric_part = size_str[
:-1
].strip() # everything except the last character (unit)
unit_part = size_str[-1] # the last character (unit)
# everything except the last character (unit)
numeric_part = size_str[:-1].strip()
# the last character (unit)
unit_part = size_str[-1]

# Ensure the numeric part is a valid number
try:
Expand Down

0 comments on commit 092eb73

Please sign in to comment.