Skip to content

Commit 8f114c4

Browse files
authored
Merge pull request #250 from hugovk/rm-eol
2 parents ecabeba + 5165fed commit 8f114c4

File tree

8 files changed

+28
-54
lines changed

8 files changed

+28
-54
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ clean-pyc:
1515
find . -name '*~' -exec rm -f {} +
1616

1717
install:
18-
python setup.py install
18+
python3 setup.py install
1919

2020
docs:
2121
$(MAKE) -C docs html

docs/conf.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Python LiveReload documentation build configuration file, created by
43
# sphinx-quickstart on Sat May 5 18:36:44 2012.
@@ -42,8 +41,8 @@
4241
master_doc = 'index'
4342

4443
# General information about the project.
45-
project = u'Python LiveReload'
46-
copyright = u'2012, <a href="http://lepture.com">Hsiaoming Yang</a>'
44+
project = 'Python LiveReload'
45+
copyright = '2012, <a href="http://lepture.com">Hsiaoming Yang</a>'
4746

4847
# The version info for the project you're documenting, acts as replacement for
4948
# |version| and |release|, also used in various other places throughout the
@@ -192,8 +191,8 @@
192191
# Grouping the document tree into LaTeX files. List of tuples
193192
# (source start file, target name, title, author, documentclass [howto/manual]).
194193
latex_documents = [
195-
('index', 'PythonLiveReload.tex', u'Python LiveReload Documentation',
196-
u'Hsiaoming Yang', 'manual'),
194+
('index', 'PythonLiveReload.tex', 'Python LiveReload Documentation',
195+
'Hsiaoming Yang', 'manual'),
197196
]
198197

199198
# The name of an image file (relative to this directory) to place at the top of
@@ -222,8 +221,8 @@
222221
# One entry per manual page. List of tuples
223222
# (source start file, name, description, authors, manual section).
224223
man_pages = [
225-
('index', 'livereload', u'Python LiveReload Documentation',
226-
[u'Hsiaoming Yang'], 1)
224+
('index', 'livereload', 'Python LiveReload Documentation',
225+
['Hsiaoming Yang'], 1)
227226
]
228227

