Changeset e2e3900 in rattail


Ignore:
Timestamp:
07/26/2022 02:25:04 PM (6 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
5e978e8
Parents:
5685603
git-author:
Lance Edgar <lance@…> (07/26/2022 02:24:37 PM)
git-committer:
Lance Edgar <lance@…> (07/26/2022 02:25:04 PM)
Message:

Add basic python3 support for rattail import-sample cmd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rattail/importing/sample.py

    r5685603 re2e3900  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2017 Lance Edgar
     5#  Copyright © 2010-2022 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    2727from __future__ import unicode_literals, absolute_import
    2828
     29import csv
    2930import os
    3031import datetime
    3132import decimal
    3233import logging
     34
     35import six
    3336
    3437from rattail import importing
     
    9598        Return all data rows from CSV file, as returned by CSV parser.
    9699        """
    97         with open(self.data_path, 'rb') as csv_file:
    98             reader = UnicodeDictReader(csv_file)
    99             return list(reader)               
     100        if six.PY2:
     101            with open(self.data_path, 'rb') as csv_file:
     102                reader = UnicodeDictReader(csv_file)
     103                return list(reader)
     104
     105        with open(self.data_path, 'rt') as csv_file:
     106            reader = csv.DictReader(csv_file)
     107            return list(reader)
    100108
    101109
Note: See TracChangeset for help on using the changeset viewer.