taobao.sellercats.list.get 获取前台展示的店铺内卖家自定义商品类目
        
        此API添加卖家店铺内自定义类目 父类目parent_cid值等于0：表示此类目为店铺下的一级类目，值不等于0：表示此类目有父类目 注：因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示，但是不影响在该类目下商品发布
428819
def get(self, nick):
        ''''''
        request = TOPRequest('taobao.sellercats.list.get')
        request['nick'] = nick
        self.create(self.execute(request))
        return self.seller_cats
1239376
public GetQYMenuResponse list(String agentId){
        BeanUtil.requireNonNull(agentId, "应用ID不能为空");
        GetQYMenuResponse response;
        String url = BASE_API_URL + "cgi-bin/menu/get?access_token=#&agentid=" + agentId;
        BaseResponse r = executeGet(url);
        if (isSuccess(r.getErrcode())) {
            JSONObject jsonObject = JSONUtil.getJSONFromString(r.getErrmsg());
            //通过jsonpath不断修改type的值，才能正常解析- -
            List buttonList = (List) JSONPath.eval(jsonObject, "$.menu.button");
            if (CollectionUtil.isNotEmpty(buttonList)) {
                for (Object button : buttonList) {
                    List subList = (List) JSONPath.eval(button, "$.sub_button");
                    if (CollectionUtil.isNotEmpty(subList)) {
                        for (Object sub : subList) {
                            Object type = JSONPath.eval(sub, "$.type");
                            JSONPath.set(sub, "$.type", type.toString().toUpperCase());
                        }
                    }else{
                        Object type = JSONPath.eval(button, "$.type");
                        JSONPath.set(button, "$.type", type.toString().toUpperCase());
                    }
                }
            }
            response = JSONUtil.toBean(jsonObject.toJSONString(), GetQYMenuResponse.class);
        } else {
            response = JSONUtil.toBean(r.toJsonString(), GetQYMenuResponse.class);
        }
        return response;
    }
486240
def get(self, fields=[], product_id=None, cid=None, props=None):
        ''''''
        request = TOPRequest('taobao.product.get')
        if not fields:
            fields = self.fields
        request['fields'] = fields
        if product_id!=None: request['product_id'] = product_id
        if cid!=None: request['cid'] = cid
        if props!=None: request['props'] = props
        self.create(self.execute(request)['product'])
        return self
203962
def items_detail_get(self, num_iids, fields=[], **kwargs):
        ''''''
        request = TOPRequest('taobao.taobaoke.items.detail.get')
        request['num_iids'] = num_iids
        if not fields:
            taobaokeItem = TaobaokeItem()
            fields = taobaokeItem.fields
        request['fields'] = fields
        for k, v in kwargs.iteritems():
            if k not in ('nick', 'outer_code', 'pid') and v==None: continue
            request[k] = v
        self.create(self.execute(request), fields=['taobaoke_item_details', 'total_results'], models={'taobaoke_item_details':TaobaokeItemDetail})
        return self.taobaoke_item_details
1287255
def list_questions(self):
        
        # 取得新 API 的結果
        data = self.get_question()
        # 實作相容的結構
        result = {}
        for number in data:
            # 繳交期限
            deadline = data[number]['deadline']
            # 是否已經過期限
            expired = '期限已到' if data[number]['expired'] else '期限未到'
            # 是否繳交
            status = '已繳' if data[number]['status'] else '未繳'
            # 程式語言種類
            language = data[number]['language']
            # 儲存題目資訊
            result[number] = [deadline, expired, status, language]
        # 回傳結果
        return result
849146
def add(self, name, session, pict_url=None, parent_cid=None, sort_order=None):
        ''''''
        request = TOPRequest('taobao.sellercats.list.add')
        request['name'] = name
        if pict_url!=None: request['pict_url'] = pict_url
        if parent_cid!=None: request['parent_cid'] = parent_cid
        if sort_order!=None: request['sort_order'] = sort_order
        self.create(self.execute(request, session)['seller_cat'])
        return self
230457
def order_search(self, article_code, **kwargs):
        ''''''
        request = TOPRequest('taobao.vas.order.search')
        request['article_code'] = article_code
        for k, v in kwargs.iteritems():
            if k not in ('item_code', 'nick', 'start_created', 'end_created', 'biz_type', 'biz_order_id', 'order_id', 'page_size','page_no') and v==None: continue
            request[k] = v
        self.create(self.execute(request), fields=['article_biz_orders','total_item'], models={'article_biz_orders':ArticleBizOrder})
        return self.article_biz_orders
821226
def get(self, nicks=[], fields=[]):
        ''''''
        request = TOPRequest('taobao.users.get')
        request['nicks'] = ','.join(nicks)
        if not fields:
            user = User()
            fields = user.fields
        request['fields'] = ','.join(fields)
        self.create(self.execute(request))
        return self.users
