2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-12-18 06:22:18 +00:00

import order fixed by ruff

This commit is contained in:
Philip Sargent 2024-12-15 18:54:47 +00:00
parent eb74940ca8
commit 30760654b7
34 changed files with 83 additions and 112 deletions

View File

@ -5,13 +5,12 @@ Modified for Expo April 2021.
import re
from http import HTTPStatus
from django.test import Client, TestCase
from django.contrib.auth.models import User
from django.test import Client, TestCase
import settings
from troggle.core.models.caves import Cave
from troggle.core.models.troggle import Person, PersonExpedition, Expedition
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.utils import current_expo
current_year = current_expo()

View File

@ -107,6 +107,7 @@ class SimpleTest(SimpleTestCase):
def test_import_urls(self):
from django.conf import settings
#from django.conf.urls import include, url
from django.contrib import admin, auth
from django.urls import resolve, reverse
@ -146,7 +147,7 @@ class ImportTest(TestCase):
@classmethod
def setUpTestData(cls):
import troggle.settings as settings
from troggle.parsers.logbooks import LOGBOOKS_DIR, DEFAULT_LOGBOOK_FILE
from troggle.parsers.logbooks import DEFAULT_LOGBOOK_FILE, LOGBOOKS_DIR
LOGBOOKS_PATH = settings.EXPOWEB / LOGBOOKS_DIR
test_year = "1986"

View File

@ -9,12 +9,12 @@ import pathlib
import re
from http import HTTPStatus
from django.contrib.auth.models import User
from django.test import Client, TestCase
import troggle.settings as settings
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import Expedition
from django.contrib.auth.models import User
from troggle.core.models.wallets import Wallet
from troggle.core.utils import current_expo
current_year = current_expo()

View File

@ -22,13 +22,13 @@ import subprocess
import unittest
from http import HTTPStatus
from django.test import Client, SimpleTestCase, TestCase
from django.contrib.auth.models import User
from django.test import Client, SimpleTestCase, TestCase
from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.troggle import Expedition, DataIssue, Person, PersonExpedition
from troggle.core.utils import current_expo
import troggle.parsers.logbooks as lbp
from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.troggle import DataIssue, Expedition, Person, PersonExpedition
from troggle.core.utils import current_expo
current_year = current_expo()

View File

@ -91,7 +91,8 @@ import re
from http import HTTPStatus
from django.test import Client, TestCase
from django.urls import reverse, path
from django.urls import path, reverse
# class SimplePageTest(unittest.TestCase):
class URLTests(TestCase):

View File

@ -29,8 +29,7 @@ class ImportTest(TestCase):
#ed to go through all modules and copy all imports here
from io import StringIO
from cuy.club.models import (Article, Event, Member, Webpage,
WebpageCategory)
from cuy.club.models import Article, Event, Member, Webpage, WebpageCategory
from cuy.website.views.generic import PUBLIC_LOGIN
from django.conf import settings
from django.contrib.auth.decorators import login_required

View File

@ -1,6 +1,6 @@
# Copilot: Sure, based on your `urls.py` file, here's how you might write end-to-end tests for the `survey_scans` endpoints:
from django.test import TestCase, Client
from django.test import Client, TestCase
from django.urls import reverse
# Copilot does not know that there is no data in the database, so that the tests need to pre-populate with

View File

@ -12,8 +12,8 @@ from troggle.core.models.survex import (
SurvexPersonRole,
SurvexStation,
)
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import DataIssue, Expedition, Person, PersonExpedition
from troggle.core.models.wallets import Wallet
"""This code significantly adds to the capabilities of the Django Management control panel for Troggle data.
In particular, it enables JSON export of any data with 'export_as_json'

View File

@ -1,17 +1,15 @@
# from tinymce.widgets import TinyMCE
import re
import django.forms as forms
from django.core.exceptions import ValidationError
from django.forms import ModelForm
from django.forms.models import modelformset_factory
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance
from troggle.core.views.editor_helpers import HTMLarea
from django.core.exceptions import ValidationError
# from tinymce.widgets import TinyMCE
import re
"""These are all the class-based Forms used by troggle.
There are other, simpler, upload forms in view/uploads.py

View File

