Browse Source

validate config file for empty lines (closes #24)

Signed-off-by: r4sas <r4sas@i2pmail.org>
dependabot/add-v2-config-file
R4SAS 4 years ago
parent
commit
5909e7330b
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 8
      pbincli/actions.py
  2. 7
      pbincli/cli.py
  3. 2
      setup.py

8
pbincli/actions.py

@ -1,5 +1,13 @@ @@ -1,5 +1,13 @@
from pbincli.format import Paste
from pbincli.utils import PBinCLIError
import signal
def signal_handler(sig, frame):
print('Keyboard interrupt received, terminating...')
exit(0)
signal.signal(signal.SIGINT, signal_handler)
def send(args, api_client, settings=None):
from pbincli.api import Shortener

7
pbincli/cli.py

@ -3,7 +3,7 @@ import os, sys, argparse @@ -3,7 +3,7 @@ import os, sys, argparse
import pbincli.actions
from pbincli.api import PrivateBin
from pbincli.utils import PBinCLIException, validate_url
from pbincli.utils import PBinCLIException, PBinCLIError, validate_url
CONFIG_PATHS = [os.path.join(".", "pbincli.conf", ),
os.path.join(os.getenv("HOME") or "~", ".config", "pbincli", "pbincli.conf") ]
@ -13,8 +13,13 @@ def read_config(filename): @@ -13,8 +13,13 @@ def read_config(filename):
settings = {}
with open(filename) as f:
for l in f.readlines():
if len(l.strip()) == 0:
continue
try:
key, value = l.strip().split("=")
settings[key.strip()] = value.strip()
except ValueError as pe:
PBinCLIError("Unable to parse config file, please check it for errors.")
return settings

2
setup.py

@ -17,7 +17,7 @@ setup( @@ -17,7 +17,7 @@ setup(
long_description_content_type='text/x-rst',
author='R4SAS',
author_email='r4sas@i2pmail.org',
url='https://github.com/r4sas/PBinCLI',
url='https://github.com/r4sas/PBinCLI/',
keywords='privatebin cryptography security',
license='MIT',
classifiers=[

Loading…
Cancel
Save