1094900
def get(self, session, **kwargs):
        ''''''
        request = TOPRequest('taobao.fenxiao.cooperation.get')
        for k, v in kwargs.iteritems():
            if k not in ('status', 'start_date', 'end_date', 'trade_type', 'page_no', 'page_size') and v==None: continue
            request[k] = v
        self.create(self.execute(request, session), fields=['total_results','cooperations'], models={'cooperations':Cooperation})
        return self.cooperations
309868
def search_cat(self, catid, keyword, p_index=1):
        '''
        
        '''
        catid = 'sid' + catid
        logger.info('-' * 20)
        logger.info('search cat')
        logger.info('catid: {0}'.format(catid))
        logger.info('keyword: {0}'.format(keyword))

        # catid = ''
        if p_index == '' or p_index == '-1':
            current_page_number = 1
        else:
            current_page_number = int(p_index)
        res_all = self.ysearch.get_all_num(keyword, catid=catid)

        results = self.ysearch.search_pager(
            keyword,
            catid=catid,
            page_index=current_page_number,
            doc_per_page=CMS_CFG['list_num']
        )
        page_num = int(res_all / CMS_CFG['list_num'])

        kwd = {'title': '查找结果',
               'pager': '',
               'count': res_all,
               'current_page': current_page_number,
               'catid': catid,
               'keyword': keyword}

        self.render('misc/search/search_list.html',
                    kwd=kwd,
                    srecs=results,
                    pager=gen_pager_bootstrap_url(
                        '/search/{0}/{1}'.format(catid, keyword),
                        page_num,
                        current_page_number
                    ),
                    userinfo=self.userinfo,
                    cfg=CMS_CFG)
1365793
def update_category(uid, post_data):
    '''
    
    '''

    # deprecated
    # catid = kwargs['catid'] if MCategory.get_by_uid(kwargs.get('catid')) else None
    # post_data = self.get_post_data()
    if 'gcat0' in post_data:
        pass
    else:
        return False

    # Used to update MPost2Category, to keep order.
    the_cats_arr = []
    # Used to update post extinfo.
    the_cats_dict = {}

    # for old page. deprecated
    # def_cate_arr.append('def_cat_uid')

    def_cate_arr = ['gcat{0}'.format(x) for x in range(10)]
    for key in def_cate_arr:
        if key not in post_data:
            continue
        if post_data[key] == '' or post_data[key] == '0':
            continue
        # 有可能选重复了。保留前面的
        if post_data[key] in the_cats_arr:
            continue

        the_cats_arr.append(post_data[key] + ' ' * (4 - len(post_data[key])))
        the_cats_dict[key] = post_data[key] + ' ' * (4 - len(post_data[key]))

    # if catid:
    #     def_cat_id = catid
    if the_cats_arr:
        def_cat_id = the_cats_arr[0]
    else:
        def_cat_id = None

    if def_cat_id:
        the_cats_dict['gcat0'] = def_cat_id
        the_cats_dict['def_cat_uid'] = def_cat_id
        the_cats_dict['def_cat_pid'] = MCategory.get_by_uid(def_cat_id).pid

    # Add the category
    logger.info('Update category: {0}'.format(the_cats_arr))
    logger.info('Update category: {0}'.format(the_cats_dict))

    MPost.update_jsonb(uid, the_cats_dict)

    for index, idx_catid in enumerate(the_cats_arr):
        MPost2Catalog.add_record(uid, idx_catid, index)

    # Delete the old category if not in post requests.
    current_infos = MPost2Catalog.query_by_entity_uid(uid, kind='').objects()
    for cur_info in current_infos:
        if cur_info.tag_id not in the_cats_arr:
            MPost2Catalog.remove_relation(uid, cur_info.tag_id)
157520
def _get_lottery_detail_by_id(self, id):
        
        header = '编号 期号 开奖日期 开奖号码'.split()
        pt = PrettyTable()
        pt._set_field_names(header)

        url = QUERY_DETAIL_URL.format(id=id)
        import requests
        content = requests.get(url).text
        d = pq(content)
        if d('table.historylist'):
            # 输出彩种
            info = d('div.historyHd1 h2').text()
            print(info)
            # 输出table
            rows = d('table.historylist>tbody>tr')
            for idx, row in enumerate(rows):
                i = pq(row)
                qh = i('td:eq(0)').text().strip()
                kjrq = i('td:eq(1)').text().strip()
                hm_r = colored.red(i('td:eq(2) td.redBalls').text().strip())
                hm_g = colored.green(i('td:eq(2) td.blueBalls').text().strip())
                kjhm = ' '.join([hm_r, hm_g])
                item = [idx + 1, qh, kjrq, kjhm]
                pt.add_row(item)
            print(pt)
        elif d('table#draw_list'):
            # 输出彩种
            info = d('div.cpinfo>div.title').text()
            print(info)
            # 输出table
            rows = d('table#draw_list>tbody>tr')
            for idx, row in enumerate(rows):
                i = pq(row)
                qh = i('td.td2').text().strip()
                kjrq = i('td.td1').text().strip()
                hm_r = colored.red(i('td.td3 span.ball_1').text().strip())
                hm_g = colored.green(i('td.td3 span.ball_2').text().strip())
                kjhm = ' '.join([hm_r, hm_g])
                item = [idx + 1, qh, kjrq, kjhm]
                pt.add_row(item)
            print(pt)
        else:
            print('请联系作者')
