# Path: vise/constants.py
# DOWNLOADS_URL = 'vise:downloads'
# WELCOME_URL = 'vise:welcome'
# STATUS_BAR_HEIGHT = 24
# FOLLOW_LINK_KEY_MAP = {getattr(Qt.Key, 'Key_' + x.upper()): x for x in string.ascii_lowercase + string.digits}
# VISE_SCHEME = 'vise'
# def _get_cache_dir():
# def _get_config_dir():
# def get_windows_username():
# def local_socket_address():
# 
# Path: vise/resources.py
# @lru_cache(maxsize=512)
# def get_icon(name):
#     if not name.startswith('images/'):
#         name = 'images/' + name
#     return QIcon(get_data_as_path(name))
# 
# Path: vise/settings.py
# def to_json(obj):
# def from_json(obj):
#     def __init__(self, name):
#     def conn(self):
#     def get(self, name, default=None):
#     def set(self, name, val):
#     def __getitem__(self, name):
#     def __setitem__(self, name, val):
#     def __delitem__(self, name):
#     def buffer_commits(self):
#     def buffer_commits(self, val):
#     def __enter__(self):
#     def __exit__(self, *args):
# def safe_makedirs(path):
# def create_script(
#     name, src, world=QWebEngineScript.ScriptWorldId.ApplicationWorld, injection_point=QWebEngineScript.InjectionPoint.DocumentCreation, on_subframes=True
# ):
# def client_script():
# def insert_scripts(profile, *scripts):
# def get_spell_langs():
# def create_profile(parent=None, private=False):
# def profile():
# def do_delete_profile(profile):
# def delete_profile():
# def quickmarks():
# class DynamicPrefs:
# TITLE_TOKEN = None
#     TITLE_TOKEN = hexlify(os.urandom(32)).decode('ascii')


import os
import re
import shutil
import string
import sys
        import fcntl
        import runpy
from functools import lru_cache
from gettext import gettext as _
from xml.sax.saxutils import escape
from PyQt6.QtCore import (QBuffer, QByteArray, QMimeDatabase, QObject, Qt,
                          QTimer, QUrl, pyqtSignal, QIODeviceBase)
from PyQt6.QtGui import (QCursor, QDesktopServices, QFontMetrics, QIcon,
                         QPainter, QPixmap, QStaticText, QTextOption)
from PyQt6.QtWidgets import (QApplication, QDialog, QDialogButtonBox,
                             QFileDialog)
from .constants import cache_dir, str_version
from .resources import get_icon
from .settings import gprefs
    from IPython.terminal.embed import InteractiveShellEmbed
    from IPython.terminal.prompts import Prompts, Token
    from traitlets.config.loader import Config
    from PyQt6.QtWidgets import QApplication, QLabel
    ans = QStaticText(text)
    to = ans.textOption()
    to.setWrapMode(QTextOption.WrapMode.NoWrap)
    ans.setTextOption(to)
    ans.setTextFormat(Qt.TextFormat.RichText)
    return ans


class BusyCursor:

    def __enter__(self):
        QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))

    def __exit__(self, *args):
        QApplication.restoreOverrideCursor()


def choose_files(name, parent=None, title=None, filters=(), all_files=False, select_only_single_file=False, default_dir='~'):
    '''
    Ask user to choose a bunch of files.
    :param name: Unique dialog name used to store the opened directory
    :param title: Title to show in dialogs titlebar
    :param filters: list of allowable extensions. Each element of the list
                    must be a 2-tuple with first element a string describing
                    the type of files to be filtered and second element a
                    string of space separated file extensions.
    :param all_files: If True add All files to filters.
    :param select_only_single_file: If True only one file can be selected
    :param default_dir: The initial directory to show
    '''

# Path: vise/constants.py
# DOWNLOADS_URL = 'vise:downloads'
# WELCOME_URL = 'vise:welcome'
# STATUS_BAR_HEIGHT = 24
# FOLLOW_LINK_KEY_MAP = {getattr(Qt.Key, 'Key_' + x.upper()): x for x in string.ascii_lowercase + string.digits}
# VISE_SCHEME = 'vise'
# def _get_cache_dir():
# def _get_config_dir():
# def get_windows_username():
# def local_socket_address():
# 
# Path: vise/resources.py
# @lru_cache(maxsize=512)
# def get_icon(name):
#     if not name.startswith('images/'):
#         name = 'images/' + name
#     return QIcon(get_data_as_path(name))
# 
# Path: vise/settings.py
# def to_json(obj):
# def from_json(obj):
#     def __init__(self, name):
#     def conn(self):
#     def get(self, name, default=None):
#     def set(self, name, val):
#     def __getitem__(self, name):
#     def __setitem__(self, name, val):
#     def __delitem__(self, name):
#     def buffer_commits(self):
#     def buffer_commits(self, val):
#     def __enter__(self):
#     def __exit__(self, *args):
# def safe_makedirs(path):
# def create_script(
#     name, src, world=QWebEngineScript.ScriptWorldId.ApplicationWorld, injection_point=QWebEngineScript.InjectionPoint.DocumentCreation, on_subframes=True
# ):
# def client_script():
# def insert_scripts(profile, *scripts):
# def get_spell_langs():
# def create_profile(parent=None, private=False):
# def profile():
# def do_delete_profile(profile):
# def delete_profile():
# def quickmarks():
# class DynamicPrefs:
# TITLE_TOKEN = None
#     TITLE_TOKEN = hexlify(os.urandom(32)).decode('ascii')


# Path: vise/utils.py
import os
import re
import shutil
import string
import sys
        import fcntl
        import runpy
from functools import lru_cache
from gettext import gettext as _
from xml.sax.saxutils import escape
from PyQt6.QtCore import (QBuffer, QByteArray, QMimeDatabase, QObject, Qt,
                          QTimer, QUrl, pyqtSignal, QIODeviceBase)
from PyQt6.QtGui import (QCursor, QDesktopServices, QFontMetrics, QIcon,
                         QPainter, QPixmap, QStaticText, QTextOption)
from PyQt6.QtWidgets import (QApplication, QDialog, QDialogButtonBox,
                             QFileDialog)
from .constants import cache_dir, str_version
from .resources import get_icon
from .settings import gprefs
    from IPython.terminal.embed import InteractiveShellEmbed
    from IPython.terminal.prompts import Prompts, Token
    from traitlets.config.loader import Config
    from PyQt6.QtWidgets import QApplication, QLabel

    ans = QStaticText(text)
    to = ans.textOption()
    to.setWrapMode(QTextOption.WrapMode.NoWrap)
    ans.setTextOption(to)
    ans.setTextFormat(Qt.TextFormat.RichText)
    return ans


class BusyCursor:

    def __enter__(self):
        QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))

    def __exit__(self, *args):
        QApplication.restoreOverrideCursor()


def choose_files(name, parent=None, title=None, filters=(), all_files=False, select_only_single_file=False, default_dir='~'):
    '''
    Ask user to choose a bunch of files.
    :param name: Unique dialog name used to store the opened directory
    :param title: Title to show in dialogs titlebar
    :param filters: list of allowable extensions. Each element of the list
                    must be a 2-tuple with first element a string describing
                    the type of files to be filtered and second element a
                    string of space separated file extensions.
    :param all_files: If True add All files to filters.
    :param select_only_single_file: If True only one file can be selected
    :param default_dir: The initial directory to show
    '''

    initial_dir = os.path.abspath(gprefs.get('choose-files-initial-dir-' + name, os.path.expanduser(default_dir)))