Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the black tool #29

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Run the black tool

  • Loading branch information
Cereal2nd committed Oct 12, 2019
commit 44f4ba209aef52b7d5ccb3b2e08f8a799783bc4c
@@ -22,11 +22,11 @@

print(sys.path)

#sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('.'))

#print(sys.path)
# print(sys.path)

sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))

print(sys.path)

@@ -39,38 +39,40 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.imgmath',
'sphinx.ext.viewcode']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.imgmath",
"sphinx.ext.viewcode",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'python-velbus'
copyright = '2011, Thomas Delaet'
author = 'Thomas Delaet'
project = "python-velbus"
copyright = "2011, Thomas Delaet"
author = "Thomas Delaet"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.12'
version = "0.12"
# The full version, including alpha/beta/rc tags.
release = '0.12'
release = "0.12"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -85,7 +87,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
@@ -96,7 +98,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
# html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -107,25 +109,25 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
"**": [
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'python-velbusdoc'
htmlhelp_basename = "python-velbusdoc"


# -- Options for LaTeX output ---------------------------------------------
@@ -134,15 +136,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
@@ -152,19 +151,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'python-velbus.tex', 'python-velbus Documentation',
'Thomas Delaet', 'manual'),
(
master_doc,
"python-velbus.tex",
"python-velbus Documentation",
"Thomas Delaet",
"manual",
)
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'python-velbus', 'python-velbus Documentation',
[author], 1)
]
man_pages = [(master_doc, "python-velbus", "python-velbus Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
@@ -173,10 +174,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'python-velbus', 'python-velbus Documentation',
author, 'python-velbus', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"python-velbus",
"python-velbus Documentation",
author,
"python-velbus",
"One line description of project.",
"Miscellaneous",
)
]



@@ -1 +1 @@
pyserial==3.3
pyserial == 3.3
@@ -1,16 +1,17 @@
from setuptools import setup

with open('README.md') as file:
with open("README.md") as file:
long_description = file.read()

