semvec/pypi-packages huggingface dataset:
systemd-socketserver 1.0
Socket server implementation that works with systemd socket activation
Requires Python: >=3

# systemd-socketserver

_systemd-socketserver_ is a simple Python 3 package that provides the `SystemdSocketServer` class,
a socket server implementation that works in tandem with systemd's socket activation feature.

Very useful for writing basic socket activated daemons.

### Installation

Install from PyPi:

    pip install systemd-socketserver

Or clone from Git and install from source:

    setup.py install

### Basic Usage

For a full example see the `example` directory.

The following Python module, when activated via `.socket` unit, will echo the first sent line to the socket
then disconnect.

    class EchoHandler(socketserver.StreamRequestHandler):
        def handle(self):
            self.data = self.rfile.readline()
            self.wfile.write(self.data.upper())

    server = systemd_socketserver.listen_server(EchoHandler)

    if server is None:
        print('this example only supports socket activation', file=sys.stderr)
        return

    server.listen_forever()


### Features:

* Supports and auto detects both listen and accept sockets (`Accept=true|false` in the `.socket` unit)
* Supports named file descriptors, making it easy to bind different handlers to different sockets.

    This feature relies on functionality currently not present in the most recent package release of
    [python-systemd](https://github.com/systemd/python-systemd), namely the `listen_fds_with_names` function.
    Calling `listen_servers_with_names` will throw a `NotImplementedException` in this case.

    Building python-systemd from source will include support for `listen_fds_with_names` and hence this feature
    will work.

    For an example of this functionality see the code in the `example` directory.


### Known Limitations

* This module has only been tested with INET sockets.
* Better documentation TODO.
cpcctool 0.0.3
CPCC Tool.
Requires Python: >=3.6

# cpcc-tool
Some method for Software copyright application in China, including the generation of source code Word documents, source code statistics, etc.

```
pip install cpcctool
```

**Example: Generate documentation for the first and last 40 pages of source code**

```python
  import uuid
  import os
  from cpcctool import gen_code_docx, docx_first_40_pages, docx_last_40_pages
  src_dirs = [
    r"F:\workspace\xxx\code1\",
    r"F:\workspace\xxx\code2\"
  ]
  dst_file = str(uuid.uuid4()) + ".docx"
  gen_code_docx(src_dirs, dst_file)
  dst_file = os.path.abspath(dst_file)
  docx_first_n_pages(dst_file, r"xxxSystem XXX V2.0.0 Source Code first 40 pages.docx", 40)
  docx_last_n_pages(dst_file, r"xxxSystem XXX V2.0.0 Source Code last 40 pages.docx", 40)
```

**Example: Statistics source code total lines**

```python
from cpcctool import count_code_lines
src_dirs = [
    r"F:\workspace\xxx\code1\",
    r"F:\workspace\xxx\code2\"
]
cloc_exe = r"F:\workspace\l2m2\cpcc-tool\cloc-1.84.exe"
count = count_code_lines(cloc_exe, src_dirs)
print(count)
```

## Publish to PyPI

```
pip install --user --upgrade setuptools wheel twine
python setup.py sdist bdist_wheel
python -m twine upload dist/*
```

## Reference

- [CLOC](https://github.com/AlDanial/cloc)
- [python-docx](https://python-docx.readthedocs.io/en/latest/)
- [How do I delete a range (pages) in a document using VBA.](https://social.msdn.microsoft.com/Forums/office/en-US/b5b34fd3-e36b-432c-94d2-9c687e273440/how-do-i-delete-a-range-pages-in-a-document-using-vba?forum=worddev)