From 9e29ed4356cbc3721082f0388463a875902012c4 Mon Sep 17 00:00:00 2001 From: Xavier Fiechter Date: Fri, 11 Aug 2023 23:12:48 +0200 Subject: [PATCH] fixing pep8 issues --- exporter/views.py | 30 ++++++++++++++++++++++++------ importer/admin.py | 1 - importer/migrations/__init__.py | 0 importer/models.py | 1 - importer/tests.py | 3 --- importer/views.py | 3 +-- labelbase/models.py | 12 ++++++------ labellabor/settings.py | 8 ++++---- labellabor/urls.py | 8 +++++--- labellabor/views.py | 1 + userprofile/apps.py | 2 +- userprofile/models.py | 1 - userprofile/tests.py | 3 --- userprofile/views.py | 6 +----- 14 files changed, 43 insertions(+), 36 deletions(-) delete mode 100644 importer/admin.py delete mode 100644 importer/migrations/__init__.py delete mode 100644 importer/models.py delete mode 100644 importer/tests.py delete mode 100644 userprofile/tests.py diff --git a/exporter/views.py b/exporter/views.py index 6cf6639..8caddc5 100644 --- a/exporter/views.py +++ b/exporter/views.py @@ -7,17 +7,35 @@ from django.contrib.auth.decorators import login_required @login_required def stream_labels_as_jsonl(request, labelbase_id): """ - Google Chrome blocks downloads that it considers to be potentially dangerous or harmful to your computer. If you are trying to download a file that Chrome is blocking, there are a few ways to resolve the issue: + Google Chrome blocks downloads that it considers to be potentially dangerous + or harmful to your computer. If you are trying to download a file that + Chrome is blocking, there are a few ways to resolve the issue: - Whitelist the site: If you trust the site from which you are downloading the file, you can add it to your list of trusted sites in Chrome. To do this, go to the site, click the lock icon in the address bar, and then click "Site settings". In the "Permissions" section, click "Downloads", and then toggle the switch next to "Block dangerous and deceptive downloads" to "Off". + Whitelist the site: If you trust the site from which you are downloading + the file, you can add it to your list of trusted sites in Chrome. + To do this, go to the site, click the lock icon in the address bar, and + then click "Site settings". In the "Permissions" section, click + "Downloads", and then toggle the switch next to "Block dangerous + and deceptive downloads" to "Off". - Download the file in Incognito mode: Chrome blocks downloads based on your browsing history, so downloading the file in Incognito mode may bypass the block. To open an Incognito window, click the three dots in the upper-right corner of Chrome, and then click "New incognito window". + Download the file in Incognito mode: Chrome blocks downloads based on + your browsing history, so downloading the file in Incognito mode may + bypass the block. To open an Incognito window, click the three dots in + the upper-right corner of Chrome, and then click "New incognito window". - Change the file extension: Sometimes, changing the file extension from .exe or .zip to .txt, for example, can help bypass the block. However, this may not always work, and the file may still be harmful even if the extension is changed. + Change the file extension: Sometimes, changing the file extension + from .exe or .zip to .txt, for example, can help bypass the block. + However, this may not always work, and the file may still be harmful + even if the extension is changed. - Use a different browser: If none of the above methods work, you can try downloading the file using a different browser, such as Mozilla Firefox or Microsoft Edge. + Use a different browser: If none of the above methods work, you can try + downloading the file using a different browser, such as Mozilla Firefox + or Microsoft Edge. - Keep in mind that Chrome's download protection is in place to help keep your computer safe, so only download files from sources that you trust. If you are unsure whether a file is safe, it's always a good idea to scan it with an antivirus program before downloading. + Keep in mind that Chrome's download protection is in place to help keep + your computer safe, so only download files from sources that you trust. + If you are unsure whether a file is safe, it's always a good idea to scan + it with an antivirus program before downloading. """ def get_queryset(): diff --git a/importer/admin.py b/importer/admin.py deleted file mode 100644 index 694323f..0000000 --- a/importer/admin.py +++ /dev/null @@ -1 +0,0 @@ -from django.contrib import admin diff --git a/importer/migrations/__init__.py b/importer/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/importer/models.py b/importer/models.py deleted file mode 100644 index 137941f..0000000 --- a/importer/models.py +++ /dev/null @@ -1 +0,0 @@ -from django.db import models diff --git a/importer/tests.py b/importer/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/importer/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/importer/views.py b/importer/views.py index 798bc77..9b0ebff 100644 --- a/importer/views.py +++ b/importer/views.py @@ -1,10 +1,9 @@ from django.http import HttpResponseRedirect from django.shortcuts import render from django.contrib.auth.decorators import login_required -import tempfile import os import json -from labelbase.models import Labelbase, Label +from labelbase.models import Labelbase from labelbase.serializers import LabelSerializer from django.shortcuts import get_object_or_404 from django.contrib import messages diff --git a/labelbase/models.py b/labelbase/models.py index e226913..2ae4fea 100644 --- a/labelbase/models.py +++ b/labelbase/models.py @@ -62,9 +62,9 @@ class Label(models.Model): ) origin = encrypt( models.CharField( - help_text=("Optional key origin information referencing the wallet " - "associated with the label. The origin property should " - "only appear where type is 'tx'.") + help_text=("""Optional key origin information referencing the wallet + associated with the label. The origin property should + only appear where type is 'tx'.""") max_length=160, default="", blank=True, @@ -72,9 +72,9 @@ class Label(models.Model): ) spendable = encrypt( models.BooleanField( - help_text=("One of true or false, denoting if an output should be " - "spendable by the wallet. The spendable property only " - "where type is 'output'.") + help_text=("""One of true or false, denoting if an output should be + spendable by the wallet. The spendable property only + where type is 'output'.""") max_length=160, default=False, ) diff --git a/labellabor/settings.py b/labellabor/settings.py index 1eb6afe..5a34067 100644 --- a/labellabor/settings.py +++ b/labellabor/settings.py @@ -1,6 +1,7 @@ import os +import sentry_sdk +from sentry_sdk.integrations.django import DjangoIntegration from pathlib import Path - from configparser import RawConfigParser # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -37,8 +38,7 @@ else: ALLOWED_HOSTS = [proj_config.get("internal", "allowed_host")] -import sentry_sdk -from sentry_sdk.integrations.django import DjangoIntegration + sentry_sdk.init( dsn="https://3b833ae08ccc4ff68793e961fff4921c@o4504646963232768.ingest.sentry.io/4504646967361536", @@ -128,7 +128,7 @@ DATABASES = { "USER": proj_config.get("database", "user"), "OPTIONS": {"charset": "utf8mb4"}, "PASSWORD": proj_config.get("database", "password"), - 'HOST': 'localhost', + 'HOST': 'localhost', 'PORT': 3306, } } diff --git a/labellabor/urls.py b/labellabor/urls.py index 53ef4ca..44d13c5 100644 --- a/labellabor/urls.py +++ b/labellabor/urls.py @@ -1,11 +1,9 @@ -from django.conf import settings from django.contrib import admin from django.contrib.auth.views import LogoutView from django.urls import include, path from two_factor.urls import urlpatterns as tf_urls from labelbase.api import LabelAPIView, LabelbaseAPIView from rest_framework.documentation import include_docs_urls -from rest_framework.urlpatterns import format_suffix_patterns from django.contrib.auth.decorators import login_required from userprofile.views import ProfileView, APIKeyView from .views import ( @@ -88,7 +86,11 @@ urlpatterns = [ login_required(LabelbaseFormView.as_view()), name="labelbase_new" ), - # path('labelbase//label//edit/', login_required(LabelUpdateView.as_view()), name='edit_label'), + # path( + # 'labelbase//label//edit/', + # login_required(LabelUpdateView.as_view()), + # name='edit_label' + #), path( "label//edit/", login_required(LabelUpdateView.as_view()), diff --git a/labellabor/views.py b/labellabor/views.py index 5a0083e..945794d 100644 --- a/labellabor/views.py +++ b/labellabor/views.py @@ -16,6 +16,7 @@ from labelbase.forms import LabelForm, LabelbaseForm from django.http import HttpResponseRedirect from rest_framework.authtoken.models import Token + class AboutView(TemplateView): template_name = "about.html" diff --git a/userprofile/apps.py b/userprofile/apps.py index 68113e5..f036568 100644 --- a/userprofile/apps.py +++ b/userprofile/apps.py @@ -6,4 +6,4 @@ class UserprofileConfig(AppConfig): name = "userprofile" def ready(self): - import userprofile.signals + import userprofile.signals # noqa: F401 diff --git a/userprofile/models.py b/userprofile/models.py index 52199bd..243ddcf 100644 --- a/userprofile/models.py +++ b/userprofile/models.py @@ -5,7 +5,6 @@ from labelbase.models import Labelbase class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) - mempool_endpoint = models.CharField( max_length=160, default="https://mempool.space", diff --git a/userprofile/tests.py b/userprofile/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/userprofile/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/userprofile/views.py b/userprofile/views.py index 167344a..7b6e2dd 100644 --- a/userprofile/views.py +++ b/userprofile/views.py @@ -1,19 +1,15 @@ -from django.shortcuts import render -from django.views.generic import TemplateView # FormView, +from django.views.generic import TemplateView from rest_framework.authtoken.models import Token class ProfileView(TemplateView): """ """ - template_name = "profile.html" class APIKeyView(TemplateView): """ """ - template_name = "apikey.html" - def get_context_data(self, **kwargs): context = super(APIKeyView, self).get_context_data(**kwargs) context["api_token"] = Token.objects.get(user_id=self.request.user.id)