gist.cafe utils for Python
Project description
Useful utils for gist.cafe Python Apps.
Usage
Simple usage example:
import requests
import operator
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json, Undefined
from typing import Optional
from gistcafe import inspect
@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclass
class GithubRepo:
name: str
description: Optional[str] = None
homepage: Optional[str] = None
lang: Optional[str] = field(metadata=config(field_name="language"),default=None)
watchers: Optional[int] = 0
forks: Optional[int] = 0
orgName = "python"
response = requests.get(f'https://api.github.com/orgs/{orgName}/repos')
orgRepos = GithubRepo.schema().loads(response.text, many=True)
orgRepos.sort(key=operator.attrgetter('watchers'), reverse=True)
print(f'Top 3 {orgName} Repos:')
inspect.printdump(orgRepos[0:3])
print(f'\nTop 10 {orgName} Repos:')
inspect.printdumptable(orgRepos[0:10],headers=['name','lang','watchers','forks'])
inspect.vars({ 'orgRepos': orgRepos })
Which outputs:
Top 3 python Repos:
[
{
name: mypy,
description: Optional static typing for Python 3 and 2 (PEP 484),
homepage: http://www.mypy-lang.org/,
lang: Python,
watchers: 9638,
forks: 1564
},
{
name: peps,
description: Python Enhancement Proposals,
homepage: https://www.python.org/dev/peps/,
lang: Python,
watchers: 2459,
forks: 921
},
{
name: typeshed,
description: Collection of library stubs for Python, with static types,
homepage: ,
lang: Python,
watchers: 1942,
forks: 972
}
]
Top 10 python Repos:
+--------------+-----------+------------+---------+
| name | lang | watchers | forks |
|--------------+-----------+------------+---------|
| mypy | Python | 9638 | 1564 |
| peps | Python | 2459 | 921 |
| typeshed | Python | 1942 | 972 |
| pythondotorg | Python | 1038 | 432 |
| asyncio | | 945 | 178 |
| typing | Python | 840 | 130 |
| raspberryio | Python | 217 | 38 |
| typed_ast | C | 171 | 43 |
| planet | Python | 100 | 145 |
| psf-salt | SaltStack | 87 | 50 |
+--------------+-----------+------------+---------+
Whilst inspect.vars() lets you view variables in gist.cafe viewer:
View and execute Python gists with gist.cafe, e.g: gist.cafe/2b11948d23e051396d62bb7853aad674.
Features and bugs
Please file feature requests and bugs at the issue tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gistcafe-0.0.3.tar.gz.
File metadata
- Download URL: gistcafe-0.0.3.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0636c79e18aa8334685983f5fdd51f5a890281ebca6b2dddf0aa4decc7195643
|
|
| MD5 |
f802aef876a4a733d4dbc19e1a575215
|
|
| BLAKE2b-256 |
289658718e7d3cef2e39a809c70040fb857e93f346e0fe5bcbcac3e0488d5232
|
File details
Details for the file gistcafe-0.0.3-py3-none-any.whl.
File metadata
- Download URL: gistcafe-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fd9fca7504244937fb304f9c51a493658101a0fcc277fdbe9ac40f76d24e7d5
|
|
| MD5 |
0b9d2e0044a6dcd1494f35f66e6ca5bd
|
|
| BLAKE2b-256 |
2d33af7702e0b3b24a00704b503c6b0c1468f6e9357cda8fadced51fdffcf258
|