Skip to main content

Tagging arbitrary data

Project description

TagManager

TagManager is a Python library that allows tagging arbitrary data and managing tags both in pure Python and using databases. The library supports PostgreSQL. Integration with other databases is also possible: for this, you need to describe a subclass of the DataStorage class to interact with a database.

Table of contents

Description

The library allows working with data that consists of a set of entries with unique identifiers. When adding entries to the tag manager, you only need to specify their identifiers.

You can create tags and group them into groups. Tags in different groups can have the same names.

Example: 7 tags divided into 2 groups

group: "color"
  tags: "red", "green", "orange", "blue"
group: "fruit"
  tags: "apple", "orange", "banana"

Created tags can be used to mark added entries.

Project structure

tag_manager/
├── __init__.py
├── typing.py        # The types used
├── errors.py        # The possible errors
├── data_storage.py  # Tagged data storages
├── tag_manager.py   # The main class for tag management
└── cli.py           # The command line interface

Usage

Get started

  • Creating a tagged data storage using only Python.
    from tag_manager import TagManager, SimpleOrderedDataStorage, autocli
    
    tm = TagManager(SimpleOrderedDataStorage())
    storage_name = 'example_storage'
    
    cli = autocli(tm, storage_name)
    cli.run()
    
  • Creating a tagged data storage using PostgreSQL.
    from tag_manager import TagManager, PostgresDataStorage, autocli
    
    # You must store the password in the DB_PASSWORD environment variable.
    # You can use this BASH command:
    # $ read -s DB_PASSWORD && export DB_PASSWORD
    
    login, host, port, db_name = ...
    tm = TagManager(PostgresDataStorage(login, host, port, db_name))
    
    cli = autocli(tm, db_name)
    cli.run()
    

Interaction via CLI

Basic commands:
  • groups
    View the list of tag groups.

  • groups ? <group>
    Check if the <group> exists.

  • groups + <group>*
    Add groups.

  • groups - <group>*
    Delete groups.

  • groups r <old_group> <new_group>
    Rename <old_group> to <new_group>.
    If the <new_group> already exists, the renaming will not take place.

  • groups m <old_group> <new_group>
    Rename <old_group> to <new_group>.
    If the <new_group> already exists, a merge will occur: all tags from the <old_group> will move to the <new_group>, and the <old_group> will be deleted.

  • tags
    View the list of tags.

  • tags <group>
    View the list of tags from the <group>.

  • tags <group> ? <tag>
    Check if the <tag> exists in the <group>.

  • tags <group> + <tag>*
    Add tags to the <group>.

  • tags <group> - <tag>*
    Delete tags from the <group>.

  • tags <group> r <old_tag> <new_group> <new_tag>
    Move the tag from the group <group> to the group <new_group> and rename <old_tag> to <new_tag>. If <new_tag> already exists, the operation will not be performed.

  • tags <group> m <old_tag> <new_group> <new_tag>
    Move the tag from the group to the group <new_group> and rename <old_tag> to <new_tag>. If both tags already exist, a merge will occur: all entries containing <old_tag> will contain <new_tag>.

  • entries
    View the list of entries.

  • entries ? <entry_id>
    Check if the entry with <entry_id> exists.

  • entries + <entry_id>*
    Add entries with the specified ids.

  • entries - <entry_id>*
    Delete entries with the specified ids.

  • entries r <old_id> <new_id>
    Rename <old_id> to <new_id>. If <new_id> already exists, the renaming will not take place.

  • entries m <old_id> <new_id>
    Rename <old_id> to <new_id>. If <new_id> already exists, a merge will occur: all tags from the entry with <old_id> will be added to the entry with <new_id>, and the entry with <old_id> will be deleted.

  • entries t <entry_id>
    View the list of tags for the entry with <entry_id>.

  • entries t <entry_id> ? <group> <tag>
    Check if the entry with <entry_id> contains the <tag> from the <group>.

  • entries t <entry_id>* + <group> <tag>*
    Add tags from the <group> to the entries with the specified ids.

  • entries t <entry_id>* - <group> <tag>*
    Delete tags from the <group> from the entries with the specified ids.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t_manager-0.1.2.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t_manager-0.1.2-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file t_manager-0.1.2.tar.gz.

File metadata

  • Download URL: t_manager-0.1.2.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for t_manager-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9b48c2011f09e4dc8d93d767d21a4ad00ac739c564b17a56f31112be14e619f1
MD5 dd6d93fdfebafc839b0face4961755f4
BLAKE2b-256 3e25dbc474e288c6c636a4fca8fa2584aaa9b3196a23462ef951b7bc617f4bd2

See more details on using hashes here.

File details

Details for the file t_manager-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: t_manager-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for t_manager-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b8f91e68aa02c1753947909356978a6259b423a785178ec374721f25cb03a3d
MD5 54e04d09a764d657d8648c140e7c7883
BLAKE2b-256 3e0fb5cd63627acfcc504d6161f0bf79230bbf6710f4085abff0d06923d15011

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page