forked from ISUCT/Informatics_2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54a7df5
commit e070b63
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
|
||
|
||
|