Compare commits

..

2 Commits
main ... main

Author SHA1 Message Date
Mikhail Zelenyy
e26b8e541b For homework 4 2023-11-04 19:05:45 +03:00
Mikhail Zelenyy
fb45d7291c For homework 3 2023-10-13 22:33:07 +03:00
22 changed files with 225 additions and 432 deletions

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="accountSettings">
<option name="activeRegion" value="us-east-1" />
<option name="recentlyUsedRegions">
<list>
<option value="us-east-1" />
</list>
</option>
</component>
</project>

View File

@ -1,46 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myValues">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="nobr" />
<item index="1" class="java.lang.String" itemvalue="noembed" />
<item index="2" class="java.lang.String" itemvalue="comment" />
<item index="3" class="java.lang.String" itemvalue="noscript" />
<item index="4" class="java.lang.String" itemvalue="embed" />
<item index="5" class="java.lang.String" itemvalue="script" />
<item index="6" class="java.lang.String" itemvalue="write" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E501" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N806" />
<option value="N801" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="dict.name" />
<option value="list.expend" />
<option value="Utils.tinder_api.profile.json" />
<option value="database.db_actions.filter_by" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (memorizer)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (memorizer)" project-jdk-type="Python SDK" />
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,150 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="dd534306-bad2-4a21-9900-301e2372c24e" name="Changes" comment="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="2W26FqrPo9vBvfRQlTjZRBbveHH" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/petr/ProgProjects/memorizer&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;editing.templates&quot;
}
}</component>
<component name="RunManager">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="memorizer" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="dd534306-bad2-4a21-9900-301e2372c24e" name="Changes" comment="" />
<created>1695918229877</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1695918229877</updated>
</task>
<task id="LOCAL-00001" summary="-">
<option name="closed" value="true" />
<created>1695918258831</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1695918258831</updated>
</task>
<task id="LOCAL-00002" summary="pyproject.toml">
<option name="closed" value="true" />
<created>1695920407450</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1695920407450</updated>
</task>
<task id="LOCAL-00003" summary="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html">
<option name="closed" value="true" />
<created>1695928888806</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1695928888806</updated>
</task>
<task id="LOCAL-00004" summary="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html">
<option name="closed" value="true" />
<created>1695929296847</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1695929296847</updated>
</task>
<task id="LOCAL-00005" summary="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html">
<option name="closed" value="true" />
<created>1695929354247</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1695929354247</updated>
</task>
<task id="LOCAL-00006" summary="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html">
<option name="closed" value="true" />
<created>1695929481447</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1695929481447</updated>
</task>
<task id="LOCAL-00007" summary="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html">
<option name="closed" value="true" />
<created>1695929537019</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1695929537019</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="-" />
<MESSAGE value="pyproject.toml" />
<MESSAGE value="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html" />
<option name="LAST_COMMIT_MESSAGE" value="Finis the first home task &#10;https://sciprogcentre.github.io/green-courses/pages/advanced_python/2023/hw/01.html" />
</component>
</project>

View File

@ -1,7 +0,0 @@
Copyright 2023 PETR ANDREEV
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,59 +1,2 @@
The main of the Memorizer / Generator: # advanced-python-homework-2023
1. help you learn english
2. based on your new vocabulary, create texts for you which help you understand something new (you decided the subject)
3. help you create content (your subject, or the Memorizer can offer to you) pr improve self based on your new vocabulary (you can choose a learning rate (amount vocabulary has to be used in your content))
## Creating a Virtual Environment and Installing Dependencies
To set up a virtual environment for your project and install dependencies, follow these steps:
1. **Install Python 3.11:**
Make sure you have Python 3.11 installed on your system. You can download it from the official Python website.
2. **Create a Virtual Environment:**
Open your terminal or command prompt and navigate to your project directory. Then, run the following command to create a virtual environment. Replace `<venv>` with your preferred virtual environment name:
```bash
python3.11 -m venv <venv>
```
3. ** Activate the Virtual Environment:On Windows:**
On Windows:
```bash
.\<venv>\Scripts\activate
```
On macOS and Linux:
```bash
source <venv>/bin/activate
```
Your command prompt should now show the virtual environment name, indicating that it's active.
4. ** Install Dependencies: **
Use pip to install the project's dependencies from the requirements.txt file. Replace <path_to_requirements.txt> with the actual path to your requirements.txt file:
```bash
pip install -r <path_to_requirements.txt>
```
This will install all the necessary packages for your project.
5. ** Deactivate the Virtual Environment: **
This returns you to your system's global Python environment.
Now you have a virtual environment set up for your project with all the required dependencies installed. You can activate it whenever you work on your project to isolate its dependencies from the system-wide Python installation.
## Creating Documentation
1. ** Open 'Controls' directory **
On Linux:
```bash
cd ./memorizer/controls
```
2. ** Run the next command **
On Linux:
```bash
$ sphinx-quickstart
```
3. Follow the instructions of sphinx

