Skip to content

Commit 2820690

Browse files
committed
Fixed PEP8 style issues
1 parent d9dbf6e commit 2820690

4 files changed

Lines changed: 56 additions & 53 deletions

File tree

doc/conf.py

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
# import sys
15+
# import os
1516
import rsa
1617

1718
# If extensions (or modules to document with autodoc) are in another directory,
1819
# add these directories to sys.path here. If the directory is relative to the
1920
# documentation root, use os.path.abspath to make it absolute, like shown here.
20-
#sys.path.insert(0, os.path.abspath('.'))
21+
# sys.path.insert(0, os.path.abspath('.'))
2122

2223
# -- General configuration -----------------------------------------------------
2324

2425
# If your documentation needs a minimal Sphinx version, state it here.
25-
#needs_sphinx = '1.0'
26+
# needs_sphinx = '1.0'
2627

2728
# Add any Sphinx extension module names here, as strings. They can be extensions
2829
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
2930
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
30-
'sphinx.ext.coverage', 'sphinx.ext.pngmath']
31+
'sphinx.ext.coverage', 'sphinx.ext.pngmath']
3132

3233
# I would like to add 'sphinx.ext.viewcode', but it causes a UnicodeDecodeError
3334

@@ -62,33 +63,33 @@
6263

6364
# There are two options for replacing |today|: either, you set today to some
6465
# non-false value, then it is used:
65-
#today = ''
66+
# today = ''
6667
# Else, today_fmt is used as the format for a strftime call.
67-
#today_fmt = '%B %d, %Y'
68+
# today_fmt = '%B %d, %Y'
6869

6970
# List of patterns, relative to source directory, that match files and
7071
# directories to ignore when looking for source files.
7172
exclude_patterns = ['_build']
7273

7374
# The reST default role (used for this markup: `text`) to use for all documents.
74-
#default_role = None
75+
# default_role = None
7576

7677
# If true, '()' will be appended to :func: etc. cross-reference text.
77-
#add_function_parentheses = True
78+
# add_function_parentheses = True
7879

7980
# If true, the current module name will be prepended to all description
8081
# unit titles (such as .. function::).
81-
#add_module_names = True
82+
# add_module_names = True
8283

8384
# If true, sectionauthor and moduleauthor directives will be shown in the
8485
# output. They are ignored by default.
85-
#show_authors = False
86+
# show_authors = False
8687

8788
# The name of the Pygments (syntax highlighting) style to use.
8889
pygments_style = 'sphinx'
8990

9091
# A list of ignored prefixes for module index sorting.
91-
#modindex_common_prefix = []
92+
# modindex_common_prefix = []
9293

9394

9495
# -- Options for HTML output ---------------------------------------------------
@@ -100,26 +101,26 @@
100101
# Theme options are theme-specific and customize the look and feel of a theme
101102
# further. For a list of options available for each theme, see the
102103
# documentation.
103-
#html_theme_options = {}
104+
# html_theme_options = {}
104105

105106
# Add any paths that contain custom themes here, relative to this directory.
106-
#html_theme_path = []
107+
# html_theme_path = []
107108

108109
# The name for this set of Sphinx documents. If None, it defaults to
109110
# "<project> v<release> documentation".
110-
#html_title = None
111+
# html_title = None
111112

112113
# A shorter title for the navigation bar. Default is the same as html_title.
113-
#html_short_title = None
114+
# html_short_title = None
114115

115116
# The name of an image file (relative to this directory) to place at the top
116117
# of the sidebar.
117-
#html_logo = None
118+
# html_logo = None
118119

119120
# The name of an image file (within the static path) to use as favicon of the
120121
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
121122
# pixels large.
122-
#html_favicon = None
123+
# html_favicon = None
123124

124125
# Add any paths that contain custom static files (such as style sheets) here,
125126
# relative to this directory. They are copied after the builtin static files,
@@ -128,86 +129,85 @@
128129

129130
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
130131
# using the given strftime format.
131-
#html_last_updated_fmt = '%b %d, %Y'
132+
# html_last_updated_fmt = '%b %d, %Y'
132133

133134
# If true, SmartyPants will be used to convert quotes and dashes to
134135
# typographically correct entities.
135-
#html_use_smartypants = True
136+
# html_use_smartypants = True
136137

137138
# Custom sidebar templates, maps document names to template names.
138-
#html_sidebars = {}
139+
# html_sidebars = {}
139140

140141
# Additional templates that should be rendered to pages, maps page names to
141142
# template names.
142-
#html_additional_pages = {}
143+
# html_additional_pages = {}
143144

144145
# If false, no module index is generated.
145-
#html_domain_indices = True
146+
# html_domain_indices = True
146147

147148
# If false, no index is generated.
148-
#html_use_index = True
149+
# html_use_index = True
149150

150151
# If true, the index is split into individual pages for each letter.
151-
#html_split_index = False
152+
# html_split_index = False
152153

153154
# If true, links to the reST sources are added to the pages.
154-
#html_show_sourcelink = True
155+
# html_show_sourcelink = True
155156

156157
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
157-
#html_show_sphinx = True
158+
# html_show_sphinx = True
158159

159160
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
160-
#html_show_copyright = True
161+
# html_show_copyright = True
161162

162163
# If true, an OpenSearch description file will be output, and all pages will
163164
# contain a <link> tag referring to it. The value of this option must be the
164165
# base URL from which the finished HTML is served.
165-
#html_use_opensearch = ''
166+
# html_use_opensearch = ''
166167

