Import python modules by their hash.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

README.md 2.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. casimport
  2. =========
  3. This is a python module that is designed to load Python code from a
  4. cryptographic hash. The idea is that instead of having to package
  5. up simple code as a Python package, you can import it directly via
  6. the hash.
  7. There is the concept of aliases to make the import statements easier
  8. to read. An alias file is currently limited to python packages (modules
  9. in a directory w/ an __init__.py file). An example is the randpkg in
  10. the fixtures directory. You can put a file named cas_aliases.txt along
  11. side the __init__.py file. Each line of the file is:
  12. ```
  13. <alias> <url>
  14. ```
  15. Where alias is a simple name, and url is a location to find the file
  16. at. Currently, at least one hash url must be specified.
  17. The following url schemes are supported:
  18. <dl>
  19. <dt>hash</dt>
  20. <dd>At least one of these MUST be specified. The url format is specified
  21. by [hash-uri](https://github.com/hash-uri/hash-uri) and currently only
  22. a hash value of sha256 is supported.</dd>
  23. <dt>ipfs</dt>
  24. <dd>The format follows ipfs scheme url as specified by the
  25. [IPFS Addressing](https://github.com/ipfs/in-web-browsers/blob/master/ADDRESSING.md)
  26. document. It is recommend that CIDv1 addresses are used, as the
  27. host portion of a URL is case insensitive, and CIDv0 (the current
  28. default) values are case sensitive. An example is:
  29. `ipfs://bafkreibtbcckul7lwxqz7nyzj3dknhwrdxj5o4jc6gsroxxjhzz46albym`.</dd>
  30. <dt>https</dt>
  31. <dd>This is the standard web url that everyone is familar with.</dd>
  32. </dl>
  33. Usage
  34. -----
  35. Top level usage:
  36. ```
  37. import casimport
  38. from cas.v1_f_330884aa2febb5e19fb7194ec6a69ed11dd3d77122f1a5175ee93e73cf0161c3 import hello
  39. print(repr(hello('Alice')))
  40. ```
  41. Defintion of module names in cas package:
  42. v<num>_<type>_<arg>
  43. Currently v1 is defined, and has the following types:
  44. f The arg is the hash of the Python source file.
  45. Example generated via: shasum -a 256 hello.py
  46. a An alias. Any aliases must be loaded before being
  47. processed. This is a short name that could be used.
  48. Configuration
  49. -------------
  50. By default, a configuration file is read from `~/.casimport/casimport.conf`.
  51. The configuration file allows the specification of the priority of the
  52. different modules (does casimport search IPFS or HTTPS urls first), and
  53. the configuration each of the modules.
  54. The first time you import casimport, a sample configuration will be created.
  55. The default is a local cache the home directory, and then to use IPFS
  56. gateway, followed by normal https urls.