prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  The purl of Alpine ecosystem is inconsistent with purl-spec
  According to [**purl-type `apk`**](https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#apk) ([PR](https://github.com/package-url/purl-spec/pull/171)), it seems that the purl type of `Alpine` should be `apk` and the purl namespace can be `alpine`. In this project, however, the purl type of `Alpine` is `alpine`.
  
  As a result, the purl of a package is **different** when apply different standards. For example, the purl of the `curl` package is `pkg:apk/alpine/curl` according to purl-spec while it is `pkg:alpine/curl` in this project.
  
  
  
  </issue>
  <code>
  [start of osv/purl_helpers.py]
  1 # Copyright 2022 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 """PURL conversion utilities."""
  15 
  16 from urllib.parse import quote
  17 
  18 PURL_ECOSYSTEMS = {
  19     'crates.io': 'cargo',
  20     'Debian': 'deb',
  21     'Hex': 'hex',
  22     'Go': 'golang',
  23     'Maven': 'maven',
  24     'NuGet': 'nuget',
  25     'npm': 'npm',
  26     'Packagist': 'composer',
  27     'OSS-Fuzz': 'generic',
  28     'PyPI': 'pypi',
  29     'RubyGems': 'gem',
  30 }
  31 
  32 
  33 def _url_encode(package_name):
  34   """URL encode a PURL `namespace/name` or `name`."""
  35   parts = package_name.split('/')
  36   return '/'.join(quote(p) for p in parts)
  37 
  38 
  39 def package_to_purl(ecosystem, package_name):
  40   """Convert a ecosystem and package name to PURL."""
  41   purl_type = PURL_ECOSYSTEMS.get(ecosystem)
  42   if not purl_type:
  43     return None
  44 
  45   suffix = ''
  46 
  47   if purl_type == 'maven':
  48     # PURLs use / to separate the group ID and the artifact ID.
  49     package_name = package_name.replace(':', '/', 1)
  50 
  51   if purl_type == 'deb':
  52     package_name = 'debian/' + package_name
  53     suffix = '?arch=source'
  54 
  55   return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'
  56
  [end of osv/purl_helpers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/osv/purl_helpers.py b/osv/purl_helpers.py
  --- a/osv/purl_helpers.py
  +++ b/osv/purl_helpers.py
  @@ -16,6 +16,7 @@
   from urllib.parse import quote
   
   PURL_ECOSYSTEMS = {
  +    'Alpine': 'apk',
       'crates.io': 'cargo',
       'Debian': 'deb',
       'Hex': 'hex',
  @@ -48,8 +49,12 @@
       # PURLs use / to separate the group ID and the artifact ID.
       package_name = package_name.replace(':', '/', 1)
   
  -  if purl_type == 'deb':
  +  if purl_type == 'deb' and ecosystem == 'Debian':
       package_name = 'debian/' + package_name
       suffix = '?arch=source'
   
  +  if purl_type == 'apk' and ecosystem == 'Alpine':
  +    package_name = 'alpine/' + package_name
  +    suffix = '?arch=source'
  +
     return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'
  
verification_info: {"golden_diff": "diff --git a/osv/purl_helpers.py b/osv/purl_helpers.py\n--- a/osv/purl_helpers.py\n+++ b/osv/purl_helpers.py\n@@ -16,6 +16,7 @@\n from urllib.parse import quote\n \n PURL_ECOSYSTEMS = {\n+    'Alpine': 'apk',\n     'crates.io': 'cargo',\n     'Debian': 'deb',\n     'Hex': 'hex',\n@@ -48,8 +49,12 @@\n     # PURLs use / to separate the group ID and the artifact ID.\n     package_name = package_name.replace(':', '/', 1)\n \n-  if purl_type == 'deb':\n+  if purl_type == 'deb' and ecosystem == 'Debian':\n     package_name = 'debian/' + package_name\n     suffix = '?arch=source'\n \n+  if purl_type == 'apk' and ecosystem == 'Alpine':\n+    package_name = 'alpine/' + package_name\n+    suffix = '?arch=source'\n+\n   return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'\n", "issue": "The purl of Alpine ecosystem is inconsistent with purl-spec\nAccording to [**purl-type `apk`**](https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#apk) ([PR](https://github.com/package-url/purl-spec/pull/171)), it seems that the purl type of `Alpine` should be `apk` and the purl namespace can be `alpine`. In this project, however, the purl type of `Alpine` is `alpine`.\r\n\r\nAs a result, the purl of a package is **different** when apply different standards. For example, the purl of the `curl` package is `pkg:apk/alpine/curl` according to purl-spec while it is `pkg:alpine/curl` in this project.\r\n\r\n\n", "before_files": [{"content": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"PURL conversion utilities.\"\"\"\n\nfrom urllib.parse import quote\n\nPURL_ECOSYSTEMS = {\n    'crates.io': 'cargo',\n    'Debian': 'deb',\n    'Hex': 'hex',\n    'Go': 'golang',\n    'Maven': 'maven',\n    'NuGet': 'nuget',\n    'npm': 'npm',\n    'Packagist': 'composer',\n    'OSS-Fuzz': 'generic',\n    'PyPI': 'pypi',\n    'RubyGems': 'gem',\n}\n\n\ndef _url_encode(package_name):\n  \"\"\"URL encode a PURL `namespace/name` or `name`.\"\"\"\n  parts = package_name.split('/')\n  return '/'.join(quote(p) for p in parts)\n\n\ndef package_to_purl(ecosystem, package_name):\n  \"\"\"Convert a ecosystem and package name to PURL.\"\"\"\n  purl_type = PURL_ECOSYSTEMS.get(ecosystem)\n  if not purl_type:\n    return None\n\n  suffix = ''\n\n  if purl_type == 'maven':\n    # PURLs use / to separate the group ID and the artifact ID.\n    package_name = package_name.replace(':', '/', 1)\n\n  if purl_type == 'deb':\n    package_name = 'debian/' + package_name\n    suffix = '?arch=source'\n\n  return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'\n", "path": "osv/purl_helpers.py"}]}