diff --git a/extra/python/modules/__builtin__/__builtin__.factor b/extra/python/modules/__builtin__/__builtin__.factor new file mode 100644 index 0000000000..fb8c8846ff --- /dev/null +++ b/extra/python/modules/__builtin__/__builtin__.factor @@ -0,0 +1,31 @@ +USING: python.syntax ; +IN: python.modules.__builtin__ + +PY-FROM: __builtin__ => + callable ( obj -- ? ) + dir ( obj -- seq ) + int ( val -- s ) + len ( seq -- n ) + open ( name mode -- file ) + range ( n -- seq ) + repr ( obj -- str ) ; + +PY-METHODS: obj => + __name__ ( self -- n ) + __str__ ( o -- str ) ; + +PY-METHODS: file => + close ( self -- ) + fileno ( self -- n ) + tell ( self -- n ) ; + +PY-METHODS: str => + lower ( self -- self' ) + partition ( self sep -- bef sep aft ) + startswith ( self str -- ? ) + title ( self -- self' ) + zfill ( self n -- str' ) ; + +PY-METHODS: list => + append ( list obj -- ) + remove ( list obj -- ) ; diff --git a/extra/python/modules/argparse/argparse.factor b/extra/python/modules/argparse/argparse.factor new file mode 100644 index 0000000000..fdfdd934ed --- /dev/null +++ b/extra/python/modules/argparse/argparse.factor @@ -0,0 +1,7 @@ +USING: python.syntax ; +IN: python.modules.argparse + +PY-FROM: argparse => ArgumentParser ( -- self ) ; +PY-METHODS: ArgumentParser => + add_argument ( self name ** -- ) + format_help ( self -- str ) ; diff --git a/extra/python/modules/datetime/datetime.factor b/extra/python/modules/datetime/datetime.factor new file mode 100644 index 0000000000..0fe0621ef5 --- /dev/null +++ b/extra/python/modules/datetime/datetime.factor @@ -0,0 +1,4 @@ +USING: python.syntax ; +IN: python.modules.datetime + +PY-FROM: datetime => timedelta ( ** -- timedelta ) ; diff --git a/extra/python/modules/os/os.factor b/extra/python/modules/os/os.factor new file mode 100644 index 0000000000..6ab8ebaa5c --- /dev/null +++ b/extra/python/modules/os/os.factor @@ -0,0 +1,6 @@ +USING: python.syntax ; +IN: python.modules.os + +PY-FROM: os => + getpid ( -- y ) + system ( x -- y ) ; diff --git a/extra/python/modules/os/path/path.factor b/extra/python/modules/os/path/path.factor new file mode 100644 index 0000000000..30a8a2c219 --- /dev/null +++ b/extra/python/modules/os/path/path.factor @@ -0,0 +1,6 @@ +USING: python.syntax ; +IN: python.modules.os.path + +PY-FROM: os.path => + basename ( x -- x' ) + splitext ( x -- base ext ) ; diff --git a/extra/python/modules/sys/sys.factor b/extra/python/modules/sys/sys.factor new file mode 100644 index 0000000000..f84238f7d7 --- /dev/null +++ b/extra/python/modules/sys/sys.factor @@ -0,0 +1,8 @@ +USING: python.syntax ; +IN: python.modules.sys + +PY-FROM: sys => + path ( -- seq ) + argv ( -- seq ) + getrefcount ( obj -- n ) + platform ( -- x ) ; diff --git a/extra/python/modules/time/time.factor b/extra/python/modules/time/time.factor new file mode 100644 index 0000000000..9c4212ab3b --- /dev/null +++ b/extra/python/modules/time/time.factor @@ -0,0 +1,4 @@ +USING: python.syntax ; +IN: python.modules.time + +PY-FROM: time => sleep ( n -- ) ; diff --git a/extra/python/throwing/throwing.factor b/extra/python/throwing/throwing.factor index 4cdf539d48..7e783aba98 100644 --- a/extra/python/throwing/throwing.factor +++ b/extra/python/throwing/throwing.factor @@ -1,12 +1,9 @@ -USING: arrays kernel python python.ffi python.syntax sequences ; +USING: arrays kernel python python.ffi python.modules.__builtin__ python.syntax +sequences ; IN: python.throwing PY-FROM: traceback => format_tb ( tb -- seq ) ; -PY-METHODS: obj => - __name__ ( o -- str ) - __str__ ( o -- str ) ; - : throw-error ( ptype pvalue ptraceback -- ) [ [ $__name__ py> ]