This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
import time | |
from asyncio import run | |
from binascii import hexlify | |
from pathlib import Path | |
from ipv8.configuration import ConfigBuilder, WalkerDefinition, Strategy, default_bootstrap_defs | |
from ipv8.peerdiscovery.community import DiscoveryCommunity | |
from ipv8.peerdiscovery.network import PeerObserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from typing import Type, TypeVar, cast | |
from pony.orm import Database | |
from pony.orm.core import EntityMeta # This is a "secret" import | |
class UnboundEntityMeta(EntityMeta): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
In this example we have the `important_protection` fixture, | |
that SHOULD be called. It triggers "redefined-outer-name (W0621)" and | |
"Redefining name '...' from outer scope". | |
This example shows that two types of errors could have been prevented | |
by following the suggested Pylint definition, instead of ignoring the | |
warning. | |
## The suggested definition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from asyncio import StreamReader, StreamWriter, StreamReaderProtocol, get_running_loop, Transport | |
from typing import Mapping, Any | |
from ipv8.community import Community | |
from ipv8.messaging.lazy_payload import vp_compile, VariablePayload | |
from ipv8.peer import Peer | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python Dependency Find Version (pydepfindver.py) | |
============================================= | |
Brute force all known versions of your pip dependencies to see which ones work for your project. | |
- Includes html report functionality. | |
- Stores (intermediate) results in files so you can resume or quickly update for new releases of dependencies. | |
- Uses venv. | |
An example for https://github.com/Tribler/py-ipv8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from asyncio import ensure_future, get_event_loop | |
from pyipv8.ipv8_service import IPv8 | |
from pyipv8.ipv8.configuration import get_default_configuration | |
async def start_ipv8(): | |
# Create an IPv8 object with the default settings. | |
ipv8 = IPv8(get_default_configuration()) | |
await ipv8.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
from attestation_tutorial_common import finish, http_get, http_post, start, urlstr, wait_for_list | |
# Remove the output of previous experiments. | |
if os.path.exists('./state_1'): | |
shutil.rmtree('./state_1') | |
if os.path.exists('./state_2'): | |
shutil.rmtree('./state_2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
from attestation_tutorial_common import finish, http_get, http_post, start, urlstr, wait_for_list | |
# Remove the output of previous experiments. | |
if os.path.exists('./state_1'): | |
shutil.rmtree('./state_1') | |
if os.path.exists('./state_2'): | |
shutil.rmtree('./state_2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import six | |
from six.moves import xrange | |
class String(six.text_type): | |
@staticmethod | |
def as_raw_unicode(value=u""): | |
if isinstance(value, six.text_type): | |
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis, os, struct, sys | |
from six import integer_types | |
unary_ops = { | |
'UNARY_POSITIVE': '+%s', | |
'UNARY_NEGATIVE': '-%s', | |
'UNARY_NOT': 'not %s', | |
'UNARY_CONVERT': '`%s`', |
NewerOlder