Exemple #1
0
def post_collections ( new_collections, old_collections,parent,collections_tree,log,pas,domen ):
  n=0
  print parent
  for nc in new_collections:
   to_do=list()
   suffix=nc
   while (1): 
    (first_part,delim,suffix)=suffix.partition("|")
    if suffix =="":
     to_do.append([first_part,suffix,parent])
     break
    if suffix in old_collections:
     id=old_collections[suffix]
    else:
     id=""
    to_do.append([first_part,suffix,id])
   to_do2=list()
   for td in to_do:
    to_do2.append (td)
    if td[2]!="":
     break
   to_do=to_do2 
   for i in range(0,len(to_do)):
    td=to_do.pop()
    if td[2]!="":
     id = td[2]
    id= api_set.add_collection_to_site ( id,td[0],log,pas,domen)
    if (id):
     create_collection_in_tree ( collections_tree.getroot(),td[0],id,td[2])
     old_collections[td[0]+'|'+td[1]]=id
     print [td[0]+'|'+td[1],id]
     n=n+1
    else:
     break
  return n
Exemple #2
0
for i in range (0,len(table)):
 tmp =categories( table[i], cat_index,top_level_source_name )
 for j in range(0,len(tmp)):
  tm=tmp[j]
  print tm.decode('cp1251').encode('utf-8')
  id_old=id
#  print id_old
  id=post_collection.find_collection_id_by_name ( collections,id ,tm )
  if (id):  
   True
   if j==0:
    first_col=id
   print "finded"+id
  else:
   id= api_set.add_collection_to_site ( id_old,tm.decode('cp1251').encode('utf-8'),log,pas,domen)
   if j==0:
    first_col=id
   print "new  "+str(id)
   if (id):
#    create_collection_in_tree ( collections,tm.decode('cp1251'),id,id_old)
    collections.write(id+".txt")
   else :
    break
 print "_________________"       
# print (unicode(tmp[len(tmp)-1],'cp1251'))+ unicode (len(tmp))
 art = table[i][art_index]
 prod_id = find_product_id_by_artikul ( prods_tree, art )
 print prod_id 
 if (prod_id): 
  if ( if_product_in_collection (collects_tree, prod_id, id) == False ):