コード例 #1
0
ファイル: dynamic_folder.py プロジェクト: nicolasderam/shop
 def get_dynamic_property_and_language(self, name, dynamic_schema, language=None):
     value, language = ShopFolder.get_property_and_language(self, name, language)
     datatype = dynamic_schema[name]
     # Default value
     if value is None:
         value = datatype.get_default()
     elif getattr(datatype, "multiple", False):
         if not isinstance(value, list):
             # Decode the property
             # Only support list of strings
             value = list(Tokens.decode(value))
         # Else a list was already set by "set_property"
     else:
         value = datatype.decode(value)
     return value, language
コード例 #2
0
ファイル: dynamic_folder.py プロジェクト: nicolasderam/shop
 def get_dynamic_property_and_language(self,
                                       name,
                                       dynamic_schema,
                                       language=None):
     value, language = ShopFolder.get_property_and_language(
         self, name, language)
     datatype = dynamic_schema[name]
     # Default value
     if value is None:
         value = datatype.get_default()
     elif getattr(datatype, 'multiple', False):
         if not isinstance(value, list):
             # Decode the property
             # Only support list of strings
             value = list(Tokens.decode(value))
         # Else a list was already set by "set_property"
     else:
         value = datatype.decode(value)
     return value, language
コード例 #3
0
 def test_Tokens(self):
     data = 'value1 value2 value3'
     result = ('value1', 'value2', 'value3')
     self.assertEqual(Tokens.decode(data), result)
     self.assertEqual(Tokens.encode(result), data)
コード例 #4
0
ファイル: test_datatypes.py プロジェクト: Nabellaleen/itools
 def test_Tokens(self):
     data = "value1 value2 value3"
     result = ("value1", "value2", "value3")
     self.assertEqual(Tokens.decode(data), result)
     self.assertEqual(Tokens.encode(result), data)