Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gistcafe-0.0.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gistcafe-0.0.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for gistcafe-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0636c79e18aa8334685983f5fdd51f5a890281ebca6b2dddf0aa4decc7195643
MD5 f802aef876a4a733d4dbc19e1a575215
BLAKE2b-256 289658718e7d3cef2e39a809c70040fb857e93f346e0fe5bcbcac3e0488d5232

See more details on using hashes here.

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

Hashes for gistcafe-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4fd9fca7504244937fb304f9c51a493658101a0fcc277fdbe9ac40f76d24e7d5
MD5 0b9d2e0044a6dcd1494f35f66e6ca5bd
BLAKE2b-256 2d33af7702e0b3b24a00704b503c6b0c1468f6e9357cda8fadced51fdffcf258

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page