rse.main.database package
Submodules
rse.main.database.base module
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
rse.main.database.filesystem module
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- class rse.main.database.filesystem.FileSystemDatabase(config_dir, config=None, **kwargs)[source]
Bases:
rse.main.database.base.Database
A FileSystemDatabase writes raw json to files to a database.
- database = 'filesystem'
- get(uid=None, exact=False)[source]
Get a software repo based on a uid. If exact is not needed, we can search for a match based on the partial uid. If exact is False, and a uid is not provided, get the last repository created.
- iter_parsers(fullpath=False)[source]
list executors based on the subfolders in the base database folder.
- list_repos(name=None)[source]
list software repositories, either under a particular parser name or just under all parsers. This returns repos in rows to be printed (or otherwise parsed).
- search(query, taxonomy=None, criteria=None)[source]
A filesystem search can only support returning results with filenames. For taxonomy and criteria items, we load them and search. We organize results based on the query, taxonomy, and criteria The results returned are separate (e.g., a single repo can appear in more than one list).
- class rse.main.database.filesystem.SoftwareRepository(parser, data_base, exists=False)[source]
Bases:
object
A software repository is a filesystem representation of a repo. It can take a uid, determine if the repo exists, and then interact with the metadata for it. If the repo is instantiated without a unique id it is assumed to not exist yet, otherwise it must already exist.
- property avatar
- create(should_exist=False)[source]
create the filename if it doesn’t exist, otherwise if it should (and does not) exit on error.
- property description
- property filename
- has_criteria_annotation(uid, username)[source]
Determine if a repository has been annotated by a user.
- load_taxonomy()[source]
Given a repository directory, load taxonomy annotations if they exist The taxonomy.tsv file should be a tab separated file with: username category-unique-id. This means that we keep a record of who has categorized what, and load this information into the taxonomy dictionary (organized by the category-unique-id which then has a total count and list of users).
- property parser_dir
- save_criteria()[source]
Save criteria to file. Each file is named based on the criteria id, and is a tab separated file that includes the username and response.
- save_taxonomy()[source]
Save taxonomy to file. Each file is named taxonomy.tsv, and is a tab separated file that includes the username and response.
- update_criteria(uid, username, response)[source]
Update a criteria, meaning adding a True/False answer to the unique id for the user. We are currently assuming that criteria have yes/no responses, and True == yes, False == no.
- property url
rse.main.database.models module
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- class rse.main.database.models.SoftwareRepository(uid=None, parser=None, data={})[source]
Bases:
sqlalchemy.orm.decl_api.Base
A software repository.
- property avatar
- criteria
- data
- property description
- has_criteria_annotation(uid, username)[source]
Determine if a repository has been annotated by a user.
- parser_name
- taxonomy
- timestamp
- uid
- property url
rse.main.database.relational module
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- class rse.main.database.relational.RelationalDatabase(config_dir, config=None, **kwargs)[source]
Bases:
rse.main.database.base.Database
A RelationalDatabase is a more robust relational datbase (to sqlite). Since the global database property can be any of postgresql, mysql+pysq;, it is defined on init. The sqlite database also uses this class, but defines a custom init function to handle the rse.db file.
- create_database()[source]
create the databsae based on the string, whether it’s relational or sqlite. self.db must be defined.
- get(uid=None)[source]
Get a repo based on a uid. Exits on error if doesn’t exist. If a uid is not provided, get the last updated repository.
- list_repos(name=None)[source]
list repos, either under a particular parser name (if provided) or just the parsers.
rse.main.database.sqlite module
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- class rse.main.database.sqlite.SqliteDatabase(config_dir, config=None, **kwargs)[source]
Bases:
rse.main.database.relational.RelationalDatabase
A SqliteDatabase writes to a rse.db file in $HOME/.rse. This is the suggested database backend for QueueMe, as it doesn’t require anything beyond a filesystem and still allows for relational type queries.
- database = 'sqlite'
Module contents
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- rse.main.database.init_db(database, config_dir=None, database_string='', config=None)[source]
Initialize the database, meaning a base client and appropriate functions to save, or generate a unique ID based on the backend being used. Each client has it’s own init to check for a connection (or filesystem path existence) and then functions to interact with entities.