Utils format fixes

master
Kevin Froman 2020-08-12 18:07:04 -05:00
parent c9af24392d
commit 2a7c933321
3 changed files with 17 additions and 14 deletions

View File

@ -1,9 +1,9 @@
''' """Onionr - Private P2P Communication.
Onionr - Private P2P Communication
class to access ANSI control codes class to access ANSI control codes
''' """
''' import re
"""
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
@ -16,12 +16,11 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' """
import re
class Colors: class Colors:
''' """ANSI color code collection."""
This class allows you to set the color if ANSI codes are supported
'''
reset='\033[0m' reset='\033[0m'
bold='\033[01m' bold='\033[01m'
disable='\033[02m' disable='\033[02m'
@ -58,3 +57,4 @@ class Colors:
@staticmethod @staticmethod
def filter(data): def filter(data):
return re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]').sub('', str(data)) return re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]').sub('', str(data))

View File

@ -2,6 +2,8 @@
Get the node's Tor hostname Get the node's Tor hostname
""" """
from . import identifyhome
import filepaths
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -16,8 +18,6 @@ Get the node's Tor hostname
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
from . import identifyhome
import filepaths
def get_hostname(): def get_hostname():

View File

@ -31,7 +31,8 @@ class _GetTor:
def get(self): def get(self):
if self.tor_hs is None: if self.tor_hs is None:
try: try:
with open(filepaths.tor_hs_address_file, 'r') as transport_file: with open(filepaths.tor_hs_address_file, 'r') as \
transport_file:
self.tor_hs = transport_file.read().strip() self.tor_hs = transport_file.read().strip()
if not self.tor_hs: if not self.tor_hs:
self.tor_hs = None self.tor_hs = None
@ -39,8 +40,10 @@ class _GetTor:
pass pass
return self.tor_hs return self.tor_hs
_tor_getter = _GetTor() _tor_getter = _GetTor()
def get(): def get():
transports = [_tor_getter.get()] transports = [_tor_getter.get()]
for file in files: for file in files: