File build.patch of Package python-jedihttp

Index: python-jedihttp-0+git.1497381496.75b8b74/setup.py
===================================================================
--- /dev/null
+++ python-jedihttp-0+git.1497381496.75b8b74/setup.py
@@ -0,0 +1,17 @@
+import os
+from setuptools import setup
+
+setup(
+    name = "jedihttp",
+    version = "0.0.0",
+    author = "Andrea Cedraro",
+    author_email = "a.cedraro@gmail.com",
+    description = ("HTTP/JSON wrapper around jedi"),
+    license = "Apache-2.0",
+    url = "https://github.com/vheon/JediHTTP",
+    packages = ['jedihttp'],
+    scripts = ['jedihttp-server'],
+    install_requires = ['waitress',
+                        'bottle',
+                        'argparse'],
+)
Index: python-jedihttp-0+git.1497381496.75b8b74/jedihttp.py
===================================================================
--- python-jedihttp-0+git.1497381496.75b8b74.orig/jedihttp.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#     Copyright 2015 Cedraro Andrea <a.cedraro@gmail.com>
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-#    limitations under the License.
-
-from jedihttp import utils
-utils.AddVendorFolderToSysPath()
-
-import logging
-import json
-import os
-import sys
-from base64 import b64decode
-from argparse import ArgumentParser
-from waitress import serve
-from jedihttp import handlers
-from jedihttp.hmac_plugin import HmacPlugin
-
-
-def ParseArgs():
-  parser = ArgumentParser()
-  parser.add_argument( '--host', type = str, default = '127.0.0.1',
-                       help = 'server host' )
-  parser.add_argument( '--port', type = int, default = 0,
-                       help = 'server port' )
-  parser.add_argument( '--log', type = str, default = 'info',
-                       choices = [ 'debug', 'info', 'warning',
-                                   'error', 'critical' ],
-                       help = 'log level' )
-  parser.add_argument( '--hmac-file-secret', type = str,
-                       help = 'file containing hmac secret' )
-  return parser.parse_args()
-
-
-def SetUpLogging( log_level ):
-  numeric_level = getattr( logging, log_level.upper(), None )
-  if not isinstance( numeric_level, int ):
-    raise ValueError( 'Invalid log level: {0}'.format( log_level ) )
-
-  # Has to be called before any call to logging.getLogger().
-  logging.basicConfig( format = '%(asctime)s - %(levelname)s - %(message)s',
-                       level = numeric_level )
-
-
-def GetSecretFromTempFile( tfile ):
-  key = 'hmac_secret'
-  with open( tfile ) as hmac_file:
-    try:
-      data = json.load( hmac_file )
-      if key not in data:
-        sys.exit( "A json file with a key named 'secret' was expected for "
-                  "the secret exchange, but wasn't found" )
-      hmac_secret = data[ key ]
-    except ValueError:
-      sys.exit( "A JSON was expected for the secret exchange" )
-  os.remove( tfile )
-  return hmac_secret
-
-
-def Main():
-  args = ParseArgs()
-
-  SetUpLogging( args.log )
-
-  if args.hmac_file_secret:
-    hmac_secret = GetSecretFromTempFile( args.hmac_file_secret )
-    handlers.app.config[ 'jedihttp.hmac_secret' ] = b64decode( hmac_secret )
-    handlers.app.install( HmacPlugin() )
-
-  serve( handlers.app,
-         host = args.host,
-         port = args.port )
-
-if __name__ == "__main__":
-  Main()
Index: python-jedihttp-0+git.1497381496.75b8b74/jedihttp/utils.py
===================================================================
--- python-jedihttp-0+git.1497381496.75b8b74.orig/jedihttp/utils.py
+++ python-jedihttp-0+git.1497381496.75b8b74/jedihttp/utils.py
@@ -18,6 +18,7 @@ import sys
 def AddVendorFolderToSysPath():
   vendor_folder = os.path.join( os.path.dirname( __file__ ), '..', 'vendor' )
 
