Skip to main content

Automatic schedule for Kursk State Polytechnic College (KSPC)

Project description

schedule-kspc

Python библиотека, реализует автоматизированное расписание для Курского Государственного Политехнического Колледжа (КГПК). KSPS - Kursk State Polytechnic College.

  • Установка последней версии модуля
pip install schedule-kspc

📂 DirManager

Упрощенная работа с файлами и директориями:

import os
from schedule_kspc.DirManager import Tree, Node

if __name__ == '__main__':
    # Create root node/tree
    root_node = Node(name='root', path=os.getcwd())
    dir_manger = Tree(root_node=root_node)

    # Add node/child
    dir_manger.add_node(root=root_node, name='child-1')
    dir_manger.root_node.children[0].add_child(name='child-1-1')
    
    # Add node/child
    dir_manger.add_node(root=root_node, name='child-2')
    dir_manger.root_node.children[1].add_child(name='child-2-1')
    
    # Create folders
    dir_manger.make_folders(node=root_node)
    
    print(dir_manger)
  • Файловая структура:

root
├── child-1
│   └── child-1-1
└── child-2
    └── child-2-1

Поиск релевантных файлов из выбранного каталога

  • Выявление паттерна даты и упорядочивание по хронологической близости
import os
from random import randint
from datetime import datetime
from schedule_kspc.Store import DATETIME_PATTERN
from schedule_kspc.DirManager import Tree, Node, get_relevant_files

# Create file (random filename by datetime)
def create_file(path: str) -> None:

    year, month, day = (
        randint(2000, 2024),
        randint(1, 12),
        randint(1, 28)
    )

    hour, minute, second = (
        randint(0, 23),
        randint(0, 59),
        randint(0, 59)
    )

    random_date: datetime = datetime(year, month, day, hour, minute, second)
    filename: str = random_date.strftime(DATETIME_PATTERN)
    file = open(f'{path}\\{filename}_schedule.txt', mode='w')
    file.close()

# Create directory tree
def create_test_directory_tree() -> Tree:
    root_node = Node(name='root', path=os.getcwd())
    dir_manger = Tree(root_node=root_node)
    dir_manger.make_folders(node=root_node)
    return dir_manger


if __name__ == '__main__':
    # Directory tree
    tree = create_test_directory_tree()

    # Test files
    create_file(path=tree.root_node.path)
    create_file(path=tree.root_node.path)
    create_file(path=tree.root_node.path)
    create_file(path=tree.root_node.path)

    # Get all files in directory
    print(tree.get_files(tree.root_node))

    # Get relevant files
    print(get_relevant_files(dir_tree=tree, dir_node=tree.root_node))
  • Файловая структура:

  root:
  ├── 03.08.2012_10.07.20_schedule.txt
  ├── 13.07.2011_21.30.13_schedule.txt
  ├── 16.04.2023_13.20.12_schedule.txt
  └── 17.11.2006_05.21.10_schedule.txt
  • Результат (Get all files in directory):

  ['03.08.2012_10.07.20_schedule.txt', '13.07.2011_21.30.13_schedule.txt', '16.04.2023_13.20.12_schedule.txt', '17.11.2006_05.21.10_schedule.txt']
  • Результат (Get relevant files):

  {'root': ['16.04.2023_13.20.12_schedule.txt', '03.08.2012_10.07.20_schedule.txt', '13.07.2011_21.30.13_schedule.txt', '17.11.2006_05.21.10_schedule.txt']}

🌐 WebRequests

Упрощенная работа с асинхронными http запросами

  • Поиск паттерна ссылки на html странице:
from schedule_kspc import Store
from schedule_kspc import WebRequests


@WebRequests.http_request
async def get_files():
    files: list = await WebRequests.http_find_html_pattern(url=Store.URL["site"], pattern=Store.URL_FILE_PATTERN)
    print(files)

if __name__ == "__main__":
    get_files()
  • Скачивание файлов по ссылке с указанием директории и названия файла (Пример)
from os import getcwd
from schedule_kspc import Store
from schedule_kspc import WebRequests


current_path: str = getcwd()


@WebRequests.http_request
async def download_files():
    files: list = await WebRequests.http_find_html_pattern(url=Store.URL["site"], pattern=Store.URL_FILE_PATTERN)

    for file in files:
        await WebRequests.http_download_file(url=Store.URL['file'] + file[0], folder=current_path, filename=file[1])


if __name__ == "__main__":
    download_files()

📅 ExcelParser

Автоматизированное чтение excel расписания

from schedule_kspc import ExcelParser
from schedule_kspc.Store import WEEKDAYS, LESSONS, Lesson

if __name__ == '__main__':
    # Excel parser
    xl_parser = ExcelParser(filename='example.xlsx')

    # Parse schedule of sheetnames
    schedule: dict = xl_parser.parse_schedule_sheetnames()

    # Parse schedule of teachers
    schedule_teachers: dict = xl_parser.parse_schedule_teachers()

    ...

📝 JsonAdapter

Автоматизированная запись данных в json файл

from schedule_kspc import JsonAdapter

if __name__ == '__main__':
    # Json adapter
    json_adapter = JsonAdapter(filename='file.json')

    # Json adapter / create file & write data
    json_adapter.write(
        data={'example': [1, 2, 3, 4, 5], 'example-2': 'string', 'example-3': dict(example='string')},
        indent=4, ensure_ascii=False
    )
  • Результат:

  file.json:
  {
      "example": [1, 2, 3, 4, 5],
      "example-2": "string",
      "example-3": {
          "example": "string"
      }
  }

⚡ LoadSchedule

  • Загрузка расписания, парсинг excel документа, сериализация в json файл:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schedule_kspc-1.0.6.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

schedule_kspc-1.0.6-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file schedule_kspc-1.0.6.tar.gz.

File metadata

  • Download URL: schedule_kspc-1.0.6.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for schedule_kspc-1.0.6.tar.gz
Algorithm Hash digest
SHA256 c7c85ed4bcca63fa482a81791c34e633c7f9f945a0d1f56f3a0a6f5eb89cf4e6
MD5 01e66c5ca27935691779377dda68d8fb
BLAKE2b-256 18ee82a84994916df333563216101ab8c4b722f72b2acc19a72c62d58bd606d3

See more details on using hashes here.

File details

Details for the file schedule_kspc-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: schedule_kspc-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for schedule_kspc-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 897f1d7ac6cf8823b6b010143c9be836ab433493414e8dba2cab37d568a5af68
MD5 b04a586e00bbb710e781fd5a9fe0db2c
BLAKE2b-256 e458d42350de259f5e0a541aa443be218f8249e0dfe9e10dc5a5a413a7c9e9a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page