from utilities import url_to_json


def run(project_id, repo_path, cursor, **options):
    query = 'SELECT url FROM projects WHERE id = ' + str(project_id)
    cursor.execute(query)
    record = cursor.fetchone()

    full_url = record[0].rstrip()
    json_response = url_to_json(full_url, headers={
            'Accept': 'application/vnd.github.drax-preview+json'
        }
    )

    if 'license' in json_response:
        result = 1
    else:
        result = 0

    return result

if __name__ == '__main__':
    print("Attribute plugins are not meant to be executed directly.")

from core import tokenize
from utilities import url_to_json


def run(project_id, repo_path, cursor, **options):
    query = 'SELECT url FROM projects WHERE id = ' + str(project_id)
    cursor.execute(query)
    record = cursor.fetchone()

    full_url = tokenize(record[0].rstrip())
    json_response = url_to_json(full_url, headers={
            'Accept': 'application/vnd.github.drax-preview+json'
        }
    )

    result = 'license' in json_response
    return result, int(result)

if __name__ == '__main__':
    print("Attribute plugins are not meant to be executed directly.")

Update license attribute to return binary and raw result
Update license attribute to return binary and raw result

+ from core import tokenize
  from utilities import url_to_json
  
  
  def run(project_id, repo_path, cursor, **options):
      query = 'SELECT url FROM projects WHERE id = ' + str(project_id)
      cursor.execute(query)
      record = cursor.fetchone()
  
-     full_url = record[0].rstrip()
+     full_url = tokenize(record[0].rstrip())
      json_response = url_to_json(full_url, headers={
              'Accept': 'application/vnd.github.drax-preview+json'
          }
      )
  
-     if 'license' in json_response:
+     result = 'license' in json_response
+     return result, int(result)
-         result = 1
-     else:
-         result = 0
- 
-     return result
  
  if __name__ == '__main__':
      print("Attribute plugins are not meant to be executed directly.")
  
Update license attribute to return binary and raw result
## Code Before:
from utilities import url_to_json


def run(project_id, repo_path, cursor, **options):
    query = 'SELECT url FROM projects WHERE id = ' + str(project_id)
    cursor.execute(query)
    record = cursor.fetchone()

    full_url = record[0].rstrip()
    json_response = url_to_json(full_url, headers={
            'Accept': 'application/vnd.github.drax-preview+json'
        }
    )

    if 'license' in json_response:
        result = 1
    else:
        result = 0

    return result

if __name__ == '__main__':
    print("Attribute plugins are not meant to be executed directly.")

## Instruction:
Update license attribute to return binary and raw result
## Code After:
from core import tokenize
from utilities import url_to_json


def run(project_id, repo_path, cursor, **options):
    query = 'SELECT url FROM projects WHERE id = ' + str(project_id)
    cursor.execute(query)
    record = cursor.fetchone()

    full_url = tokenize(record[0].rstrip())
    json_response = url_to_json(full_url, headers={
            'Accept': 'application/vnd.github.drax-preview+json'
        }
    )

    result = 'license' in json_response
    return result, int(result)

if __name__ == '__main__':
    print("Attribute plugins are not meant to be executed directly.")
