OILS / asdl / demo.sh View on Github | oilshell.org

68 lines, 12 significant
1#!/usr/bin/env bash
2#
3# Demo of Python codegen for simpler imports and API
4# With backward compatibility
5#
6# Usage:
7# asdl/demo.sh <function name>
8
9set -o nounset
10set -o pipefail
11set -o errexit
12
13py-api() {
14 local pkg=_tmp/runtime_asdl
15
16 mkdir -v -p $pkg
17
18 touch _tmp/__init__.py
19
20 cat >$pkg/__init__.py <<EOF
21class value_t(object):
22 pass
23
24class value_e(object):
25 pass
26
27class value(object):
28 class Str(value_t):
29 pass
30
31# Do all the aliases LAST
32#from .value import Str as value__Str
33
34EOF
35
36 cat >$pkg/value.py <<EOF
37
38#from . import value_t
39#
40#class Str(value_t):
41# pass
42EOF
43
44
45 PYTHONPATH=_tmp python2 -c '
46#from _tmp.runtime_asdl import value, value_e, value_t
47#from _tmp.runtime_asdl import value__Str
48
49from _tmp.runtime_asdl import value, value_e, value_t
50
51
52print(value)
53
54print(value.Str)
55#print(value.Str.__bases__)
56
57#print(value__Str)
58
59print()
60
61print(value_e)
62print(value_t)
63'
64
65 python3 -m mypy _tmp/runtime_asdl/{__init__,value}.py
66}
67
68"$@"