mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Removed Python2 hack
This commit is contained in:
@ -2,7 +2,6 @@ import csv
|
|||||||
from io import StringIO
|
from io import StringIO
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -186,11 +185,6 @@ def unpack_grouped_choices(choices):
|
|||||||
return unpacked_choices
|
return unpacked_choices
|
||||||
|
|
||||||
|
|
||||||
def utf8_encoder(data):
|
|
||||||
for line in data:
|
|
||||||
yield line.encode('utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Widgets
|
# Widgets
|
||||||
#
|
#
|
||||||
@ -353,12 +347,7 @@ class CSVDataField(forms.CharField):
|
|||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
|
|
||||||
records = []
|
records = []
|
||||||
|
reader = csv.reader(StringIO(value))
|
||||||
# Python 2 hack for Unicode support in the CSV reader
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
reader = csv.reader(utf8_encoder(StringIO(value)))
|
|
||||||
else:
|
|
||||||
reader = csv.reader(StringIO(value))
|
|
||||||
|
|
||||||
# Consume and validate the first line of CSV data as column headers
|
# Consume and validate the first line of CSV data as column headers
|
||||||
headers = next(reader)
|
headers = next(reader)
|
||||||
|
Reference in New Issue
Block a user