Skip to content

Commit 15de413

Browse files
committed
Made ready for pypi
1 parent b12e115 commit 15de413

File tree

13 files changed

+280
-2
lines changed

13 files changed

+280
-2
lines changed

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2020 Ben Hack
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# python-message
2-
A small socket wrapper used in my projects
1+
# python-simpleprotocol
2+
A small socket wrapper
3+
4+
Used for sending code, subcode, parameters.
5+
Code: Integer
6+
Subcode: Integer
7+
Params: Array of strings
8+
9+
10+
Only has basic use, as shown in this example:
11+
12+
13+
Server:
14+
15+
```
16+
17+
import simpleprotocol
18+
19+
server = simpleprotocol.SimpleServer(port=8080)
20+
21+
while True:
22+
handler = server.accept()
23+
handler.send(0)
24+
print(handler.get())
25+
handler.send(1)
26+
print(handler.get())
27+
28+
29+
```
30+
31+
Client:
32+
33+
```
34+
35+
import simpleprotocol
36+
37+
socket = simpleprotocol.SimpleProtocol()
38+
39+
if socket.get().code:
40+
socket.send(1, 0, ["That sounds good!"])
41+
else:
42+
socket.send(1, 1, ["Oh dear, that's not right..."])
43+
44+
```

client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import simpleprotocol
2+
3+
socket = simpleprotocol.SimpleProtocol(port=8080)
4+
5+
if socket.get().code:
6+
socket.send(1, 0, ["That sounds good!"])
7+
else:
8+
socket.send(1, 1, ["Oh dear, that's not right..."])
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

server.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import simpleprotocol
2+
3+
server = simpleprotocol.SimpleServer(port=8080)
4+
5+
while True:
6+
handler = server.accept()
7+
handler.send(0)
8+
print(handler.get())
9+
handler = server.accept()
10+
handler.send(1)
11+
print(handler.get())

setup.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import setuptools
2+
3+
with open("README.md", "r") as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name="simpleprotocol", # Replace with your own username
8+
version="1.0.0",
9+
author="Ben Hack",
10+
author_email="[email protected]",
11+
description="A package for using a basic protocol socket",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
url="https://github.com/Chinbob2515/python-message",
15+
packages=setuptools.find_packages(),
16+
classifiers=[
17+
"Programming Language :: Python :: 3",
18+
"License :: OSI Approved :: MIT License",
19+
"Operating System :: OS Independent",
20+
],
21+
python_requires='>=3.6',
22+
)

simpleprotocol/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .simpleprotocol import LOG, SimpleServer, SimpleProtocol
2+
3+
__all__ = [
4+
LOG,
5+
SimpleServer,
6+
SimpleProtocol
7+
]

0 commit comments

Comments
 (0)