Skip to content

Commit 6602745

Browse files
committed
flake8: fix imports,
flake8 reported the following: templating.py:25:1: F401 'base64' imported but unused templating.py:25:1: F401 'mimetypes' imported but unused templating.py:25:1: F401 'string' imported but unused templating.py:28:1: F401 'time' imported but unused templating.py:28:1: F401 'hashlib' imported but unused templating.py:34:1: F401 'roundup.i18n' imported but unused templating.py:35:1: F401 'roundup.i18n._' imported but unused templating.py:36:1: F401 'roundup.anypy.strings.b2s' imported but unused templating.py:36:1: F401 'roundup.anypy.strings.s2b' imported but unused templating.py:43:1: F401 'roundup.anypy.random_' imported but unused templating.py:47:5: F401 'pickle' imported but unused Turns out time import was used by test_templating via from roundup.cgi.templating import * so added import time to test_templating Also split out multiple imports on one line into sepearate lines. Changed todo = to __todo__ to make flake8 shut up about module level imports not at top of file. Moved definiton of _disable_url_schemes for same reason.
1 parent 942d211 commit 6602745

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

roundup/cgi/templating.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Implements the API used in the HTML templating for the web interface.
22
"""
33

4-
todo = """
4+
__todo__ = """
55
- Document parameters to Template.render() method
66
- Add tests for Loader.load() method
77
- Most methods should have a "default" arg to supply a value
@@ -19,32 +19,22 @@
1919

2020
__docformat__ = 'restructuredtext'
2121

22-
# List of schemes that are not rendered as links in rst and markdown.
23-
_disable_url_schemes = ['javascript', 'data']
24-
25-
import base64, cgi, re, os.path, mimetypes, csv, string
2622
import calendar
23+
import cgi
24+
import csv
25+
import os.path
26+
import re
2727
import textwrap
28-
import time, hashlib
29-
30-
from roundup.anypy.html import html_escape
3128

32-
from roundup.anypy import urllib_
3329
from roundup import hyperdb, date, support
34-
from roundup import i18n
35-
from roundup.i18n import _
36-
from roundup.anypy.strings import is_us, b2s, s2b, us2s, s2u, u2s, StringIO
37-
38-
from .KeywordsExpr import render_keywords_expression_editor
39-
30+
from roundup.anypy import urllib_
31+
from roundup.anypy.html import html_escape
32+
from roundup.anypy.strings import is_us, us2s, s2u, u2s, StringIO
33+
from roundup.cgi import TranslationService, ZTUtils
4034
from roundup.cgi.timestamp import pack_timestamp
41-
from roundup.cgi import TranslationService
35+
from roundup.exceptions import RoundupException
36+
from .KeywordsExpr import render_keywords_expression_editor
4237

43-
import roundup.anypy.random_ as random_
44-
try:
45-
import cPickle as pickle
46-
except ImportError:
47-
import pickle
4838
try:
4939
from StructuredText.StructuredText import HTML as StructuredText
5040
except ImportError:
@@ -61,12 +51,15 @@
6151
except ImportError:
6252
from itertools import izip_longest as zip_longest
6353

64-
from roundup.exceptions import RoundupException
54+
55+
# List of schemes that are not rendered as links in rst and markdown.
56+
_disable_url_schemes = ['javascript', 'data']
6557

6658

6759
def _import_markdown2():
6860
try:
69-
import markdown2, re
61+
import markdown2
62+
import re
7063

7164
class Markdown(markdown2.Markdown):
7265
# don't allow disabled protocols in links
@@ -205,9 +198,6 @@ def _options(config):
205198

206199
markdown = _import_markdown2() or _import_markdown() or _import_mistune()
207200

208-
# bring in the templating support
209-
from roundup.cgi import ZTUtils
210-
211201

212202
def anti_csrf_nonce(client, lifetime=None):
213203
''' Create a nonce for defending against CSRF attack.

test/test_templating.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import print_function
22
import unittest
3+
import time
34
from cgi import FieldStorage, MiniFieldStorage
45

56
from roundup.cgi.templating import *

0 commit comments

Comments
 (0)