@ -1,7 +1,6 @@
from django.core.management.base import BaseCommand
"""this is now replaced by databaseRest.py
This is an example of how to create our own bespoke commandline

View File

@ -1,18 +1,17 @@
import os
import os
import re
from collections import defaultdict
from datetime import datetime, timezone
from pathlib import Path
from django.db import models, DataError
from django.db import DataError, models
from django.template import loader
import settings
from troggle.core.models.logbooks import QM
from troggle.core.models.survex import SurvexStation, utmToLatLng
from troggle.core.models.troggle import DataIssue, TroggleModel
from troggle.core.utils import TROG, writetrogglefile, parse_aliases
from troggle.core.utils import TROG, parse_aliases, writetrogglefile
# Use the TROG global object to cache the cave lookup list. No good for multi-user.., or even multi-page. Pointless in fact.
Gcavelookup = TROG["caves"]["gcavelookup"]

View File

@ -1,16 +1,14 @@
import re
from pathlib import Path
from urllib.parse import urljoin
from django.db import models
from django.urls import reverse
from django.template import loader
from django.urls import reverse
import settings
from troggle.core.models.troggle import Expedition, TroggleModel
"""The model declarations LogBookEntry, PersonLogEntry, QM
"""

View File

@ -1,12 +1,13 @@
import math
import os
import re
from urllib.parse import urljoin
from pathlib import Path
from urllib.parse import urljoin
from django.conf import settings
from django.db import models
from django.urls import reverse
from troggle.core.utils import height_from_utm, throw
# from troggle.core.models.troggle import DataIssue # circular import. Hmm

View File

@ -10,8 +10,8 @@ from django.conf import settings
from django.db import models
from django.urls import reverse
from troggle.core.models.troggle import DataIssue
from troggle.core.models.caves import get_cave_leniently
from troggle.core.models.troggle import DataIssue
# from troggle.core.models.survex import SurvexBlock
# from troggle.core.models.troggle import DataIssue # circular import. Hmm

View File

@ -2,15 +2,13 @@ import hashlib
import logging
import math
import os
import re
import random
import re
import resource
import string
import subprocess
from datetime import datetime, timezone
from decimal import getcontext
from pathlib import Path
from django.contrib.auth.models import User

View File

@ -1,8 +1,7 @@
from django.conf import settings
from django.contrib.auth import authenticate
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth import forms as auth_forms
from django.contrib.auth import login, logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render

View File

@ -1,32 +1,29 @@
import os
import re
import django
import subprocess
import tempfile
import zipfile
import urllib
from bs4 import BeautifulSoup
import zipfile
from pathlib import Path
import django
from bs4 import BeautifulSoup
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect, FileResponse
from django.shortcuts import render, redirect
from django.http import FileResponse, HttpResponse, HttpResponseNotFound, HttpResponseRedirect
from django.shortcuts import redirect, render
from django.template import loader
from django.urls import NoReverseMatch, reverse
from django.utils.safestring import mark_safe
import troggle.settings as settings
from troggle.core.forms import CaveForm, EntranceForm, EntranceLetterForm # CaveAndEntranceFormSet,
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently
from troggle.core.models.logbooks import QM
from troggle.core.models.wallets import Wallet
from troggle.core.utils import write_and_commit
from troggle.core.utils import current_expo
from troggle.core.utils import current_expo, write_and_commit
from troggle.core.views import expo
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
from troggle.parsers.caves import read_cave, read_entrance
from django.template import loader
from django.utils.safestring import mark_safe
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
from .auth import login_required_if_public

View File

@ -2,6 +2,7 @@ import io
from pathlib import Path
import django.forms as forms
import piexif
from django.http import JsonResponse
from django.shortcuts import render
from django.template import loader
@ -9,8 +10,6 @@ from django.urls import reverse
from django.views.decorators.csrf import ensure_csrf_cookie
from PIL import Image
import piexif
import troggle.settings as settings
from troggle.core.utils import WriteAndCommitError, write_and_commit

View File

@ -14,7 +14,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
import troggle.core.views.caves
import troggle.settings as settings
from troggle.core.models.caves import Cave
from troggle.core.utils import WriteAndCommitError, write_and_commit, current_expo
from troggle.core.utils import WriteAndCommitError, current_expo, write_and_commit
from troggle.core.views.editor_helpers import HTMLarea
from troggle.core.views.uploads import edittxtpage

View File

@ -1,20 +1,17 @@
import re
from django.db.models import Q
from django.shortcuts import render
from django.shortcuts import redirect, render
from django.views.generic.list import ListView
from django.shortcuts import render, redirect
import troggle.settings as settings
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry, QM, writelogbook
from troggle.core.models.logbooks import QM, LogbookEntry, PersonLogEntry, writelogbook
from troggle.core.models.survex import SurvexBlock, SurvexFile
from troggle.core.models.troggle import Expedition, Person
from troggle.core.models.wallets import Wallet
from troggle.core.utils import TROG, current_expo
from troggle.parsers.imports import import_logbook
"""These views are for logbook items when they appear in an 'expedition' page
and for persons: their individual pages and their perseonexpedition pages.

