id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,290,000 | cifar100.py | enriquetomasmb_nebula/nebula/core/datasets/cifar100/cifar100.py | from nebula.core.datasets.nebuladataset import NebulaDataset
from torchvision import transforms
from torchvision.datasets import CIFAR100
import os
class CIFAR100Dataset(NebulaDataset):
def __init__(
self,
num_classes=100,
partition_id=0,
partitions_number=1,
batch_size=32,... | 4,115 | Python | .py | 87 | 36.908046 | 124 | 0.642018 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,001 | tasks.py | enriquetomasmb_nebula/nebula/core/utils/tasks.py | import asyncio
import logging
async def debug_tasks():
while True:
tasks = asyncio.all_tasks()
logging.info(f"Active tasks: {len(tasks)}")
for task in tasks:
logging.info(f"Task: {task}")
await asyncio.sleep(5)
| 261 | Python | .py | 9 | 22.444444 | 51 | 0.624 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,002 | certificate.py | enriquetomasmb_nebula/nebula/core/utils/certificate.py | import os
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.serialization import Encoding, NoEncryption, PrivateFormat, load_pem_private_key
from cryptogr... | 4,636 | Python | .py | 103 | 36.980583 | 116 | 0.665114 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,003 | nebulalogger.py | enriquetomasmb_nebula/nebula/core/utils/nebulalogger.py | from aim.pytorch_lightning import AimLogger
from datetime import datetime
import logging
from lightning.pytorch.utilities import rank_zero_only
from aim.sdk.run import Run
from aim import Image
from lightning.pytorch.loggers.logger import rank_zero_experiment
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from... | 1,723 | Python | .py | 39 | 37.025641 | 119 | 0.659905 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,004 | helper.py | enriquetomasmb_nebula/nebula/core/utils/helper.py | import logging
from typing import OrderedDict, List, Optional
import copy
import torch
def cosine_metric2(model1: OrderedDict[str, torch.Tensor], model2: OrderedDict[str, torch.Tensor], similarity: bool = False) -> Optional[float]:
if model1 is None or model2 is None:
logging.info("Cosine similarity canno... | 7,803 | Python | .py | 168 | 36.422619 | 174 | 0.608805 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,005 | deterministic.py | enriquetomasmb_nebula/nebula/core/utils/deterministic.py | import logging
import numpy as np
import os
import random
import torch
def enable_deterministic(config):
seed = config.participant["scenario_args"]["random_seed"]
logging.info("Fixing randomness with seed {}".format(seed))
np.random.seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
random.seed(s... | 512 | Python | .py | 16 | 28.375 | 63 | 0.748988 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,006 | locker.py | enriquetomasmb_nebula/nebula/core/utils/locker.py | import threading
import logging
import inspect
import asyncio
class Locker:
def __init__(self, name, verbose=True, async_lock=False, *args, **kwargs):
self._name = name
self._verbose = verbose
self._async_lock = async_lock
if async_lock:
self._lock = asyncio.Lock(*args... | 3,476 | Python | .py | 77 | 36.077922 | 127 | 0.602306 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,007 | nebulalogger_tensorboard.py | enriquetomasmb_nebula/nebula/core/utils/nebulalogger_tensorboard.py | import logging
from lightning.pytorch.loggers import TensorBoardLogger
from datetime import datetime
class NebulaTensorBoardLogger(TensorBoardLogger):
def __init__(self, scenario_start_time, *args, **kwargs):
self.scenario_start_time = scenario_start_time
self.local_step = 0
self.global_s... | 2,376 | Python | .py | 50 | 38.18 | 130 | 0.62063 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,008 | messages.py | enriquetomasmb_nebula/nebula/core/network/messages.py | import logging
from nebula.core.pb import nebula_pb2
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
class MessagesManager:
def __init__(self, addr, config, cm: "CommunicationsManager"):
self.addr = addr
self.config = co... | 2,948 | Python | .py | 72 | 32.069444 | 117 | 0.664921 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,009 | discoverer.py | enriquetomasmb_nebula/nebula/core/network/discoverer.py | import asyncio
import logging
from nebula.addons.functions import print_msg_box
from typing import TYPE_CHECKING
from nebula.core.pb import nebula_pb2
if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
class Discoverer:
def __init__(self, addr, config, cm: "Communication... | 1,992 | Python | .py | 35 | 46.8 | 155 | 0.671282 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,010 | forwarder.py | enriquetomasmb_nebula/nebula/core/network/forwarder.py | import asyncio
import logging
import time
from typing import TYPE_CHECKING
from nebula.addons.functions import print_msg_box
from nebula.core.utils.locker import Locker
if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
class Forwarder:
def __init__(self, config, cm: "Comm... | 3,574 | Python | .py | 63 | 45.507937 | 111 | 0.652774 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,011 | propagator.py | enriquetomasmb_nebula/nebula/core/network/propagator.py | import asyncio
import logging
from collections import deque
from abc import ABC, abstractmethod
from nebula.addons.functions import print_msg_box
from typing import TYPE_CHECKING
from typing import List, Tuple, Any, Optional
if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
... | 6,523 | Python | .py | 117 | 47.111111 | 191 | 0.695283 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,012 | communications.py | enriquetomasmb_nebula/nebula/core/network/communications.py | import hashlib
import logging
import sys
import os
import traceback
import collections
from datetime import datetime
import requests
import asyncio
import subprocess
from nebula.addons.mobility import Mobility
from nebula.core.network.discoverer import Discoverer
from nebula.core.network.forwarder import Forwarder
fro... | 43,081 | Python | .py | 748 | 42.362299 | 298 | 0.587681 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,013 | health.py | enriquetomasmb_nebula/nebula/core/network/health.py | import asyncio
import logging
import time
from nebula.addons.functions import print_msg_box
from typing import TYPE_CHECKING
from nebula.core.pb import nebula_pb2
if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
class Health:
def __init__(self, addr, config, cm: "Commun... | 3,242 | Python | .py | 59 | 42.627119 | 122 | 0.620133 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,014 | connection.py | enriquetomasmb_nebula/nebula/core/network/connection.py | import asyncio
import logging
import time
from geopy import distance
import json
import zlib, bz2, lzma
import uuid
from dataclasses import dataclass
from typing import Dict, Any, Optional
import lz4.frame
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from nebula.core.network.communications import Communicat... | 15,670 | Python | .py | 316 | 38.920886 | 151 | 0.618393 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,015 | scikit.py | enriquetomasmb_nebula/nebula/core/training/scikit.py | import logging
import pickle
import traceback
from sklearn.metrics import accuracy_score
class Scikit:
def __init__(self, model, data, config=None, logger=None):
self.model = model
self.data = data
self.config = config
self.logger = logger
self.round = 0
self.epochs... | 2,192 | Python | .py | 63 | 25.936508 | 81 | 0.600757 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,016 | lightning.py | enriquetomasmb_nebula/nebula/core/training/lightning.py | import copy
import gc
import logging
from collections import OrderedDict
import asyncio
import os
import pickle
import traceback
import hashlib
import io
import gzip
import torch
from lightning import Trainer
from lightning.pytorch.callbacks import ProgressBar, ModelSummary
from torch.nn import functional as F
from neb... | 14,950 | Python | .py | 305 | 38.967213 | 193 | 0.631575 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,017 | siamese.py | enriquetomasmb_nebula/nebula/core/training/siamese.py | import logging
from collections import OrderedDict
import traceback
import hashlib
import io
import torch
from lightning import Trainer
from lightning.pytorch.callbacks import RichProgressBar, RichModelSummary
from lightning.pytorch.callbacks.progress.rich_progress import RichProgressBarTheme
from nebula.core.utils.det... | 7,163 | Python | .py | 168 | 31.702381 | 178 | 0.604531 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,018 | nebula_pb2.py | enriquetomasmb_nebula/nebula/core/pb/nebula_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: nebula.proto
# Protobuf Python Version: 4.25.3
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf imp... | 4,089 | Python | .py | 40 | 99.925 | 2,121 | 0.779619 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,019 | conf.py | enriquetomasmb_nebula/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
import subprocess
subprocess.call(['sphinx-apidoc', '-f', '-o', '.', '../nebula']) # The same ... | 2,710 | Python | .py | 66 | 38.818182 | 95 | 0.674179 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,020 | main.py | enriquetomasmb_nebula/app/main.py | import argparse
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..")) # Parent directory where is the NEBULA module
import nebula
from nebula.controller import Controller
from nebula.scenarios import ScenarioManagement
argparser = argparse.ArgumentParser(description="Controller of NEBUL... | 3,170 | Python | .py | 127 | 21.188976 | 109 | 0.652906 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,021 | attacks.py | enriquetomasmb_nebula/nebula/addons/attacks/attacks.py | from typing import Any
import torch
import numpy as np
from torchmetrics.functional import pairwise_cosine_similarity
from copy import deepcopy
import logging
# To take into account:
# - Malicious nodes do not train on their own data
# - Malicious nodes aggregate the weights of the other nodes, but not their own
# - ... | 5,210 | Python | .tac | 119 | 36.554622 | 111 | 0.662584 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,022 | attacks.json | enriquetomasmb_nebula/nebula/tests/attacks.json | [
{
"scenario_title": "FedAvg_Fully_nodes5_MNIST_No Attack",
"scenario_description": "",
"simulation": true,
"federation": "DFL",
"topology": "Custom",
"nodes": {
"0": {
"id": 0,
"ip": "192.168.50.2",
"port": "45000",
"role": "aggregator",
"malicio... | 77,847 | Python | .tac | 3,027 | 14.070367 | 75 | 0.394114 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,023 | nebula.addons.attacks.poisoning.rst | enriquetomasmb_nebula/docs/nebula.addons.attacks.poisoning.rst | nebula.addons.attacks.poisoning package
=======================================
Submodules
----------
nebula.addons.attacks.poisoning.datapoison module
-------------------------------------------------
.. automodule:: nebula.addons.attacks.poisoning.datapoison
:members:
:undoc-members:
:show-inheritance:
n... | 896 | Python | .tac | 28 | 29.392857 | 61 | 0.601863 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,024 | nebula.addons.attacks.rst | enriquetomasmb_nebula/docs/nebula.addons.attacks.rst | nebula.addons.attacks package
=============================
Subpackages
-----------
.. toctree::
:maxdepth: 4
nebula.addons.attacks.poisoning
Submodules
----------
nebula.addons.attacks.attacks module
------------------------------------
.. automodule:: nebula.addons.attacks.attacks
:members:
:undoc-m... | 476 | Python | .tac | 21 | 20.142857 | 45 | 0.604027 | enriquetomasmb/nebula | 8 | 2 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,025 | nodes.py | huagetai_ComfyUI_LightGradient/nodes.py | import torch
import random
import numpy as np
from enum import Enum
from nodes import MAX_RESOLUTION
# Images generated by combination of different creases need to be normalized
def normalize_img(img):
return (img / img.max()) * 255
# cross = True if cross crease is wanted
def create_uneven_array(low, up, steps, s... | 8,770 | Python | .py | 199 | 38.015075 | 179 | 0.649589 | huagetai/ComfyUI_LightGradient | 8 | 3 | 2 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,026 | setup.py | facebookresearch_chai/setup.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# This software may be used and distributed according to the terms of the GNU General Public License version 3.
from setuptools import setup, find_packages
setup(name="llama", version="0.0.0", packages=find_packages())
| 274 | Python | .py | 4 | 67 | 111 | 0.783582 | facebookresearch/chai | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,027 | example_chai.py | facebookresearch_chai/example_chai.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# This software may be used and distributed according to the terms of the GNU General Public License version 3.
from typing import Tuple
import os
import sys
import torch
import fire
import time
import json
from pathlib import Path
from fairscale.nn.model_parallel... | 3,457 | Python | .py | 98 | 30.816327 | 111 | 0.684053 | facebookresearch/chai | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,028 | perform_offline_clustering.py | facebookresearch_chai/perform_offline_clustering.py | import os
import json
import argparse
import numpy as np
from collections import defaultdict
from collections import Counter
from scipy.spatial.distance import cdist
from sklearn.cluster import AgglomerativeClustering
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
def parse_args(parser):
parse... | 5,838 | Python | .py | 137 | 30.021898 | 93 | 0.548427 | facebookresearch/chai | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,029 | tetramesh.py | mxhulab_cryotrans/src/cryotrans/tetramesh.py | __all__ = [
'tetramesh',
'MeshLoss'
]
import numpy as np
import torch
from numpy.typing import NDArray
def tetramesh(xs : NDArray[np.float32], n : NDArray[np.float32]) -> NDArray[np.float32]:
vertices = np.array([
[0, 0, 0],
[0, 1, 0],
[1, 0, 0],
[1, 1, 0],
[0, 0, 1... | 1,172 | Python | .py | 38 | 24.131579 | 88 | 0.492471 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,030 | ode_net.py | mxhulab_cryotrans/src/cryotrans/ode_net.py | __all__ = [
'ODENet'
]
import torch
from .velocity_net import VelocityNet
class ODENet(torch.nn.Module):
def __init__(self, n_frames : int = 10, **vnet_kwargs):
super().__init__()
self.n_frames = n_frames
self.v = VelocityNet(**vnet_kwargs)
def forward(self, x : torch.Tensor) -> ... | 642 | Python | .py | 21 | 23.047619 | 59 | 0.543831 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,031 | velocity_net.py | mxhulab_cryotrans/src/cryotrans/velocity_net.py | __all__ = [
'VelocityNet'
]
import torch
class VelocityNet(torch.nn.Module):
def __init__(self, depth : int = 3, width : int = 100, dim : int = 3):
super().__init__()
self.depth = depth
for i in range(depth):
layer = torch.nn.Linear(dim if i == 0 else width, dim if i == de... | 735 | Python | .py | 19 | 30.105263 | 95 | 0.54073 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,032 | particles.py | mxhulab_cryotrans/src/cryotrans/particles.py | __all__ = [
'particles'
]
import numpy as np
from typing import Tuple
from numpy.typing import NDArray
def particles(vol : NDArray[np.float32], threshold : float = 1e-6) -> Tuple[NDArray[np.float32]]:
n = vol.shape[0]
vol = np.where(vol < threshold, 0, vol)
xs = np.nonzero(vol)
rho = vol[xs]
x... | 400 | Python | .py | 14 | 25.142857 | 97 | 0.640625 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,033 | gridding.py | mxhulab_cryotrans/src/cryotrans/gridding.py | __all__ = [
'Gridding'
]
import cupy as cp
import torch
from typing import Tuple
from .utility import torch_to_cupy, cupy_to_torch, BLOCKDIM, BLOCKSIZE
ker_gridding3d = cp.RawKernel(r'''
extern "C" __global__ void gridding3d(
const float* rho,
const float* xs,
int m,
float* vol,
int n1,
in... | 7,804 | Python | .py | 157 | 41.33758 | 184 | 0.379618 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,034 | predict.py | mxhulab_cryotrans/src/cryotrans/predict.py | import argparse
import mrcfile
import sys
import torch
import numpy as np
from numpy.typing import NDArray
from pathlib import Path
from .ode_net import ODENet
from .particles import particles
from .gridding import Gridding
def parse_args():
parser = argparse.ArgumentParser(description = 'CryoTRANS: Predicting hig... | 3,368 | Python | .py | 66 | 45.606061 | 148 | 0.6231 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,035 | train.py | mxhulab_cryotrans/src/cryotrans/train.py | import argparse
import mrcfile
import sys
import torch
import numpy as np
from pathlib import Path
from skimage.transform import downscale_local_mean
from time import time
from typing import Optional
from numpy.typing import NDArray
from .ode_net import ODENet
from .particles import particles
from .gridding import Grid... | 6,840 | Python | .py | 140 | 42.607143 | 148 | 0.591977 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,036 | wasserstein2_loss.py | mxhulab_cryotrans/src/cryotrans/wasserstein2_loss.py | __all__ = [
'Wasserstein2Loss'
]
import cupy as cp
import torch
from typing import Dict, Tuple
from .utility import torch_to_cupy, cupy_to_torch, BLOCKDIM, BLOCKSIZE
ker_blur = cp.RawKernel(r'''
extern "C" __global__ void blur(
const float* src,
int size,
int n,
float B,
float* dst)
{
int ... | 3,331 | Python | .py | 85 | 30.8 | 99 | 0.535913 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,037 | utility.py | mxhulab_cryotrans/src/cryotrans/utility.py | import cupy as cp
import torch
from torch.utils.dlpack import to_dlpack, from_dlpack
BLOCKSIZE = 1024
BLOCKDIM = lambda x : (x - 1) // BLOCKSIZE + 1
def cupy_to_torch(x : cp.ndarray) -> torch.Tensor:
return from_dlpack(x.toDlpack())
def torch_to_cupy(x : torch.Tensor) -> cp.ndarray:
return cp.fromDlpack(to_d... | 330 | Python | .py | 9 | 34.444444 | 53 | 0.726415 | mxhulab/cryotrans | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,290,038 | logging.py | nyaoouo_NyLib2/nylib/logging.py | import io
import logging
import os.path
import pathlib
import sys
import threading
import time
import typing
import zipfile
Verbose1 = 9
Verbose2 = 8
Verbose3 = 7
class AsciiFormat:
end = 0
bold = 1
italic = 2
underline = 4
strikethrough = 9
grey = 90
red = 91
green = 92
yellow =... | 5,976 | Python | .py | 162 | 28.419753 | 154 | 0.597856 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,039 | pattern.py | nyaoouo_NyLib2/nylib/pattern.py | # xx xx xx xx 空格分割
# [xx:yy] 单字节从 xx 到 yy
# [xx|yy|zz] 单字节 xx 或 yy 或 zz
# ? ? ? ? 视作变量(默认不储存)
# ^ ^ ^ ^ 视作字串(默认储存)
# * * * * 视作跳转(默认储存)
# ?{n} / *{n} 视作匹配n次
# ?{n:m} / *{n:m} 视作匹配n-m次
# (xx xx xx xx) 不存储的分组
# <xx xx xx xx> 储存的分组
# <* * * *: yy yy yy yy> 对分组数据二级匹配
# <* * * *: yy yy yy yy <* * * *:zz zz zz zz>> 对分组数据多级匹配... | 14,375 | Python | .py | 328 | 30.777439 | 127 | 0.5127 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,040 | ntdll.py | nyaoouo_NyLib2/nylib/winapi/ntdll.py | from .utils import *
_dll = ctypes.WinDLL('ntdll.dll')
NtQueryInformationProcess = def_win_api(_dll.NtQueryInformationProcess, ctypes.c_long, (ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p), error_nt=True)
NtOpenFile = def_win_api(_dll.NtOpenFile, ctypes.c_long, (ctypes.c_void_p, ct... | 718 | Python | .py | 6 | 118.5 | 186 | 0.751055 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,041 | user32.py | nyaoouo_NyLib2/nylib/winapi/user32.py | from .utils import *
_dll = ctypes.WinDLL('user32.dll')
OpenClipboard = def_win_api(_dll.OpenClipboard, ctypes.c_void_p, (ctypes.c_void_p,), error_zero=True)
EmptyClipboard = def_win_api(_dll.EmptyClipboard, ctypes.c_bool, (), error_zero=True)
SetClipboardData = def_win_api(_dll.SetClipboardData, ctypes.c_void_p, (cty... | 453 | Python | .py | 6 | 74.333333 | 121 | 0.748879 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,042 | msvcrt.py | nyaoouo_NyLib2/nylib/winapi/msvcrt.py | from .utils import *
_dll = ctypes.CDLL('msvcrt.dll')
memcpy = def_win_api(_dll.memcpy, ctypes.c_void_p, (ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t), error_zero=True)
| 176 | Python | .py | 3 | 57.333333 | 120 | 0.709302 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,043 | shell32.py | nyaoouo_NyLib2/nylib/winapi/shell32.py | from .utils import *
_dll = ctypes.WinDLL('Shell32.dll')
SHGetPropertyStoreFromParsingName = def_win_api(_dll.SHGetPropertyStoreFromParsingName, ctypes.c_long, (ctypes.c_wchar_p, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_void_p), error_nonzero=True)
| 269 | Python | .py | 3 | 88 | 209 | 0.780303 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,044 | advapi32.py | nyaoouo_NyLib2/nylib/winapi/advapi32.py | from .utils import *
_dll = ctypes.WinDLL('advapi32.dll')
OpenProcessToken = def_win_api(_dll.OpenProcessToken, ctypes.c_long, (ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p), error_zero=True)
LookupPrivilegeName = def_win_api(_dll.LookupPrivilegeNameW, ctypes.c_long, (ctypes.c_wchar_p, ctypes.c_void_p, ctypes.c_wc... | 3,148 | Python | .py | 55 | 53.527273 | 196 | 0.724774 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,045 | kernel32.py | nyaoouo_NyLib2/nylib/winapi/kernel32.py | from .utils import *
_dll = ctypes.WinDLL('kernel32.dll')
GetCurrentProcess = def_win_api(_dll.GetCurrentProcess, ctypes.c_void_p, (), error_zero=True)
CreateToolhelp32Snapshot = def_win_api(_dll.CreateToolhelp32Snapshot, HANDLE, (ctypes.c_ulong, ctypes.c_ulong), error_val=INVALID_HANDLE_VALUE)
Process32First = def_wi... | 5,149 | Python | .py | 37 | 138.135135 | 250 | 0.75269 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,046 | utils.py | nyaoouo_NyLib2/nylib/winapi/utils.py | import typing
from .defs import *
_NULL = type('NULL', (), {})
_SetLastError = ctypes.windll.kernel32.SetLastError
def def_win_api(func, res_type: typing.Any = ctypes.c_void_p, arg_types=(), error_zero=False, error_nonzero=False, error_val: typing.Any = _NULL, error_nt=False):
func.argtypes = arg_types
func.... | 1,321 | Python | .py | 39 | 23.974359 | 162 | 0.549961 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,047 | __init__.py | nyaoouo_NyLib2/nylib/winapi/__init__.py | from .kernel32 import *
from .advapi32 import *
from .ntdll import *
from .user32 import *
from .msvcrt import *
from .shell32 import *
| 136 | Python | .py | 6 | 21.666667 | 23 | 0.769231 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,048 | defs.py | nyaoouo_NyLib2/nylib/winapi/defs.py | import ctypes
import locale
import ctypes.wintypes
IS_64BIT = ctypes.sizeof(ctypes.c_void_p) == 8
DEFAULT_ENCODING = locale.getpreferredencoding()
NT_SUCCESS = lambda res: 0 <= res < 0x80000000
NT_STATUS = ctypes.c_ulong
HANDLE = ctypes.c_uint64 if IS_64BIT else ctypes.c_uint32
INVALID_HANDLE_VALUE = (1 << 64) - 1 i... | 6,600 | Python | .py | 183 | 28.852459 | 95 | 0.599906 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,049 | __init__.py | nyaoouo_NyLib2/nylib/ctype/__init__.py | """
A module to access memory with ctypes, but different from ctypes,
this module allow to use custom native accessors, so it can be used to access memory of other process
"""
import ctypes
import functools
import operator
import struct
import typing
from .memory_manage import MemoryManager
from .. import winapi
from... | 21,333 | Python | .py | 505 | 34.865347 | 177 | 0.596257 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,050 | memory_manage.py | nyaoouo_NyLib2/nylib/ctype/memory_manage.py | import bisect
import io
class ChunkManager:
def __init__(self, ptr, size):
self.ptr = ptr
self.size = size
init_chunk = (0, size) # (offset, size)
self.chunks_by_offset = [init_chunk]
self.chunks_by_size = [init_chunk]
self.allocated = {} # (offset, size)[]
... | 4,539 | Python | .py | 108 | 33.268519 | 119 | 0.578888 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,051 | pipe.py | nyaoouo_NyLib2/nylib/winutils/pipe.py | import ctypes
import threading
import time
import typing
from .. import winapi
_T = typing.TypeVar('_T')
class PipeHandlerBase:
active_pipe_handler = {}
buf_size = 64 * 1024
handle = None
period = .001
def __init__(self):
self.serve_thread = threading.Thread(target=self.serve, daemon=Tr... | 5,828 | Python | .py | 157 | 26.318471 | 107 | 0.563475 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,052 | pipe_rpc.py | nyaoouo_NyLib2/nylib/winutils/pipe_rpc.py | import logging
import pickle
import threading
import traceback
import types
import typing
from .pipe import PipeServer, PipeServerHandler, PipeClient
from ..utils.simple import Counter
from ..utils.threading import ResEventList
_T = typing.TypeVar('_T')
CLIENT_CALL = 0
CLIENT_SUBSCRIBE = 1
CLIENT_UNSUBSCRIBE = 2
SE... | 6,938 | Python | .py | 174 | 29.729885 | 107 | 0.575167 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,053 | inline_hook.py | nyaoouo_NyLib2/nylib/winutils/inline_hook.py | from ..utils.pip import required
required('setuptools', 'keystone-engine', 'capstone')
import re
import struct
import typing
import capstone
import keystone
if typing.TYPE_CHECKING:
from ..process import Process
ks_ = keystone.Ks(keystone.KS_ARCH_X86, keystone.KS_MODE_64)
cs_ = capstone.Cs(capstone.CS_ARCH_X86,... | 5,232 | Python | .py | 129 | 32.48062 | 150 | 0.587436 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,054 | process.py | nyaoouo_NyLib2/nylib/winutils/process.py | import ctypes
import sys
import shlex
from .. import winapi
def iter_processes():
hSnap = winapi.CreateToolhelp32Snapshot(0x00000002, 0)
process_entry = winapi.ProcessEntry32()
process_entry.dwSize = ctypes.sizeof(process_entry)
winapi.Process32First(hSnap, ctypes.byref(process_entry))
try:
... | 3,150 | Python | .py | 76 | 33.644737 | 124 | 0.670592 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,055 | __init__.py | nyaoouo_NyLib2/nylib/winutils/__init__.py | from .process import *
from .. import winapi
def write_to_clipboard(text: str):
text = text.encode('utf-16le') + b'\0\0'
if not winapi.OpenClipboard(0):
raise ctypes.WinError()
winapi.EmptyClipboard()
try:
if not (h := winapi.GlobalAlloc(0x0042, len(text))):
raise ctypes.Wi... | 586 | Python | .py | 18 | 25.444444 | 60 | 0.621908 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,056 | msvc.py | nyaoouo_NyLib2/nylib/winutils/msvc.py | import contextlib
import functools
import itertools
import os
import os.path
import subprocess
import winreg
@functools.cache
def msvc14_find_vc2017():
if not (root := os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")): return None, None
for component in (
"Microsoft.VisualStu... | 3,989 | Python | .py | 94 | 34.446809 | 146 | 0.626996 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,057 | ensure_env.py | nyaoouo_NyLib2/nylib/winutils/ensure_env.py | import atexit
import ctypes
import itertools
import logging
import os
import os.path
import pathlib
import shlex
import shutil
import subprocess
import tarfile
import tempfile
import time
import winreg
from . import msvc
from ..utils.web import download
logger = logging.getLogger(__name__)
def get_tmpdir():
if ... | 9,873 | Python | .py | 210 | 40.52381 | 192 | 0.664724 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,058 | __init__.py | nyaoouo_NyLib2/nylib/winutils/python_loader/__init__.py | import ctypes
import os
import pathlib
import shutil
import subprocess
import sys
import tempfile
import time
from ...process import Process
def build_loader(dst, build_dir=None):
from .. import msvc, ensure_env
ensure_env.ensure_msvc()
plat_spec = 'x86_amd64' # TODO: check
build_env = msvc.load_vcv... | 2,623 | Python | .py | 61 | 36.934426 | 95 | 0.642773 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,059 | __init__.py | nyaoouo_NyLib2/nylib/winutils/python_hijack/__init__.py | import configparser
import os
import pathlib
import shutil
import subprocess
import sys
import sysconfig
import tempfile
DLLMAIN_TEMPLATE = '''
'''
def iter_pe_exported(pe_path):
from ...utils.pip import required
required('pefile')
import pefile
pe = pefile.PE(pe_path)
for exp in pe.DIRECTORY_ENT... | 5,209 | Python | .py | 116 | 37.137931 | 141 | 0.596688 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,060 | external.py | nyaoouo_NyLib2/nylib/structs/external.py | import ctypes
import typing
from nylib.process import Process
_T = typing.TypeVar('_T')
class ExStruct:
_size_: int
_need_free_: bool = False
def __new__(cls, process: Process, address: int = None):
self = object.__new__(cls)
self._process_ = process
if address is None:
... | 6,731 | Python | .py | 166 | 31.807229 | 112 | 0.574739 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,061 | pkg_archive.py | nyaoouo_NyLib2/nylib/utils/pkg_archive.py | import base64
import pathlib
import pickle
import zlib
finder_identifier = '_IsNyPkgArchiveFinder0001'
template_main = f'''
def __pkg_loader__(archive_code):
import sys
for _finder in sys.meta_path:
if hasattr(_finder, {finder_identifier!r}):
finder = _finder
break
else:
... | 3,362 | Python | .py | 74 | 35.013514 | 136 | 0.560768 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,062 | preprocessor.py | nyaoouo_NyLib2/nylib/utils/preprocessor.py | # $RAISE "Preprocessor is already imported, dont reload it"
# default support macros
# - $SYM_FROM [Name] [Module] [Expr] : define a symbol from a module value
# - $SYM [Name] [Expr] : define a symbol
# - $INCLUDE [Name]: include a file with predefined symbols, absolute name only
# - $IF [Expr] / $ELSE / $ELIF [Expr] ... | 7,433 | Python | .py | 193 | 27.704663 | 115 | 0.534064 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,063 | prime.py | nyaoouo_NyLib2/nylib/utils/prime.py | import io
rand_engine = 'secrets'
match rand_engine:
case 'os':
import os
randint = lambda a, b: a + int.from_bytes(os.urandom(((b - a).bit_length() + 7) // 8), 'little') % (b - a)
randbytes = os.urandom
case 'secrets':
import secrets
randint = lambda a, b: secrets.ra... | 4,419 | Python | .py | 124 | 28.451613 | 114 | 0.545497 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,064 | mutex.py | nyaoouo_NyLib2/nylib/utils/mutex.py | import os
import pathlib
if os.name == "nt":
import msvcrt
def portable_lock(fp):
fp.seek(0)
msvcrt.locking(fp.fileno(), msvcrt.LK_LOCK, 1)
def is_lock(fp):
fp.seek(0)
try:
msvcrt.locking(fp.fileno(), msvcrt.LK_NBLCK, 1)
except OSError:
... | 1,554 | Python | .py | 53 | 21.09434 | 67 | 0.569012 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,065 | simple.py | nyaoouo_NyLib2/nylib/utils/simple.py | import functools
import threading
aligned4 = lambda v: (v + 0x3) & (~0x3)
aligned8 = lambda v: (v + 0x7) & (~0x7)
aligned16 = lambda v: (v + 0xf) & (~0xf)
class Counter:
def __init__(self, start=0):
self.value = start
self.lock = threading.Lock()
def get(self):
with self.lock:
... | 588 | Python | .py | 18 | 26.444444 | 52 | 0.599291 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,066 | __init__.py | nyaoouo_NyLib2/nylib/utils/__init__.py | import ast
import collections
import contextlib
import ctypes
import functools
import inspect
import struct
import threading
import pathlib
import time
import typing
_T = typing.TypeVar('_T')
_T2 = typing.TypeVar('_T2')
def count_func_time(func):
import time
def wrapper(*args, **kwargs):
start = tim... | 8,358 | Python | .py | 241 | 26.427386 | 167 | 0.565817 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,067 | threading.py | nyaoouo_NyLib2/nylib/utils/threading.py | import threading
import typing
import ctypes
_T = typing.TypeVar('_T')
def terminate_thread(t: threading.Thread | int, exc_type=SystemExit):
if isinstance(t, threading.Thread):
if not t.is_alive(): return
try:
t = next(tid for tid, tobj in threading._active.items() if tobj is t)
... | 2,085 | Python | .py | 61 | 24.704918 | 86 | 0.55644 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,068 | web.py | nyaoouo_NyLib2/nylib/utils/web.py | import pathlib
import typing
from .pip import required
if typing.TYPE_CHECKING:
from tqdm import tqdm
def download(url, dst, *requests_args, unlink_if_exists=True, chunk_size=1024 * 1024, show_progress=False, **requests_kwargs):
required('requests')
import requests
dst = pathlib.Path(dst)
if d... | 1,331 | Python | .py | 39 | 25.769231 | 126 | 0.590164 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,069 | pip.py | nyaoouo_NyLib2/nylib/utils/pip.py | import logging
import socket
import urllib.request
import urllib.error
import urllib.parse
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning, module=".*packaging\\.version")
PIP_SOURCE = {
'PYPI': 'https://pypi.python.org/simple',
# mirror sites in China...
'阿里云': 'https://mirr... | 4,063 | Python | .py | 109 | 31.183486 | 117 | 0.678489 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,070 | ks_asm.py | nyaoouo_NyLib2/nylib/utils/ks_asm.py | from . import pip
pip.required('setuptools', 'keystone-engine', 'capstone')
import keystone
import capstone
def comp(code, address, data=None, resolves=None, arch=keystone.KS_ARCH_X86, mode=keystone.KS_MODE_64):
_resolves = {}
if resolves:
for k, v in resolves.items():
if isinstance(k, s... | 669 | Python | .py | 19 | 28.157895 | 103 | 0.625194 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,071 | namespace.py | nyaoouo_NyLib2/nylib/process/namespace.py | import typing
if typing.TYPE_CHECKING:
from . import Process
_aligned4 = lambda v: (v + 0x3) & (~0x3)
_aligned16 = lambda v: (v + 0xf) & (~0xf)
class Namespace:
chunk_size = 0x10000
def __init__(self, process: 'Process'):
self.process = process
self.res = []
self.ptr = 0
... | 1,570 | Python | .py | 46 | 25.652174 | 81 | 0.582672 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,072 | __init__.py | nyaoouo_NyLib2/nylib/process/__init__.py | import ctypes
import functools
import pathlib
import struct
import typing
from .namespace import Namespace
from ..pattern import CachedRawMemoryPatternScanner, StaticPatternSearcher
from .. import ctype as m_ctype
from .. import winapi, winutils
_T = typing.TypeVar('_T')
class Process:
current: 'Process'
de... | 16,743 | Python | .py | 327 | 39.75841 | 157 | 0.587854 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,073 | imgui_inspect.py | nyaoouo_NyLib2/nylib/mono/imgui_inspect.py | import typing
from nylib import imguiutils
from nylib.pyimgui import imgui
from . import *
_T = typing.TypeVar('_T')
class _MonoInspector(imguiutils.Inspector[_T]):
def item_name(self, item):
return item[0]
def on_item_selected(self, item):
super().on_item_selected(item)
self.select... | 2,608 | Python | .py | 63 | 31.714286 | 127 | 0.599209 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,074 | type_cast.py | nyaoouo_NyLib2/nylib/mono/type_cast.py | import typing
from .defines import *
from .defines import _MonoObj
_Mono2Py = {}
_Py2Mono = {}
_SimpleCData: typing.Type = next(t for t in ctypes.c_void_p.__mro__ if '_SimpleCData' in t.__name__)
_CData: typing.Type = next(t for t in ctypes.c_void_p.__mro__ if '_CData' in t.__name__)
def _mono2py(t: MonoTypeEnum):
... | 2,863 | Python | .py | 86 | 29.302326 | 100 | 0.69214 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,075 | __init__.py | nyaoouo_NyLib2/nylib/mono/__init__.py | import ctypes
import enum
import functools
import typing
from .defines import *
from .defines import _MonoObj
from .type_cast import py2mono, mono2py
class MonoObject_(_MonoObj):
def init(self):
MonoApi.get_instance().mono_runtime_object_init(self.ptr)
@functools.cached_property
def cls(self):
... | 16,720 | Python | .py | 373 | 36.495979 | 128 | 0.650317 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,076 | enums.py | nyaoouo_NyLib2/nylib/mono/defines/enums.py | import enum
class MonoTypeEnum(enum.IntEnum):
END = 0x00 # End of List
VOID = 0x01
BOOLEAN = 0x02
CHAR = 0x03
I1 = 0x04
U1 = 0x05
I2 = 0x06
U2 = 0x07
I4 = 0x08
U4 = 0x09
I8 = 0x0a
U8 = 0x0b
R4 = 0x0c
R8 = 0x0d
STRING = 0x0e
PTR = 0x0f # arg: <type> tok... | 11,950 | Python | .py | 310 | 35.490323 | 76 | 0.773463 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,077 | __init__.py | nyaoouo_NyLib2/nylib/mono/defines/__init__.py | import ctypes
from nylib import winapi
from .enums import *
class _MonoObj:
def __new__(cls, ptr):
if not ptr:
return None
return super().__new__(cls)
def __init__(self, ptr):
self.ptr = ptr
def __eq__(self, other):
if isinstance(other, _MonoObj):
... | 44,558 | Python | .py | 503 | 80.809145 | 228 | 0.691158 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,078 | __init__.py | nyaoouo_NyLib2/nylib/imguiutils/__init__.py | import typing
from ..pyimgui import imgui
from ..pyimgui.imgui import ctx
_T = typing.TypeVar('_T')
def BeginFullScreenBackGround(name: str = '', open: bool = True, flags: int = 0):
viewport = imgui.GetMainViewport()
cls = imgui.ImGuiWindowClass()
cls.DockNodeFlagsOverrideSet = imgui.ImGuiDockNodeFlags_... | 3,307 | Python | .py | 71 | 34.28169 | 125 | 0.595903 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,079 | __init__.py | nyaoouo_NyLib2/nylib/hook/__init__.py | import ctypes
import typing
from . import detours
class Hook:
def __init__(self, at: int, hook_func, restype: typing.Type = ctypes.c_void_p, argtypes: typing.Iterable[typing.Type] = ()):
"""
创建一个 hook, 注意需要手动调用 install()
:param at: 该函数的内存地址
:param hook_func: 钩子函数
:param r... | 2,670 | Python | .py | 56 | 37.392857 | 221 | 0.659557 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,080 | detours.py | nyaoouo_NyLib2/nylib/hook/detours/detours.py | import ctypes
import os.path
import sys
_dll = ctypes.cdll.LoadLibrary(os.path.join(os.path.dirname(sys.executable if getattr(sys, "frozen", False) else __file__), 'DetoursEx.dll'))
def _make_api(name, restype, argtypes):
if f := getattr(_dll, name, None):
f.restype = restype
f.argtypes = argtype... | 14,279 | Python | .py | 374 | 33.868984 | 141 | 0.695467 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,081 | __init__.py | nyaoouo_NyLib2/nylib/hook/detours/__init__.py | import ctypes
from .detours import *
def check(c):
if c: raise ctypes.WinError(c)
class DetourTransaction:
def __init__(self, set_thread=None):
self.set_thread = set_thread
def __enter__(self):
check(DetourTransactionBegin())
try:
check(DetourUpdateThread(self.set_t... | 660 | Python | .py | 20 | 24.85 | 99 | 0.627172 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,082 | setup_llvm_dev.py | nyaoouo_NyLib2/scripts/setup_llvm_dev.py | import hashlib
import os
import pathlib
import shutil
import subprocess
from nylib.winutils import ensure_env, msvc
os.environ['Path'] += r';D:\tool\cmake-3.29.0-windows-x86_64\bin;'
def file_last_modified(path: pathlib.Path) -> int:
return path.stat().st_mtime_ns
def file_md5(path: pathlib.Path) -> str:
... | 3,886 | Python | .py | 86 | 37.325581 | 142 | 0.601798 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,083 | pyimgui_generate.py | nyaoouo_NyLib2/scripts/pyimgui/pyimgui_generate.py | import io
import json
import os
import pathlib
import re
import shutil
import subprocess
import sys
from nylib.utils.pip import required
from nylib.winutils import ensure_env
from func_wrappers import wrappers as specified_wrappers
class CodeWriter:
class IndentPopper:
def __init__(self, writer, need_pus... | 23,761 | Python | .py | 536 | 34.115672 | 212 | 0.538282 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,084 | pyimgui_test.py | nyaoouo_NyLib2/scripts/pyimgui/pyimgui_test.py | import contextlib
import io
import os
import pathlib
import threading
import time
def get_cat_image(dst, cb=None):
import urllib.request
url = 'https://cataas.com/cat'
buffer = io.BytesIO()
with urllib.request.urlopen(url) as response:
chunk = 128
content_length = response.getheader('C... | 11,557 | Python | .py | 210 | 34.77619 | 185 | 0.498099 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,085 | func_wrappers.py | nyaoouo_NyLib2/scripts/pyimgui/func_wrappers.py | wrappers = {}
def gfunc_todo(func_name):
wrappers[f"_GFUNC_:{func_name}"] = f'/* TODO:{func_name} */'
def gfunc_otsupport(func_name):
wrappers[f"_GFUNC_:{func_name}"] = f'/* NotSupport:{func_name} */'
gfunc_todo("ImFont_CalcTextSizeA")
gfunc_todo("ImFontAtlas_GetTexDataAsAlpha8")
gfunc_todo("ImFontAtlas_G... | 1,323 | Python | .py | 35 | 34.828571 | 81 | 0.712157 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,086 | inject_main.py | nyaoouo_NyLib2/scripts/test_inject/inject_main.py | import contextlib
import os
import pathlib
import sys
import threading
import traceback
import typing
from nylib.winutils.pipe_rpc import RpcServer
if typing.TYPE_CHECKING:
from nylib.pyimgui import imgui
_T = typing.TypeVar('_T')
class Gui(typing.Generic[_T]):
last_io: 'imgui.ImGuiIO' = None
def __ini... | 2,724 | Python | .py | 72 | 29.861111 | 118 | 0.618071 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,087 | test_inject.py | nyaoouo_NyLib2/scripts/test_inject/test_inject.py | import contextlib
import os
import pathlib
import threading
import typing
from nylib.process import Process
from nylib.winutils import enable_privilege, iter_processes
from nylib.winutils.pipe_rpc import RpcClient
from nylib.winutils.python_loader import run_script
from nylib.pyimgui import Dx11Window, imgui
from nyl... | 7,548 | Python | .py | 162 | 33.08642 | 177 | 0.569059 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,088 | client_script.py | nyaoouo_NyLib2/scripts/test_inject/client_script.py | import typing
def reload_all(prefix):
import sys
import importlib
modules = [module for name, module in sys.modules.items() if name == prefix or name.startswith(prefix + '.')]
for module in modules:
importlib.reload(module)
reload_all('nylib.imguiutils')
reload_all('nylib.mono')
from nylib.m... | 2,634 | Python | .py | 63 | 30.539683 | 124 | 0.580595 | nyaoouo/NyLib2 | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,089 | main.py | MNeMoNiCuZ_ImageSorting/main.py | # main.py
import tkinter as tk
from scripts.gui_setup import setup_gui
def main():
root = tk.Tk()
root.title("Image Sorting Tool")
root.geometry("1200x800")
config = {} # Initialize config dictionary here
setup_gui(root, config)
root.mainloop()
if __name__ == "__main__":
main()
| 310 | Python | .py | 12 | 22.333333 | 52 | 0.662162 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,090 | gui_setup.py | MNeMoNiCuZ_ImageSorting/scripts/gui_setup.py | # gui_setup.py
import tkinter as tk
from .menu import setup_menu
from .category_buttons import setup_category_buttons, sort_files # Import sort_files
from .logger import setup_logger, log_info
from .hotkey_utils import bind_hotkeys # Import from hotkey_utils
def setup_gui(root, config):
setup_logger() #... | 3,249 | Python | .py | 59 | 48.457627 | 135 | 0.703055 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,091 | file_manager.py | MNeMoNiCuZ_ImageSorting/scripts/file_manager.py | import os
def scan_folder(folder_path):
images = []
duplicates = []
file_dict = {}
for root, _, files in os.walk(folder_path):
for file in files:
if file.lower().endswith(('.jpg', '.jpeg', '.png', '.webp', '.gif')):
name, ext = os.path.splitext(file)
... | 753 | Python | .py | 20 | 28.95 | 81 | 0.584131 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,092 | image_display.py | MNeMoNiCuZ_ImageSorting/scripts/image_display.py | # image_display.py
from PIL import Image, ImageTk
import tkinter as tk
import os
def format_size(size):
for unit in ['bytes', 'KB', 'MB', 'GB', 'TB']:
if size < 1024.0:
return f"{size:.2f} {unit}"
size /= 1024.0
def display_images(image_frame, thumbnails_frame, images):
if not imag... | 2,405 | Python | .py | 49 | 43.22449 | 179 | 0.686804 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,093 | hotkey_utils.py | MNeMoNiCuZ_ImageSorting/scripts/hotkey_utils.py | # hotkey_utils.py
from .category_buttons import sort_files
def bind_hotkeys(root, config, image_frame, thumbnails_frame):
print("Executing bind_hotkeys...")
for category in config.get("categories", []):
hotkey = category.get("hotkey")
if hotkey:
try:
# Use default a... | 884 | Python | .py | 14 | 52.857143 | 198 | 0.637097 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,094 | config_manager.py | MNeMoNiCuZ_ImageSorting/scripts/config_manager.py | import json
import os
def load_config_file(file_path):
if os.path.exists(file_path):
with open(file_path, 'r') as file:
return json.load(file)
return {}
def save_config_file(config, file_path):
with open(file_path, 'w') as file:
json.dump(config, file, indent=4)
| 305 | Python | .py | 10 | 25.3 | 42 | 0.651877 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,095 | file_operations.py | MNeMoNiCuZ_ImageSorting/scripts/file_operations.py | # file_operations.py
import tkinter as tk
from tkinter import filedialog, messagebox
from .image_display import display_images
from .file_manager import validate_folder
from .logger import log_error, log_info
from .config_manager import load_config_file, save_config_file
from .category_buttons import setup_categ... | 3,353 | Python | .py | 59 | 49.169492 | 120 | 0.699023 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,096 | category_management.py | MNeMoNiCuZ_ImageSorting/scripts/category_management.py | # category_management.py
import tkinter as tk
from tkinter import simpledialog, filedialog, messagebox
from .config_manager import save_config_file
from .category_buttons import setup_category_buttons, add_sorting_button
from .hotkey_utils import bind_hotkeys
VALID_HOTKEYS = list("abcdefghijklmnopqrstuvwxyzABCD... | 4,595 | Python | .py | 73 | 51.958904 | 166 | 0.65618 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,097 | category_buttons.py | MNeMoNiCuZ_ImageSorting/scripts/category_buttons.py | # category_buttons.py
import tkinter as tk
import shutil
import os
from tkinter import messagebox
from .logger import log_error, log_info
from .image_display import display_images as show_images
# Define the number of buttons per row
BUTTONS_PER_ROW = 6 # You can adjust this number as needed
def setup_cat... | 3,970 | Python | .py | 71 | 48.43662 | 171 | 0.684034 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,098 | logger.py | MNeMoNiCuZ_ImageSorting/scripts/logger.py | import logging
def setup_logger():
logging.basicConfig(filename='output.log', level=logging.INFO,
format='%(asctime)s %(levelname)s:%(message)s')
def log_error(message):
logging.error(message)
def log_info(message):
logging.info(message) | 287 | Python | .py | 8 | 28.75 | 72 | 0.664234 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |
2,290,099 | menu.py | MNeMoNiCuZ_ImageSorting/scripts/menu.py | # menu.py
import tkinter as tk
from .file_operations import load_project, save_project_as
from .category_management import add_category, edit_categories
from .file_operations import select_folder
def setup_menu(root, config, image_frame, thumbnails_frame, buttons_frame, console_frame, menu_color):
menu_bar ... | 1,471 | Python | .py | 19 | 72.368421 | 161 | 0.737206 | MNeMoNiCuZ/ImageSorting | 8 | 1 | 8 | GPL-3.0 | 9/5/2024, 10:48:51 PM (Europe/Amsterdam) |