Skip to content

Commit

Permalink
Merge pull request #73 from gm3dmo/ipdb
Browse files Browse the repository at this point in the history
Adding ipdb back to the mix
  • Loading branch information
gm3dmo authored Oct 20, 2023
2 parents ada9c64 + 3ed4f72 commit 71839a8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
21 changes: 7 additions & 14 deletions cmp/country-import-to-model.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@

# read csv.py
# read csv_file and create a country model for each row in the csv file
# the csv_file has the format "id,name,alpha2,alpha3,country_code"
# read countries.json

from cmp.models import Country
import json

csv_file = "/tmp/countries.csv"
from cmp.models import Country

with open(csv_file, "r") as f:
for line in f:
line = line.strip()
if line.startswith("#"):
continue
id, name, alpha2, alpha3, old_id, blah = line.split(",")
c = Country(name=name, alpha2=alpha2, alpha3=alpha3, old_id=old_id)
print(c)
c.save()
with open('countries.json') as f:
data = json.load(f)
for country in data:
print(country['name']['common'])
8 changes: 2 additions & 6 deletions cmp/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from django.shortcuts import render, HttpResponse

from .forms import editCountryForm

# from IPython import embed
# Create your views here.

from cmp.forms import editCountryForm

def index(request):
return render(request, "cmp/index.html")
Expand All @@ -18,7 +14,6 @@ def army_number_search(request):
except ValueError:
return HttpResponse("Please enter a valid Army Number")
return original_unit(request, army_number)

return render(request, "cmp/army-number-search.html")


Expand Down Expand Up @@ -219,6 +214,7 @@ def original_unit(request, army_number):
def edit_countries(request):
post = request.POST
form = editCountryForm(post or None)
breakpoint()
if post and form.is_valid():
form.save()
return HttpResponse("Country Added")
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import sys

#os.environ.setdefault("PYTHONBREAKPOINT", "ipdb.set_trace")
os.environ.setdefault("PYTHONBREAKPOINT", "ipdb.set_trace")
#os.environ["PYTHONBREAKPOINT"] = "ipdb.set_trace"


Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ black # used to format code
whitenoise
django-crispy-forms
crispy-bootstrap5
ipdb
48 changes: 47 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@
#
# pip-compile
#
appnope==0.1.3
# via ipython
asgiref==3.7.2
# via django
asttokens==2.4.0
# via stack-data
backcall==0.2.0
# via ipython
black==23.9.1
# via -r requirements.in
certifi==2023.7.22
# via sentry-sdk
click==8.1.7
# via black
coverage[toml]==7.3.1
# via pytest-cov
# via
# coverage
# pytest-cov
crispy-bootstrap5==0.7
# via -r requirements.in
decorator==5.1.1
# via
# ipdb
# ipython
django==4.2.5
# via
# -r requirements.in
Expand All @@ -33,10 +45,20 @@ django-environ==0.11.2
# via -r requirements.in
django-htmx==1.16.0
# via -r requirements.in
executing==2.0.0
# via stack-data
flake8==6.1.0
# via -r requirements.in
iniconfig==2.0.0
# via pytest
ipdb==0.13.13
# via -r requirements.in
ipython==8.16.1
# via ipdb
jedi==0.19.1
# via ipython
matplotlib-inline==0.1.6
# via ipython
mccabe==0.7.0
# via flake8
mypy-extensions==1.0.0
Expand All @@ -45,16 +67,30 @@ packaging==23.1
# via
# black
# pytest
parso==0.8.3
# via jedi
pathspec==0.11.2
# via black
pexpect==4.8.0
# via ipython
pickleshare==0.7.5
# via ipython
platformdirs==3.10.0
# via black
pluggy==1.3.0
# via pytest
prompt-toolkit==3.0.39
# via ipython
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.2
# via stack-data
pycodestyle==2.11.0
# via flake8
pyflakes==3.1.0
# via flake8
pygments==2.16.1
# via ipython
pytest==7.4.2
# via
# pytest-cov
Expand All @@ -65,11 +101,21 @@ pytest-django==4.5.2
# via -r requirements.in
sentry-sdk==1.31.0
# via -r requirements.in
six==1.16.0
# via asttokens
sqlparse==0.4.4
# via
# django
# django-debug-toolbar
stack-data==0.6.3
# via ipython
traitlets==5.11.2
# via
# ipython
# matplotlib-inline
urllib3==2.0.6
# via sentry-sdk
wcwidth==0.2.8
# via prompt-toolkit
whitenoise==6.6.0
# via -r requirements.in

0 comments on commit 71839a8

Please sign in to comment.