-  for folder in os.listdir( vendor_folder ):
-    sys.path.insert( 0, os.path.realpath( os.path.join( vendor_folder,
-                                                        folder ) ) )
+  if os.path.exists(vendor_folder):
+    for folder in os.listdir( vendor_folder ):
+      sys.path.insert( 0, os.path.realpath( os.path.join( vendor_folder,
+                                                          folder ) ) )
Index: python-jedihttp-0+git.1497381496.75b8b74/jedihttp-server
===================================================================
--- /dev/null
+++ python-jedihttp-0+git.1497381496.75b8b74/jedihttp-server
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#     Copyright 2015 Cedraro Andrea <a.cedraro@gmail.com>
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+#    limitations under the License.
+
+from jedihttp import utils
+utils.AddVendorFolderToSysPath()
+
+import logging
+import json
+import os
+import sys
+from base64 import b64decode
+from argparse import ArgumentParser
+from waitress import serve
+from jedihttp import handlers
+from jedihttp.hmac_plugin import HmacPlugin
+
+
+def ParseArgs():
+  parser = ArgumentParser()
+  parser.add_argument( '--host', type = str, default = '127.0.0.1',
+                       help = 'server host' )
+  parser.add_argument( '--port', type = int, default = 0,
+                       help = 'server port' )
+  parser.add_argument( '--log', type = str, default = 'info',
+                       choices = [ 'debug', 'info', 'warning',
+                                   'error', 'critical' ],
+                       help = 'log level' )
+  parser.add_argument( '--hmac-file-secret', type = str,
+                       help = 'file containing hmac secret' )
+  return parser.parse_args()
+
+
+def SetUpLogging( log_level ):
+  numeric_level = getattr( logging, log_level.upper(), None )
+  if not isinstance( numeric_level, int ):
+    raise ValueError( 'Invalid log level: {0}'.format( log_level ) )
+
+  # Has to be called before any call to logging.getLogger().
+  logging.basicConfig( format = '%(asctime)s - %(levelname)s - %(message)s',
+                       level = numeric_level )
+
+
+def GetSecretFromTempFile( tfile ):
+  key = 'hmac_secret'
+  with open( tfile ) as hmac_file:
+    try:
+      data = json.load( hmac_file )
+      if key not in data:
+        sys.exit( "A json file with a key named 'secret' was expected for "
+                  "the secret exchange, but wasn't found" )
+      hmac_secret = data[ key ]
+    except ValueError:
+      sys.exit( "A JSON was expected for the secret exchange" )
+  os.remove( tfile )
+  return hmac_secret
+
+
+def Main():
+  args = ParseArgs()
+
+  SetUpLogging( args.log )
+
+  if args.hmac_file_secret:
+    hmac_secret = GetSecretFromTempFile( args.hmac_file_secret )
+    handlers.app.config[ 'jedihttp.hmac_secret' ] = b64decode( hmac_secret )
+    handlers.app.install( HmacPlugin() )
+
+  serve( handlers.app,
+         host = args.host,
+         port = args.port )
+
+if __name__ == "__main__":
+  Main()
Index: python-jedihttp-0+git.1497381496.75b8b74/jedihttp/tests/end_to_end_test.py
===================================================================
--- python-jedihttp-0+git.1497381496.75b8b74.orig/jedihttp/tests/end_to_end_test.py
+++ python-jedihttp-0+git.1497381496.75b8b74/jedihttp/tests/end_to_end_test.py
@@ -40,12 +40,12 @@ class HmacAuth( requests.auth.AuthBase )
 PORT = 50000
 SECRET = 'secret'
 PATH_TO_JEDIHTTP = path.abspath( path.join( path.dirname( __file__ ),
-                                            '..', '..', 'jedihttp.py' ) )
+                                            '..', '..', 'jedihttp-server' ) )
 
 
 def wait_for_jedihttp_to_start( jedihttp ):
   line = jedihttp.stdout.readline().decode( 'utf8' )
-  good_start = line.startswith( 'serving on' )
+  good_start = line.lower().startswith( 'serving on' )
   reason = jedihttp.stdout.read().decode( 'utf8' ) if not good_start else ''
   return good_start, reason
 
Index: python-jedihttp-0+git.1497381496.75b8b74/jedihttp/tests/handlers_test.py
===================================================================
--- python-jedihttp-0+git.1497381496.75b8b74.orig/jedihttp/tests/handlers_test.py
+++ python-jedihttp-0+git.1497381496.75b8b74/jedihttp/tests/handlers_test.py
@@ -180,7 +180,7 @@ def test_good_gotoassignment_do_not_foll
       'in_builtin_module': False,
       'line': 1,
       'column': 21,
-      'docstring': 'imported_function()\n\n',
+      'docstring': '',
       'description': 'def imported_function',
       'full_name': 'imported.imported_function',
       'is_keyword': False
@@ -315,7 +315,7 @@ def test_names():
         'in_builtin_module': False,
         'line': 1,
         'column': 7,
-        'docstring': contains_string( 'OS routines' ),
+        'docstring': '',
         'description': 'module os',
         'full_name': 'os',
         'is_keyword': False
openSUSE Build Service is sponsored by