View File

@ -1,20 +0,0 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -1,20 +0,0 @@
"""
SCADA System Package
This Python package represents a SCADA (Supervisory Control and Data Acquisition) system, which is designed to monitor and control industrial processes, infrastructure, and equipment. SCADA systems play a crucial role in various industries, such as manufacturing, energy, and utilities.
Key Features of a SCADA System:
- Real-time Data Acquisition: SCADA systems collect data from sensors, devices, and equipment in real-time.
- Remote Monitoring: Operators can remotely monitor and visualize the status and performance of processes.
- Control and Automation: SCADA systems allow for remote control and automation of industrial processes.
- Alarm and Event Management: They provide alerting and event handling capabilities for timely response to issues.
- Historical Data Logging: SCADA systems store historical data for analysis, reporting, and compliance.
- User Authentication and Access Control: Access to the system is secured through user authentication and role-based access control.
- Data Visualization: They offer rich data visualization tools like charts, graphs, and dashboards.
- Integration with PLCs and RTUs: SCADA systems interface with Programmable Logic Controllers (PLCs) and Remote Terminal Units (RTUs).
- Reporting and Analysis: They support data analysis, reporting, and trend analysis for process optimization.
A well-designed SCADA system is crucial for efficient and safe operation in various industrial settings.
For more details on specific functionalities and usage, please refer to the package modules and documentation.
"""

View File

@ -1,28 +0,0 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'memorizer'
copyright = '2023, Petr Andreev'
author = 'Petr Andreev'
release = '0.0.1'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = []
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'alabaster'
html_static_path = ['_static']

82
controls/device.py Normal file
View File

@ -0,0 +1,82 @@
from dataclasses import dataclass
from typing import Optional, Collection, Any
from abc import abstractmethod
class DeviceLifecycleState:
pass # TODO(Homework #3)
class DevaceError(Exception):
pass
class NonReadableTrait(Exception):
pass
class NonWritableTrait(Exception):
pass
@dataclass
class TraitDescriptor:
name: str
info: Optional[str] = None
readable: bool = True
writable: bool = False
@dataclass
class ActionDescriptor:
name: str
arguments: dict[str, type]
info: Optional[str] = None
class Device:
# TODO(Homework #3)
_state = DeviceLifecycleState.INIT
@property
def state(self) -> DeviceLifecycleState:
return self._state
def close(self):
self._state = DeviceLifecycleState.CLOSE
def trait_descriptors(self) -> Collection[TraitDescriptor]:
pass
def action_descriptors(self) -> Collection[ActionDescriptor]:
pass
@abstractmethod
def __getitem__(self, trait_name: str) -> Optional[Any]:
"""Return logical state of trait `trait_name`."""
pass
class SynchronyDevice(Device):
def open(self):
self._state = DeviceLifecycleState.OPEN
@abstractmethod
def execute(self, action_name: str, *args, **kwargs):
"""Execute action `action_name`, using `args` and `kwargs` as action argument."""
pass
@abstractmethod
def read(self, trait_name: str) -> Any:
"""Read physical state of trait `trait_name` from device."""
raise NonReadableTrait
@abstractmethod
def write(self, trait_name: str, value: Any) -> bool:
"""Pass `value` to trait `trait_name` of device."""
raise NonWritableTrait
@abstractmethod
def invalidate(self, trait_name: str):
"""Invalidate logical state of trait `trait_name`"""
pass

View File

@ -1,20 +0,0 @@
.. memorizer documentation master file, created by
sphinx-quickstart on Thu Sep 28 22:30:30 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to memorizer's documentation!
=====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -1,35 +0,0 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

0
equipment/__init__.py Normal file
View File

View File

@ -0,0 +1,8 @@
from turtle import Turtle
from controls.device import SynchronyDevice
class TurtleDevice(SynchronyDevice):
pass # TODO(Homework #3)

View File

