Skip to main content

Cache (a tiny part of) the internet

Project description

graze

Cache (a tiny part of) the internet.

install

pip install graze

Example

from graze import Graze
import os
rootdir = os.path.expanduser('~/graze')
g = Graze(rootdir)
list(g)

If this is your first time, you got nothing:

[]

So get something. For no particular reason let's be self-referential and get myself:

url = 'https://raw.githubusercontent.com/thorwhalen/graze/master/README.md'
content = g[url]
type(content), len(content)

Before I grew up, I had only 46 petty bytes:

(bytes, 46)

These were:

print(content.decode())

# graze

Cache (a tiny part of) the internet

But now, here's the deal. List your g keys now. Go ahead, don't be shy!

list(g)
['https://raw.githubusercontent.com/thorwhalen/graze/master/README.md']

What does that mean?

I means you have a local copy of these contents.

The file path isn't really https://..., it's rootdir/https/..., but you only have to care about that if you actually have to go get the file with something else than graze. Because graze will give it to you.

How? Same way you got it in the first place:

content_2 = g[url]
assert content_2 == content

But this time, it didn't ask the internet. It just got it's local copy.

And if you want a fresh copy?

No problem, just delete your local one. You guessed! The same way you would delete a key from a dict:

del g[url]

Project details


Download files

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

Files for graze, version 0.0.11
Filename, size File type Python version Upload date Hashes
Filename, size graze-0.0.11-py3-none-any.whl (5.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size graze-0.0.11.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page