From bab253ac9fd825890b36f8354f1f109752aadff7 Mon Sep 17 00:00:00 2001
From: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Date: Wed, 14 Dec 2016 10:21:25 +0200
Subject: [PATCH] Fixes to various issues reported by pyflakes

Pyflake is a python (2) source checker. This patch fixes various
(mostly trivial) errors and warnings it reports.

Change-Id: Ia35c5ac61751b927814cf693994c632c412386ea
---
 build_tools/get_documentation.py                              | 3 ---
 build_tools/post_process_documentation.py                     | 4 +---
 .../config/versions/4c573e7135bd_fix_tos_field_types.py       | 1 -
 .../versions/5139253c0423_make_q_member_uniqueid_autoinc.py   | 1 -
 rest-api-templates/asterisk_processor.py                      | 1 +
 rest-api-templates/swagger_model.py                           | 2 +-
 rest-api-templates/transform.py                               | 1 -
 7 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/build_tools/get_documentation.py b/build_tools/get_documentation.py
index 2ff4cb2b94..3211896460 100644
--- a/build_tools/get_documentation.py
+++ b/build_tools/get_documentation.py
@@ -9,11 +9,8 @@ the GNU General Public License Version 2.
 '''
 
 import sys
-import os
 import xml.dom.minidom
 
-from xml.dom.minidom import Element
-
 
 def get_manager_event_method_type(candidate_string):
     if "ast_manager_event_multichan" in candidate_string:
diff --git a/build_tools/post_process_documentation.py b/build_tools/post_process_documentation.py
index 5fa1c5b587..c1496beabf 100644
--- a/build_tools/post_process_documentation.py
+++ b/build_tools/post_process_documentation.py
@@ -9,11 +9,9 @@ the GNU General Public License Version 2.
 '''
 
 import sys
-import os
 import optparse
-import xml.dom.minidom
 
-from xml.dom.minidom import Element, parse
+from xml.dom.minidom import parse
 
 
 def merge_parameter_information(managerEvent):
diff --git a/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py b/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
index 27b498f30a..17906ae19d 100755
--- a/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
+++ b/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
@@ -11,7 +11,6 @@ revision = '4c573e7135bd'
 down_revision = '28887f25a46f'
 
 from alembic import op
-from alembic import context
 import sqlalchemy as sa
 from sqlalchemy.dialects.postgresql import ENUM
 
diff --git a/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py b/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py
index 01d4985fe5..72f5ee1696 100755
--- a/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py
+++ b/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py
@@ -33,7 +33,6 @@ import sqlalchemy as sa
 
 
 def upgrade():
-    context = op.get_context()
     # Was unable to find a way to use op.alter_column() to add the unique
     # index property.
     op.drop_column('queue_members', 'uniqueid')
diff --git a/rest-api-templates/asterisk_processor.py b/rest-api-templates/asterisk_processor.py
index 68a6799946..9812946730 100644
--- a/rest-api-templates/asterisk_processor.py
+++ b/rest-api-templates/asterisk_processor.py
@@ -20,6 +20,7 @@
 Asterisk RESTful HTTP binding code.
 """
 
+import os
 import re
 
 from swagger_model import *
diff --git a/rest-api-templates/swagger_model.py b/rest-api-templates/swagger_model.py
index c71352a012..08852415c0 100644
--- a/rest-api-templates/swagger_model.py
+++ b/rest-api-templates/swagger_model.py
@@ -737,7 +737,7 @@ class ResourceListing(Stringify):
         self.swagger_version = resources_json.get('swaggerVersion')
         if not self.swagger_version in SWAGGER_VERSIONS:
             raise SwaggerError(
-                "Unsupported Swagger version %s" % swagger_version, context)
+                "Unsupported Swagger version %s" % self.swagger_version, context)
 
         validate_required_fields(resources_json, self.required_fields, context)
         self.api_version = resources_json['apiVersion']
diff --git a/rest-api-templates/transform.py b/rest-api-templates/transform.py
index fc12efe859..c3a0300640 100644
--- a/rest-api-templates/transform.py
+++ b/rest-api-templates/transform.py
@@ -52,7 +52,6 @@ class Transform(object):
         dest_exists = os.path.exists(dest_file)
         if dest_exists and not self.overwrite:
             return
-        tmp_file = tempfile.mkstemp()
         with tempfile.NamedTemporaryFile() as out:
             out.write(renderer.render(self.template, model))
             out.flush()
-- 
GitLab