167168
# This is the file name suffix for HTML files (e.g. ".xhtml").
168-
#html_file_suffix = None
169+
# html_file_suffix = None
169170

170171
# Output file base name for HTML help builder.
171172
htmlhelp_basename = 'Python-RSAdoc'
172173

173-
174174
# -- Options for LaTeX output --------------------------------------------------
175175

176176
# The paper size ('letter' or 'a4').
177-
#latex_paper_size = 'letter'
177+
# latex_paper_size = 'letter'
178178

179179
# The font size ('10pt', '11pt' or '12pt').
180-
#latex_font_size = '10pt'
180+
# latex_font_size = '10pt'
181181

182182
# Grouping the document tree into LaTeX files. List of tuples
183183
# (source start file, target name, title, author, documentclass [howto/manual]).
184184
latex_documents = [
185-
('index', 'Python-RSA.tex', u'Python-RSA Documentation',
186-
u'Sybren A. Stüvel', 'manual'),
185+
('index', 'Python-RSA.tex', u'Python-RSA Documentation',
186+
u'Sybren A. Stüvel', 'manual'),
187187
]
188188

189189
# The name of an image file (relative to this directory) to place at the top of
190190
# the title page.
191-
#latex_logo = None
191+
# latex_logo = None
192192

193193
# For "manual" documents, if this is true, then toplevel headings are parts,
194194
# not chapters.
195-
#latex_use_parts = False
195+
# latex_use_parts = False
196196

197197
# If true, show page references after internal links.
198-
#latex_show_pagerefs = False
198+
# latex_show_pagerefs = False
199199

200200
# If true, show URL addresses after external links.
201-
#latex_show_urls = False
201+
# latex_show_urls = False
202202

203203
# Additional stuff for the LaTeX preamble.
204-
#latex_preamble = ''
204+
# latex_preamble = ''
205205

206206
# Documents to append as an appendix to all manuals.
207-
#latex_appendices = []
207+
# latex_appendices = []
208208

209209
# If false, no module index is generated.
210-
#latex_domain_indices = True
210+
# latex_domain_indices = True
211211

212212

213213
# -- Options for manual page output --------------------------------------------
@@ -220,4 +220,3 @@
220220
]
221221

222222
todo_include_todos = True
223-

rsa/key.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,16 @@ def _load_pkcs1_der(cls, keyfile):
441441
# ASN.1 contents of DER encoded private key:
442442
#
443443
# RSAPrivateKey ::= SEQUENCE {
444-
# version Version,
444+
# version Version,
445445
# modulus INTEGER, -- n
446446
# publicExponent INTEGER, -- e
447447
# privateExponent INTEGER, -- d
448448
# prime1 INTEGER, -- p
449449
# prime2 INTEGER, -- q
450450
# exponent1 INTEGER, -- d mod (p-1)
451-
# exponent2 INTEGER, -- d mod (q-1)
451+
# exponent2 INTEGER, -- d mod (q-1)
452452
# coefficient INTEGER, -- (inverse of q) mod p
453-
# otherPrimeInfos OtherPrimeInfos OPTIONAL
453+
# otherPrimeInfos OtherPrimeInfos OPTIONAL
454454
# }
455455

456456
if priv[0] != 0:

rsa/prime.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
Roberto Tamassia, 2002.
2121
"""
2222

23-
__all__ = ['getprime', 'are_relatively_prime']
24-
2523
import rsa.randnum
2624

25+
__all__ = ['getprime', 'are_relatively_prime']
26+
2727

2828
def gcd(p, q):
2929
"""Returns the greatest common divisor of p and q
@@ -47,7 +47,8 @@ def jacobi(a, b):
4747
assert a > 0
4848
assert b > 0
4949

50-
if a == 0: return 0
50+
if a == 0:
51+
return 0
5152
result = 1
5253
while a > 1:
5354
if a & 1:
@@ -58,7 +59,8 @@ def jacobi(a, b):
5859
if (((b * b) - 1) >> 3) & 1:
5960
result = -result
6061
a >>= 1
61-
if a == 0: return 0
62+
if a == 0:
63+
return 0
6264
return result
6365

6466

@@ -69,7 +71,8 @@ def jacobi_witness(x, n):
6971

7072
f = pow(x, n >> 1, n)
7173

72-
if j == f: return False
74+
if j == f:
75+
return False
7376
return True
7477

7578

@@ -93,7 +96,8 @@ def randomized_primality_testing(n, k):
9396

9497
for _ in range(k):
9598
x = rsa.randnum.randint(n - 1)
96-
if jacobi_witness(x, n): return False
99+
if jacobi_witness(x, n):
100+
return False
97101

98102
return True
99103

rsa/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def private_to_public():
5050

5151
# Read the input data
5252
if cli.infilename:
53-
print('Reading private key from %s in %s format' % \
53+
print('Reading private key from %s in %s format' %
5454
(cli.infilename, cli.inform), file=sys.stderr)
5555
with open(cli.infilename, 'rb') as infile:
5656
in_data = infile.read()
@@ -69,7 +69,7 @@ def private_to_public():
6969
out_data = pub_key.save_pkcs1(cli.outform)
7070

7171
if cli.outfilename:
72-
print('Writing public key to %s in %s format' % \
72+
print('Writing public key to %s in %s format' %
7373
(cli.outfilename, cli.outform), file=sys.stderr)
7474
with open(cli.outfilename, 'wb') as outfile:
7575
outfile.write(out_data)

0 commit comments

Comments
 (0)