Skip to content

Commit

Permalink
Merge branch 'release-0.2.0'
Browse files Browse the repository at this point in the history
claire-lex committed Jul 28, 2020
2 parents aac56b0 + 549656b commit 1ab68bb
Showing 20 changed files with 1,122 additions and 1,094 deletions.
7 changes: 7 additions & 0 deletions bof/__init__.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,11 @@
The content of this class should not be used directly, unless writing a
new protocol submodule. Available from direct bof import (``import bof``)
:frame:
Generic frame representation as objects within BOF. Classes from this
submodule should be inherited by protocol implementations, but they should
not be used directly by the end user.
:byte:
Set of functions for byte conversion and handling. Accessed via import of
the byte submodule (``from bof import byte``).
@@ -31,4 +36,6 @@

from .base import *
from .network import *
from .frame import *
from .byte import *
from .spec import *
18 changes: 1 addition & 17 deletions bof/base.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
"""

import logging
import json
from datetime import datetime
from re import sub

@@ -102,25 +101,10 @@ def log(message:str, level:str="INFO") -> bool:
logging.log(level, message)
return _LOGGING_ENABLED

###############################################################################
# BOF JSON FILE HANDLING #
###############################################################################

def load_json(filename:str) -> dict:
"""Loads a JSON file and returns the associated dictionary.
:raises BOFLibraryError: if the file cannot be opened.
"""
try:
with open(filename, 'r') as jsonfile:
return json.load(jsonfile)
except Exception as e:
raise BOFLibraryError("JSON File {0} cannot be used.".format(filename)) from None

###############################################################################
# STRING MANIPULATION #
###############################################################################

def to_property(value:str) -> str:
"""Replace all non alphanumeric characters in a string with ``_``"""
return sub('[^0-9a-zA-Z]+', '_', value)
return sub('[^0-9a-zA-Z]+', '_', value.lower())
Loading

0 comments on commit 1ab68bb

Please sign in to comment.