Basic Click Application
$ pip install click
$ python click_hello.py Jeff
Hello Jeff!
$ python click_hello.py Alice
Hello Alice!
import json | |
from typing import Optional | |
from typing import TYPE_CHECKING | |
if TYPE_CHECKING: | |
from pandas import DataFrame | |
class JsonableEncoderError(Exception): | |
pass |
#!/usr/bin/env bash | |
set -e | |
help() | |
{ | |
echo "Usage: $0 [[-c | --container]" | |
echo " --]" | |
echo "" | |
echo "Script Options:" |
Requirement\Solution, conf.py , config.ini , config/ directory , proj-ops/ repository , Config Server | |
change config , ✅ , ✅ , ✅ , ✅ , ✅ | |
Simple(in minutes) , ✅ , ✅ , ✅ , ❌(required opration technology), ❌(not a problem if has a great library) | |
Coupling , ❌ , ✅ , ✅ config/prd.ini ❌ config/prd.py, -- , ✅ | |
mulitple environment, ❌ , ❌ , ✅ , ✅ , ✅ | |
security , ❌ , ❌ , ❌ , ✅ , ✅ | |
maintenance cost , ✅ , ✅ , ✅ , ✅ |
from pathlib import Path | |
from typing import Any, Dict, Optional, Union | |
from hydra import compose, initialize_config_dir | |
from omegaconf import DictConfig | |
from pydantic import BaseModel, BaseSettings | |
from pydantic.env_settings import SettingsSourceCallable | |
# {python project}/app/config.py | |
project_dir = Path(__file__).parent.parent |
def is_balance(s) -> bool: | |
open, close = '<{[(', ')]}>' | |
brackets = dict(zip(open, close[::-1])) | |
# print( brackets ) | |
stack = [] | |
for c in s: | |
if c in brackets: # open; O(1) | |
stack.append(c) # .push | |
elif c in brackets.values(): # close; O(4) |
def mergesort(seq): | |
mid = len(seq) // 2 | |
lft, rgt = seq[:mid], seq[mid:] | |
if len(lft) > 1: lft = mergesort(lft) | |
if len(rgt) > 1: rgt = mergesort(rgt) | |
res = [] | |
while lft and rgt: | |
if lft[-1] >= rgt[-1]: res.append(lft.pop()) | |
else: res.append(rgt.pop()) | |
return (lft or rgt) + res[::-1] |
Basic Click Application
$ pip install click
$ python click_hello.py Jeff
Hello Jeff!
$ python click_hello.py Alice
Hello Alice!
You can then restrict a test run to only run tests marked with webtest
:
$ pytest -v -m webtest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 3 deselected / 1 selected
/* | |
Usage: | |
``` | |
$ mkdir myscreenshot | |
$ cd myscreenshot | |
$ npm i puppeteer --save | |
$ | |
$ vim myScreenshot.js | |
const puppeteer = require('puppeteer'); | |
... |
<html> | |
<head> | |
<script defer src="https://pyscript.net/latest/pyscript.js"></script> | |
</head> | |
<body> | |
<div id="output"></div> | |
<py-script> | |
import asyncio | |
async def main(): |