Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Mar 21, 2023
0 parents commit 3cd873d
Show file tree
Hide file tree
Showing 25 changed files with 632 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint

on:
- push
- pull_request
- workflow_dispatch

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test files formatting
uses: psf/black@stable
15 changes: 15 additions & 0 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint

on:
- push
- workflow_dispatch

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: pre-commit/[email protected]
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*[Uu]ntitled*

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
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/

# 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
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.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

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__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/
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
default_install_hook_types: [pre-commit]

repos:
- repo: "https://github.com/psf/black"
rev: "22.3.0"
hooks:
- id: black
stages: [commit]
- id: black-jupyter
stages: [commit]

- repo: "https://github.com/kynan/nbstripout"
rev: "0.5.0"
hooks:
- id: nbstripout
stages: [commit]

- repo: "https://github.com/pre-commit/mirrors-prettier"
rev: "v2.7.1"
hooks:
- id: prettier
stages: [commit]
exclude: "CHANGELOG.md"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.215"
hooks:
- id: ruff
stages: [commit]
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) 2020 Food and Agriculture Organization of the United Nations (FAO)

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.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# sepal leafmap

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/12rambau/sepal-leafmap/blob/master/LICENSE)
[![Black badge](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# About

Provide access to the power of leafmap as a standalone application
11 changes: 11 additions & 0 deletions component/message/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Creation of the Translator object associated with the application.
Can be accessed via the foolowing code: ``from component.message import cm``
"""

from pathlib import Path

from sepal_ui.translator import Translator

# create a translator object
cm = Translator(Path(__file__).parent)
Empty file added component/message/en/.gitignore
Empty file.
5 changes: 5 additions & 0 deletions component/message/en/about.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"about": {
"pathname": "ABOUT_en.md"
}
}
12 changes: 12 additions & 0 deletions component/message/en/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"app": {
"title": "sepal leafmap",
"footer": "The sky is the limit \u00a9 {}",
"banner": "This is a automatically generated application. Remove this banner once your application is ready.",
"link": {
"code": "Code link",
"wiki": "Documentation and tutorials",
"issue": "Github Issues"
}
}
}
56 changes: 56 additions & 0 deletions component/message/test_translation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"\n",
"# add parent dir to import cm\n",
"sys.path.insert(0, os.path.abspath(\"../\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from message import cm\n",
"\n",
"cm.key_use(os.path.abspath(\"../../\"), \"cm\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
6 changes: 6 additions & 0 deletions component/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Module to gather all the models from the application.
If you only have few widgets, a module is not necessary and you can simply use a model.py file
In a big module with lot of custom models, it can make sense to split things in separate files for the sake of maintenance.
If you use a module import all the functions here to only have 1 call to make
"""
7 changes: 7 additions & 0 deletions component/parameter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""module to gather all the parameters used in the application.
if you only have few widgets, a module is not necessary and you can simply use a parameter.py file. Iin a big module with lot of custom parmeters, it can make sense to split things in separate files for the sake of maintenance.
If you use a module import all the functions here to only have 1 call to make
"""

from .directory import *
8 changes: 8 additions & 0 deletions component/parameter/directory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""All directories used in the application."""

from pathlib import Path

# this directory is the root directory of all sepal dashboard app.
# Change it if you develop in another environment.
module_dir = Path.home() / "module_results"
module_dir.mkdir(exist_ok=True)
7 changes: 7 additions & 0 deletions component/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Module to gather all scripts of the application.
If you only have few widgets, a module is not necessary and you can simply use a scripts.py file
In a big module with lot of custom scripts, it can make sense to split things in separate files for the sake of maintenance
If you use a module import all the functions here to only have 1 call to make
"""
8 changes: 8 additions & 0 deletions component/tile/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Package to gather all the tiles created in the application.
If you only have few widgets, a module is not necessary and you can simply use a tile.py file
In a big module with lot of custom tiles, it can make sense to split things in separate files for the sake of maintenance
If you use a module import all the functions here to only have 1 call to make.
"""

from .map_tile import *
47 changes: 47 additions & 0 deletions component/tile/map_tile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""The map displayed in the map application."""

from ipyleaflet import WidgetControl
from sepal_ui import mapping as sm
from sepal_ui import sepalwidgets as sw


class MapTile(sw.Tile):
def __init__(self):
"""Specific Map integrating all the widget components.
Use this map to gather all your widget and place them on it. It will reduce the amount of work to perform in the notebook
"""
# create a map
self.m = sm.SepalMap(zoom=3) # to be visible on 4k screens
self.m.add_control(
sm.FullScreenControl(
self.m, fullscreen=True, fullapp=True, position="topright"
)
)

# create the tile
super().__init__("map_tile", "", [self.m])

def set_code(self, link):
"""Add the code link btn to the map."""
btn = sm.MapBtn("fa-solid fa-code", href=link, target="_blank")
control = WidgetControl(widget=btn, position="bottomleft")
self.m.add(control)

return

def set_wiki(self, link):
"""Add the wiki link btn to the map."""
btn = sm.MapBtn("fa-solid fa-book-open", href=link, target="_blank")
control = WidgetControl(widget=btn, position="bottomleft")
self.m.add(control)

return

def set_issue(self, link):
"""Add the code link btn to the map."""
btn = sm.MapBtn("fa-solid fa-bug", href=link, target="_blank")
control = WidgetControl(widget=btn, position="bottomleft")
self.m.add(control)

return
Loading

0 comments on commit 3cd873d

Please sign in to comment.