Skip to main content

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 файл:

Metadata

Release files for schedule-kspc 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schedule-kspc 1.0.6
File Size Uploaded
schedule_kspc-1.0.6.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for schedule-kspc 1.0.6
File Interpreter ABI Platform
schedule_kspc-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / schedule_kspc-1.0.6.tar.gz

Download URL schedule_kspc-1.0.6.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c7c85ed4bcca63fa482a81791c34e633c7f9f945a0d1f56f3a0a6f5eb89cf4e6
BLAKE2b-256 checksum
How to use checksums
18ee82a84994916df333563216101ab8c4b722f72b2acc19a72c62d58bd606d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.11 Windows/10

Release files / schedule_kspc-1.0.6-py3-none-any.whl

Download URL schedule_kspc-1.0.6-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
897f1d7ac6cf8823b6b010143c9be836ab433493414e8dba2cab37d568a5af68
BLAKE2b-256 checksum
How to use checksums
e458d42350de259f5e0a541aa443be218f8249e0dfe9e10dc5a5a413a7c9e9a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.11 Windows/10

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page