333361
def ajax_list_catalog(self, catid):
        '''
        
        '''
        out_arr = {}
        for catinfo in MPost2Catalog.query_postinfo_by_cat(catid):
            out_arr[catinfo.uid] = catinfo.title

        json.dump(out_arr, self)
1513
def add(self, cid, price, image, name, desc, major, market_time, property_alias, session, **kwargs):
        ''''''
        request = TOPRequest('taobao.product.add')
        request['cid'] = cid
        request['price'] = price
        request['image'] = image
        request['name'] = name
        request['desc'] = desc
        request['major'] = major
        request['market_time'] = market_time
        request['property_alias'] = property_alias
        for k, v in kwargs.iteritems():
            if k not in ('outer_id', 'props', 'binds', 'sale_props', 'customer_props', 'order_by', 'ww_status', 'post_free', 'location_state', 'location_city', 'is_3D', 'start_score', 'end_score', 'start_volume', 'end_volume', 'one_station', 'is_cod', 'is_mall', 'is_prepay', 'genuine_security', 'promoted_service', 'stuff_status', 'start_price', 'end_price', 'page_no', 'page_size', 'auction_flag', 'auto_post', 'has_discount', 'is_xinpin') and v==None: continue
            if k == 'location_state': k = 'location.state'
            if k == 'location_city': k = 'location.city'
            request[k] = v
        self.create(self.execute(request, session)['product'])
        return self
275910
function tree(list) {
  const mapped = {}; // { id: name } 形式方便取值

  list.forEach((it) => {
    mapped[it.id] = it;
  });

  const result = [];

  list.forEach((it) => {
    if (it.pid === '') {
      result.push(it);
    } else {
      const parent = mapped[it.pid];
      if (parent) {
        if (!parent.children) {
          parent.children = [];
        }
        parent.children.push(it);
      }
    }
  });

  return result;
}
330163
function localList(options) {
  options = options || {};
  const isIntranet = env.isIntranet();
  const fieModulesPath = home.getModulesPath();
  const tPrefix = utils.toolkitPrefix();
  const pPrefix = utils.pluginPrefix();
  const moduleCwd = isIntranet ? path.resolve(fieModulesPath, '@ali') : fieModulesPath;
  const modules = globby.sync([`${tPrefix}*`, `${pPrefix}*`, '!.*', '!*.*'], {
    cwd: moduleCwd,
  });
  let modulePkgs = [];

  log.debug('modules path = %s', moduleCwd);

  modules.forEach(item => {
    const pkgPath = path.resolve(moduleCwd, item, 'package.json');
    if (fs.existsSync(pkgPath)) {
      const modPkg = fs.readJsonSync(pkgPath);
      modulePkgs.push({
        name: modPkg.name,
        description: modPkg.description,
        chName:
          modPkg.fieOption && modPkg.fieOption.chName
            ? modPkg.fieOption.chName
            : modPkg.description,
      });
    }
  });

  modulePkgs = options.type ? utils.moduleFilter(modulePkgs, options.type) : modulePkgs;

  log.debug('所有本地模块: %o', modulePkgs);

  return modulePkgs;
}
567704
function toUrl(source, baseId) {
        // 分离 模块标识 和 .extension
        var extReg = /(\.[a-z0-9]+)$/i;
        var queryReg = /(\?[^#]*)$/;
        var extname = '';
        var id = source;
        var query = '';

        if (queryReg.test(source)) {
            query = RegExp.$1;
            source = source.replace(queryReg, '');
        }

        if (extReg.test(source)) {
            extname = RegExp.$1;
            id = source.replace(extReg, '');
        }

        if (baseId != null) {
            id = normalize(id, baseId);
        }

        var url = id;

        // paths处理和匹配
        var isPathMap;
        indexRetrieve(id, pathsIndex, function (value, key) {
            url = url.replace(key, value);
            isPathMap = 1;
        });

        // packages处理和匹配
        if (!isPathMap) {
            indexRetrieve(id, packagesIndex, function (value, key, item) {
                url = url.replace(item.name, item.location);
            });
        }

        // 相对路径时，附加baseUrl
        if (!/^([a-z]{2,10}:\/)?\//i.test(url)) {
            url = requireConf.baseUrl + url;
        }

        // 附加 .extension 和 query
        url += extname + query;

        // urlArgs处理和匹配
        indexRetrieve(id, urlArgsIndex, function (value) {
            url += (url.indexOf('?') > 0 ? '&' : '?') + value;
        });

        return url;
    }