Skip to content

Commit

Permalink
Merge pull request #237 from matthewlewis112/onboarding
Browse files Browse the repository at this point in the history
Reformatted code and added black code formatter
  • Loading branch information
matthewlewis112 authored Sep 9, 2020
2 parents bc819c2 + 2bc82df commit 3181c65
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 138 deletions.
42 changes: 21 additions & 21 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ignore=CVS

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# ignore-patterns=

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
Expand Down Expand Up @@ -43,7 +43,7 @@ unsafe-load-any-extension=no

# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=
# confidence=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
Expand Down Expand Up @@ -186,13 +186,13 @@ max-spelling-suggestions=4

# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=
# spelling-dict=

# List of comma separated words that should not be checked.
spelling-ignore-words=
# spelling-ignore-words=

# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=
# spelling-private-dict-file=

# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
Expand All @@ -216,7 +216,7 @@ contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# generated-members=

# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
Expand All @@ -239,7 +239,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local,str
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
ignored-modules=numpy

# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
Expand All @@ -258,7 +258,7 @@ missing-member-max-choices=1

# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
# additional-builtins=

# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
Expand Down Expand Up @@ -343,14 +343,14 @@ argument-naming-style=snake_case

# Regular expression matching correct argument names. Overrides argument-
# naming-style
#argument-rgx=
# argument-rgx=

# Naming style matching correct attribute names
attr-naming-style=snake_case

# Regular expression matching correct attribute names. Overrides attr-naming-
# style
#attr-rgx=
# attr-rgx=

# Bad variable names which should always be refused, separated by a comma
bad-names=foo,
Expand All @@ -371,14 +371,14 @@ class-attribute-naming-style=any
class-naming-style=PascalCase

# Regular expression matching correct class names. Overrides class-naming-style
#class-rgx=
# class-rgx=

# Naming style matching correct constant names
const-naming-style=UPPER_CASE

# Regular expression matching correct constant names. Overrides const-naming-
# style
#const-rgx=
# const-rgx=

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
Expand All @@ -389,7 +389,7 @@ function-naming-style=snake_case

# Regular expression matching correct function names. Overrides function-
# naming-style
#function-rgx=
# function-rgx=

# Good variable names which should always be accepted, separated by a comma
good-names=i,
Expand All @@ -407,25 +407,25 @@ inlinevar-naming-style=any

# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style
#inlinevar-rgx=
# inlinevar-rgx=

# Naming style matching correct method names
method-naming-style=snake_case

# Regular expression matching correct method names. Overrides method-naming-
# style
#method-rgx=
# method-rgx=

# Naming style matching correct module names
module-naming-style=snake_case

# Regular expression matching correct module names. Overrides module-naming-
# style
#module-rgx=
# module-rgx=

# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# name-group=

# Regular expression which should only match function or class names that do
# not require a docstring.
Expand All @@ -440,7 +440,7 @@ variable-naming-style=snake_case

# Regular expression matching correct variable names. Overrides variable-
# naming-style
#variable-rgx=
# variable-rgx=


[IMPORTS]
Expand All @@ -462,15 +462,15 @@ ext-import-graph=

# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# import-graph=

# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
# int-import-graph=

# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# known-standard-library=

# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
Expand Down
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pylint
python-dotenv
pytest
shapely
black
30 changes: 18 additions & 12 deletions src/coms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'''methods neccecary for coms'''
"""methods neccecary for coms"""
import time
import json

class Coms():
'''compartenmentalizes coms functionality and scope'''

class Coms:
"""compartenmentalizes coms functionality and scope"""

configs = None
con_timestamp = 0
gcs_timestamp = 0
Expand All @@ -13,22 +15,23 @@ class Coms():
xbee_callback = None

def __init__(self, configs, xbee_callback):
'''initializes coms object'''
"""initializes coms object"""
self.configs = configs
self.xbee_callback = xbee_callback

sim_file = configs["comm_sim_file"]
self.comm_simulation(sim_file)


def comm_simulation(self, comm_file):
'''Reads through comm simulation file from configs and calls
xbee_callback to simulate radio messages.'''
print('listening for messages')
"""Reads through comm simulation file from configs and calls
xbee_callback to simulate radio messages."""
print("listening for messages")
with open(comm_file, "r") as com_data:
comms = json.load(com_data) # reads the json file
prev_time = 0
for instr in comms: # gets time and message from each json object (instruction)
for (
instr
) in comms: # gets time and message from each json object (instruction)
curr_time = instr["time"]
time.sleep(curr_time - prev_time) # waits for the next instruction
# Send message to xbee_callback
Expand All @@ -37,12 +40,15 @@ def comm_simulation(self, comm_file):


class DummyMessage:
'''Dummy msg class for comm simulation thread to be compatible with xbee_callback function'''
"""Dummy msg class for comm simulation thread to be compatible with xbee_callback function"""

def __init__(self, data=None):
self.data = data # UTF-8 encoded JSON message
self.remote_device = DummyRemoteDevice()


class DummyRemoteDevice:
'''Dummy remote device object for use in DummyMessage'''
"""Dummy remote device object for use in DummyMessage"""

def __init__(self):
self.get_64bit_addr = lambda _: 'comms simulation'
self.get_64bit_addr = lambda _: "comms simulation"
Loading

0 comments on commit 3181c65

Please sign in to comment.