How to use the tinydb.TinyDB function in tinydb

To help you get started, we’ve selected a few tinydb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github signetlabdei / sem / sem / cli.py View on Github external
def merge(move, output_dir, sources):
    """
    Merge multiple results folder into one, by copying the results over to a new folder.

    For a faster operation (which on the other hand destroys the campaign data
    if interrupted), the move option can be used to directly move results to
    the new folder.
    """
    # Get paths for all campaign JSONS
    jsons = []
    for s in sources:
        filename = "%s.json" % os.path.split(s)[1]
        jsons += [os.path.join(s, filename)]

    # Check that the configuration for all campaigns is the same
    reference_config = TinyDB(jsons[0]).table('config')
    for j in jsons[1:]:
        for i, j in zip(reference_config.all(), TinyDB(j).table('config').all()):
            assert i == j

    # Create folders for new results directory
    filename = "%s.json" % os.path.split(output_dir)[1]
    output_json = os.path.join(output_dir, filename)
    output_data = os.path.join(output_dir, 'data')
    os.makedirs(output_data)

    # Create new database
    db = TinyDB(output_json)
    db.table('config').insert_multiple(reference_config.all())

    # Import results from all databases to the new JSON file
    for s in sources:
github RobotLocomotion / spartan / src / ContactParticleFilter / python / experimentmanager.py View on Github external
def setupExperimentDataFiles(self):
        unique_name = ExperimentManager.makeUniqueName() + "_" + self.config['mode']
        folderName = os.path.join(self.cpfSourceDir, "data", "experiments", unique_name)
        cmd = "mkdir -p " + folderName
        print cmd
        os.system(cmd)

        time.sleep(0.5)


        self.dataFolderName = folderName
        self.db_json = os.path.join(folderName, 'db.json')
        self.db = tinydb.TinyDB(self.db_json)
        # create tinydb database
github tommistolercz / plugin.video.vk / resources / lib / addon.py View on Github external
def clearplayedvideos():  # type: () -> None
    """
    Clear played videos.
    """
    # ask user for confirmation
    if not xbmcgui.Dialog().yesno(
            ADDON.getLocalizedString(30059).encode('utf-8'),
            ADDON.getLocalizedString(30033).encode('utf-8')
    ):
        return
    # purge db table
    db = tinydb.TinyDB(buildfp(FILENAME_DB))
    db.purge_table(DBT_PLAYEDVIDEOS)
    # refresh content
    xbmc.executebuiltin('Container.Refresh()')
github himanshub16 / 21Lane / 21Lane / settings.py View on Github external
def restore_default_settings(self):
		dbase = TinyDB('settings.json')
		dbase.purge()
		dbase.close()
		self.__init__()
github cea-sec / ivre / ivre / db / tiny.py View on Github external
def db_scans(self):
        """The DB for scan files"""
        try:
            return self._db_scans
        except AttributeError:
            self._db_scans = TDB(os.path.join(self.basepath,
                                              "%s.json" % self.dbname_scans))
            return self._db_scans
github mozilla-services / GitHub-Audit / report_branch_status.py View on Github external
def main(driver=None):
    args = parse_args()
    repo_status = []
    with tinydb.TinyDB(args.infile[0].name) as db:
        gh = db.table("GitHub")
        for repo in get_repos(gh):
            if of_interest(args, repo):
                status = collect_status(gh, repo)
                repo_status.append(status)

    report_repos(args, repo_status)
github DragonComputer / Dragonfire / dragonfire / __init__.py View on Github external
tw_user (str):              Twitter username of the person querying DragonfireAI Twitter account with a mention
        """

        self.args = args
        self.userin = userin
        self.user_full_name = user_full_name
        self.user_prefix = user_prefix
        self.userin.twitter_user = tw_user
        self.testing = testing
        self.inactive = False
        self.h = None
        if not self.args["server"]:
            self.inactive = True
        if self.testing:
            home = expanduser("~")
            self.config_file = TinyDB(home + '/.dragonfire_config.json')
github lakewik / EasyStorj / UI / flask_ownstorj / ownstorj / models / playlist_manager.py View on Github external
def __init__(self):
        self.ownstorj_playlists_db = TinyDB('ownstorj_playlists.json')
        self.playlists_table = self.ownstorj_playlists_db.table('playlists')
        self.tracks_table = self.ownstorj_playlists_db.table('tracks')