Issues (105)

personroles/resources/mop_tinyDB.py (5 issues)

1
#!/usr/bin/env python
0 ignored issues
show
Coding Style Naming introduced by
Module name "mop_tinyDB" doesn't conform to snake_case naming style ('[^\\W\\dA-Z][^\\WA-Z]*$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
2
# -*- coding: utf-8 -*-
3
"""A wrapper class for the mops database"""
4
import os
5
import sys
6
7
PACKAGE_PARENT = ".."
8
SCRIPT_DIR = os.path.dirname(
9
    os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))
10
)  # isort:skip # noqa # pylint: disable=wrong-import-position
11
sys.path.append(
12
    os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT))
13
)  # isort: skip # noqa # pylint: disable=wrong-import-position
14
15
import tinydb  # type: ignore # isort: skip # noqa # pylint: disable=wrong-import-position
0 ignored issues
show
Unable to import 'tinydb'
Loading history...
16
17
18
class MopsDB():
0 ignored issues
show
Missing class docstring
Loading history...
19
20
    def __init__(self, db_path):
21
        self._db = tinydb.TinyDB(db_path + "mop_db.json")
22
23
    def join(self, mop):
0 ignored issues
show
Missing function or method docstring
Loading history...
24
        mop_key = self._db.insert(mop.__dict__)
25
        mop.key = mop_key
26
        self._db.update(mop, doc_key=[mop_key])
27
        return mop_key
28
29
    def fetch(self, mop_key):
0 ignored issues
show
Missing function or method docstring
Loading history...
30
        return self._db.get(doc_key=mop_key)
31