repo_full_name
stringlengths
6
93
repo_url
stringlengths
25
112
repo_api_url
stringclasses
28 values
owner
stringclasses
28 values
repo_name
stringclasses
28 values
description
stringclasses
28 values
stars
int64
617
98.8k
forks
int64
31
355
watchers
int64
990
999
license
stringclasses
2 values
default_branch
stringclasses
2 values
repo_created_at
timestamp[s]date
2012-07-24 23:12:50
2025-06-16 08:07:28
repo_updated_at
timestamp[s]date
2026-02-23 15:23:15
2026-05-03 18:52:12
repo_topics
listlengths
0
13
repo_languages
unknown
is_fork
bool
1 class
open_issues
int64
3
104
file_path
stringlengths
3
208
file_name
stringclasses
509 values
file_extension
stringclasses
1 value
file_size_bytes
int64
101
84k
file_url
stringclasses
627 values
file_raw_url
stringclasses
627 values
file_sha
stringclasses
624 values
language
stringclasses
8 values
parsed_at
stringdate
2026-05-04 01:12:36
2026-05-04 19:41:55
text
stringlengths
100
102k
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/bash/bash.py
null
null
null
null
null
null
Python
2026-05-04T02:20:14.729397
""" Bash tool - Execute bash commands """ import os import re import sys import subprocess import tempfile from typing import Dict, Any from agent.tools.base_tool import BaseTool, ToolResult from agent.tools.utils.truncate import truncate_tail, format_size, DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES from common.log import ...
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/browser/browser_service.py
null
null
null
null
null
null
Python
2026-05-04T02:20:14.755907
""" Browser service - Playwright wrapper managing browser lifecycle and page operations. All Playwright calls run on a dedicated background thread so that callers from any worker thread can safely use the service. An idle-timeout mechanism automatically shuts down the browser (and its thread) after a configurable per...
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/browser/browser_tool.py
null
null
null
null
null
null
Python
2026-05-04T02:20:14.772227
""" Browser tool - Control a Chromium browser for web navigation and interaction. Uses Playwright under the hood. Browser instance is lazily started on first use, reused across tool calls within the same session, and cleaned up via close(). """ import json import os from typing import Dict, Any, Optional from agent....
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/memory/memory_get.py
null
null
null
null
null
null
Python
2026-05-04T02:20:15.533072
""" Memory get tool Allows agents to read specific sections from memory files """ from agent.tools.base_tool import BaseTool class MemoryGetTool(BaseTool): """Tool for reading memory file contents""" name: str = "memory_get" description: str = ( "Read specific content from memory files. " ...
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/edit/edit.py
null
null
null
null
null
null
Python
2026-05-04T02:20:15.533802
""" Edit tool - Precise file editing Edit files through exact text replacement """ import os from typing import Dict, Any from agent.tools.base_tool import BaseTool, ToolResult from common.utils import expand_path from agent.tools.utils.diff import ( strip_bom, detect_line_ending, normalize_to_lf, res...
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/memory/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:20:15.534259
""" Memory tools for Agent Provides memory_search and memory_get tools """ from agent.tools.memory.memory_search import MemorySearchTool from agent.tools.memory.memory_get import MemoryGetTool __all__ = ['MemorySearchTool', 'MemoryGetTool']
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/memory/memory_search.py
null
null
null
null
null
null
Python
2026-05-04T02:20:15.534722
""" Memory search tool Allows agents to search their memory using semantic and keyword search """ from typing import Dict, Any, Optional from agent.tools.base_tool import BaseTool class MemorySearchTool(BaseTool): """Tool for searching agent memory""" name: str = "memory_search" description: str = ...
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/env_config/env_config.py
null
null
null
null
null
null
Python
2026-05-04T02:20:15.535498
""" Environment Configuration Tool - Manage API keys and environment variables """ import os import re from typing import Dict, Any from pathlib import Path from agent.tools.base_tool import BaseTool, ToolResult from common.log import logger from common.utils import expand_path # API Key 知识库:常见的环境变量及其描述 API_KEY_REG...
zhayujie/CowAgent
https://github.com/zhayujie/CowAgent
null
null
null
null
43,987
null
null
mit
null
null
null
null
null
null
null
agent/tools/ls/ls.py
null
null
null
null
null
null
Python
2026-05-04T02:20:16.519046
""" Ls tool - List directory contents """ import os from typing import Dict, Any from agent.tools.base_tool import BaseTool, ToolResult from agent.tools.utils.truncate import truncate_head, format_size, DEFAULT_MAX_BYTES from common.utils import expand_path DEFAULT_LIMIT = 500 class Ls(BaseTool): """Tool for ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/image_controller/ImageQt.py
null
null
null
null
null
null
Python
2026-05-04T02:20:18.982573
# # The Python Imaging Library. # $Id$ # # a simple Qt image interface. # # history: # 2006-06-03 fl: created # 2006-06-04 fl: inherit from QImage instead of wrapping it # 2006-06-05 fl: removed toimage helper; move string support to ImageQt # 2013-11-13 fl: add support for Qt5 (aurelien.ballier@cyclonit.com) # # Copyr...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/image_controller/image_connector.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.021704
# ============================================= # =============== 图片处理连接器 =============== # ============================================= from .image_provider import copyImage, saveImage, openImage from .screenshot_controller import ScreenshotController from PySide2.QtCore import QObject, Slot, Signal class ImageCo...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/image_controller/screenshot_controller.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.027634
# ======================================== # =============== 截图控制 =============== # ======================================== from ..image_controller.image_provider import PixmapProvider # 图片提供器 from ..utils.file_finder import findFiles import time from PySide2.QtGui import QGuiApplication, QClipboard, QImage, QPixma...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/image_controller/image_provider.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.029046
# ========================================================== # =============== Python向Qml传输 Pixmap 图像 =============== # ========================================================== import os from uuid import uuid4 # 唯一ID from urllib.parse import unquote from PySide2.QtCore import Qt, QByteArray, QBuffer from PySide2.Qt...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/event_bus/key_mouse/keyboard.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.031612
from pynput import keyboard from PySide2.QtCore import QMutex from time import time from umi_log import logger from ...platform import Platform from ..pubsub_service import PubSubService # 按键转换器 class _KeyTranslator: # 回调函数的 KeyCode 类型 转为键名字符串 @staticmethod def key2name(key): return Platform.getK...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/imports/call_func.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.038301
# ================================================================== # =============== 为插件提供接口,在主线程中调用指定函数 =============== # ================================================================== """ from call_func import CallFunc def func(): print("延时3秒调用!") id = CallFunc.delay(func, 3) # 延时调用 # CallFunc.delayStop(...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/event_bus/pubsub_service.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.039735
# ============================================ # =============== 发布/订阅模式 =============== # ============================================ from PySide2.QtCore import QObject, Slot, Signal, QMutex, QThread, QCoreApplication from umi_log import logger # 发布/订阅 服务类 class _PubSubServiceClass: def __init__(self): ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/event_bus/key_mouse/key_mouse_connector.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.040805
# ======================================================== # =============== 键盘/鼠标连接器,在qml调用 =============== # ======================================================== from PySide2.QtCore import QObject, Slot from .keyboard import HotkeyCtrl class KeyMouseConnector(QObject): # ========================= 【热键】 ===...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/main.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.043154
# Umi-OCR # OCR software, free and offline. 开源、免费的离线OCR软件。 # Website - https://github.com/hiroi-sora/Umi-OCR # Author - hiroi-sora # # You are free to use, modify, and distribute Umi-OCR, but it must include # the original author's copyright statement and the following license statement. # 您可以免费地使用、修改和分发 Umi-OCR ,但必须包含...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/event_bus/pubsub_connector.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.095074
# ======================================================== # =============== 发布/订阅连接器,在qml调用 =============== # ======================================================== from PySide2.QtCore import QObject, Slot from .pubsub_service import PubSubService from umi_log import logger class PubSubConnector(QObject): de...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/imports/plugin_i18n.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.599721
# ========================================================= # =============== 为插件提供简易的i18n翻译API =============== # ========================================================= import os import csv from umi_log import logger LangCode = "" # 设置语言 def setLangCode(langCode): global LangCode LangCode = langCode c...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/mission_doc.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.656808
# =============================================== # =============== 文档 - 任务管理器 =============== # =============================================== # API所有页数page 均为1开始 import fitz # PyMuPDF import time import math from PIL import Image from io import BytesIO from umi_log import logger from .mission import Mission from...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/mission.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.662975
# ============================================== # =============== 任务管理器 基类 =============== # ============================================== from PySide2.QtCore import QMutex, QRunnable from threading import Condition from uuid import uuid4 # 唯一ID import time from umi_log import logger from ..utils.thread_pool impo...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/imports/umi_log.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.668641
""" 日志模块 Python: ========================= from umi_log import logger logger.debug("调试信息") logger.info("普通信息") logger.warning("警告信息") logger.error("错误信息")) logger.critical("严重错误信息") # exc_info 只能在 except 块中开启 logger.error("错误信息", exc_info=True, stack_info=True) # 覆盖 LogRecord 的属性 logger.debug("信息", extra={"cove...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/doc_preview_connector.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.669849
# =============================================== # =============== 文档预览 - 连接器 =============== # =============================================== from PySide2.QtCore import QObject, Slot, Signal from PySide2.QtGui import QPixmap, QImage import fitz # PyMuPDF from umi_log import logger from .simple_mission import Simp...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/mission_ocr.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.678773
# =============================================== # =============== OCR - 任务管理器 =============== # =============================================== """ 一种任务管理器为全局单例,不同标签页要执行同一种任务,要访问对应的任务管理器。 任务管理器中有一个引擎API实例,所有任务均使用该API。 标签页可以向任务管理器提交一组任务队列,其中包含了每一项任务的信息,及总体的参数和回调。 """ import os from umi_log import logger from .missi...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/mission_connector.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.679697
# ===================================================================== # =============== qml与【后端Python任务控制器们】的连接器 =============== # ===================================================================== from PySide2.QtCore import QObject, Slot, Signal # 本模块内定义的任务控制器单例 from .mission_ocr import MissionOCR from umi_log ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/imports/umi_about.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.680948
# Umi-OCR # OCR software, free and offline. 开源、免费的离线OCR软件。 # Website - https://github.com/hiroi-sora/Umi-OCR # Author - hiroi-sora # # You are free to use, modify, and distribute Umi-OCR, but it must include # the original author's copyright statement and the following license statement. # 您可以免费地使用、修改和分发 Umi-OCR ,但必须包含...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/mission_qrcode.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.689991
# ================================================= # =============== 二维码 - 任务管理器 =============== # ================================================= import base64 from PIL import Image, ImageEnhance, ImageFilter from io import BytesIO from .mission import Mission try: import zxingcpp except Exception as e: z...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/mission_queue.py
null
null
null
null
null
null
Python
2026-05-04T02:20:19.713467
# 任务队列类 from uuid import uuid4 from typing import Callable, Any from umi_log import logger class MissionQueue: def __init__( self, msnList: list, # 任务内容列表,每项为一个任务元素 configs: dict = {}, # 任务控制参数 # 回调函数 # 整个队列 即将启动。回调参数(self) onStart: Callable[["MissionQueue"], No...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/mission/simple_mission.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.237988
# ============================================= # =============== 简单任务管理器 =============== # ============================================= from PySide2.QtCore import QMutex from ..utils.thread_pool import threadRun # 异步执行函数 class SimpleMission: def __init__(self, msnTask): self._msnTask = msnTask # 任务函...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_csv.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.259385
# 输出到csv表格文件 import csv from umi_log import logger from .output import Output from .tools import getDataText class OutputCsv(Output): def __init__(self, argd): self.encodings = [ # 保存编码优先级 "ansi", # Windows系统本地编码。在linux和macos下会抛出异常 "ascii", # 纯英 "gbk", # 简中 ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.274472
from .output_txt import OutputTxt from .output_txt_plain import OutputTxtPlain from .output_txt_individual import OutputTxtIndividual from .output_md import OutputMD from .output_jsonl import OutputJsonl from .output_csv import OutputCsv from .output_pdf_layered import OutputPdfLayered from .output_pdf_one_layer import...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/api/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.275712
# =============================================== # =============== OCR 插件接口管理 =============== # =============================================== from umi_log import logger ApiDict = {} AllDict = {} # TODO: 静态插件 # 由插件控制器调用,初始化OCR插件的接口。传入动态插件 def initOcrPlugins(plugins): global ApiDict, AllDict for p in plugi...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.298488
# OCR输出器的基类。按指定的格式,将传入的文本输出到指定地方。 from .tools import getDataText from ...platform import Platform import os class Output: def __init__(self, argd): self.dir = argd["outputDir"] # 输出路径(文件夹) self.fileName = argd["outputFileName"] # 文件名 self.outputPath = f"{self.dir}/{self.fileName}.txt" ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_md.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.311474
# 输出markdown格式 from .output import Output from .tools import getDataText import os class OutputMD(Output): def __init__(self, argd): self.dir = argd["outputDir"] # 输出路径(文件夹) self.fileName = argd["outputFileName"] # 文件名 self.outputPath = f"{self.dir}/{self.fileName}.md" # 输出路径 ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_pdf_one_layer.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.312592
# 单层纯文本 PDF import fitz # PyMuPDF from umi_log import logger from .output_pdf_layered import OutputPdfLayered class OutputPdfOneLayer(OutputPdfLayered): def __init__(self, argd): super().__init__(argd) self.opacity = 1 # 文本不透明 self.outputPath = f"{self.dir}/{self.fileName}.text.pdf" #...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_jsonl.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.327049
# 输出到jsonl文件 from .output import Output import json class OutputJsonl(Output): def __init__(self, argd): self.dir = argd["outputDir"] # 输出路径(文件夹) self.fileName = argd["outputFileName"] # 文件名 self.outputPath = f"{self.dir}/{self.fileName}.jsonl" # 输出路径 self.ignoreBlank = argd["...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_pdf_layered.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.349948
# 双层可搜索 searchable pdf # https://github.com/pymupdf/PyMuPDF/discussions/2299 import os import fitz # PyMuPDF from umi_log import logger from .output import Output class OutputPdfLayered(Output): def __init__(self, argd): self.dir = argd["outputDir"] # 输出路径(文件夹) self.originPath = argd["originPa...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_txt.py
null
null
null
null
null
null
Python
2026-05-04T02:20:20.368261
# 输出到txt文件 from .output import Output from .tools import getDataText class OutputTxt(Output): def __init__(self, argd): self.dir = argd["outputDir"] # 输出路径(文件夹) self.fileName = argd["outputFileName"] # 文件名 self.outputPath = f"{self.dir}/{self.fileName}.txt" # 输出路径 self.ignoreBl...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/ignore_area.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.128878
# 忽略区域 from .tbpu import Tbpu class IgnoreArea(Tbpu): def __init__(self, areaList): self.tbpuName = "忽略区域" self.areaList = areaList def run(self, textBlocks): # 返回是否矩形框 a 包含 b def isInBox(a, b): return ( a[0][0] <= b[0][0] and a[0][...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_multi_para.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.129945
# 排版解析-多栏-自然段 from .tbpu import Tbpu from .parser_tools.line_preprocessing import linePreprocessing # 行预处理 from .parser_tools.gap_tree import GapTree # 间隙树排序算法 from .parser_tools.paragraph_parse import ParagraphParse # 段内分析器 class MultiPara(Tbpu): def __init__(self): self.tbpuName = "排版解析-多栏-自然段" ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/tools.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.131660
# 从data中提取、拼接文本 def getDataText(data): textOut = "" l = len(data) - 1 for i, tb in enumerate(data): textOut += tb["text"] if i < l: textOut += tb["end"] return textOut
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_txt_plain.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.133063
# 纯文本(无格式)txt文件 from .output import Output from .tools import getDataText class OutputTxtPlain(Output): def __init__(self, argd): self.dir = argd["outputDir"] # 输出路径(文件夹) self.fileName = argd["outputFileName"] # 文件名 self.outputPath = f"{self.dir}/{self.fileName}.p.txt" # 输出路径 #...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/output/output_txt_individual.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.173543
# 单独txt文件 import os from .output import Output from .tools import getDataText class OutputTxtIndividual(Output): def __init__(self, argd): super().__init__(argd) # 是否输出到原目录 self.outputSource = argd["outputDirType"] == "source" def openOutputFile(self): pass # 覆盖父类方法 def...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_single_para.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.737874
# 排版解析-单栏-自然段 from .parser_single_line import SingleLine from .parser_tools.line_preprocessing import linePreprocessing # 行预处理 from .parser_tools.paragraph_parse import ParagraphParse # 段内分析器 class SinglePara(SingleLine): def __init__(self): self.tbpuName = "排版解析-单栏-自然段" # 段内分析器对象 get_...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_single_none.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.748008
# 排版解析-单栏-无换行 from .parser_single_line import SingleLine from .parser_tools.paragraph_parse import word_separator # 上下句间隔符 class SingleNone(SingleLine): def __init__(self): self.tbpuName = "排版解析-单栏-无换行" def run(self, textBlocks): textBlocks = super().run(textBlocks) # 找到换行符,更改为间隔符 ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_single_line.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.778866
# 排版解析-单栏-单行 from .tbpu import Tbpu from .parser_tools.line_preprocessing import linePreprocessing # 行预处理 from .parser_tools.paragraph_parse import word_separator # 上下句间隔符 class SingleLine(Tbpu): def __init__(self): self.tbpuName = "排版解析-单栏-单行" # 从文本块列表中找出所有行 def get_lines(self, textBlocks): ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_tools/gap_tree.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.849854
# 【间隙·树·排序算法】 GapTree_Sort_Algorithm # 对OCR结果或PDF提取的文本进行版面分析,按人类阅读顺序进行排序。 # Author: hiroi-sora # https://github.com/hiroi-sora/GapTree_Sort_Algorithm from typing import Callable class GapTree: def __init__(self, get_bbox: Callable): """ :param get_bbox: 函数,传入单个文本块, 返回该文本块左...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.913656
# tbpu : text block processing unit 文本块后处理 from .parser_none import ParserNone from .ignore_area import IgnoreArea from .parser_multi_para import MultiPara from .parser_multi_line import MultiLine from .parser_multi_none import MultiNone from .parser_single_para import SinglePara from .parser_single_line import Singl...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_multi_line.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.980330
# 排版解析-多栏-单行 from .tbpu import Tbpu from .parser_tools.line_preprocessing import linePreprocessing # 行预处理 from .parser_tools.gap_tree import GapTree # 间隙树排序算法 class MultiLine(Tbpu): def __init__(self): self.tbpuName = "排版解析-多栏-单行" # 构建算法对象,指定包围盒的元素位置 self.gtree = GapTree(lambda tb: tb[...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_single_code.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.981120
# 排版解析-单栏-代码段 from .parser_single_line import SingleLine from .parser_tools.line_preprocessing import linePreprocessing # 行预处理 from bisect import bisect_left class SingleCode(SingleLine): def __init__(self): self.tbpuName = "排版解析-单栏-代码段" def merge_line(self, line): # 合并一行 A = line[0] ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_multi_none.py
null
null
null
null
null
null
Python
2026-05-04T02:20:21.988039
# 排版解析-多栏-无换行 from .tbpu import Tbpu from .parser_tools.line_preprocessing import linePreprocessing # 行预处理 from .parser_tools.gap_tree import GapTree # 间隙树排序算法 from .parser_tools.paragraph_parse import word_separator # 上下句间隔符 class MultiNone(Tbpu): def __init__(self): self.tbpuName = "排版解析-多栏-无换行" ...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_none.py
null
null
null
null
null
null
Python
2026-05-04T02:20:22.099890
# 排版解析-不做处理 from .tbpu import Tbpu class ParserNone(Tbpu): def __init__(self): self.tbpuName = "排版解析-不做处理" def run(self, textBlocks): for tb in textBlocks: if "end" not in tb: tb["end"] = "\n" # 默认结尾间隔符为换行 return textBlocks
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_tools/line_preprocessing.py
null
null
null
null
null
null
Python
2026-05-04T02:20:22.326246
# ========================================= # =============== 按行预处理 =============== # ========================================= from statistics import median # 中位数 from math import atan2, cos, sin, sqrt, pi, radians, degrees from umi_log import logger angle_threshold = 3 # 进行一些操作的最小角度阈值 angle_threshold_rad = radia...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/tbpu.py
null
null
null
null
null
null
Python
2026-05-04T02:20:22.327019
# tbpu : text block processing unit # 文块处理器的基类。 # OCR返回的结果中,一项包含文字、包围盒、置信度的元素,称为一个“文块” - text block 。 # 文块不一定是完整的一句话或一个段落。反之,一般是零散的文字。 # 一个OCR结果常由多个文块组成。 # 文块处理器就是:将传入的多个文块进行处理,比如合并、排序、删除文块。 class Tbpu: def __init__(self): self.tbpuName = "文块处理单元-未知" def run(self, textBlocks): """输入:textBlock...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/platform/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:20:22.379204
# 根据当前环境,提供不同平台对象 import sys # 根据当前操作系统选择要导入的模块 _plat = sys.platform if _plat.startswith("win32"): from .win32.win32_api import Api as _Platform elif _plat.startswith("linux"): from .linux.linux_api import Api as _Platform elif _plat.startswith("darwin"): raise ImportError("尚未支持macos系统!") else: raise I...
hiroi-sora/Umi-OCR
https://github.com/hiroi-sora/Umi-OCR
null
null
null
null
43,871
null
null
mit
null
null
null
null
null
null
null
UmiOCR-data/py_src/ocr/tbpu/parser_tools/paragraph_parse.py
null
null
null
null
null
null
Python
2026-05-04T02:20:22.379941
# 段落分析器 # 对已经是一个列区块之内的文本块,判断其段落关系。 from typing import Callable import unicodedata # 传入前句尾字符和后句首字符,返回分隔符 def word_separator(letter1, letter2): # 判断Unicode字符是否属于中文、日文或韩文字符集 def is_cjk(character): cjk_unicode_ranges = [ (0x4E00, 0x9FFF), # 中文 (0x3040, 0x30FF), # 日文 ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/api-render.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.860043
#!/usr/bin/env python3 import os import shutil import textwrap from pathlib import Path import pdoc.render_helpers here = Path(__file__).parent if os.environ.get("DOCS_ARCHIVE", False): edit_url_map = {} else: edit_url_map = { "mitmproxy": "https://github.com/mitmproxy/mitmproxy/blob/main/mitmproxy/"...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/examples.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.871331
#!/usr/bin/env python3 import re from pathlib import Path here = Path(__file__).absolute().parent example_dir = here / ".." / "src" / "examples" / "addons" examples = example_dir.glob("*.py") overview = [] listings = [] for example in examples: code = example.read_text() slug = str(example.with_suffix("").re...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/clirecording/screenplays.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.909273
#!/usr/bin/env python3 from clidirector import CliDirector def record_user_interface(d: CliDirector): tmux = d.start_session(width=120, height=36) window = tmux.attached_window d.start_recording("recordings/mitmproxy_user_interface.cast") d.message( "Welcome to the mitmproxy tutorial. In this...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/build.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.913309
#!/usr/bin/env python3 import shutil import subprocess import sys from pathlib import Path here = Path(__file__).parent for script in sorted((here / "scripts").glob("*.py")): print(f"Generating output for {script.name}...") out = subprocess.check_output( [sys.executable, script.absolute()], cwd=here, ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/filters.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.915495
#!/usr/bin/env python3 from mitmproxy import flowfilter print('<table class="table filtertable"><tbody>') for i in flowfilter.help: print("<tr><th>%s</th><td>%s</td></tr>" % i) print("</tbody></table>")
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/api-events.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.926340
#!/usr/bin/env python3 import contextlib import inspect import textwrap import typing from pathlib import Path from mitmproxy import addonmanager from mitmproxy import hooks from mitmproxy import log from mitmproxy.proxy import layer from mitmproxy.proxy import server_hooks from mitmproxy.proxy.layers import dns from ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/clirecording/clidirector.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.927550
import json import random import subprocess import threading import time from typing import NamedTuple import libtmux class InstructionSpec(NamedTuple): instruction: str time_from: float time_to: float class CliDirector: def __init__(self): self.record_start = None self.pause_betwee...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/options.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.937546
#!/usr/bin/env python3 import asyncio from mitmproxy import options from mitmproxy import optmanager from mitmproxy.tools import console from mitmproxy.tools import dump from mitmproxy.tools import web masters = { "mitmproxy": console.master.ConsoleMaster, "mitmdump": dump.DumpMaster, "mitmweb": web.maste...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
docs/scripts/clirecording/record.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.939287
#!/usr/bin/env python3 import screenplays from clidirector import CliDirector if __name__ == "__main__": director = CliDirector() screenplays.record_user_interface(director) screenplays.record_intercept_requests(director) screenplays.record_modify_requests(director) screenplays.record_replay_reques...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/anatomy.py
null
null
null
null
null
null
Python
2026-05-04T02:20:25.968141
""" Basic skeleton of a mitmproxy addon. Run as follows: mitmproxy -s anatomy.py """ import logging class Counter: def __init__(self): self.num = 0 def request(self, flow): self.num = self.num + 1 logging.info("We've seen %d flows" % self.num) addons = [Counter()]
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/commands-simple.py
null
null
null
null
null
null
Python
2026-05-04T02:20:26.900720
"""Add a custom command to mitmproxy's command prompt.""" import logging from mitmproxy import command class MyAddon: def __init__(self): self.num = 0 @command.command("myaddon.inc") def inc(self) -> None: self.num += 1 logging.info(f"num = {self.num}") addons = [MyAddon()]
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/contentview.py
null
null
null
null
null
null
Python
2026-05-04T02:20:26.901370
from mitmproxy import contentviews class SwapCase(contentviews.Contentview): def prettify(self, data: bytes, metadata: contentviews.Metadata) -> str: return data.swapcase().decode() def render_priority(self, data: bytes, metadata: contentviews.Metadata) -> float: if metadata.content_type and ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/anatomy2.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.031956
"""An addon using the abbreviated scripting syntax.""" def request(flow): flow.request.headers["myheader"] = "value"
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-add-header.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.054431
"""Add an HTTP header to each response.""" class AddHeader: def __init__(self): self.num = 0 def response(self, flow): self.num = self.num + 1 flow.response.headers["count"] = str(self.num) addons = [AddHeader()]
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/contentview-interactive.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.083368
from mitmproxy import contentviews class InteractiveSwapCase(contentviews.InteractiveContentview): def prettify( self, data: bytes, metadata: contentviews.Metadata, ) -> str: return data.swapcase().decode() def reencode( self, prettified: str, metad...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/commands-flows.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.084632
"""Handle flows as command arguments.""" import logging from collections.abc import Sequence from mitmproxy import command from mitmproxy import flow from mitmproxy import http from mitmproxy.log import ALERT class MyAddon: @command.command("myaddon.addheader") def addheader(self, flows: Sequence[flow.Flow]...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/filter-flows.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.176275
""" Use mitmproxy's filter pattern in scripts. """ from __future__ import annotations import logging from mitmproxy import flowfilter from mitmproxy import http from mitmproxy.addonmanager import Loader class Filter: filter: flowfilter.TFilter def configure(self, updated): if "flowfilter" in updat...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/duplicate-modify-replay.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.349685
"""Take incoming HTTP requests and replay them with modified parameters.""" from mitmproxy import ctx def request(flow): # Avoid an infinite loop by not replaying already replayed requests if flow.is_replay == "request": return flow = flow.copy() # Only interactive tools have a view. If we ha...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/dns-simple.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.351114
""" Spoof DNS responses. In this example, we fiddle with IPv6 (AAAA) records: - For example.com, `::1` is returned. (domain is hosted on localhost) - For example.org, an NXDOMAIN error is returned. (domain does not exist) - For all other domains, return a non-error response without any records. (domain exi...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-modify-query-string.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.484633
"""Modify HTTP query parameters.""" from mitmproxy import http def request(flow: http.HTTPFlow) -> None: flow.request.query["mitmproxy"] = "rocks"
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-modify-form.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.518580
"""Modify an HTTP form submission.""" from mitmproxy import http def request(flow: http.HTTPFlow) -> None: if flow.request.urlencoded_form: # If there's already a form, one can just add items to the dict: flow.request.urlencoded_form["mitmproxy"] = "rocks" else: # One can also just pa...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-redirect-requests.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.598068
"""Redirect HTTP requests to another server.""" from mitmproxy import http def request(flow: http.HTTPFlow) -> None: # pretty_host takes the "Host" header of the request into account, # which is useful in transparent mode where we usually only have the IP # otherwise. if flow.request.pretty_host == "...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-reply-from-proxy.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.631220
"""Send a reply from the proxy without sending the request to the remote server.""" from mitmproxy import http def request(flow: http.HTTPFlow) -> None: if flow.request.pretty_url == "http://example.com/path": flow.response = http.Response.make( 200, # (optional) status code b"He...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-stream-modify.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.706267
""" Modify a streamed response. Generally speaking, we recommend *not* to stream messages you need to modify. Modifying streamed responses is tricky and brittle: - If the transfer encoding isn't chunked, you cannot simply change the content length. - If you want to replace all occurrences of "foobar", make sur...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-stream-simple.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.710384
""" Select which responses should be streamed. Enable response streaming for all HTTP flows. This is equivalent to passing `--set stream_large_bodies=1` to mitmproxy. """ def responseheaders(flow): """ Enables streaming for all responses. This is equivalent to passing `--set stream_large_bodies=1` to mit...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/commands-paths.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.790775
"""Handle file paths as command arguments.""" import logging from collections.abc import Sequence from mitmproxy import command from mitmproxy import flow from mitmproxy import http from mitmproxy import types from mitmproxy.log import ALERT class MyAddon: @command.command("myaddon.histogram") def histogram...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/http-trailers.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.791922
""" This script simply prints all received HTTP Trailers. HTTP requests and responses can contain trailing headers which are sent after the body is fully transmitted. Such trailers need to be announced in the initial headers by name, so the receiving endpoint can wait and read them after the body. """ from mitmproxy ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/internet-in-mirror.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.922274
""" Mirror all web pages. Useful if you are living down under. """ from mitmproxy import http def response(flow: http.HTTPFlow) -> None: if flow.response and flow.response.content: flow.response.content = flow.response.content.replace( b"</head>", b"<style>body {transform: scaleX(-1);}</styl...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/io-read-saved-flows.py
null
null
null
null
null
null
Python
2026-05-04T02:20:27.929673
#!/usr/bin/env python """ Read a mitmproxy dump file. """ import pprint import sys from mitmproxy import http from mitmproxy import io from mitmproxy.exceptions import FlowReadException with open(sys.argv[1], "rb") as logfile: freader = io.FlowReader(logfile) pp = pprint.PrettyPrinter(indent=4) try: ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/log-events.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.120649
"""Post messages to mitmproxy's event log.""" import logging from mitmproxy.addonmanager import Loader from mitmproxy.log import ALERT logger = logging.getLogger(__name__) def load(loader: Loader): logger.info("This is some informative text.") logger.warning("This is a warning.") logger.error("This is ...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/nonblocking.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.203321
""" Make events hooks non-blocking using async or @concurrent. """ import asyncio import logging import time from mitmproxy.script import concurrent # Toggle between asyncio and thread-based alternatives. if True: # Hooks can be async, which allows the hook to call async functions and perform async I/O # wit...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/options-configure.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.233059
"""React to configuration changes.""" from typing import Optional from mitmproxy import ctx from mitmproxy import exceptions class AddHeader: def load(self, loader): loader.add_option( name="addheader", typespec=Optional[int], default=None, help="Add a hea...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/shutdown.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.295920
""" A simple way of shutting down the mitmproxy instance to stop everything. Usage: mitmproxy -s shutdown.py and then send a HTTP request to trigger the shutdown: curl --proxy localhost:8080 http://example.com/path """ import logging from mitmproxy import ctx from mitmproxy import http def request(fl...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/options-simple.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.314747
""" Add a new mitmproxy option. Usage: mitmproxy -s options-simple.py --set addheader=true """ from mitmproxy import ctx class AddHeader: def __init__(self): self.num = 0 def load(self, loader): loader.add_option( name="addheader", typespec=bool, def...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/websocket-inject-message.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.358699
""" Inject a WebSocket message into a running connection. This example shows how to inject a WebSocket message into a running connection. """ import asyncio from mitmproxy import ctx from mitmproxy import http # Simple example: Inject a message as a response to an event def websocket_message(flow: http.HTTPFlow):...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/tcp-simple.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.359952
""" Process individual messages from a TCP connection. This script replaces full occurrences of "foo" with "bar" and prints various details for each message. Please note that TCP is stream-based and *not* message-based. mitmproxy splits stream contents into "messages" as they are received by socket.recv(). This is pre...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/websocket-simple.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.506482
"""Process individual messages from a WebSocket connection.""" import logging import re from mitmproxy import http def websocket_message(flow: http.HTTPFlow): assert flow.websocket is not None # make type checker happy # get the latest message message = flow.websocket.messages[-1] # was the messag...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/addons/wsgi-flask-app.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.564344
""" Host a WSGI app in mitmproxy. This example shows how to graft a WSGI app onto mitmproxy. In this instance, we're using the Flask framework (http://flask.pocoo.org/) to expose a single simplest-possible page. """ from flask import Flask from mitmproxy.addons import asgiapp app = Flask("proxapp") @app.route("/"...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/contrib/all_markers.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.637758
from mitmproxy import command from mitmproxy import ctx from mitmproxy.utils import emoji @command.command("all.markers") def all_markers(): "Create a new flow showing all marker values" for marker in emoji.emoji: ctx.master.commands.call( "view.flows.create", "get", f"https://example.com/...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/contrib/block_dns_over_https.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.730500
""" This module is for blocking DNS over HTTPS requests. It loads a blocklist of IPs and hostnames that are known to serve DNS over HTTPS requests. It also uses headers, query params, and paths to detect DoH (and block it) """ import logging # known DoH providers' hostnames and IP addresses to block default_blocklis...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/contrib/change_upstream_proxy.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.813094
from mitmproxy import http from mitmproxy.connection import Server from mitmproxy.net.server_spec import ServerSpec # This scripts demonstrates how mitmproxy can switch to a second/different upstream proxy # in upstream proxy mode. # # Usage: mitmdump # -s change_upstream_proxy.py # --mode upstream:http://default-...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/contrib/check_ssl_pinning.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.868154
import ipaddress import time import OpenSSL import mitmproxy from mitmproxy import ctx from mitmproxy.certs import Cert # Certificate for client connection is generated in dummy_cert() in certs.py. Monkeypatching # the function to generate test cases for SSL Pinning. def monkey_dummy_cert(privkey, cacert, commonna...
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy
null
null
null
null
43,374
null
null
mit
null
null
null
null
null
null
null
examples/contrib/custom_next_layer.py
null
null
null
null
null
null
Python
2026-05-04T02:20:28.868803
""" This addon demonstrates how to override next_layer to modify the protocol in use. In this example, we are forcing connections to example.com:443 to instead go as plaintext to example.com:80. Example usage: - mitmdump -s custom_next_layer.py - curl -x localhost:8080 -k https://example.com """ import loggi...