229228
# If true, show URL addresses after external links.
@@ -236,8 +235,8 @@
236235
# (source start file, target name, title, author,
237236
# dir menu entry, description, category)
238237
texinfo_documents = [
239-
('index', 'PythonLiveReload', u'Python LiveReload Documentation',
240-
u'Hsiaoming Yang', 'PythonLiveReload', 'One line description of project.',
238+
('index', 'PythonLiveReload', 'Python LiveReload Documentation',
239+
'Hsiaoming Yang', 'PythonLiveReload', 'One line description of project.',
241240
'Miscellaneous'),
242241
]
243242

livereload/handlers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
livereload.handlers
43
~~~~~~~~~~~~~~~~~~~

livereload/server.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
livereload.server
43
~~~~~~~~~~~~~~~~~
@@ -27,11 +26,10 @@
2726
from .handlers import LiveReloadHandler, LiveReloadJSHandler
2827
from .handlers import ForceReloadHandler, StaticFileHandler
2928
from .watcher import get_watcher_class
30-
from six import string_types, PY3
3129

3230
import sys
3331

34-
if sys.version_info >= (3, 7) or sys.version_info.major == 2:
32+
if sys.version_info >= (3, 7):
3533
import errno
3634
else:
3735
from os import errno
@@ -94,8 +92,7 @@ def run_shell():
9492
logger.error(stderr)
9593
return stderr
9694
#: stdout is bytes, decode for python3
97-
if PY3:
98-
stdout = stdout.decode()
95+
stdout = stdout.decode()
9996
with open(output, mode) as f:
10097
f.write(stdout)
10198

@@ -104,7 +101,7 @@ def run_shell():
104101

105102
class LiveScriptInjector(web.OutputTransform):
106103
def __init__(self, request):
107-
super(LiveScriptInjector, self).__init__(request)
104+
super().__init__(request)
108105

109106
def transform_first_chunk(self, status_code, headers, chunk, finishing):
110107
if HEAD_END in chunk:
@@ -143,7 +140,7 @@ def start_response(status, response_headers, exc_info=None):
143140
status_code, reason = data["status"].split(' ', 1)
144141
status_code = int(status_code)
145142
headers = data["headers"]
146-
header_set = set(k.lower() for (k, v) in headers)
143+
header_set = {k.lower() for (k, v) in headers}
147144
body = escape.utf8(body)
148145

149146
if HEAD_END in body:
@@ -174,7 +171,7 @@ def start_response(status, response_headers, exc_info=None):
174171
self._log(status_code, request)
175172

176173

177-
class Server(object):
174+
class Server:
178175
"""Livereload server interface.
179176
180177
Initialize a server and watch file changes::
@@ -239,10 +236,10 @@ def alert():
239236
:param ignore: A function return True to ignore a certain pattern of
240237
filepath.
241238
"""
242-
if isinstance(func, string_types):
239+
if isinstance(func, str):
243240
cmd = func
244241
func = shell(func)
245-
func.name = "shell: {}".format(cmd)
242+
func.name = f"shell: {cmd}"
246243

247244
self.watcher.watch(filepath, func, delay, ignore=ignore)
248245

@@ -332,7 +329,7 @@ def serve(self, port=5500, liveport=None, host=None, root=None, debug=None,
332329
self.root = root
333330

334331
self._setup_logging()
335-
logger.info('Serving on http://%s:%s' % (host, port))
332+
logger.info(f'Serving on http://{host}:{port}')
336333

337334
self.default_filename = default_filename
338335

@@ -346,7 +343,7 @@ def serve(self, port=5500, liveport=None, host=None, root=None, debug=None,
346343

347344
def opener():
348345
time.sleep(open_url_delay)
349-
webbrowser.open('http://%s:%s' % (host, port))
346+
webbrowser.open(f'http://{host}:{port}')
350347
threading.Thread(target=opener).start()
351348

352349
try:

livereload/watcher.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
livereload.watcher
43
~~~~~~~~~~~~~~~~~~
@@ -13,12 +12,7 @@
1312
import logging
1413
import os
1514
import time
16-
import sys
17-
18-
if sys.version_info.major < 3:
19-
import inspect
20-
else:
21-
from inspect import signature
15+
from inspect import signature
2216

2317
try:
2418
import pyinotify
@@ -28,7 +22,7 @@
2822
logger = logging.getLogger('livereload')
2923

3024

31-
class Watcher(object):
25+
class Watcher:
3226
"""A file watcher registry."""
3327
def __init__(self):
3428
self._tasks = {}
@@ -108,12 +102,8 @@ def examine(self):
108102
if not name:
109103
name = getattr(func, '__name__', 'anonymous')
110104
logger.info(
111-
"Running task: {} (delay: {})".format(name, delay))
112-
if sys.version_info.major < 3:
113-
sig_len = len(inspect.getargspec(func)[0])
114-
else:
115-
sig_len = len(signature(func).parameters)
116-
if sig_len > 0 and isinstance(changed, list):
105+
f"Running task: {name} (delay: {delay})")
106+
if len(signature(func).parameters) > 0 and isinstance(changed, list):
117107
func(changed)
118108
else:
119109
func()
@@ -206,10 +196,7 @@ def is_folder_changed(self, path, ignore=None):
206196

207197
def get_changed_glob_files(self, path, ignore=None):
208198
"""Check if glob path has any changed filepaths."""
209-
if sys.version_info[0] >=3 and sys.version_info[1] >=5:
210-
files = glob.glob(path, recursive=True)
211-
else:
212-
files = glob.glob(path)
199+
files = glob.glob(path, recursive=True)
213200
changed_files = [f for f in files if self.is_file_changed(f, ignore)]
214201
return changed_files
215202

server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding: utf-8
2-
31
from livereload import Server, shell
42

53
server = Server()

setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
[bdist_wheel]
2-
universal = 1
3-
41
[metadata]
52
license_file = LICENSE

setup.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43
import re
54
from setuptools import setup
65

76

87
def fread(filepath):
9-
with open(filepath, 'r') as f:
8+
with open(filepath) as f:
109
return f.read()
1110

1211

@@ -33,12 +32,11 @@ def version():
3332
]
3433
},
3534
install_requires=[
36-
'tornado;python_version>"2.7"',
37-
'tornado<6;python_version=="2.7"',
38-
'six',
35+
'tornado',
3936
],
4037
license='BSD',
4138
include_package_data=True,
39+
python_requires='>=3.6',
4240
classifiers=[
4341
'Development Status :: 4 - Beta',
4442
'Environment :: Console',
@@ -49,13 +47,12 @@ def version():
4947
'Operating System :: MacOS :: MacOS X',
5048
'Operating System :: POSIX :: Linux',
5149
'Programming Language :: Python',
52-
'Programming Language :: Python :: 2',
53-
'Programming Language :: Python :: 2.7',
5450
'Programming Language :: Python :: 3',
55-
'Programming Language :: Python :: 3.5',
5651
'Programming Language :: Python :: 3.6',
5752
'Programming Language :: Python :: 3.7',
5853
'Programming Language :: Python :: 3.8',
54+
'Programming Language :: Python :: 3.9',
55+
'Programming Language :: Python :: 3 :: Only',
5956
'Programming Language :: Python :: Implementation :: CPython',
6057
'Programming Language :: Python :: Implementation :: PyPy',
6158
'Topic :: Software Development :: Build Tools',

0 commit comments

Comments
 (0)