Skip to content

Commit

Permalink
bug fix and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
huntcsg committed Jun 1, 2016
1 parent 878be1f commit cf53cf1
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 58 deletions.
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -146,11 +146,11 @@ brag-util init
::

$ brag-util init --help
usage: brag-util init [-h] [-m {reldb,files,mongodb}] [-c]
usage: brag-util init [-h] [-m {files}] [-c]

optional arguments:
-h, --help show this help message and exit
-m {reldb,files,mongodb}, --mechanism {reldb,files,mongodb}
-m {files}, --mechanism {files}
Select the persistence mechanism. Default: files.
-c, --clobber If set, overwrites existing configuration files.

Expand Down
3 changes: 1 addition & 2 deletions bragly/config.py
Expand Up @@ -23,8 +23,7 @@ def get_config(mechanism=None):
default.
Args:
mechanism (str): The mechanism to use for persistance. One of 'files',
'reldb' (relational database), or 'mongdb'.
mechanism (str): The mechanism to use for persistance. 'files' is the only current valid option.
Returns:
dict: A dictionary of configuration values relevant to the given
Expand Down
2 changes: 0 additions & 2 deletions bragly/config_examples/config-files.ini
@@ -1,7 +1,5 @@
[mechanisms]
files = ON
reldb = OFF
mongodb = OFF

[files]
; The file format that things will be saved in
Expand Down
12 changes: 0 additions & 12 deletions bragly/config_examples/config-mongodb.ini

This file was deleted.

12 changes: 0 additions & 12 deletions bragly/config_examples/config-reldb.ini

This file was deleted.

4 changes: 1 addition & 3 deletions bragly/persist.py
Expand Up @@ -8,13 +8,11 @@
"""

from __future__ import absolute_import, print_function
from bragly.persistance import files, reldb, mongodb
from bragly.persistance import files
from bragly.config import get_config

MECHANISMS = {
'files': files,
'mongodb': mongodb,
'reldb': reldb
}


Expand Down
9 changes: 8 additions & 1 deletion bragly/persistance/files.py
Expand Up @@ -63,7 +63,7 @@ def write(message, file_path=None, file_dir=None, form='json'):
message=message,
)
else:
raise RuntimeError('Form {form} not supported or missing.'.format(form))
raise RuntimeError('Form {form} not supported or missing.'.format(form=form))

file_path = _get_file_path(form, file_path, file_dir)

Expand Down Expand Up @@ -205,6 +205,9 @@ def _coerce_line(parsed_line, out_form):
'tags': parsed_line.tags,
'message': parsed_line.message
}, indent=2).strip()
else:
raise TypeError('form must be one of parsed_line, log, json, or json-pretty. '
'Instead got {form}'.format(form=out_form))


def search(start, end, out_form, tags, text,
Expand All @@ -231,6 +234,8 @@ def search(start, end, out_form, tags, text,
"""
base_results = read(start, end, 'parsed_line', form, file_dir, file_path)
for result in base_results:

# Handle any of the filters matching
if not all_args:
if tags and set(tags).intersection(set(result.tags)):
yield _coerce_line(result, out_form)
Expand All @@ -239,6 +244,8 @@ def search(start, end, out_form, tags, text,
yield _coerce_line(result, out_form)
elif not text and not tags:
yield _coerce_line(result, out_form)

# Handle all filters matching
else:
tags_in_tags = False
text_in_message = False
Expand Down
8 changes: 0 additions & 8 deletions bragly/persistance/mongodb.py

This file was deleted.

8 changes: 0 additions & 8 deletions bragly/persistance/reldb.py

This file was deleted.

8 changes: 0 additions & 8 deletions bragly/tests/test_cli.py
Expand Up @@ -207,14 +207,6 @@ def test_util_init_parsing():
'clobber': True,
},
},
{
'args': 'init --clobber --mechanism reldb',
'result': {
'func': 'init',
'mechanism': 'reldb',
'clobber': True,
},
},
]

for test_case in test_cases:
Expand Down

0 comments on commit cf53cf1

Please sign in to comment.