@ -0,0 +1,35 @@
import cmd
import threading
from queue import Queue
from equipment.turtle_device import TurtleDevice
class TurtleDeviceThread(threading.Thread):
# TODO(Homework 4)
def __init__(self):
super().__init__()
self.device = TurtleDevice()
self.queue = Queue()
class NoBlockingTurtleShell(cmd.Cmd):
intro = 'Welcome to the turtle shell. Type help or ? to list commands.\n'
prompt = '(turtle) '
file = None
def __init__(self, turtle_thread: TurtleDeviceThread):
pass # TODO(Homework 4)
def do_execute(self, arg):
pass # TODO(Homework 4)
def do_exit(self, arg):
pass # TODO(Homework 4)
if __name__ == '__main__':
turtle_thread = TurtleDeviceThread()
# TODO(Homework 4: Correct start thread)
NoBlockingTurtleShell(turtle_thread).cmdloop()

View File

@ -1,15 +0,0 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.poetry]
name = "Memorizer"
version = "0.0.1"
description = "A utility that will help you learn new English words, mathematical theorems with proofs, etc. It doesn't matter what kind of object you want to learn. You can upload a question and answer, set repetition frequency and response time. The basic idea is to ask you what you have chosen, for the time you have chosen, then show the answer."
authors = ["Petr Andreev <petr96andreev@gmail.com>"]
license = "MIT"
[tool.poetry.dependencies]
python = "^3.11"
[tool.poetry.dev-dependencies]

View File

@ -1,3 +0,0 @@
Sphinx
Pylint
MyPy

View File

@ -0,0 +1,12 @@
from unittest import TestCase
from controls.device import DeviceLifecycleState
class DeviceLifecycleStateTest(TestCase):
def setUp(self) -> None:
pass
def test_enum(self):
self.assertEqual(DeviceLifecycleStateTest["INIT"], DeviceLifecycleStateTest.INIT)

View File

@ -0,0 +1,13 @@
from unittest import TestCase
from equipment.turtle_device import TurtleDevice
class TurtleDeviceTest(TestCase):
def setUp(self) -> None:
self.device = TurtleDevice()
def test_open(self):
self.device.open()
self.device.close()

74
turtle_shell.py Normal file
View File

@ -0,0 +1,74 @@
import cmd, sys
from turtle import *
class TurtleShell(cmd.Cmd):
intro = 'Welcome to the turtle shell. Type help or ? to list commands.\n'
prompt = '(turtle) '
file = None
# ----- basic turtle commands -----
def do_forward(self, arg):
'Move the turtle forward by the specified distance: FORWARD 10'
forward(*parse(arg))
def do_right(self, arg):
'Turn turtle right by given number of degrees: RIGHT 20'
right(*parse(arg))
def do_left(self, arg):
'Turn turtle left by given number of degrees: LEFT 90'
left(*parse(arg))
def do_goto(self, arg):
'Move turtle to an absolute position with changing orientation. GOTO 100 200'
goto(*parse(arg))
def do_home(self, arg):
'Return turtle to the home position: HOME'
home()
def do_circle(self, arg):
'Draw circle with given radius an options extent and steps: CIRCLE 50'
circle(*parse(arg))
def do_position(self, arg):
'Print the current turtle position: POSITION'
print('Current position is %d %d\n' % position())
def do_heading(self, arg):
'Print the current turtle heading in degrees: HEADING'
print('Current heading is %d\n' % (heading(),))
def do_color(self, arg):
'Set the color: COLOR BLUE'
color(arg.lower())
def do_undo(self, arg):
'Undo (repeatedly) the last turtle action(s): UNDO'
def do_reset(self, arg):
'Clear the screen and return turtle to center: RESET'
reset()
def do_bye(self, arg):
'Stop recording, close the turtle window, and exit: BYE'
print('Thank you for using Turtle')
self.close()
bye()
return True
# ----- record and playback -----
def do_record(self, arg):
'Save future commands to filename: RECORD rose.cmd'
self.file = open(arg, 'w')
def do_playback(self, arg):
'Playback commands from a file: PLAYBACK rose.cmd'
self.close()
with open(arg) as f:
self.cmdqueue.extend(f.read().splitlines())
def precmd(self, line):
line = line.lower()
if self.file and 'playback' not in line:
print(line, file=self.file)
return line
def close(self):
if self.file:
self.file.close()
self.file = None
def parse(arg):
'Convert a series of zero or more numbers to an argument tuple'
return tuple(map(int, arg.split()))
if __name__ == '__main__':
TurtleShell().cmdloop()