| @@ -1,9 +1,33 @@ | |||||
| casimport | casimport | ||||
| ========= | ========= | ||||
| This is a python module that is designed to load Python code from a | |||||
| cryptographic hash. The idea is that instead of having to package | |||||
| up simple code as a Python package, you can import it directly via | |||||
| the hash. | |||||
| There is the concept of aliases to make the import statements easier | |||||
| to read. This is currently limited to packages (on disk). An example | |||||
| is the randpkg in the fixtures directory. You can put a file named | |||||
| cas_aliases.txt along side your __init__.py file. Each line of the | |||||
| file is: | |||||
| ``` | |||||
| <alias> <url> | |||||
| ``` | |||||
| Where alias is a simple name, and url is a location to find the file | |||||
| at. Currently, at least on hash url that follows the | |||||
| [hash-uri](https://github.com/hash-uri/hash-uri) format w/ a hash | |||||
| value of sha256. The other supported url type is ipfs. The format | |||||
| follows the [IPFS Addressing](https://github.com/ipfs/in-web-browsers/blob/master/ADDRESSING.md) | |||||
| document, and it is recommend that CIDv1 addresses are used, as the | |||||
| host portion of a URL is case insensitive, and CIDv0 (the current | |||||
| default) values are case sensitive. | |||||
| Usage | Usage | ||||
| ----- | ----- | ||||
| Top level usage: | |||||
| ``` | ``` | ||||
| import casimport | import casimport | ||||
| from cas.v1_f_330884aa2febb5e19fb7194ec6a69ed11dd3d77122f1a5175ee93e73cf0161c3 import hello | from cas.v1_f_330884aa2febb5e19fb7194ec6a69ed11dd3d77122f1a5175ee93e73cf0161c3 import hello | ||||
| @@ -11,7 +35,7 @@ from cas.v1_f_330884aa2febb5e19fb7194ec6a69ed11dd3d77122f1a5175ee93e73cf0161c3 i | |||||
| print(repr(hello('Alice'))) | print(repr(hello('Alice'))) | ||||
| ``` | ``` | ||||
| Defintion of hash: | |||||
| Defintion of module names in cas package: | |||||
| v<num>_<type>_<arg> | v<num>_<type>_<arg> | ||||
| Currently v1 is defined, and has the following types: | Currently v1 is defined, and has the following types: | ||||