读入对应目录下所有模板
Jul 16, 2009
772461
public synchronized void  loadAll(){
		group.clear();
		count=0;

		List<File> files = MyFiles.getAllFiles(fileName, ".txt");
		if(files==null||files.size()==0){
			System.err.println("模板为空");
		}
		try {
			for(int i=0;i<files.size();i++){
					read(files.get(i).toString());
					//记录文件修改时间
					lastModTime.put(files.get(i).toString(),files.get(i).lastModified());

			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("总模板数: " +count);
	}
794901
function Queue() {
    
            /**
             * 统计文件数。
             * * `numOfQueue` 队列中的文件数。
             * * `numOfSuccess` 上传成功的文件数
             * * `numOfCancel` 被移除的文件数
             * * `numOfProgress` 正在上传中的文件数
             * * `numOfUploadFailed` 上传错误的文件数。
             * * `numOfInvalid` 无效的文件数。
             * @property {Object} stats
             */
            this.stats = {
                numOfQueue: 0,
                numOfSuccess: 0,
                numOfCancel: 0,
                numOfProgress: 0,
                numOfUploadFailed: 0,
                numOfInvalid: 0
            };
    
            // 上传队列，仅包括等待上传的文件
            this._queue = [];
    
            // 存储所有文件
            this._map = {};
        }
1074728
function () {
        var fileList = [];
        /*获取原文件列表*/
        Object.keys(src).forEach(function(key){
            fileList.push(src[key]);
        });
        return fileList;
    }
192040
function getNextVisibleNode(self) {
        var children = self.get('children'), n, parent;
        if (self.get('expanded') && children.length) {
            return children[0];
        }    // 没有展开或者根本没有儿子节点
             // 深度遍历的下一个
        // 没有展开或者根本没有儿子节点
        // 深度遍历的下一个
        n = self.next();
        parent = self;
        while (!n && (parent = parent.get('parent'))) {
            n = parent.next();
        }
        return n;
    }
1272453
function getBaesVsersion(dir, callBack) {
        fs.readdir(`${dir}/`, (err, files) => {
            let dirList = [],
                baseVersion;
            if (err) {
                console.log('第一次部署中...');
                fs.mkdir(dir, () => {
                    callBack([1, 1, 1]);
                });
            } else {
                if (files.length == 0) {
                    files = ['1.1.1'];
                }
                console.log('部署目标已存在，正在更新中...');
                files.forEach((v)=> {
                    let intV = v.replace(/\./g, '');
                    if (!!parseInt(intV)) {
                        dirList.push(intV);
                    }
                });
                baseVersion = Math.max.apply(null, dirList).toString().split('');
                callBack(baseVersion);
            }
        });
    }
1189743
function(){
      var src = this.installArray.shift(); 

      if(typeof src !== 'undefined'){
        var parts = src.split('/'); 
        var resourcePath = this.getResourcePath(parts[parts.length-2]); 
        var dest = this.basePath + resourcePath + '/' + parts[parts.length-1]; 
        
        if(typeof resourcePath !== 'undefined'){
          this._install(src, dest); 
        }else{
          this.triggerNext(); 
        }
         
      }else{
        this.log('all done, get ready to rock!  (╯°□°）╯︵ ┻━┻');
        rl.close(); 
      }
    }
911857
function callBack($from,$to,$customerSerNum,$fromSerNum,$promptTone)
	  {
        //子帐号鉴权信息验证，对必选参数进行判空。
        $auth=$this->subAuth();
        if($auth!=""){
            return $auth;
        }
        // 拼接请求包体
        if($this->BodyType=="json"){
           $body= "{'from':'$from','to':'$to','customerSerNum':'$customerSerNum','fromSerNum':'$fromSerNum','promptTone':'$promptTone'}";
        }else{
           $body= "<CallBack>
                     <from>$from</from>
                     <to>$to</to>
                     <customerSerNum>$customerSerNum</customerSerNum>
                     <fromSerNum>$fromSerNum</fromSerNum>
                     <promptTone>$promptTone</promptTone>
                   </CallBack>";
        }
        $this->showlog("request body = ".$body);
        // 大写的sig参数
        $sig =  strtoupper(md5($this->SubAccountSid . $this->SubAccountToken . $this->Batch));
        // 生成请求URL
        $url="https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/SubAccounts/$this->SubAccountSid/Calls/Callback?sig=$sig";
        $this->showlog("request url = ".$url);
        // 生成授权：子帐号Id + 英文冒号 + 时间戳
        $authen=base64_encode($this->SubAccountSid . ":" . $this->Batch);
        // 生成包头
        $header = array("Accept:application/$this->BodyType","Content-Type:application/$this->BodyType;charset=utf-8","Authorization:$authen");
        // 发请求
        $result = $this->curl_post($url,$body,$header);
        $this->showlog("response body = ".$result);
        if($this->BodyType=="json"){//JSON格式
           $datas=json_decode($result);
        }else{ //xml格式
           $datas = simplexml_load_string(trim($result," \t\n\r"));
        }
      //  if($datas == FALSE){
//            $datas = new stdClass();
//            $datas->statusCode = '172003';
//            $datas->statusMsg = '返回包体错误'; 
//        }
        return $datas;
	}
468403
async function rmdir(src) {
    let stats = await stat(src);

    // 判断是否存在文件夹
    if (stats) {
        if (stats.isDirectory()) {
            let files = await readdir(src);

            // 移除下级目录
            await Promise.all(
                files.map(file => rmdir(path.join(src, file)))
            );

            // 移除文件夹
            await removedir(src);
        } else {
            await unlink(src);
        }
    }
}
1351820
public function notfound() {
        $router = Router::driver();
        if (isset($this->call['notfound']) && !call_user_func($this->call['notfound'], $router)) {
            return;
        }
        if(ob_get_level() > 0) {
            ob_clean();
        }
        //if (!headers_sent()) {
        //    header('HTTP/1.1 404 Not Found');
        //    header('Status:404 Not Found');
        //}
        //if (f('ajax')) {
        //    Config::$o->debug and quit('Ajax Not Found:' . $router->getModel(). '/' . $router->getController() . '/' . $router->getFunction());
        //    quit('404 page not found url!');
        //}
        if (Config::$o->debug) {
            $hint = I18n::t('请求无法应答！');
            $message = I18n::t('请检查下面路由信息是否正确！ %s%s%s%s',[
                '<br/>module : '.$router->module,
                '<br/>folder : '.$router->folder,
                '<br/>controller : '.$router->controller,
                '<br/>function : '.$router->function
            ]);
        }
        include __DIR__ . DS . 'html' . DS . 'hint.tpl.php';
    }
375500
def get_notices(self):
        
        result = []
        # 取得公布欄訊息列表
        for date, title in self.get_notice().items():
            content = self.get_notice_content(date)
            result.append([date, title, content])
        # 回傳結果
        return result
1072419
function getCustomDeps(info) {
    var res = [];

    if (info.modules && Array.isArray(info.modules)) {
        info = info.modules;
    }
    else {
        info = [];
    }

    info.forEach(function (item) {
        // 只包含额外需要包含的模块
        // 对额外排除的模块不做处理
        if (item.charAt(0) === '~') {
            res.push(item.substring(1));
        }
    });

    return res;
}
367037
function formatPath(filePath, root) {
  let dir = root;

  if (!path.isAbsolute(root)) {
    dir = path.join(process.cwd(), root);
  }

  // 修复windows下的\路径问题
  dir = dir.replace(/\\/g, '/');

  return filePath
    .replace(/\\/g, '/')
    .replace(dir, '')
    .split('.')[0];
}
54113
function videoIntent(){
        $this->waitAnswer();

        $videoName = $this->getSlot('videoname');
        if($videoName){
            $video = $this->getDetailBy("video","title",$videoName);
            $directives = $this->getVideoPlay($video["id"]);
            if($directives){
                return [
                    'directives' => $directives
                ];
            }else{
                $speech = "没有找到你要播放的视频";
                $hint = new Hint('第一个','我想看告白气球');
                $template = $this->getVideoCard();
                return [
                    'outputSpeech' => $speech,
                    'directives' => [$hint,$template],
                ];
            }
        }
        $speech = '请选择您要播放的视频';
        $reprompt = '没有听懂，请告诉我想要播放的视频';
        $template = $this->getVideoCard();
        
        //定义hint指令
        $hint = new Hint('第一个','我想看告白气球');
        return [
            'outputSpeech' => $speech,
            'reprompt' => $reprompt,
            'directives' => [$hint,$template],
        ];
    }
12954
function attachMiddleware(app, options) {
    // 日志中间件
    app.use(log.express());
    // 初始化中间件
    app.use(require('./lib/middleware/init'));
    // 设置上下文
    app.use(setContext);

    // 附加自定义中间件
    beforeMiddlewares.forEach(function (fn) {
        app.use(fn);
    });

    // 路由绑定
    router.use(app);

    // 附加自定义中间件
    afterMiddlewares.forEach(function (fn) {
        app.use(fn);
    });

    // 页面渲染中间件
    var renderHTML = require('./lib/middleware/renderHTML');
    app.use(renderHTML({
        templateData: options.templateData,
        indexFile: options.indexFile
    }));
    // 错误处理
    app.use(require('./lib/middleware/error'));
}
110531
function rudePackager(ret, pack, settings, opt) {
  var files = ret.src;

  // 生成映射表，方便快速查找！
  var idmapping = ret.idmapping = {};
  var urlmapping = ret.urlmapping = {};
  Object.keys(files).forEach(function(subpath) {
    var file = files[subpath];
    idmapping[file.id] = file;
    if (file.release) {
      urlmapping[file.getUrl()] = file;
    }
  });

  Object.keys(files).forEach(function(subpath) {
    var file = files[subpath];

    compile(file);
  });

  function compile(file) {
    var processor = rudePackager.lang[file.loaderLang] || rudePackager.lang[settings.processor[file.ext]];

    // 非 htmlLike 或者 没有处理器，或者已经处理过了，则跳过。
    if (!file.isHtmlLike || file.loaderLang === false || !processor || file._resource) {
      return;
    }

    // 可以让 processor 调用。
    processor._compile = compile;

    // 修改之前先，先备份。
    file._rudeBackup = file.getContent();

    var resource = createResource(ret, file);
   // console.log(resource);


    file._resource = resource;
    processor.init && processor.init(file, resource, settings);

    // all in one 包含异步依赖。
    if (settings.allInOne && settings.allInOne.includeAsyncs) {
      // 把所以异步的 js 当同步加载。
      resource.res.forEach(function(item) {
        item.async = false;
      });
    }

    processor.beforePack && processor.beforePack(file, resource, settings);

    if (settings.allInOne) {
      allInOnePack(file, resource, ret, settings.allInOne === true ? {} : settings.allInOne);
    }

    processor.before && processor.before(file, resource, settings);
    processor(file, resource, settings);
    processor.after && processor.after(file, resource, settings);

    ret.pkg[file.subpath] = file;

  }
}
1055446
function(domain, ip, groupName, target_groupName) {
		this._batchHost(function(hostsobject) {
			var group = hostsobject[groupName];
			var t_group = hostsobject[target_groupName] = hostsobject[target_groupName] || [];
			if (group) {
				var host, move, i;
				//目标分组里是否存在该条host，若存在则不作处理。
				for (i = 0; i < t_group.length; i++) {
					host = t_group[i];
					if (host.domain === domain && host.ip === ip) {
						return false;
					}
				}
				for (i = 0; i < group.length; i++) {
					host = group[i];
					if (host.domain === domain && host.ip === ip) {
						t_group.push(host);
						group.splice(i, 1);
						break;
					}
				}
				return hostsobject;
			}
		});
	}
1167047
function makeDirs(plan, dest, savedir, callback) {

  // フォルダパスのリストを作成
  let all = plan.map(file => {
    let dirname = path.dirname(path.join(savedir, dest, file)); //ファイル名を除外
    return pathcrumb(dirname);
  });

  // 配列をフラットにして重複分を排除
  let uniq = _.uniq(_.flatten(all));

  // フォルダを作成
  let shell = path.join(__dirname, '../sh/makedirs.sh');
  return exec('chmod +x ' + shell, (error, stdout, stderr) => {
    return execFile(shell, uniq, (error, stdout, stderr) => {
      if (error !== null) throw ('[Error: makeDirs makedis.sh:] ' + error);
    }).on('close', callback);
  });
}