Skip to content

Commit

Permalink
Lab ISUCT#6 was done.
Browse files Browse the repository at this point in the history
  • Loading branch information
Egorkin-enabled committed Feb 11, 2024
1 parent 54a7df5 commit e070b63
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Python package

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd ./python
pip install -r requirements.txt
- name: Lint with flake8
run: |
cd ./python
flake8 ./
- name: Lint with MyPy
run: |
cd ./python
mypy ./
- name: Test with unittest
run: |
cd ./python
python -m unittest
82 changes: 82 additions & 0 deletions python/lab_4/document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Kozlov Egor 1/278; Variant 11

class Document:
def __init__(self, path: str, docType: str, docSize: int):
if not isinstance(path, str):
raise TypeError("path must be str")

if not isinstance(docType, str):
raise TypeError("docType must be str")

self.__documentPath = path
self.__documentType = docType
self.documentSize = docSize

@property
def documentPath(self) -> str:
return self.__documentPath

@property
def documentType(self) -> str:
return self.__documentType

@property
def documentSize(self) -> int:
return self.__documentSize

@documentSize.setter
def documentSize(self, value) -> None:
if not isinstance(value, int):
raise TypeError("docSize must be int")

if value < 0:
raise ValueError(value)

self.__documentSize = value

def __str__(self) -> str:
return f"Document: '{self.documentPath}', '{self.documentType}', {self.documentSize}"

if __name__ == "__main__":
print("Test 1")
instance = Document("/media/Files/Script.docx", "docx", 32000)

print("Test 2")
try:
Document(32, "docx", 32000)
except Exception as e:
print("Catched:", e)

print("Test 3")
try:
Document("/media/Files/Script.docx", 128, 32000)
except Exception as e:
print("Catched:", e)

print("Test 4")
try:
Document("/media/Files/Script.docx", "docx", "32000")
except Exception as e:
print("Catched:", e)

print("Test 5")
try:
Document("/media/Files/Script.docx", "docx", -10)
except Exception as e:
print("Catched:", e)

print(str(instance))

instance.documentSize = 1600

print(str(instance))

try:
instance.documentSize = -18
except Exception as e:
print("Catched:", e)

print(str(instance))



0 comments on commit e070b63

Please sign in to comment.