Code Monkey home page Code Monkey logo

pyzotero-local's Introduction

pyzotero-local

A Python tool kit for interacting with the locally hosted Zotero database.

Features

  • Well-designed api with typehint, very easy to use.
  • All path will be located automatically, no need to assign it manually.

Install

pip install zolocal

Usage

access dataset

access zotero local database and query values

from pprint import pprint
from pyzolocal.sqls import gets as g

pprint(g.get_attachments()[:3])
pprint(g.get_items_info()[:3])
    # more get function including tag/ collection/ creator/ type

read profile

get profile root and profiles (from this)

from pprint import pprint
from pyzolocal.prefs import prefjs_fn
from pyzolocal.prefs.gets import (get_and_parse_user_prefs,
                                  search_user_prefs,
                                  get_and_parse_user_pref)
from pyzolocal.prefs.common import dataDir

pprint(dataDir())
pprint(prefjs_fn())
pprint(get_and_parse_user_prefs())

# =============================
\path\to\dataDir
\path\to\prefs.js
{'app.update.download.attempts': 0,
 'app.update.elevate.attempts': 0,
 'app.update.lastUpdateTime.addon-background-update-timer': 1613312615,
    ...}

sync profile

compress your user Profile

from pyzolocal.sync.base import bundle,dump

bundle('./')
dump('./Profiles.zip',...)

global search

index and global search files (supported by whoosh)

you need to install whoosh manually by pip install whoosh

from pprint import pprint
from pyzolocal.files import index, search_content

index() # run once when attahed file updated
res = search_content('my file')
pprint(res)


# ========================
{'base': {'doc_count': 42, 'hit_count': 5, 'result_count': 5},
 'result': [{'contents': ['training and validation). However, 15 of 457 videos '
                          'are invalid (<b class="match term0">file</b> '
                          'corrupted or have no transcript), so we move 15 '
                          'videos from the development set to the testing'],
             'path': 'storage\\AAZW6H2B\\... .pdf',
             'title': 'Learning Semantic Concepts and Temporal Alignment'},
...}

web api for local database

by fastapi

from pyzolocal.apis.fastapi import get_fastapis

app = get_fastapis()

then start it by uvicorn or other asgi framework.

see fastapi_demo

by flask

from pyzolocal.apis.flask import get_flaskapis

app = get_flaskapis()
app.run()

then visit http://127.0.0.1:8000/docs to view api list

TODOs

  • compatible with MacOS and Linux
  • more synchronize function
  • pyqt5 wrapper

Development

git clone https://github.com/sailist/pyzotero-local
cd pyzotero-local
python setup.py sdist bdist_wheel

file structure

pyzolocal
│
├─apis
│  │  base.py # for locally web api
│  │  fastapi.py # TODO
│  └─ flask.py  # TODO
│
├─beans  # data structure
│  │  enum.py
│  │  struct.py
│  └─ types.py
│
├─files  # for global search
│  │  base.py
│  └─ gets.py
│
├─prefs  # for reading profiles 
│  │  base.py
│  │  common.py
│  └─ gets.py
│
├─sqls  # for accessing database 
│  │  base.py 
│  └─ gets.py
│
└─sync  # for back-up
   │  base.py
   │  bypy.py # TODO
   │  ftp.py  # TODO 
   └─ gists.py # TODO

License

GNU © Haozhe Yang

Related repos

  • qnotero, Standalone sidekick to the Zotero reference manager
  • pyzotero, A Python client for the Zotero Web API

pyzotero-local's People

Contributors

sailist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.