Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences Between pip Installed Package Code and GitHub Version #8

Open
othmane099 opened this issue Aug 31, 2024 · 2 comments
Open

Comments

@othmane099
Copy link

I've noticed that the code in the version of the package installed via pip differs from the code in the GitHub repository. Specifically, the errors I encountered with the pip-installed package are not present in the GitHub version.

For example:

In apps.py, the name of the app in the pip-installed version is "yaml_converter", but in the GitHub version, it is "swagger_ui".

# apps.py onn GitHub
from django.apps import AppConfig

class YamlConverterConfig(AppConfig):
    name = 'swagger_ui'
# apps.py on pip
from django.apps import AppConfig

class YamlConverterConfig(AppConfig):
    name = 'yaml_converter'

In views.py, line 10, the pip-installed version uses spec = yaml.load(file.read()), while the GitHub version uses spec = yaml.safe_load(file.read()).

# views.py on GitHub
import json
import yaml
from django.core.exceptions import ImproperlyConfigured
from django.shortcuts import render
from django.conf import settings

def yaml_to_html(request):
    if hasattr(settings, 'SWAGGER_YAML_FILE'):
        file = open(settings.SWAGGER_YAML_FILE)
        spec = yaml.safe_load(file.read())
        return render(request, template_name="swagger_base.html", context={'data': json.dumps(spec)})
    else:
        raise ImproperlyConfigured('You should define SWAGGER_YAML_FILE in your settings')
# views.py on pip
import json
import yaml
from django.core.exceptions import ImproperlyConfigured
from django.shortcuts import render
from django.conf import settings

def yaml_to_html(request):
    if hasattr(settings, 'SWAGGER_YAML_FILE'):
        file = open(settings.SWAGGER_YAML_FILE)
        spec = yaml.load(file.read())
        return render(request, template_name="swagger_base.html", context={'data': json.dumps(spec)})
    else:
        raise ImproperlyConfigured('You should define SWAGGER_YAML_FILE in your settings')
@assem-ch
Copy link
Owner

assem-ch commented Sep 1, 2024

@othmane099 this worked for you when you used master branch?

@othmane099
Copy link
Author

@othmane099 this worked for you when you used master branch?

Yes, it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants