semvec/pypi-packages huggingface dataset:
pcraft 0.1.4
Pcraft
License: MIT

pCraft
======

pCraft is a PCAP Crafter, which creates a PCAP from a YAML scenario.

When generating data for testing, it is rather hard to do forthe following reasons:
- Lack of consistency between clients and servers
- Make sure no personal data leaks
- Consistency across different services.
- Keeping timing right
- etc.

This program helps solving this problem, one simply creates a script in YAML and the program outputs a PCAP.

Creating a Hello World script
-----------------------------

Create a file called "hello.yaml", we want to add the following content:

```
start: Generate_a_new_domain

Generate_a_new_domain:
  _plugin: GenerateNewDomain
  _next: DNSConnection

DNSConnection:
  _plugin: DNSConnection
  _next: loop-1

loop-1:
  count: 3
  newip: 1 # We get a new IP address for each loop
  _sleep: {"before-start":3,"interval":0.2,"once-finished":0.3}
  _next: done
  _start: DNSConnection # Where our loop starts
```

Now execute the pcraft program:
```
pcrafter hello.yaml hello.pcap
```

Let's read the result pcap using tshark:
```
$ tshark -r hello.pcap 
    1   0.000000 192.168.67.150 → 10.218.175.58 DNS 81 Standard query 0x0000 A masaryk-treasurer.com
    2   0.000552 10.218.175.58 → 192.168.67.150 DNS 118 Standard query response 0x0000 A masaryk-treasurer.com A 199.34.228.66
    3   0.001115 192.168.53.38 → 10.44.21.216 DNS 81 Standard query 0x0000 A masaryk-treasurer.com
    4   0.001529 10.44.21.216 → 192.168.53.38 DNS 118 Standard query response 0x0000 A masaryk-treasurer.com A 199.34.228.66
    5   0.002126 192.168.160.175 → 10.79.78.60  DNS 81 Standard query 0x0000 A masaryk-treasurer.com
    6   0.002531  10.79.78.60 → 192.168.160.175 DNS 118 Standard query response 0x0000 A masaryk-treasurer.com A 199.34.228.66
    7   0.003038 192.168.33.44 → 10.46.101.67 DNS 81 Standard query 0x0000 A masaryk-treasurer.com
    8   0.003439 10.46.101.67 → 192.168.33.44 DNS 118 Standard query response 0x0000 A masaryk-treasurer.com A 199.34.228.66
    9   0.003947 192.168.140.220 → 10.117.63.91 DNS 81 Standard query 0x0000 A masaryk-treasurer.com
   10   0.004350 10.117.63.91 → 192.168.140.220 DNS 118 Standard query response 0x0000 A masaryk-treasurer.com A 199.34.228.66
```

Writing a Scenario
------------------

Please look at the documentation on this topic to understand more about the engine: "[Writing a Scenario][scenario]".


Available Plugins
-----------------

The Plugins documentation is generated from themselves: [Plugins Documentation][plugins]


[scenario]: doc/scenario.md
[plugins]: doc/plugins.md
asyncfile 1.0.0
An asynchronous file handling module.
License: MIT
Requires Python: >=3.6.0
Keywords: python,asyncio,fileio

asyncfile
===========

A simple and up-to-date module that enables compatibility with asyncio and fileIO operations in Python.

Purpose
--------

Operating on files in Python is a synchronous activity. When normally operating on file this does not
cause any problems. However, when files are tampered with in code that also runs the asyncio event
loop, this can cause the `asyncio <https://docs.python.org/3/library/asyncio.html>`_ `event loop <https://docs.python.org/3/library/asyncio-eventloop.html>`_ to block. This negatively effects the program's performance
and should therefore be avoided. The ``asyncfile`` module avoids this problem by running the file operations in a separate
thread so that the event loop is not as harshly affected.

Features
----------

* *async* and *await* syntax is used
* There is almost complete coverage of the `io <https://docs.python.org/3/library/io.html#module-io>`_ module's classes
* The syntax and utility is similar to the built-in Python `open <https://docs.python.org/3/library/functions.html#open>`_ function and the built-in `io <https://docs.python.org/3/library/io.html#module-io>`_ module
* Lightweight in speed and memory

Installation
-----------------

Installing ``asyncfile`` should be done through `PIP <https://pypi.org/project/pip/>`_:

.. code:: sh

    pip install asyncfile


Open Examples
--------------

If you were to have regular, blocking code, you can easily transition it to ``asyncfile``

**Blocking:**

.. code:: py

    with open('fake_file', 'r') as f:
        print(f.read())

**Non-Blocking:**

.. code:: py

    import asyncfile
    import asyncio

    custom_loop = asyncio.get_event_loop() # You can pass in your own loop

    async def open_file():
        async with asyncfile.open('fake_file', 'r', loop=custom_loop) as f:
            print(await f.read())
    
    custom_loop.run_until_complete(open_file())

These both produce the same results, but one is better suited for asyncio-based code.

IO Examples
--------------

**Blocking:**

.. code:: py
    
    import io

    wrap = io.FileIO('fake_file.txt', 'wb')

    buff = io.BufferedReader(wrap)
    buff.write(b'Random bytes')
    print(buff.fileno())
    print(buff.raw)
    print(buff.readable())
    buff.close()

**Non-Blocking:**

.. code:: py

    import asyncfile
    import asyncio

    async def no_block(file_path):
        wrap = asyncfile.AsyncFileIO(file_path, 'rb')
        buff = asyncfile.AsyncBufferedReader(wrap)
        await buff.read(-1)
        print(await buff.fileno())
        print(buff.raw)
        print(await buff.readable())
        await buff.close()
    
    loop = asyncio.get_event_loop()
    loop.run_until_complete(no_block('fake_file.txt'))

**Blocking:**

.. code:: py

    import io

    for i in io.FileIO('fake_file.txt'):
        print(i)

**Non-Blocking:**

.. code:: py

    import asyncfile
    import asyncio

    async def async_iteration():
        async for i in asyncfile.AsyncFileIO('fake_file.txt'):
            print(i)