This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice | |
from typing import Iterable, List, Optional, Sequence | |
def table_trim(tbl: Iterable[List], max_rows: Optional[int], max_cols: Optional[int]) -> Sequence[List[str]]: | |
if max_rows is not None: | |
tbl = islice(tbl, max_rows) | |
if max_cols is not None: | |
tbl = (row[:max_cols] for row in tbl) | |
return tbl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[flake8] | |
max-line-length=119 | |
ignore=E203 | |
exclude = venv/* | |
#max-complexity = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tool.black] | |
line-length = 119 | |
target-version = ['py310'] | |
# include = '\.pyi?$' | |
# 'extend-exclude' excludes files or directories in addition to the defaults | |
#extend-exclude = ''' | |
## A regex preceded with ^/ will apply only to files and directories | |
## in the root of the project. | |
#( | |
# ^/foo.py # exclude a file named foo.py in the root of the project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PY_DOCS_PACKAGES=pyperclip tabulate | |
## docs ############################################################################################################### | |
.PHONY: docs | |
docs: | |
pdoc3 --html -o docs -f $(PY_DOCS_PACKAGES) | |
#cp logo.png docs/ | |
.PHONY: live | |
live: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## flake, black, isort ################################################################################################ | |
.PHONY: flake | |
flake: | |
flake8 --include=$(PY_FILES) | |
.PHONY: black | |
black: | |
black --check --diff $(PY_FILES) | |
black-fix: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## info ############################################################################################################### | |
v: | |
python --version && pip --version | |
## jupyterlab ######################################################################################################### | |
lab: | |
jupyter-lab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not sys.version_info.major == 3 and sys.version_info.minor >= 6: | |
print("Python 3.6 or higher is required.") | |
print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor)) | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# abbrevation: ifna | |
# desription: if __name__ == '__main__': | |
# scope: top | |
def _main(): | |
print('main') | |
if __name__ == '__main__': | |
_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# myself | |
*skipgit* | |
# python | |
__pycache__/ | |
*.py[cod] | |
# jetbrains | |
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [pyperclip/__init__.py at master · asweigart/pyperclip](https://github.com/asweigart/pyperclip/blob/master/src/pyperclip/__init__.py) | |
try: | |
from shutil import which as _executable_exists | |
except ImportError: | |
# The "which" unix command finds where a command is. | |
if platform.system() == 'Windows': | |
WHICH_CMD = 'where' | |
else: | |
WHICH_CMD = 'which' |
NewerOlder