#68 When searching by source name try to get a direct match first
Merged 7 years ago by pingou. Opened 7 years ago by pingou.

file modified
+20 -11
@@ -83,6 +83,7 @@ 

  

      return wrapper

  

+ 

  @asyncio.coroutine

  def _get_pkg(branch, name=None, action=None, srcname=None):

      ''' Return the pkg information for the given package in the specified
@@ -134,7 +135,8 @@ 

  

  def _get_pretty(request):

      pretty = False

-     get_params = MultiDict(urllib.parse.parse_qsl(request.query_string.lower()))

+     get_params = MultiDict(urllib.parse.parse_qsl(

+         request.query_string.lower()))

      if get_params.get('pretty'):

          if str(get_params.get('pretty', None)) in ['1', 'true']:

              pretty = True
@@ -174,7 +176,8 @@ 

                      out[datatype] = data

  

              # New meta-data present for soft dependency management in RPM

-             for datatype in ['enhances', 'recommends', 'suggests', 'supplements']:

+             for datatype in [

+                     'enhances', 'recommends', 'suggests', 'supplements']:

                  data = yield from mdapilib.get_package_info(

                      session, pkg.pkgKey, datatype.capitalize())

                  if data:
@@ -214,8 +217,9 @@ 

      if pretty:

          args = dict(sort_keys=True, indent=4, separators=(',', ': '))

  

-     output = web.Response(body=json.dumps(output, **args).encode('utf-8'),

-                         content_type='application/json')

+     output = web.Response(

+         body=json.dumps(output, **args).encode('utf-8'),

+         content_type='application/json')

      return output

  

  
@@ -233,8 +237,10 @@ 

      if pretty:

          args = dict(sort_keys=True, indent=4, separators=(',', ': '))

  

-     return web.Response(body=json.dumps(output, **args).encode('utf-8'),

-                         content_type='application/json')

+     return web.Response(

+         body=json.dumps(output, **args).encode('utf-8'),

+         content_type='application/json')

+ 

  

  @asyncio.coroutine

  @allows_jsonp
@@ -263,8 +269,9 @@ 

      if pretty:

          args = dict(sort_keys=True, indent=4, separators=(',', ': '))

  

-     return web.Response(body=json.dumps(output, **args).encode('utf-8'),

-                         content_type='application/json')

+     return web.Response(

+         body=json.dumps(output, **args).encode('utf-8'),

+         content_type='application/json')

  

  

  @asyncio.coroutine
@@ -294,8 +301,9 @@ 

      if pretty:

          args = dict(sort_keys=True, indent=4, separators=(',', ': '))

  

-     return web.Response(body=json.dumps(output, **args).encode('utf-8'),

-                         content_type='application/json')

+     return web.Response(

+         body=json.dumps(output, **args).encode('utf-8'),

+         content_type='application/json')

  

  

  @asyncio.coroutine
@@ -305,7 +313,8 @@ 

      pretty = _get_pretty(request)

      output = sorted(list(set([

          # Remove the front part `mdapi-` and the end part -<type>.sqlite

-         filename.replace('mdapi-', '').rsplit('-', 2)[0].replace('-updates', '')

+         filename.replace('mdapi-', '').rsplit('-', 2)[0].replace(

+             '-updates', '')

          for filename in os.listdir(CONFIG['DB_FOLDER'])

          if filename.startswith('mdapi') and filename.endswith('.sqlite')

      ])))

file modified
+10 -1
@@ -107,7 +107,12 @@ 

  def get_package_by_src(session, pkg_name):

      ''' Return information about a package, if we can find it.

      '''

-     output = None

+     # First try if there is a package matching exactly the provided name

+     simple_match = yield from get_package(session, pkg_name)

+     if simple_match and simple_match.basename == pkg_name:

+         return simple_match

+ 

+     # If there is not a direct match, look by the sourcerpm name

      cnt = 0

      try:

          pkg = session.query(
@@ -163,6 +168,7 @@ 

  

      return output

  

+ 

  @asyncio.coroutine

  def get_package_info(session, pkgKey, tablename):

      ''' Return the information contained in the specified table for the
@@ -190,6 +196,7 @@ 

  

      return output

  

+ 

  @asyncio.coroutine

  def get_co_packages(session, srcpkg_name):

      ''' Return the name of all the packages coming from the same
@@ -214,6 +221,7 @@ 

  

      return output

  

+ 

  @asyncio.coroutine

  def get_files(session, pkg_id):

      ''' Return the list of all the files in a package given its key.
@@ -240,6 +248,7 @@ 

  

      return output

  

+ 

  @asyncio.coroutine

  def get_changelog(session, pkg_id):

      ''' Return the list of all the changelog in a package given its key.

file modified
-1
@@ -113,7 +113,6 @@ 

      __tablename__ = 'conflicts'

  

  

- 

  class Obsoletes(BASEDEP):

      ''' Maps the provides table in the primary.sqlite database from

      repodata to a python object.

Then fall back to what are potentially sub-packages.

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

1 new commit added

  • Project wide flake8 fixes
7 years ago

rebased onto 2a8ed0f

7 years ago

Pull-Request has been merged by pingou

7 years ago