View File

@ -11,6 +11,7 @@ from troggle.core.models.logbooks import LogbookEntry, writelogbook # , PersonL
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
from troggle.core.models.troggle import Expedition
from troggle.core.utils import current_expo
from troggle.parsers.imports import (
import_caves,
import_drawingsfiles,
@ -20,7 +21,7 @@ from troggle.parsers.imports import (
import_survex,
import_surveyscans,
)
from troggle.core.utils import current_expo
from .auth import login_required_if_public
"""Utility functions and code to serve the control panel and individual user's
@ -37,11 +38,11 @@ def todos(request, module):
"""produces todo text from module
We could automate this to find all those strings automatically
"""
from troggle.core.TESTS.tests import todo as tests
from troggle.core.forms import todo as forms
from troggle.core.middleware import todo as middleware
from troggle.core.models.caves import todo as modelcaves
from troggle.core.models.logbooks import todo as modellogbooks
from troggle.core.TESTS.tests import todo as tests
from troggle.core.views.caves import todo as viewcaves
from troggle.core.views.drawings import todo as viewdrawings
from troggle.core.views.logbooks import todo as viewlogbooks

View File

@ -6,17 +6,15 @@ from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render
from troggle.core.models.caves import GetCaveLookup
from troggle.core.models.survex import SingleScan, SurvexBlock, SurvexPersonRole
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import DataIssue, Expedition, Person, PersonExpedition
from troggle.core.models.wallets import Wallet
from troggle.core.utils import DatabaseResetOngoing, current_expo
from troggle.core.views.expo import getmimetype
from troggle.parsers.caves import add_cave_to_pending_list
from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.parsers.survex import set_walletdate
from troggle.core.utils import current_expo, DatabaseResetOngoing
"""
Note that caveifywallet() etc do NOT save the object to the db. They are ephemeral, just for the page rendering of the

View File

@ -7,11 +7,11 @@ from django.shortcuts import render
import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance
from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.survex import SurvexStation, SurvexPersonRole
from troggle.core.models.survex import SurvexPersonRole, SurvexStation
from troggle.core.models.troggle import DataIssue, Expedition, Person, PersonExpedition
from troggle.core.models.wallets import Wallet
from troggle.parsers.people import GetPersonExpeditionNameLookup, foreign_friends
from troggle.core.utils import current_expo
from troggle.parsers.people import GetPersonExpeditionNameLookup, foreign_friends
# from django.views.generic.list import ListView
"""Very simple report pages summarizing data about the whole set of expeditions and of

View File

@ -3,24 +3,23 @@ import difflib
import os
import re
import socket
from pathlib import Path
from collections import namedtuple
from pathlib import Path
from django import forms
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.db import models
from django.db.models import Q
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.csrf import ensure_csrf_cookie
import troggle.settings as settings
from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.caves import Cave, GetCaveLookup
from troggle.core.models.survex import SurvexFile, SurvexBlock #, SurvexDirectory
from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.survex import SurvexBlock, SurvexFile #, SurvexDirectory
from troggle.core.models.wallets import Wallet
from troggle.core.utils import only_commit, current_expo
from troggle.core.utils import current_expo, only_commit
from troggle.parsers.survex import parse_one_file
"""Everything that views survexfiles

View File

@ -1,23 +1,21 @@
import subprocess
from datetime import datetime, timezone, timedelta
from datetime import datetime, timedelta, timezone
from pathlib import Path
from django import forms
from django.core.files.storage import FileSystemStorage
from django.http import HttpResponseRedirect
from django.shortcuts import render, redirect
from django.shortcuts import redirect, render
import settings
from troggle.core.models.caves import GetCaveLookup
from troggle.core.models.logbooks import LogbookEntry, writelogbook, PersonLogEntry
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry, writelogbook
from troggle.core.models.survex import DrawingFile
from troggle.core.models.troggle import DataIssue, Expedition, PersonExpedition
from troggle.core.utils import alphabet_suffix, current_expo, sanitize_name, unique_slug, write_and_commit
from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
from .auth import login_required_if_public
"""File upload 'views'

View File

@ -14,24 +14,18 @@ from django.http import HttpResponseRedirect
from django.shortcuts import render
import settings
from troggle.core.utils import current_expo, sanitize_name
from troggle.core.models.caves import Cave
from troggle.core.models.logbooks import LogbookEntry # , PersonLogEntry
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.models.wallets import Wallet, YEAR_RANGE, make_valid_date
from troggle.core.models.wallets import YEAR_RANGE, Wallet, make_valid_date
from troggle.core.utils import current_expo, sanitize_name
from troggle.core.views.auth import login_required_if_public
from troggle.core.views.caves import getCave, get_cave_leniently
from troggle.core.views.caves import get_cave_leniently, getCave
from troggle.core.views.scans import caveifywallet, oldwallet
from troggle.core.views.uploads import FilesForm
from troggle.core.utils import current_expo
from troggle.parsers.scans import contentsjson
"""Main wallet editing form, which includes scan file upload into the wallet
"""

View File

@ -5,10 +5,11 @@ import resource
import sys
import time
import settings
from django.core.management import call_command
from django.core.management.commands import flush
import settings
""" Command-line utility for loading cave data files into troggle's database.
The command line options select which combination of classes of data will be imported,

View File

@ -42,8 +42,7 @@ else:
from django.db import models
from django.db.models import get_models
from django.db.models.fields.related import (ForeignKey, ManyToManyField,
OneToOneField)
from django.db.models.fields.related import ForeignKey, ManyToManyField, OneToOneField
from django.template import Context, Template
try:

View File

@ -2,7 +2,6 @@ import os
import re
import string
import sys
from pathlib import Path
from django.conf import settings

View File

@ -7,17 +7,16 @@ import time
from datetime import datetime, timezone
from pathlib import Path
import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance
from troggle.core.models.logbooks import QM
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole, SurvexStation
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.models.wallets import Wallet
from troggle.core.utils import chaosmonkey, get_process_memory
from troggle.parsers.logbooks import GetCaveLookup
from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
from troggle.parsers.survex import stash_data_issue, store_data_issues, ROOTBLOCK
from troggle.parsers.survex import ROOTBLOCK, stash_data_issue, store_data_issues
"""Uses the imported data to find the locations of the survey stations labelled as
entrances

View File

@ -1,9 +1,8 @@
import os
import re
import sys
import string
import sys
import time
from datetime import date, datetime
from pathlib import Path
from random import randint
@ -11,11 +10,11 @@ from random import randint
from django.conf import settings
from django.template.defaultfilters import slugify
from parsers.people import GetPersonExpeditionNameLookup, load_people_expos, known_foreigner
from parsers.people import GetPersonExpeditionNameLookup, known_foreigner, load_people_expos
from troggle.core.models.caves import GetCaveLookup
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.utils import get_process_memory, alphabet_suffix, unique_slug
from troggle.core.utils import alphabet_suffix, get_process_memory, unique_slug
EPOCH = settings.EPOCH
"""

View File

@ -3,9 +3,9 @@ import os
import re
from html import unescape
from pathlib import Path
from unidecode import unidecode
from django.conf import settings
from unidecode import unidecode
from troggle.core.models.troggle import DataIssue, Expedition, Person, PersonExpedition

View File

@ -11,12 +11,10 @@ import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
from troggle.core.models.logbooks import QM
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole, SurvexStation
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.utils import chaosmonkey, get_process_memory
from troggle.core.utils import write_and_commit
from troggle.parsers.caves import create_new_cave, do_ARGE_cave, AREACODES, ARGEAREAS
from troggle.core.models.wallets import Wallet
from troggle.core.utils import chaosmonkey, get_process_memory, write_and_commit
from troggle.parsers.caves import AREACODES, ARGEAREAS, create_new_cave, do_ARGE_cave
from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
"""Imports the tree of survex files following from a defined root .svx file

View File

@ -1,8 +1,9 @@
import os
import folium
from pathlib import Path
from PIL import Image, ExifTags
from itertools import chain
from pathlib import Path
import folium
from PIL import ExifTags, Image
"""To do
- create gpx file for adding in to existing GPSprune maps