aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-03-28 10:28:05 +0200
committerIlya Etingof <etingof@gmail.com>2016-03-28 10:28:05 +0200
commite00c050522e07f2151d4236606b5fe9cde4b68e9 (patch)
treeccce36cfd93add2aa75e61906870826ca9326d6f
parentf9ffeac602b042fc98fb3ef7accc0f97350ed3af (diff)
downloadpyasn1-e00c050522e07f2151d4236606b5fe9cde4b68e9.tar.gz
more pep8 reformatting
-rw-r--r--doc/source/conf.py118
-rw-r--r--pyasn1/codec/ber/decoder.py2
-rw-r--r--pyasn1/codec/ber/encoder.py14
-rw-r--r--pyasn1/compat/octets.py13
-rw-r--r--pyasn1/debug.py1
-rw-r--r--pyasn1/type/base.py1
-rw-r--r--pyasn1/type/tagmap.py1
-rw-r--r--pyasn1/type/univ.py2
-rw-r--r--test/type/suite.py5
-rw-r--r--test/type/test_namedtype.py1
10 files changed, 92 insertions, 66 deletions
diff --git a/doc/source/conf.py b/doc/source/conf.py
index b066f95..3fa2d2a 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -19,12 +19,12 @@ import shlex
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
+# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -46,13 +46,14 @@ templates_path = ['.templates']
source_suffix = '.rst'
# The encoding of source files.
-#source_encoding = 'utf-8-sig'
+# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'contents'
# General information about the project.
project = u'PyASN1'
+# noinspection PyShadowingBuiltins
copyright = u'2015, Ilya Etingof <ilya@glas.net>'
author = u'Ilya Etingof <ilya@glas.net>'
@@ -74,9 +75,9 @@ language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
-#today = ''
+# today = ''
# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
+# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -84,63 +85,62 @@ exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
-#default_role = None
+# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
+# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
-#add_module_names = True
+# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
-#show_authors = False
+# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
+# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
-#keep_warnings = False
+# keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
-
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
-#html_theme = 'alabaster'
+# html_theme = 'alabaster'
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
-#html_theme_options = {}
+# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
+# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
-#html_title = None
+# html_title = None
html_title = "PyASN1"
# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
+# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
-#html_logo = ""
+# html_logo = ""
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
-#html_favicon = None
+# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
@@ -155,31 +155,31 @@ if 'PYASN1DEV' in os.environ:
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
-#html_extra_path = []
+# html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
-#html_use_smartypants = True
+# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
-#html_additional_pages = {}
+# html_additional_pages = {}
# If false, no module index is generated.
-#html_domain_indices = True
+# html_domain_indices = True
# If false, no index is generated.
-#html_use_index = True
+# html_use_index = True
# If true, the index is split into individual pages for each letter.
-#html_split_index = False
+# html_split_index = False
# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False
@@ -188,29 +188,29 @@ html_show_sourcelink = False
html_show_sphinx = False
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
+# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
+# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
+# html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
-#html_search_language = 'en'
+# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
-#html_search_options = {'type': 'default'}
+# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
-#html_search_scorer = 'scorer.js'
+# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'pyasn1doc'
@@ -218,46 +218,46 @@ htmlhelp_basename = 'pyasn1doc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
+ # The paper size ('letterpaper' or 'a4paper').
+ # 'papersize': 'letterpaper',
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
+ # The font size ('10pt', '11pt' or '12pt').
+ # 'pointsize': '10pt',
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
+ # Additional stuff for the LaTeX preamble.
+ # 'preamble': '',
-# Latex figure (float) alignment
-#'figure_align': 'htbp',
+ # Latex figure (float) alignment
+ # 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
- (master_doc, 'PyASN1.tex', u'PyASN1 Documentation',
- u'Ilya Etingof \\textless{}ilya@glas.net\\textgreater{}', 'manual'),
+ (master_doc, 'PyASN1.tex', u'PyASN1 Documentation',
+ u'Ilya Etingof \\textless{}ilya@glas.net\\textgreater{}', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
-#latex_logo = None
+# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
-#latex_use_parts = False
+# latex_use_parts = False
# If true, show page references after internal links.
-#latex_show_pagerefs = False
+# latex_show_pagerefs = False
# If true, show URL addresses after external links.
-#latex_show_urls = False
+# latex_show_urls = False
# Documents to append as an appendix to all manuals.
-#latex_appendices = []
+# latex_appendices = []
# If false, no module index is generated.
-#latex_domain_indices = True
+# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
@@ -270,7 +270,7 @@ man_pages = [
]
# If true, show URL addresses after external links.
-#man_show_urls = False
+# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
@@ -279,32 +279,32 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- (master_doc, 'PyASN1', u'PyASN1 Documentation',
- author, 'PyASN1', 'One line description of project.',
- 'Miscellaneous'),
+ (master_doc, 'PyASN1', u'PyASN1 Documentation',
+ author, 'PyASN1', 'One line description of project.',
+ 'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
+# texinfo_appendices = []
# If false, no module index is generated.
-#texinfo_domain_indices = True
+# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'
+# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
-#texinfo_no_detailmenu = False
+# texinfo_no_detailmenu = False
# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = { 'python': ('https://docs.python.org/3.4/', None)}
+intersphinx_mapping = {'python': ('https://docs.python.org/3.4/', None)}
# this merges constructor docstring with class docstring
autoclass_content = 'both'
# Sort members by type
autodoc_member_order = 'bysource'
-#autodoc_member_order = 'groupwise'
+# autodoc_member_order = 'groupwise'
# Napoleon settings
napoleon_google_docstring = False
diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py
index bf58976..e22fe61 100644
--- a/pyasn1/codec/ber/decoder.py
+++ b/pyasn1/codec/ber/decoder.py
@@ -39,6 +39,7 @@ class AbstractSimpleDecoder(AbstractDecoder):
class AbstractConstructedDecoder(AbstractDecoder):
tagFormats = (tag.tagFormatConstructed,)
+ # noinspection PyUnusedLocal
def _createComponent(self, asn1Spec, tagSet, value=None):
if tagSet[0][1] not in self.tagFormats:
raise error.PyAsn1Error('Invalid tag format %s for %s' % (tagSet[0], self.protoComponent.prettyPrintType()))
@@ -669,6 +670,7 @@ class Decoder:
defaultRawDecoder = AnyDecoder()
supportIndefLength = True
+ # noinspection PyDefaultArgument
def __init__(self, tagMap, typeMap={}):
self.__tagMap = tagMap
self.__typeMap = typeMap
diff --git a/pyasn1/codec/ber/encoder.py b/pyasn1/codec/ber/encoder.py
index 441c9a3..64e55d7 100644
--- a/pyasn1/codec/ber/encoder.py
+++ b/pyasn1/codec/ber/encoder.py
@@ -17,6 +17,7 @@ class Error(Exception):
class AbstractItemEncoder:
supportIndefLenMode = 1
+ # noinspection PyMethodMayBeStatic
def encodeTag(self, t, isConstructed):
tagClass, tagFormat, tagId = t.asTuple() # this is a hotspot
v = tagClass | tagFormat
@@ -259,10 +260,10 @@ class RealEncoder(AbstractItemEncoder):
def _chooseEncBase(self, value):
m, b, e = value
- base = [2, 8, 16]
- if value.binEncBase in base:
+ encBase = [2, 8, 16]
+ if value.binEncBase in encBase:
return self._dropFloatingPoint(m, value.binEncBase, e)
- elif self.binEncBase in base:
+ elif self.binEncBase in encBase:
return self._dropFloatingPoint(m, self.binEncBase, e)
# auto choosing base 2/8/16
mantissa = [m, m, m]
@@ -271,13 +272,13 @@ class RealEncoder(AbstractItemEncoder):
encbase = 2
e = float('inf')
for i in range(3):
- sign, mantissa[i], base[i], exponenta[i] = \
- self._dropFloatingPoint(mantissa[i], base[i], exponenta[i])
+ sign, mantissa[i], encBase[i], exponenta[i] = \
+ self._dropFloatingPoint(mantissa[i], encBase[i], exponenta[i])
if abs(exponenta[i]) < abs(e) or \
(abs(exponenta[i]) == abs(e) and mantissa[i] < m):
e = exponenta[i]
m = int(mantissa[i])
- encbase = base[i]
+ encbase = encBase[i]
return sign, m, encbase, e
def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
@@ -438,6 +439,7 @@ typeMap = {
class Encoder:
supportIndefLength = True
+ # noinspection PyDefaultArgument
def __init__(self, tagMap, typeMap={}):
self.__tagMap = tagMap
self.__typeMap = typeMap
diff --git a/pyasn1/compat/octets.py b/pyasn1/compat/octets.py
index 9e795ae..410e219 100644
--- a/pyasn1/compat/octets.py
+++ b/pyasn1/compat/octets.py
@@ -8,21 +8,34 @@ from sys import version_info
if version_info[0] <= 2:
int2oct = chr
+ # noinspection PyPep8
ints2octs = lambda s: ''.join([int2oct(x) for x in s])
null = ''
oct2int = ord
+ # noinspection PyPep8
octs2ints = lambda s: [oct2int(x) for x in s]
+ # noinspection PyPep8
str2octs = lambda x: x
+ # noinspection PyPep8
octs2str = lambda x: x
+ # noinspection PyPep8
isOctetsType = lambda s: isinstance(s, str)
+ # noinspection PyPep8
isStringType = lambda s: isinstance(s, (str, unicode))
else:
ints2octs = bytes
+ # noinspection PyPep8
int2oct = lambda x: ints2octs((x,))
null = ints2octs()
+ # noinspection PyPep8
oct2int = lambda x: x
+ # noinspection PyPep8
octs2ints = lambda s: [x for x in s]
+ # noinspection PyPep8
str2octs = lambda x: x.encode('iso-8859-1')
+ # noinspection PyPep8
octs2str = lambda x: x.decode('iso-8859-1')
+ # noinspection PyPep8
isOctetsType = lambda s: isinstance(s, bytes)
+ # noinspection PyPep8
isStringType = lambda s: isinstance(s, str)
diff --git a/pyasn1/debug.py b/pyasn1/debug.py
index 7d3dfc8..c82429e 100644
--- a/pyasn1/debug.py
+++ b/pyasn1/debug.py
@@ -22,6 +22,7 @@ flagMap = {
class Printer:
+ # noinspection PyShadowingNames
def __init__(self, logger=None, handler=None, formatter=None):
if logger is None:
logger = logging.getLogger('pyasn1')
diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py
index 6b00323..fe8bf4c 100644
--- a/pyasn1/type/base.py
+++ b/pyasn1/type/base.py
@@ -268,6 +268,7 @@ class AbstractSimpleAsn1Item(Asn1ItemBase):
def prettyPrinter(self, scope=0):
return self.prettyPrint(scope)
+ # noinspection PyUnusedLocal
def prettyPrintType(self, scope=0):
return '%s -> %s' % (self.getTagSet(), self.__class__.__name__)
diff --git a/pyasn1/type/tagmap.py b/pyasn1/type/tagmap.py
index e098892..1c2e4ae 100644
--- a/pyasn1/type/tagmap.py
+++ b/pyasn1/type/tagmap.py
@@ -8,6 +8,7 @@ from pyasn1 import error
class TagMap:
+ # noinspection PyDefaultArgument
def __init__(self, posMap={}, negMap={}, defType=None):
self.__posMap = posMap.copy()
self.__negMap = negMap.copy()
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py
index 1a4673e..87f63f7 100644
--- a/pyasn1/type/univ.py
+++ b/pyasn1/type/univ.py
@@ -722,9 +722,11 @@ class BitString(base.AbstractSimpleAsn1Item):
try:
+ # noinspection PyStatementEffect
all
except NameError: # Python 2.4
+ # noinspection PyShadowingBuiltins
def all(iterable):
for element in iterable:
if not element:
diff --git a/test/type/suite.py b/test/type/suite.py
index 2b6a233..a3a22d6 100644
--- a/test/type/suite.py
+++ b/test/type/suite.py
@@ -4,7 +4,10 @@
# Copyright (c) 2005-2016, Ilya Etingof <ilya@glas.net>
# License: http://pyasn1.sf.net/license.html
#
-import test_tag, test_constraint, test_namedtype, test_univ
+import test_tag
+import test_constraint
+import test_namedtype
+import test_univ
from sys import version_info
if version_info[0:2] < (2, 7) or \
diff --git a/test/type/test_namedtype.py b/test/type/test_namedtype.py
index 84b308d..91db80b 100644
--- a/test/type/test_namedtype.py
+++ b/test/type/test_namedtype.py
@@ -43,6 +43,7 @@ class NamedTypesCaseBase(unittest.TestCase):
'OptionalNamedType': namedtype.OptionalNamedType, 'Integer': univ.Integer,
'OctetString': univ.OctetString}) == self.e, 'repr() fails'
+ # noinspection PyUnusedLocal
def testIter(self):
for t in self.e:
break