Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasCARPi committed Mar 11, 2024
0 parents commit 43106c7
Show file tree
Hide file tree
Showing 18 changed files with 1,463 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IMPORTANT: Base your PR off the 'dev' branch and target that branch.

Also please note that working on a PR doesn't automatically means that your code will be merged.
12 changes: 12 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
src: "./any2eln
201 changes: 201 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,vim
# Edit at https://www.toptal.com/developers/gitignore?templates=python,vim

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

# End of https://www.toptal.com/developers/gitignore/api/python,vim
local.env
export-*
# used in dev
entries.json
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# any2eln changelog

## any2eln 0.1.0 - unreleased
38 changes: 38 additions & 0 deletions DEVDOC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Developer documentation

## Run locally

### Install

~~~bash
git clone https://gitub.com/TheELNConsortium/any2eln
cd any2eln
python -m venv venv
source venv/bin/activate
poetry install
~~~

### Usage

~~~bash
source local.env
python any2eln
~~~

### Api doc

https://labfolder.labforward.app/api/v2/docs/development.html

### Using curl

First, login to get a TOKEN

~~~bash
curl -X POST -H 'Content-Type: application/json' -d '{"user":"[email protected]", "password": "secr3t"}' https://labfolder.labforward.app/api/v2/auth/login
~~~

and copy token in some env var like T. Then:

~~~bash
curl -H "Authorization: Bearer $T" "https://labfolder.labforward.app/api/v2/templates/26333?expand=entry"
~~~
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Nicolas CARPI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Description

**any2eln** is a tool to extract data from any Electronic Laboratory Notebook (ELN) software, to a `.eln` archive.

This `.eln` archive can then easily be re-imported in another ELN.

# Supported sources

* [Labfolder](#labfolder-module) (functional)
* Labguru (coming soon)
* Scinote (coming soon)
* Benchling (coming soon)

# Installation

~~~
git clone https://github.com/TheELNConsortium/any2eln
cd any2eln
python -m venv venv
source venv/bin/activate
poetry install
~~~

# Usage

~~~
python any2eln --help
~~~

# Labfolder module

## Description

This module allows you to extract all your data from a Labfolder.com account. It goes through all the entries and saves them per author as `.eln` archives. Using this module requires an account on Labfolder.com website.

The `DATA` elements are converted as `.csv` sheet by sheet, when possible, and the full `.json` metadata is also saved alongside.

## Disclaimer

This project is not affiliated with Labfolder software or Labforward GmbH. It simply leverages the [publicly documented API](https://labfolder.labforward.app/api/v2/docs/development.html#notebook-entries) to add a feature: export everything as `.eln`.

## Usage

~~~
python any2eln --src labfolder
~~~

The exported data will be saved in the current directory in a folder named `export-Y-m-d-H-M-s`.

For a more verbose output, add ``DEV=1`` to your execution environment.

## Caveats

If there is an error downloading a file for some reason, the error will be logged but the script will continue. Use verbose output (``DEV=1``) to have more information logged.

# License

This piece of software is under [MIT license](./LICENSE).
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://www.deltablot.com/security/
Empty file added any2eln/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions any2eln/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# TheELNConsortium/any2eln
# © 2024 Nicolas CARPi @ Deltablot
# License MIT
import argparse

from any2eln.labfolder.labfolder import Labfolder
from any2eln.utils.utils import env_or_ask


def main():
sources = ['labfolder', 'labguru', 'scinote', 'benchling']
parser = argparse.ArgumentParser(description='any2eln')
parser.add_argument('--src', required=True, help='source service you want to export from', choices=sources)
parser.add_argument('--out_dir', required=False, help='output directory', default='.')
args = parser.parse_args()

if (args.src == 'labfolder'):
username = env_or_ask('LABFOLDER_USERNAME', 'Your Labfolder username or email: ')
password = env_or_ask('LABFOLDER_PASSWORD', 'Your Labfolder password: ')
lf = Labfolder(username, password, out_dir=args.out_dir)
lf.extract()
else:
print('Not implemented.')

if __name__ == "__main__":
main()
Empty file added any2eln/labfolder/__init__.py
Empty file.
Loading

0 comments on commit 43106c7

Please sign in to comment.