zhicao/dreamzero main
PYTHON
Verdict: BENIGN
Local reference
Suspicious dependency
Inferred
| 1 |
import codecs |
|
| 2 |
from collections import Counter |
|
| 3 |
import fnmatch |
|
| 4 |
import hashlib |
|
| 5 |
import os |
|
| 6 |
import pickle |
Imports Python's pickle serialization module |
| 7 |
from typing import Any, Callable, Dict, List, Optional, Union |
|
| 8 |
|
|
| 9 |
from typing_extensions import Literal |
|
| 10 |
|
|
| 11 |
|
|
| 12 |
def set_os_envs(envs: Op… |
|
| 13:8 |
… |
|
| 14 |
Special value __delete__ or None indicates that the ENV_VAR should be removed |
|
| 15 |
""" |
|
| 16 |
if envs is None: |
|
| 17 |
envs = {} |
|
| 18 |
DEL = {None, "__delete__"} |
|
| 19 |
for k, v in envs.items(): |
|
| 20 |
if v in DEL: |
|
| 21 |
os.environ.pop(k, None) |
|
| 22 |
os.environ.update({k: str(v) for k, v in envs.items() if v not in DEL}) |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
def … |
|
| 29:3 |
…f _match_patterns_helper(element, patterns): |
|
| 30 |
for p in patterns: |
|
| 31 |
if callable(p) and p(element): |
|
| 32 |
return True |
|
| 33 |
if fnmatch.fnmatch(element, p): |
|
| 34 |
return … |
|
| 205:4 |
…OBAL_NTIMES_COUNTER = Counter() |
|
| 206 |
|
|
| 207 |
|
|
| 208 |
def global_once(name): |
|
| 209 |
""" |
|
| 210 |
Try this to automate the name: |
|
| 211 |
https://gist.github.com/techtonik/2151727#gistcomment-2333747 |
|
| 212 |
""" |
|
| 213 |
if name in _GLOBAL_ONCE_SET: |
|
| 214 |
return False |
|
| 215 |
else: |
|
| 216 |
_GLOBAL_ONCE_SET.add(name) |
|
| 217 |
return True |
|
| 218 |
|
|
| 219 |
|
|
| 220 |
def… |
|
| 246:40 |
…bj), "base64").decode() |
|
| 247 |
|
|
| 248 |
|
|
| 249 |
def decode_base64(s: str): |
|
| 250 |
return pickle.loads(codecs.decode(s.encode(), "base64")) |
codecs.decode with base64 encoding (Python) |
| 251 |
|
|
| 252 |
|
|
| 253 |
def safe_hash(input_tuple): |
|
| 254 |
# keep 128 bits of the hash |
|
| 255 |
tuple_string = repr(input_tuple).encode("utf-8") |
|
| 256 |
sha256 = hashlib.sha256() |
|
| 257 |
sha256.update(tuple_string) |
|
| 258 |
|
|
| 259 |
seed = int(sha256.hexdigest(), 16) |
|
| 260 |
|
|
| 261 |
return seed & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
|
Micro-behaviors
| 205:4 |
…OBAL_NTIMES_COUNTER = Counter() |
|
| 206 |
|
|
| 207 |
|
|
| 208 |
def global_once(name): |
|
| 209 |
""" |
|
| 210 |
Try this to automate the name: |
|
| 211 |
https://gist.github.com/techtonik/2151727#gistcomment-2333747 |
|
| 212 |
""" |
|
| 213 |
if name in _GLOBAL_ONCE_SET: |
|
| 214 |
return False |
|
| 215 |
else: |
|
| 216 |
_GLOBAL_ONCE_SET.add(name) |
|
| 217 |
return True |
|
| 218 |
|
|
| 219 |
|
|
| 220 |
def… |
|
| 246:40 |
…bj), "base64").decode() |
|
| 247 |
|
|
| 248 |
|
|
| 249 |
def decode_base64(s: str): |
|
| 250 |
return pickle.loads(codecs.decode(s.encode(), "base64")) |
|
| 251 |
|
|
| 252 |
|
|
| 253 |
def safe_hash(input_tuple): |
|
| 254 |
# keep 128 bits of the hash |
|
| 255 |
tuple_string = repr(input_tuple).encode("utf-8") |
|
| 256 |
sha256 = hashlib.sha256() |
|
| 257 |
sha256.update(tuple_string) |
|
| 258 |
|
|
| 259 |
seed = int(sha256.hexdigest(), 16) |
|
| 260 |
|
|
| 261 |
return seed & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
|
| 246:40 |
…bj), "base64").decode() |
|
| 247 |
|
|
| 248 |
|
|
| 249 |
def decode_base64(s: str): |
|
| 250 |
return pickle.loads(codecs.decode(s.encode(), "base64")) |
|
| 251 |
|
|
| 252 |
|
|
| 253 |
def safe_hash(input_tuple): |
|
| 254 |
# keep 128 bits of the hash |
|
| 255 |
tuple_string = repr(input_tuple).encode("utf-8") |
|
| 256 |
sha256 = hashlib.sha256() |
|
| 257 |
sha256.update(tuple_string) |
|
| 258 |
|
|
| 259 |
seed = int(sha256.hexdigest(), 16) |
|
| 260 |
|
|
| 261 |
return seed & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
|
| 246:40 |
…bj), "base64").decode() |
|
| 247 |
|
|
| 248 |
|
|
| 249 |
def decode_base64(s: str): |
|
| 250 |
return pickle.loads(codecs.decode(s.encode(), "base64")) |
|
| 251 |
|
|
| 252 |
|
|
| 253 |
def safe_hash(input_tuple): |
|
| 254 |
# keep 128 bits of the hash |
|
| 255 |
tuple_string = repr(input_tuple).encode("utf-8") |
|
| 256 |
sha256 = hashlib.sha256() |
|
| 257 |
sha256.update(tuple_string) |
|
| 258 |
|
|
| 259 |
seed = int(sha256.hexdigest(), 16) |
|
| 260 |
|
|
| 261 |
return seed & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
|
| 246:40 |
…bj), "base64").decode() |
|
| 247 |
|
|
| 248 |
|
|
| 249 |
def decode_base64(s: str): |
|
| 250 |
return pickle.loads(codecs.decode(s.encode(), "base64")) |
|
| 251 |
|
|
| 252 |
|
|
| 253 |
def safe_hash(input_tuple): |
|
| 254 |
# keep 128 bits of the hash |
|
| 255 |
tuple_string = repr(input_tuple).encode("utf-8") |
|
| 256 |
sha256 = hashlib.sha256() |
|
| 257 |
sha256.update(tuple_string) |
|
| 258 |
|
|
| 259 |
seed = int(sha256.hexdigest(), 16) |
|
| 260 |
|
|
| 261 |
return seed & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
|
| 1 |
import codecs |
|
| 2 |
from collections import Counter |
|
| 3 |
import fnmatch |
|
| 4 |
import hashlib |
|
| 5 |
import os |
|
| 6 |
import pickle |
|
| 7 |
from typing import Any, Callable, Dict, List, Optional, Union |
|
| 8 |
|
|
| 9 |
from typing_extensions import Literal |
|
| 10 |
|
|
| 11 |
|
|
| 12 |
def set_os_envs(envs: Op… |
|
Metadata
| 13:8 |
… |
|
| 14 |
Special value __delete__ or None indicates that the ENV_VAR should be removed |
|
| 15 |
""" |
|
| 16 |
if envs is None: |
|
| 17 |
envs = {} |
|
| 18 |
DEL = {None, "__delete__"} |
|
| 19 |
for k, v in envs.items(): |
|
| 20 |
if v in DEL: |
|
| 21 |
os.environ.pop(k, None) |
|
| 22 |
os.environ.update({k: str(v) for k, v in envs.items() if v not in DEL}) |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
def … |
|
| 205:4 |
…OBAL_NTIMES_COUNTER = Counter() |
|
| 206 |
|
|
| 207 |
|
|
| 208 |
def global_once(name): |
|
| 209 |
""" |
|
| 210 |
Try this to automate the name: |
|
| 211 |
https://gist.github.com/techtonik/2151727#gistcomment-2333747 |
|
| 212 |
""" |
|
| 213 |
if name in _GLOBAL_ONCE_SET: |
|
| 214 |
return False |
|
| 215 |
else: |
|
| 216 |
_GLOBAL_ONCE_SET.add(name) |
|
| 217 |
return True |
|
| 218 |
|
|
| 219 |
|
|
| 220 |
def… |
|
| 29:3 |
…f _match_patterns_helper(element, patterns): |
|
| 30 |
for p in patterns: |
|
| 31 |
if callable(p) and p(element): |
|
| 32 |
return True |
|
| 33 |
if fnmatch.fnmatch(element, p): |
|
| 34 |
return … |
|
Identity
| SHA-256 |
11f4727106c200784f7ded2d2e10ee03e2159cc12de184182e229a6b253aa96e |
| Filename |
misc_utils.py |
| Package |
zhicao/dreamzero |
| Version |
main |
| PURL |
pkg:huggingface/zhicao/dreamzero@main |
Timeline
| First seen |
13 Aug 2026 21:18 UTC |
| First analyzed |
29 Aug 2026 10:45 UTC |
| Last analyzed |
29 Aug 2026 10:45 UTC |
| Last updated |
29 Aug 2026 10:45 UTC |
Labeling
| Label |
unknown |
| Label source |
forager |
| Traits version |
b59b7 |