Skip to content

Commit

Permalink
Make all strings unicode in python 2
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
Tamas Szabo committed Oct 13, 2016
1 parent bb31302 commit 4db839c
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions iprestrict/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from .restrictor import IPRestrictor

__all__ = ["IPRestrictor"]
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin
from django import forms
import re
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/decorators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from functools import wraps
from django.utils.translation import ugettext as _
from django.contrib.admin.forms import AdminAuthenticationForm
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/geoip.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
'''Client-side wrapper lib around GeoIP.
By using this module we allow:
- if GeoIP2 is unavailable (pre Django 1.9) fall back on GeoIP
- make the geoip module optional. If the user opts out we don't fail on importing required modules
'''
from __future__ import unicode_literals

from django.core.exceptions import ImproperlyConfigured
from django.conf import settings

Expand Down
4 changes: 4 additions & 0 deletions iprestrict/ip_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


def get_version(ip):
return 'ipv4' if '.' in ip else 'ipv6'

Expand Down
3 changes: 3 additions & 0 deletions iprestrict/management/commands/importrules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core.management.base import BaseCommand
from django.core.management import call_command

Expand Down
3 changes: 3 additions & 0 deletions iprestrict/management/commands/reloadrules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core.management.base import BaseCommand, CommandError
from ... import models
from ...middleware import get_reload_rules_setting
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/middleware.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core import exceptions
from django.conf import settings
import logging
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import re
from django.core.urlresolvers import reverse
from django.db import models
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/restrictor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.utils import timezone


Expand Down
3 changes: 3 additions & 0 deletions iprestrict/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf.urls import url
from .views import test_rules_page, test_match, reload_rules
from .views import move_rule_up, move_rule_down
Expand Down
3 changes: 3 additions & 0 deletions iprestrict/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
Expand Down
3 changes: 3 additions & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase
from django.contrib.auth.models import User

Expand Down
3 changes: 3 additions & 0 deletions tests/test_ip_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase
from unittest import skip
from iprestrict import ip_utils as ipu
Expand Down
3 changes: 3 additions & 0 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
Expand Down
3 changes: 3 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase
import mock
from django.http import HttpResponseForbidden
Expand Down
3 changes: 3 additions & 0 deletions tests/test_restrictor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase
import mock

Expand Down
3 changes: 3 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

Expand Down
3 changes: 3 additions & 0 deletions tests/test_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
# This file is to be used for testing only
from __future__ import unicode_literals


from django.conf.urls import include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
Expand Down
3 changes: 3 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase
from django.contrib.auth.models import User

Expand Down

0 comments on commit 4db839c

Please sign in to comment.