Commits

Shinya Okano committed 7be0129

一部の日本語のコメントを英語に変更

Comments (0)

Files changed (1)

bpmappers/mappers.py

-# -*- coding: utf-8 -*-
 from copy import copy
 
 from bpmappers.utils import MultiValueDict, SortedDict
 class Options(object):
     def __init__(self, *args, **kwargs):
         self.fields = MultiValueDict()
-        # 重複チェック用のフィールド名リスト
+        # Use this list to checking for existing name.
         self.field_names = []
 
     def add_field(self, name, field):
         if isinstance(field, Field) and field.key is None:
             field.key = name
         if name in self.field_names:
-            # 既に登録されてる場合は削除する
+            # if the field is already registered, remove it.
             lst = self.fields.getlist(field.key)
             self.fields.setlist(field.key, [tp for tp in lst if tp[0] != name])
             for key in list(self.fields.keys()):
                     opt.add_field(_name, field)
         for k, v in attrs.items():
             if isinstance(v, BaseField):
-                # fieldsMultiValueDict
+                # fields is MultiValueDict
                 opt.add_field(k, v)
         attrs['_meta'] = opt
         return type.__new__(cls, name, bases, attrs)
         self.options.update(options)
 
     def _getattr_inner(self, obj, key):
-        # attrを優先,なければスライスアクセス
+        # Priority "attr", "dict", "getattr".
         if not key:
             return
         if isinstance(obj, dict):
                         'obj': obj, 'key': key, 'mapper': self})
 
     def _getattr(self, obj, key):
-        # ドットアクセスの場合は再帰
+        # Recursive call if it is dot splited accessor.
         if '.' in key:
             keys = key.split('.')
             obj_child = self._getattr(obj, keys[0])
     def as_dict(self):
         parsed = SortedDict()
         for k in self._meta.fields:
-            # _meta.fieldsMultiValue
+            # _meta.fields is MultiValueDict
             for name, field in self._meta.fields.getlist(k):
                 if field.is_nonkey:
                     v = None
                 elif isinstance(self.data, list):
-                    # listだった場合は最初に取得できた要素を使う
+                    # if data is list, use first.
                     data_check = False
                     error = None
                     for item in self.data: