Skip to content

Commit eb2ac4c

Browse files
initial PyPi package release
1 parent 67430e3 commit eb2ac4c

File tree

11 files changed

+108
-29
lines changed

11 files changed

+108
-29
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Contributing
22

33
When contributing to this repository, please first discuss the change you wish to make via issue,
4-
email, or any other method with the owners of this repository before making a change.
4+
email, or any other method with the owners of this repository before making a change.
55

66
Please note we have a code of conduct, please follow it in all your interactions with the project.
77

88
## Pull Request (PR) Process
99

10-
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11-
build.
12-
2. Update the README.md with details of changes to the interface, this includes new environment
13-
variables, exposed ports, useful file locations and container parameters.
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
11+
2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
1412
3. Address the PR to us, we care about further steps like versioning etc.
1513

1614
## Code of Conduct
@@ -37,8 +35,7 @@ include:
3735

3836
Examples of unacceptable behavior by participants include:
3937

40-
* The use of sexualized language or imagery and unwelcome sexual attention or
41-
advances
38+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
4239
* Trolling, insulting/derogatory comments, and personal or political attacks
4340
* Public or private harassment
4441
* Publishing others' private information, such as a physical or electronic

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# python-sdk
2+
23
Python SDK is a connector library for the insanely fast HEXONET backend API.

__init__.py renamed to hexonet/apiconnector/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
from ispapi.connection import Connection
2-
from ispapi.response import Response
1+
from apiconnector.connection import Connection
2+
from apiconnector.response import Response
3+
4+
__version__ = '1.0.0'
5+
name = "apiconnector"
36

47
def connect(login=None, password=None, url=None, entity=None, user=None, role=None, config=None):
58
"""
6-
Returns an instance of ispapi.Connection
9+
Returns an instance of apiconnector.Connection
710
"""
811

912
if config == None:

connection.py renamed to hexonet/apiconnector/connection.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import ispapi.util
21
import urllib
2+
import apiconnector.util
3+
from apiconnector.response import Response
34
try:
45
# For Python 3.0 and later
56
from urllib.request import urlopen
67
except ImportError:
78
# Fall back to Python 2's urllib2
89
from urllib2 import urlopen
9-
from ispapi.response import Response
10+
try:
11+
# For Python 3.0 and later
12+
from urllib import parse as urlparse
13+
except ImportError:
14+
# Fall back to Python 2
15+
from urlparse import urlparse
1016

1117

1218
"""
13-
ISPAPI Connection
19+
APICONNECTOR Connection
1420
1521
"""
1622
class Connection:
@@ -37,15 +43,8 @@ def call_raw_http(self, command, config = None):
3743
if ('role' in self._config):
3844
post['s_login'] = self._config['login'] + "!" + self._config['role']
3945

40-
post['s_command'] = ispapi.util.command_encode(command)
41-
42-
try:
43-
# For Python 3.0 and later
44-
post = urllib.parse.urlencode(post)
45-
except:
46-
# Fall back to Python 2's urllib2
47-
post = urllib.urlencode(post)
48-
46+
post['s_command'] = apiconnector.util.command_encode(command)
47+
post = urlparse.urlencode(post)
4948
response = urlopen(self._config['url'], post.encode('UTF-8'))
5049
content = response.read()
5150
return content

response.py renamed to hexonet/apiconnector/response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ispapi.util
1+
import apiconnector.util
22

33
"""
4-
ISPAPI Response
4+
APICONNECTOR Response
55
66
"""
77
class Response:
@@ -41,7 +41,7 @@ def as_hash(self):
4141
Returns the response as a hash
4242
"""
4343
if self._response_hash == None:
44-
self._response_hash = ispapi.util.response_to_hash(self._response_string)
44+
self._response_hash = apiconnector.util.response_to_hash(self._response_string)
4545
return self._response_hash
4646

4747

@@ -50,7 +50,7 @@ def as_list_hash(self):
5050
Returns the response as a list hash
5151
"""
5252
if self._response_list_hash == None:
53-
self._response_list_hash = ispapi.util.response_to_list_hash(self.as_hash())
53+
self._response_list_hash = apiconnector.util.response_to_list_hash(self.as_hash())
5454
return self._response_list_hash
5555

5656

util.py renamed to hexonet/apiconnector/util.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import re
22
from datetime import datetime
33
import time
4-
import urllib
4+
try:
5+
# For Python 3.0 and later
6+
from urllib import parse as urlparse
7+
except ImportError:
8+
# Fall back to Python 2
9+
from urlparse import urlparse
510
import base64
611

712

@@ -152,13 +157,13 @@ def url_encode(string):
152157
URL-encodes string
153158
This function is convenient when encoding a string to be used in a query part of a URL
154159
"""
155-
return urllib.quote(string)
160+
return urlparse.quote(string)
156161

157162
def url_decode(string):
158163
"""
159164
Decodes URL-encoded string Decodes any %## encoding in the given string.
160165
"""
161-
return urllib.unquote(string)
166+
return urlparse.unquote(string)
162167

163168
def base64_encode(string):
164169
"""

scripts/createdistribution.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
python setup.py sdist bdist_wheel

scripts/uploaddistribution_live.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
twine upload dist/*

scripts/uploaddistribution_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

setup.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[bdist_wheel]
2+
universal=1
3+
4+
[metadata]
5+
license_file = LICENSE
6+
7+
[pep8]
8+
max-line-length = 120
9+
10+
[flake8]
11+
max-line-length = 120
12+
ignore = F401,E402,F403
13+
exclude = venv

0 commit comments

Comments
 (0)