8000 Deprecated nirum.rpc and remote nirum-server · nirum-lang/nirum-python@5ca2d9e · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ca2d9e

Browse files
committed
Deprecated nirum.rpc and remote nirum-server
1 parent 4ac70dd commit 5ca2d9e

File tree

5 files changed

+24
-87
lines changed

5 files changed

+24
-87
lines changed

CHANGES.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Version 0.6.0
66

77
To be released.
88

9+
- Deprecated ``nirum.rpc`` module.
10+
11+
This module and all it has provided are deprecated or obsolete. The most
12+
of them are now distributed as separated packages, or replaced by a newer
13+
concept. See also the below for details.
14+
15+
It will be completely obsolete at version 0.7.0.
16+
917
- Client transport layer. [`#79`_]
1018

1119
- Added ``nirum.transport.Transport`` interface.
@@ -44,6 +52,12 @@ To be released.
4452

4553
Use nirum-python-wsgi_ (PyPI handle: ``nirum-wsgi``) instead.
4654

55+
- ``nirum-server`` command is obsolete. The same command is now provided
56+
by nirum-python-wsgi_ (PyPI handle: ``nirum-wsgi``), a separated package.
57+
58+
- ``nirum.func.import_string()`` function and ``nirum.func.IMPORT_RE`` constant
59+
are obsolete.
60+
4761
- Fixed ``NameError`` raised from forward references. [`compiler #138`_]
4862

4963
.. _#79: https://github.com/spoqa/nirum-python/issues/79

nirum/func.py

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
import re
1+
from six.moves import urllib
22

3-
from six.moves import urllib, reduce
4-
5-
__all__ = 'IMPORT_RE', 'import_string', 'url_endswith_slash'
6-
IMPORT_RE = re.compile(
7-
r'''^
8-
(?P<modname> (?!\d) [\w]+
9-
(?: \. (?!\d)[\w]+ )*
10-
)
11-
:
12-
(?P<clsexp> (?P<clsname> (?!\d) \w+ )
13-
(?: \(.*\) )?
14-
)
15-
$''',
16-
re.X
17-
)
3+
__all__ = 'url_endswith_slash'
184

195

206
def url_endswith_slash(url):
@@ -24,28 +10,3 @@ def url_endswith_slash(url):
2410
if not path.endswith('/'):
2511
path += '/'
2612
return urllib.parse.urlunsplit((scheme, netloc, path, '', ''))
27-
28-
29-
def import_string(imp):
30-
"""Don't use this.
31-
32-
.. deprecated:: 0.6.0
33-
It will be completely obsolete at version 0.7.0.
34-
35-
"""
36-
m = IMPORT_RE.match(imp)
37-
if not m:
38-
raise ValueError(
39-
"malformed expression: {}, have to be x.y:z(...)".format(imp)
40-
)
41-
module_name = m.group('modname')
42-
import_root_mod = __import__(module_name)
43-
# it is used in `eval()`
44-
import_mod = reduce(getattr, module_name.split('.')[1:], import_root_mod) # noqa
45-
class_expression = m.group('clsexp')
46-
try:
47-
v = eval(class_expression, import_mod.__dict__, {})
48-
except AttributeError:
49-
raise ValueError("Can't import {}".format(imp))
50-
else:
51-
return v

nirum/rpc.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
""":mod:`nirum.rpc`
22
~~~~~~~~~~~~~~~~~~~
33
4+
.. deprecated:: 0.6.0
5+
This module and all it has provided are deprecated or obsolete. The most
6+
of them are now distributed as separated packages, or replaced by a newer
7+
concept.
8+
9+
It will be completely obsolete at version 0.7.0.
10+
411
"""
5-
import argparse
612
import collections
713
import json
814
import typing
@@ -13,14 +19,13 @@
1319
from werkzeug.exceptions import HTTPException
1420
from werkzeug.http import HTTP_STATUS_CODES
1521
from werkzeug.routing import Map, Rule
16-
from werkzeug.serving import run_simple
1722
from werkzeug.wrappers import Request as WsgiRequest, Response as WsgiResponse
1823

1924
from .deserialize import deserialize_meta
2025
from .exc import (NirumProcedureArgumentRequiredError,
2126
NirumProcedureArgumentValueError,
2227
UnexpectedNirumResponseError)
23-
from .func import import_string, url_endswith_slash
28+
from .func import url_endswith_slash
2429
from .serialize import serialize_meta
2530
from .service import Service as BaseService
2631

@@ -447,21 +452,3 @@ def do_request(self, request_url, payload):
447452
# with postfix named `_type`
448453
service_type = Service
449454
client_type = Client
450-
451-
452-
def main():
453-
parser = argparse.ArgumentParser(description='Nirum service runner')
454-
parser.add_argument('-H', '--host', help='the host to listen',
455-
default='0.0.0.0')
456-
parser.add_argument('-p', '--port', help='the port number to listen',
457-
type=int, default=9322)
458-
parser.add_argument('-d', '--debug', help='debug mode',
459-
action='store_true', default=False)
460-
parser.add_argument('service_impl', help='service implementation name')
461-
args = parser.parse_args()
462-
service_impl = import_string(args.service_impl)
463-
run_simple(
464-
args.host, args.port, WsgiApp(service_impl),
465-
use_reloader=args.debug, use_debugger=args.debug,
466-
use_evalex=args.debug
467-
)

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ def get_version():
8585
license='MIT license',
8686
packages=find_packages(exclude=['tests']),
8787
install_requires=install_requires,
88-
entry_points={
89-
'console_scripts': [
90-
'nirum-server = nirum.rpc:main',
91-
],
92-
},
9388
setup_requires=setup_requires,
9489
extras_require=extras_require,
9590
classifiers=[

tests/func_test.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0