Skip to content

Commit 9e57478

Browse files
committed
feat: update code
1 parent 93d1e07 commit 9e57478

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

litefs.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from gzip import GzipFile
3131
from hashlib import sha1
3232
from imp import find_module, load_module, new_module as imp_new_module
33+
from io import RawIOBase, BufferedRWPair, DEFAULT_BUFFER_SIZE
3334
from mako import exceptions
3435
from mako.lookup import TemplateLookup
3536
from mimetypes import guess_type
@@ -49,52 +50,52 @@
4950
from watchdog.observers import Observer
5051
from weakref import proxy as weakref_proxy
5152
from zlib import compress as zlib_compress
52-
from io import RawIOBase, BufferedRWPair, DEFAULT_BUFFER_SIZE
5353

5454
PY3 = sys.version_info.major > 2
5555

5656
if PY3:
5757
# Import modules in py3
5858
import socket
59+
from collections import UserDict
5960
from http.client import responses as http_status_codes
6061
from http.cookies import SimpleCookie
6162
from io import BytesIO as StringIO
6263
from urllib.parse import splitport, unquote_plus
63-
from collections import UserDict
6464
def is_unicode(s):
6565
return isinstance(s, str)
6666
def is_bytes(s):
6767
return isinstance(s, bytes)
6868
else:
6969
# Import modules in py2
7070
import _socket as socket
71-
from Cookie import SimpleCookie
7271
from cStringIO import StringIO
7372
from httplib import responses as http_status_codes
7473
from urllib import splitport, unquote_plus
74+
from Cookie import SimpleCookie
7575
from UserDict import UserDict
7676
def is_unicode(s):
7777
return isinstance(s, unicode)
7878
def is_bytes(s):
7979
return isinstance(s, basestring)
8080

8181
server_name = 'litefs'
82-
server_software = 'litefs %s' % __version__
82+
server_software = '%s %s' % (server_name, __version__)
8383

8484
default_404 = 'not_found'
8585
default_sid = '%s.sid' % server_name
86-
default_content_type = 'text/plain'
86+
default_content_type = 'text/plain; charset=utf-8'
8787

8888
EOFS = ('', '\n', '\r\n')
89-
FILES_HEADER_NAME = 'litefs.files'
89+
FILES_HEADER_NAME = '%s.files' % server_name
9090
date_format = '%Y/%m/%d %H:%M:%S'
9191
should_retry_error = (EWOULDBLOCK, EAGAIN)
9292
double_slash_sub = re.compile(r'\/{2,}').sub
9393
startswith_dot_sub = re.compile(r'\/\.+').sub
9494
suffixes = ('.py', '.pyc', '.pyo', '.so', '.mako')
9595
cgi_suffixes = ('.pl', '.py', '.pyc', '.pyo', '.php')
9696
form_dict_match = re.compile(r'(.+)\[([^\[\]]+)\]').match
97-
server_info = 'litefs/%s python/%s' % (__version__, sys.version.split()[0])
97+
server_info = '%s/%s python/%s' \
98+
% (server_name, __version__, sys.version.split()[0])
9899
cgi_runners = {
99100
'.pl' : '/usr/bin/perl',
100101
'.py' : '/usr/bin/python',
@@ -1028,7 +1029,7 @@ def _handler(self):
10281029
fp, pathname, description = find_module(name, [realbase])
10291030
except ImportError:
10301031
return None
1031-
module_name = 'litefs_%s' % uuid4().hex
1032+
module_name = '%s_%s' % (server_name, uuid4().hex)
10321033
sys.dont_write_bytecode = True
10331034
try:
10341035
module = load_module(module_name, fp, pathname, description)

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ def get_long_str(var_name):
3232
return re.search(
3333
r"%s\s*=\s*['\"]{3}([^'\"]+)['\"]{3}" % var_name, src_py).group(1)
3434

35-
version = get_str('__version__')
36-
author = get_str('__author__')
37-
license = get_str('__license__')
38-
long_description = get_long_str('__doc__')
39-
4035
setup(
4136
name='litefs',
42-
version=version,
37+
version=get_str('__version__'),
4338
description='Build a web server framework using Python.',
44-
long_description=long_description,
45-
author=author,
39+
long_description=get_long_str('__doc__'),
40+
author=get_str('__author__'),
4641
author_email='leafcoder@gmail.com',
4742
url='https://github.com/leafcoder/litefs',
4843
py_modules=['litefs'],
@@ -52,7 +47,7 @@ def get_long_str(var_name):
5247
'language_level' : language_level
5348
}
5449
),
55-
license=license,
50+
license=get_str('__license__'),
5651
platforms='any',
5752
package_data={
5853
'': ['*.txt', '*.md', 'LICENSE', 'example.py', 'MANIFEST.in'],

0 commit comments

Comments
 (0)