setup(name='python-velbus',
version='2.0.28',
url='https://github.com/thomasdelaet/python-velbus',
license='MIT',
author='Thomas Delaet',
install_requires=["pyserial==3.3"],
author_email='thomas@delaet.org',
description="Python Library for the Velbus protocol",
packages=['velbus', 'velbus.connections', 'velbus.messages', 'velbus.modules'],
platforms='any',
setup(
name="python-velbus",
version="2.0.28",
url="https://github.com/thomasdelaet/python-velbus",
license="MIT",
author="Thomas Delaet",
install_requires=["pyserial==3.3"],
author_email="thomas@delaet.org",
description="Python Library for the Velbus protocol",
packages=["velbus", "velbus.connections", "velbus.messages", "velbus.modules"],
platforms="any",
)
@@ -3,8 +3,8 @@
"""
from velbus.module_registry import MODULE_DIRECTORY

class CommandRegistry:

class CommandRegistry:
def __init__(self, module_directory):
self._module_directory = module_directory
self._default_commands = {}
@@ -16,7 +16,14 @@ def register_command(self, command_value, command_class, module_name=0):
assert isinstance(command_class, type)
assert module_name in self._module_directory.values() or module_name == 0
if module_name:
module_type = next((mtype for mtype, mname in self._module_directory.items() if mname == module_name), None)
module_type = next(
(
mtype
for mtype, mname in self._module_directory.items()
if mname == module_name
),
None,
)
self._register_override(command_value, command_class, module_type)
else:
self._register_default(command_value, command_class)
@@ -51,8 +58,10 @@ def get_command(self, command_value, module_type=0):
if command_value in self._default_commands:
return self._default_commands[command_value]


commandRegistry = CommandRegistry(MODULE_DIRECTORY)


def register_command(command_value, command_class, module_type=0):
"""
:return: None
@@ -2,6 +2,7 @@
:author: Thomas Delaet <thomas@delaet.org>
"""


class VelbusConnection(object):
"""
Generic Velbus connection
@@ -11,6 +11,7 @@
from velbus.util import VelbusException
from velbus.message import Message


class Protocol(serial.threaded.Protocol):
"""Serial protocol."""

@@ -40,28 +41,33 @@ class VelbusUSBConnection(VelbusConnection):

def __init__(self, device, controller=None):
VelbusConnection.__init__(self)
self.logger = logging.getLogger('velbus')
self.logger = logging.getLogger("velbus")
self._device = device
self.controller = controller
try:
self.serial = serial.Serial(port=device,
baudrate=self.BAUD_RATE,
bytesize=self.BYTE_SIZE,
parity=self.PARITY,
stopbits=self.STOPBITS,
xonxoff=self.XONXOFF,
rtscts=self.RTSCTS)
self.serial = serial.Serial(
port=device,
baudrate=self.BAUD_RATE,
bytesize=self.BYTE_SIZE,
parity=self.PARITY,
stopbits=self.STOPBITS,
xonxoff=self.XONXOFF,
rtscts=self.RTSCTS,
)
except serial.serialutil.SerialException:
self.logger.error("Could not open serial port, \
no messages are read or written to the bus")
self.logger.error(
"Could not open serial port, \
no messages are read or written to the bus"
)
raise VelbusException("Could not open serial port")
self._reader = serial.threaded.ReaderThread(self.serial, Protocol)
self._reader.start()
self._reader.protocol.parser = self.feed_parser
self._reader.connect()
self._write_queue = Queue()
self._write_process = threading.Thread(None, self.write_daemon,
"write_packets_process", (), {})
self._write_process = threading.Thread(
None, self.write_daemon, "write_packets_process", (), {}
)
self._write_process.daemon = True
self._write_process.start()

@@ -10,36 +10,44 @@
from velbus.util import VelbusException
from velbus.message import Message


class SocketConnection(VelbusConnection):
"""
Wrapper for Socket connection configuration
:author: Maikel Punie <maikel.punie@gmail.com>
"""

SLEEP_TIME = 60 / 1000

def __init__(self, device, controller=None):
VelbusConnection.__init__(self)
self.logger = logging.getLogger('velbus')
self.logger = logging.getLogger("velbus")
self._device = device
self.controller = controller
# get the address from a <host>:<port> format
addr = device.split(':')
addr = device.split(":")
addr = (addr[0], int(addr[1]))
try:
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.connect(addr)
except Exception:
self.logger.error("Could not open socket, \
no messages are read or written to the bus")
self.logger.error(
"Could not open socket, \
no messages are read or written to the bus"
)
raise VelbusException("Could not open socket port")
# build a read thread
self._listen_process = threading.Thread(None, self.read_daemon, "velbus-process-reader", (), {})
self._listen_process = threading.Thread(
None, self.read_daemon, "velbus-process-reader", (), {}
)
self._listen_process.daemon = True
self._listen_process.start()

# build a writer thread
self._write_queue = Queue()
self._write_process = threading.Thread(None, self.write_daemon, "velbus-connection-writer", (), {})
self._write_process = threading.Thread(
None, self.write_daemon, "velbus-connection-writer", (), {}
)
self._write_process.daemon = True
self._write_process.start()

@@ -1,21 +1,20 @@

MINIMUM_MESSAGE_SIZE = 6

MAXIMUM_MESSAGE_SIZE = MINIMUM_MESSAGE_SIZE + 8

START_BYTE = 0x0f
START_BYTE = 0x0F

END_BYTE = 0x04

HIGH_PRIORITY = 0xf8
FIRMWARE_PRIORITY = 0xf9
THIRD_PARTY_PRIORITY = 0xfa
LOW_PRIORITY = 0xfb
PRIORITY = [HIGH_PRIORITY, FIRMWARE_PRIORITY, THIRD_PARTY_PRIORITY, LOW_PRIORITY]
HIGH_PRIORITY = 0xF8
FIRMWARE_PRIORITY = 0xF9
THIRD_PARTY_PRIORITY = 0xFA
LOW_PRIORITY = 0xFB
PRIORITY = [HIGH_PRIORITY, FIRMWARE_PRIORITY, THIRD_PARTY_PRIORITY, LOW_PRIORITY]

LOW_ADDRESS = 0x00

HIGH_ADDRESS = 0xff
HIGH_ADDRESS = 0xFF

RTR = 0x40

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.