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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | rules/apps.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.005990 | from django.apps import AppConfig
class RulesConfig(AppConfig):
name = "rules"
default = True
class AutodiscoverRulesConfig(RulesConfig):
default = False
def ready(self):
from django.utils.module_loading import autodiscover_modules
autodiscover_modules("rules")
|
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | rules/contrib/rest_framework.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.007506 | from django.core.exceptions import ImproperlyConfigured, PermissionDenied
class AutoPermissionViewSetMixin:
"""
Enforces object-level permissions in ``rest_framework.viewsets.ViewSet``,
deriving the permission type from the particular action to be performed..
As with ``rules.contrib.views.AutoPermiss... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | rules/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.037242 | from .permissions import add_perm, has_perm, perm_exists, remove_perm, set_perm # noqa
from .predicates import ( # noqa
Predicate,
always_allow,
always_deny,
always_false,
always_true,
is_active,
is_authenticated,
is_group_member,
is_staff,
is_superuser,
predicate,
)
from .... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/manage.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.620670 | #!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testapp.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
|
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testapp/models.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.644579 | from __future__ import absolute_import
from django.conf import settings
from django.db import models
import rules
from rules.contrib.models import RulesModel
class Book(models.Model):
isbn = models.CharField(max_length=50, unique=True)
title = models.CharField(max_length=100)
author = models.ForeignKey(... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | rules/templatetags/rules.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.651258 | from django import template
from ..rulesets import default_rules
register = template.Library()
@register.simple_tag
def test_rule(name, obj=None, target=None):
return default_rules.test_rule(name, obj, target)
@register.simple_tag
def has_perm(perm, user, obj=None):
if not hasattr(user, "has_perm"): # pr... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | setup.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.652378 | #!/usr/bin/env python
from os.path import dirname, join
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from rules import VERSION
def get_version(version):
"""
Returns a PEP 386-compliant version number from ``version``.
"""
assert len(version) == 5
... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testapp/admin.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.689197 | from __future__ import absolute_import
from django.contrib import admin
from rules.contrib.admin import ObjectPermissionsModelAdmin
from .models import Book
class BookAdmin(ObjectPermissionsModelAdmin):
pass
admin.site.register(Book, BookAdmin)
|
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testapp/rules.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:53.744598 | from __future__ import absolute_import
import rules
# Predicates
@rules.predicate
def is_book_author(user, book):
if not book:
return False
return book.author == user
@rules.predicate
def is_boss(user):
return user.is_superuser
is_editor = rules.is_group_member("editors")
# Rules
rules.add... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:54.800485 | from django.contrib.auth.models import Group, User
import testapp.rules # noqa .imported to register rules
from testapp.models import Book
ISBN = "978-1-4302-1936-1"
class TestData:
@classmethod
def setUpTestData(cls):
adrian = User.objects.create_user(
"adrian", password="secr3t", is_s... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/test_models.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:54.801760 | from __future__ import absolute_import
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
import rules
class RulesModelTests(TestCase):
def test_preprocess(self):
self.assertTrue(rules.perm_exists("testapp.add_testmodel"))
self.assertTrue(rules.perm_exists("... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/test_admin.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:54.802928 | from django.test import TestCase
from django.urls import reverse
from . import TestData
class ModelAdminTests(TestData, TestCase):
def test_change_book(self):
# adrian can change his book as its author
self.assertTrue(self.client.login(username="adrian", password="secr3t"))
response = sel... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testapp/urls.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:54.804592 | from django.contrib import admin
from django.urls import re_path
from .views import (
BookCreateView,
BookDeleteView,
BookUpdateErrorView,
BookUpdateView,
ViewThatRaises,
ViewWithPermissionList,
change_book,
delete_book,
view_that_raises,
view_with_object,
view_with_permissi... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testapp/settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:54.805707 | from os.path import abspath, dirname
BASE_DIR = dirname(dirname(abspath(__file__)))
DEBUG = True
ADMINS = [
("test@example.com", "Administrator"),
]
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
},
}
INSTALLED_APPS = [
"django.contrib.admin",... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testapp/views.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:54.814610 | from __future__ import absolute_import
from django.http import HttpResponse
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from rules.contrib.views import (
LoginRequiredMixin,
PermissionRequiredMixin,
objectgetter,
permission_required,
)
from .models import Book
class Boo... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/test_templatetags.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:55.411310 | from django.contrib.auth.models import User
from django.template import Context, Template
from django.test import TestCase
from testapp.models import Book
from . import ISBN, TestData
class TemplateTagTests(TestData, TestCase):
tpl_format = """{{% spaceless %}}
{{% load rules %}}
{{% {tag} "{nam... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/test_rest_framework.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:55.757161 | from __future__ import absolute_import
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.serializers import ModelSer... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/test_predicates.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:55.841057 | from django.contrib.auth.models import User
from django.test import TestCase
from rules.predicates import (
is_active,
is_authenticated,
is_group_member,
is_staff,
is_superuser,
)
from . import TestData
class SwappedUser(object):
pass
class PredicateTests(TestData, TestCase):
def test_... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/test_rulesets.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:55.895508 | from unittest import TestCase
from rules.predicates import always_false, always_true
from rules.rulesets import (
RuleSet,
add_rule,
default_rules,
remove_rule,
rule_exists,
set_rule,
test_rule,
)
class RulesetTests(TestCase):
@staticmethod
def reset_ruleset(ruleset):
for ... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/test_predicates.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:55.903558 | import functools
from unittest import TestCase
from rules.predicates import (
NO_VALUE,
Predicate,
always_allow,
always_deny,
always_false,
always_true,
predicate,
)
class PredicateKwonlyTests(TestCase):
def test_predicate_kwargonly(self):
def p(foo, *, bar):
retur... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/test_permissions.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:55.933303 | from unittest import TestCase
from rules.permissions import (
ObjectPermissionBackend,
add_perm,
has_perm,
perm_exists,
permissions,
remove_perm,
set_perm,
)
from rules.predicates import always_false, always_true
class PermissionsTests(TestCase):
@staticmethod
def reset_ruleset(ru... |
dfunckt/django-rules | https://github.com/dfunckt/django-rules | null | null | null | null | 1,974 | null | null | mit | null | null | null | null | null | null | null | tests/testsuite/contrib/test_views.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:56.691821 | from __future__ import absolute_import
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.http import Http404, HttpRequest
from django.test import RequestFactory, TestCase
from django.urls import reverse
from django.utils.encoding ... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/model.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:58.925560 | #! /usr/bin/env python
import os
import threading
from abc import abstractmethod
import calendar
import datetime
import inspect
import copy
import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(script_dir, 'data')
class Serializable(object):
'''
Helper class for seriali... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/controller.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:58.936712 | #! /usr/bin/env python3
logo = r'''
_ _ _ _
/\/\ ___ _ __ | |_ __ _| (_)___| |_
/ \ / _ \ '_ \| __/ _` | | / __| __|
/ /\/\ \ __/ | | | || (_| | | \__ \ |_
\/ \/\___|_| |_|\__\__,_|_|_|___/\__|
'''
import sys
import os
if (sys.version_inf... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:58.940361 | from .adder import AdderNode
from .base import BaseNode
from .base_words import BaseWordsNode
from .case import CaseNode
from .substitution import SubstitutionNode
from .main import MainWindow, center_window, word_count_to_string
from . import const
from . import scrollable_frame |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/adder.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:58.965559 | import tkinter as Tk
from functools import partial
import datetime
import tkinter.messagebox
import locale
from .base_words import BaseWordsNode, center_window
from .const import NUMBER_LIST, DATE_FORMATS, SPECIAL_CHARACTERS
from .. import model
class AdderNode(BaseWordsNode):
'''Append and Prepend nodes. Inheri... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/base_words.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:58.995289 | import tkinter as Tk
import tkinter.filedialog
import tkinter.messagebox
from functools import partial
from .base import BaseNode
from .main import center_window, word_count_to_string
from .. import model
class FileErrorFrame(Tk.Frame):
'''This puts the error message along side a "Locate file..." button inside
... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/base.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.036153 | # coding=utf-8
from tkinter import Frame
import tkinter as Tk
from abc import abstractmethod
from functools import partial
class BaseNode(Frame):
'''Node view base class
Has a 'title' at the left-top corner, and then a '+' button for adding
attributes, and optional label on the right side with a word... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/case.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.516730 | import tkinter as Tk
import tkinter.messagebox
from functools import partial
from .base import BaseNode
from .main import center_window
from .. import model
class CaseNode(BaseNode):
'''Change the case of letters in a word
'''
def __init__(self, controller, master=None, **kwargs):
BaseNode.__ini... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/main.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.541904 | import tkinter as Tk
import tkinter.ttk as ttk
import tkinter.filedialog
import tkinter.messagebox
from functools import partial
import os
import sys
import webbrowser
import locale
# Try to set a locale for number formatting with commas
# Fall back to system default if specified locale is not available
try:
if s... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/scrollable_frame.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.546623 | #!/usr/bin/python
# -*- coding: utf-8 -*-
from tkinter import * # from x import * is bad practice
#from tkinter.ttk import *
# Adapted from https://github.com/JonathanTaquet/Oe2sSLE/blob/master/VerticalScrolledFrame.py
class VerticalScrolledFrame(Frame):
def __init__(self, parent, *args, **kw):
Frame.__... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/substitution.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.553689 | import tkinter as Tk
from functools import partial
from .base import BaseNode
from .main import center_window
from .const import SUBSTITUTION_CHECKS, SPECIAL_TYPES
from .. import model
class SubstitutionNode(BaseNode):
'''Substitute one character for another
'''
def __init__(self, controller, master=None,... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | mentalist/view/const.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.583119 | """
All constant values are declared here.
"""
import datetime
import math
cur_year = datetime.date.today().year
cur_year = math.ceil((cur_year + 5) / 5.) * 5
NUMBER_LIST = [
['small', '0-100'],
['basic', '0-1000'],
['full', '0-10000'],
['years', '1950-{}'.format(cur_year)]
]
SUBSTITUTION_CHECKS... |
sc0tfree/mentalist | https://github.com/sc0tfree/mentalist | null | null | null | null | 1,975 | null | null | mit | null | null | null | null | null | null | null | tests/test_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:42:59.599983 | import unittest
import warnings
import tempfile
import shutil
import os
import sys
import subprocess
sys.path.insert(1, os.path.join(sys.path[0], '..'))
from mentalist import model
run_hashcat_tests = False
class TestModel(unittest.TestCase):
def test_file_attr(self):
attr = model.FileAttr(path=self.test... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/_options.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.415059 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
import ast
import logging
import os
from collections.abc import Generator
from contextlib import contextmanager
from typing import Any
logger = logging.getLogger(__name__)
class InvalidOptionError(AttributeError):
"""Custom exception ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | docs/hooks/notebook_timing.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.416018 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""
MkDocs hook to time notebook execution during documentation builds.
"""
from __future__ import annotations
import sys
import time
from pathlib import Path
_timing_data: dict[str, dict] = {}
def on_pre_page(page, config, files):
... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/clustering/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.422834 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Clustering functionality for PyPSA networks."""
from typing import TYPE_CHECKING, Any
import pandas as pd
from deprecation import deprecated
from pypsa.clustering import spatial, temporal
from pypsa.clustering.spatial import SpatialClu... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | docs/hooks/cleanup.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.427000 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
import re
def on_page_markdown(markdown, page, config, files):
# Remove # doctest: +SKIP from code blocks
pattern = r"(``` py.*?```)"
def remove_doctest_skip(match):
code_block = mat... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | docs/hooks/path_aliases.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.428155 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""
Path aliases hook for MkDocs to enable simplified cross-references.
Registers aliases so that e.g. `pypsa.Network.static` resolves to the actual
documented identifier `pypsa.network.components.NetworkComponentsMixin.static`.
"""
from _... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | docs/hooks/shortcodes.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.437913 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""
Shortcode replacements for MkDocs Material theme and Griffe extension.
This module provides both MkDocs hooks for processing shortcodes in markdown pages
and a Griffe extension for processing shortcodes in API docstrings.
"""
from __fu... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.459588 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Python for Power Systems Analysis (PyPSA).
Energy system modelling library.
"""
__author__ = (
"PyPSA Developers, see https://docs.pypsa.org/latest/contributing/contributors.html"
)
__copyright__ = (
"Copyright 2015-2025 PyPSA D... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/clustering/temporal.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.460805 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Functions for temporal clustering of networks.
This module provides methods to reduce the temporal resolution of PyPSA networks
while preserving the total modeled hours through snapshot weighting adjustments,
so that the total number of ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | docs/hooks/dynamic_inspect.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.497850 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""
Retrieve docstrings from runtime objects instead of static analysis (default).
See https://mkdocstrings.github.io/griffe/guide/users/how-to/selectively-inspect/
"""
import griffe
logger = griffe.get_logger("griffe_inspect_specific_obj... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/clustering/spatial.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:03.579494 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Functions for computing network clusters."""
from __future__ import annotations
import logging
from dataclasses import dataclass
from importlib.util import find_spec
from typing import TYPE_CHECKING, Any
import networkx as nx
import nu... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/buses.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.057314 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Buses components module."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any
import pandas as pd
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components im... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/collection.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.061684 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""NetworkCollection class for handling multiple PyPSA networks."""
import logging
import re
from collections.abc import Callable, Iterator, Sequence
from typing import Any
try:
from cloudpathlib import AnyPath as Path
except ImportErr... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.082864 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Package for component specific functionality in PyPSA."""
from typing import Any
from pypsa.components._types import (
Buses,
Carriers,
Generators,
GlobalConstraints,
Lines,
LineTypes,
Links,
Loads,
P... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.083424 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components types package.
Contains all classes for specific component types. They all inherit from the Components
base class and might add additional functionality or override existing methods.
"""
from pypsa.components._types.buses imp... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/global_constraints.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.094063 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Global constraints components module."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
if TYP... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/generators.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.114116 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Generators components module."""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import pandas as pd
from pypsa.common import list_as_string
from pypsa.components._types._p... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/line_types.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.165193 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Line types components module."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
if TYPE_CHECKI... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/_patch.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.169869 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Generators components module."""
from __future__ import annotations
import re
from functools import wraps
from typing import Any, TypeVar
from pypsa.components.components import Components
from pypsa.components.types import get as get_... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/carriers.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.187608 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Carriers components module."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any
import pandas as pd
from pypsa.common import generate_colors
from pypsa.components._types._patch import patch_add_d... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/common.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.194922 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""General utility functions for PyPSA."""
from __future__ import annotations
import functools
import json
import logging
import warnings
from functools import lru_cache
from typing import TYPE_CHECKING, Any
from urllib import parse, reque... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/links.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.614515 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Links components module."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.common import list_as_string
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components._types.mi... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/loads.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.644343 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Loads components module."""
from collections.abc import Sequence
from typing import Any
import pandas as pd
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
@patch_add_... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/processes.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.712782 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Processes components module."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.common import list_as_string
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components._type... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/lines.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.718082 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Lines components module."""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import numpy as np
import pandas as pd
from pypsa.common import list_as_string
from pypsa.compon... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/mixin/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.721173 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
from pypsa.components._types.mixin.multiports import _Multiport
__all__ = ["_Multiport"]
|
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/storage_units.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.763985 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Storage units components module."""
from collections.abc import Sequence
from typing import Any
import pandas as pd
import xarray as xr
from pypsa.common import list_as_string
from pypsa.components._types._patch import patch_add_docstr... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/shunt_impedances.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.775103 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Shunt impedances components module."""
from collections.abc import Sequence
from typing import Any
import pandas as pd
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/shapes.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.776622 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Shapes components module."""
from collections.abc import Sequence
from typing import Any
import pandas as pd
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
@patch_add... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/stores.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.807133 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Stores components module."""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import pandas as pd
from pypsa.common import list_as_string
from pypsa.components._types._patch... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/mixin/multiports.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:04.825012 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""MultiPort components module."""
from __future__ import annotations
import logging
from abc import abstractmethod
import numpy as np
import pandas as pd
from pypsa.components.components import Components
from pypsa.constants import RE_... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/sub_networks.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.187782 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Sub networks components module."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
if TYPE_CHEC... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/transformer_types.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.218107 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Transformer types components module."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.components._types._patch import patch_add_docstring
from pypsa.components.components import Components
if TYPE... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/abstract.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.279429 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Abstract components module.
Only defines a base class for all Components helper classes which inherit to
`Components` class.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, A... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/_types/transformers.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.296196 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import pandas as pd
from pypsa.common import list_as_string
from pypsa.components._types._patch import patch_add_docstring
from ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/common.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.345210 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""General utility functions for PyPSA components."""
from __future__ import annotations
from typing import TYPE_CHECKING
from pypsa.components.components import Components
from pypsa.deprecations import COMPONENT_ALIAS_DICT
if TYPE_CHEC... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/components.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.356646 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components module.
Contains classes and properties relevant to all component types in PyPSA. Also imports
logic from other modules:
- components.types
Contains classes and logic relevant to specific component types in PyPSA.
Generic fun... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/descriptors.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.373211 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components descriptor module.
Contains single mixin class which is used to inherit to [pypsa.Components][] class.
Should not be used directly.
Descriptor functions only describe data and do not modify it.
"""
from __future__ import an... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/legacy.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.418275 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Legacy functionality which is kept for backwards compatibility."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pypsa.common import UnexpectedError
from pypsa.components._types import (
Buses,
C... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/array.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.442328 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Array module of PyPSA components.
Contains logic to combine static and dynamic pandas DataFrames to single xarray
DataArray for each variable.
"""
from __future__ import annotations
import copy
from typing import TYPE_CHECKING
import ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/index.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.530824 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components index module.
Contains single mixin class which is used to inherit to [pypsa.Components][] class.
Should not be used directly.
Index methods and properties are used to access the different index levels, based on
the attached ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/store.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.772052 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components store module.
Contains store class which is used to store all different components in the network.
"""
from __future__ import annotations
import logging
import re
from typing import TYPE_CHECKING, Any
from pypsa.deprecation... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/transform.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.798632 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components transform module.
Contains single mixin class which is used to inherit to [pypsa.Components][] class.
Should not be used directly.
Transform methods are methods which modify and restructure data.
"""
from __future__ import ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/costs.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.944420 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Cost calculation utilities for PyPSA."""
from __future__ import annotations
import numpy as np
import pandas as pd
def annuity(
discount_rate: float | pd.Series,
lifetime: float | pd.Series,
) -> float | pd.Series:
r"""Cal... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/components/types.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:05.956411 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Components types module.
Contains module wide component types. Default types are loaded from the package data.
Additional types can be added by the user.
"""
from __future__ import annotations
from pathlib import Path
import numpy as ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/deprecations.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:06.025231 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Deprecated functionality."""
COMPONENT_ALIAS_DICT = {
"SubNetwork": "sub_networks",
"Bus": "buses",
"Carrier": "carriers",
"GlobalConstraint": "global_constraints",
"Line": "lines",
"LineType": "line_types",
"... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/constants.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:06.056679 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Constants."""
import re
DEFAULT_EPSG = 4326
DEFAULT_TIMESTAMP = "now"
EARTH_RADIUS = 6378137.0 # equitorial radius in meters
HOURS_PER_YEAR = 8760.0
RE_PORTS = re.compile(r"^bus(\d*)$")
# Pattern for filtering bus columns without capt... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/definitions/components.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:06.070078 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Definitions for network components."""
from __future__ import annotations
import logging
from dataclasses import dataclass
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import pandas as pd
logger = logging.getLogger(__name__)... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/consistency.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:06.080173 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Consistency check functions for PyPSA networks.
Mainly used in the `Network.consistency_check()` method.
"""
from __future__ import annotations
import logging
import re
from typing import TYPE_CHECKING, Any
import numpy as np
import p... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/descriptors.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:06.104818 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Descriptors for component attributes."""
from __future__ import annotations
import logging
from dataclasses import replace
from itertools import product
from typing import TYPE_CHECKING, Any
import pandas as pd
from deprecation import ... |
PyPSA/PyPSA | https://github.com/PyPSA/PyPSA | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | pypsa/definitions/structures.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:06.139074 | # SPDX-FileCopyrightText: PyPSA Contributors
#
# SPDX-License-Identifier: MIT
"""Descriptors for component attributes."""
from __future__ import annotations
import logging
import re
from copy import deepcopy
from typing import Any
logger = logging.getLogger(__name__)
class Dict(dict):
"""Subclass of dict, whi... |
AgentOps-AI/tokencost | https://github.com/AgentOps-AI/tokencost | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | tokencost/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:08.403803 | from .costs import (
count_message_tokens,
count_string_tokens,
calculate_completion_cost,
calculate_prompt_cost,
calculate_all_costs_and_tokens,
calculate_cost_by_tokens,
configure_model,
register_model_pattern,
)
from .constants import TOKEN_COSTS_STATIC, TOKEN_COSTS, update_token_cost... |
AgentOps-AI/tokencost | https://github.com/AgentOps-AI/tokencost | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | tokencost/costs.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:08.408082 | """
Costs dictionary and utility tool for counting tokens
"""
import os
import tiktoken
import anthropic
from typing import Union, List, Dict, Literal
from .constants import TOKEN_COSTS
from decimal import Decimal
import logging
import re
from typing import Optional, Tuple, Pattern
logger = logging.getLogger(__name__... |
AgentOps-AI/tokencost | https://github.com/AgentOps-AI/tokencost | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | tests/test_costs.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:08.412948 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import pytest
from decimal import Decimal
from dotenv import load_dotenv
# Load environment variables for ANTHROPIC_API_KEY
load_dotenv()
from tokencost.costs import (
count_message_tokens,
count_string_tokens,
calculate_cost_by_tokens,
calculat... |
AgentOps-AI/tokencost | https://github.com/AgentOps-AI/tokencost | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | tokencost/constants.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:08.413410 | import os
import json
import aiohttp
import asyncio
import logging
logger = logging.getLogger(__name__)
"""
Prompt (aka context) tokens are based on number of words + other chars (eg spaces and punctuation) in input.
Completion tokens are similarly based on how long chatGPT's response is.
Prompt tokens + completion t... |
AgentOps-AI/tokencost | https://github.com/AgentOps-AI/tokencost | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | update_prices.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:08.447112 | import pandas as pd
import tokencost
from decimal import Decimal
import json
import re
# Update model_prices.json with the latest costs from the LiteLLM cost tracker
print("Fetching latest prices...")
tokencost.refresh_prices(write_file=False)
def diff_dicts(dict1, dict2):
# Filter out keys from dict1 that start... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | chatGPTEx/main_GPT4.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.650971 | #polished by GPT4
import json
import datetime
import os
import configparser
from promptsSearch import SearchPrompt, promptsDict
from markdown_it import MarkdownIt
from flask import Flask, render_template, request, Response
from search import (
directQuery,
web,
detail,
webDirect,
WebKeyWord,
loa... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | chatGPTEx/search.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.651505 | from api_class import GoogleSearchAPI, WikiSearchAPI, WolframAPI
from optimizeOpenAI import ExChatGPT,APICallList
import threading
import json
import re
import configparser
import os
import requests
program_path = os.path.realpath(__file__)
program_dir = os.path.dirname(program_path)
config_path = os.path.jo... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | chatGPTEx/api_class.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.667189 | import json
import requests
import urllib.parse
import re
import os
import string
import time
import threading
from queue import PriorityQueue as PQ
import jieba
program_path = os.path.realpath(__file__)
program_dir = os.path.dirname(program_path)
with open(program_dir+'/cn_stopwords.txt', encoding='utf-8')... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | chatGPTEx/main.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.672058 | import json
import datetime
import os
from promptsSearch import SearchPrompt,promptsDict
from markdown_it import MarkdownIt
from flask import Flask, render_template, request, Response
from search import directQuery,web,detail,webDirect,WebKeyWord,load_history,APICallList,directQuery_stream,chatbot
from graiax.text2img... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | chatGPTEx/optimizeOpenAI.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.702123 | """
A simple wrapper for the official ChatGPT API
"""
import json
import os
import threading
import time
import requests
import tiktoken
from typing import Generator
from queue import PriorityQueue as PQ
import configparser
import copy
import json
import os
import time
ENGINE = os.environ.get("GPT_ENGINE") or "gpt-3.5... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | WebChatGPTAPI/WolframLocalServer.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.733372 | from urllib.parse import urlparse, parse_qs
import http.server
import socketserver
import socket
import requests
import json
cookies = {
# YOUR COOKIE
}
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7... |
circlestarzero/EX-chatGPT | https://github.com/circlestarzero/EX-chatGPT | null | null | null | null | 1,971 | null | null | mit | null | null | null | null | null | null | null | chatGPTEx/promptsSearch.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:10.763377 | import os
import re
from fuzzywuzzy import process
from xpinyin import Pinyin
import csv
import json
name_list=[]
program_path = os.path.realpath(__file__)
program_dir = os.path.dirname(program_path)
json_file_path = program_dir+'/prompts/prompts.json'
name_list = []
promptsJSON = {}
promptsDict = {}
with open(json_fil... |
zarr-developers/zarr-python | https://github.com/zarr-developers/zarr-python | null | null | null | null | 1,970 | null | null | mit | null | null | null | null | null | null | null | packages/zarr-metadata/src/zarr_metadata/v2/array.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:13.666123 | """Zarr v2 array metadata types."""
from collections.abc import Mapping
from typing import Literal, NotRequired
from typing_extensions import TypedDict
from zarr_metadata.v2.codec import CodecMetadataV2
DataTypeMetadataV2 = str | tuple[tuple[str, str] | tuple[str, str, tuple[int, ...]], ...]
"""The v2 dtype represe... |
zarr-developers/zarr-python | https://github.com/zarr-developers/zarr-python | null | null | null | null | 1,970 | null | null | mit | null | null | null | null | null | null | null | ci/check_unlinked_types.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:13.667603 | """Check for unlinked type annotations in built documentation.
mkdocstrings renders resolved types as <a href="..."> links and unresolved
types as <span title="fully.qualified.Name">Name</span> without an anchor.
This script finds all such unlinked types in the built HTML and reports them.
Usage:
python ci/check_... |
zarr-developers/zarr-python | https://github.com/zarr-developers/zarr-python | null | null | null | null | 1,970 | null | null | mit | null | null | null | null | null | null | null | packages/zarr-metadata/src/zarr_metadata/v2/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:13.674295 | """Zarr v2 metadata types."""
from zarr_metadata.v2.array import (
ArrayDimensionSeparatorV2,
ArrayMetadataV2,
ArrayOrderV2,
DataTypeMetadataV2,
)
from zarr_metadata.v2.codec import CodecMetadataV2
from zarr_metadata.v2.consolidated import ConsolidatedMetadataV2
from zarr_metadata.v2.group import Group... |
zarr-developers/zarr-python | https://github.com/zarr-developers/zarr-python | null | null | null | null | 1,970 | null | null | mit | null | null | null | null | null | null | null | packages/zarr-metadata/src/zarr_metadata/v2/codec.py | null | null | null | null | null | null | Python | 2026-05-04T01:43:13.675736 | """
Zarr v2 codec configuration shape.
In v2, compressors and filters are numcodecs configuration dicts: a required
`id` field naming the codec, plus arbitrary codec-specific extra fields.
"""
from typing_extensions import TypedDict
class CodecMetadataV2(TypedDict, extra_items=object): # type: ignore[call-arg]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.