コード例 #1
0
 def prepend(self, k, *args, **kw):
     args = conv.flatten(list(args))
     args = [a for a in args if a != ""]
     if k in self:
         if not isinstance(self[k], list):
             self[k] = conv.to_list(self[k])
         self[k] = list(args) + self[k]
     elif len(args) == 1:
         if kw.get("make_list", False):
             self[k] = [args[0]]
         else:
             self[k] = args[0]
     elif len(args) > 1:
         self[k] = list(args)
コード例 #2
0
 def prepend(self, k, *args, **kw):
     args = conv.flatten(list(args))
     args = [a for a in args if a != ""]
     if k in self:
         if not isinstance(self[k], list):
             self[k] = conv.to_list(self[k])
         self[k] = list(args) + self[k]
     elif len(args) == 1:
         if kw.get("make_list", False):
             self[k] = [args[0]]
         else:
             self[k] = args[0]
     elif len(args) > 1:
         self[k] = list(args)
コード例 #3
0
 def append(self, k, *args, **kw):
     args = conv.flatten(list(args))
     args = [a for a in args if a != ""]
     if isinstance(k, (dict, Environment)):
         self._handle_dict(k, self.append, **kw)
     else:
         if k in self:
             if not isinstance(self[k], list):
                 self[k] = conv.to_list(self[k])
             self[k] += list(args)
         elif len(args) == 1:
             if kw.get("make_list", False):
                 self[k] = [args[0]]
             else:
                 self[k] = args[0]
         elif len(args) > 1:
             self[k] = list(args)
コード例 #4
0
 def append(self, k, *args, **kw):
     args = conv.flatten(list(args))
     args = [a for a in args if a != ""]
     if isinstance(k, (dict, Environment)):
         self._handle_dict(k, self.append, **kw)
     else:
         if k in self:
             if not isinstance(self[k], list):
                 self[k] = conv.to_list(self[k])
             self[k] += list(args)
         elif len(args) == 1:
             if kw.get("make_list", False):
                 self[k] = [args[0]]
             else:
                 self[k] = args[0]
         elif len(args) > 1:
             self[k] = list(args)
コード例 #5
0
 def prepend_unique(self, k, *args, **kw):
     args = conv.flatten(list(args))
     self.prepend(k, *self._make_unique(k, args), **kw)
コード例 #6
0
 def append_unique(self, k, *args, **kw):
     args = conv.flatten(list(args))
     if isinstance(k, (dict, Environment)):
         self._handle_dict(k, self.append_unique, **kw)
     else:
         self.append(k, *self._make_unique(k, args), **kw)
コード例 #7
0
 def prepend_unique(self, k, *args, **kw):
     args = conv.flatten(list(args))
     self.prepend(k, *self._make_unique(k, args), **kw)
コード例 #8
0
 def append_unique(self, k, *args, **kw):
     args = conv.flatten(list(args))
     if isinstance(k, (dict, Environment)):
         self._handle_dict(k, self.append_unique, **kw)
     else:
         self.append(k, *self._make_unique(k, args), **kw)