run the passed bower block in appropriate folders
765450
def perform_command(remove_components = true, &block)
      # Load in bower json file
      txt  = File.read(File.join(root_path, "bower.json"))
      json = JSON.parse(txt)


      # Load and merge root .bowerrc
      dot_bowerrc = JSON.parse(File.read(File.join(root_path, '.bowerrc'))) rescue {}
      dot_bowerrc["directory"] = components_directory

      if json.reject{ |key| ['lib', 'vendor'].include? key }.empty?
        folders = json.keys
      else
        raise "Assuming a standard bower package but cannot find the required 'name' key" unless !!json['name']
        folders = ['vendor']
      end

      folders.each do |dir|
        data = json[dir]

        # Assume using standard bower.json if folder name is not found
        data = json if data.nil?

        # Check folder existence and create?
        dir = File.join(root_path, dir, "assets")
        FileUtils.mkdir_p dir unless File.directory? dir
        # Go in to dir to act
        Dir.chdir(dir) do

          # Remove old components
          FileUtils.rm_rf("#{components_directory}/*") if remove_components

          # Create bower.json
          File.open("bower.json", "w") do |f|
            f.write(data.to_json)
          end

          # Create .bowerrc
          File.open(".bowerrc", "w") do |f|
            f.write(JSON.pretty_generate(dot_bowerrc))
          end

          # Run command
          yield  if block_given?

          # Remove bower.json
          FileUtils.rm("bower.json")

          # Remove .bowerrc
          FileUtils.rm(".bowerrc")
        end if data && !data["dependencies"].empty?
      end
    end
543105
function runCodeBlock(codeBlock) {
  var dir = path.dirname(codeBlock.filename);
  return new Promise(function(fulfill, reject) {
    var filenameWithoutDir = codeBlock.filename.replace(dir + '/', '');
    var command = runner(codeBlock, filenameWithoutDir);
    if (command === null) {
      fulfill(codeBlock);
      return;
    }
    exec(command, {cwd: dir}, function(error, stdout, stderr) {
      if (error) {
        console.error(error);
        reject(error);
      } else {
        if (stdout) {
          console.log(stdout);
        }
        if (stderr) {
          console.error(stderr);
        }
        fulfill(codeBlock);
      }
    });
  });
}
129449
def run_step(self):
        """"""
        rewriter = StreamRewriter(self.context.iter_formatted_strings)
        super().run_step(rewriter)
941416
function handleListResults( results ) {
		grunt.verbose.writeln( 'BowerMap::handleListResults' );

		for ( var k in results ) {
			if ( results.hasOwnProperty( k ) ) {
				grunt.verbose.writeln( '------------------------------------' );
				grunt.verbose.writeln( '    ' + k + ' - ' + results[k] );
				if ( ignore.indexOf( k ) >= 0 ){
					grunt.verbose.writeln( '    ' + k + ' - IGNORED' );
				}
				else{
					copyComponentFiles( k, results[k] );
				}
			}
		}
		done();
	}
1304869
function(next) {
            try { process.umask(core.umask); } catch(e) { logger.error("umask:", core.umask, e) }

            // Create all subfolders with permissions, run it before initializing db which may create files in the spool folder
            if (!cluster.isWorker && !core.worker) {
                Object.keys(core.path).forEach(function(p) {
                    var paths = Array.isArray(core.path[p]) ? core.path[p] : [core.path[p]];
                    paths.forEach(function(x) {
                        if (!x || path.isAbsolute(x)) return;
                        lib.mkdirSync(x);
                        lib.chownSync(this.uid, this.gid, x);
                    });
                });
            }
            next();
        }
665269
function getComponentMapping( name, files ) {
		grunt.verbose.writeln( 'BowerMap::getComponentMapping - ' + name );


		//first get list of all files
		var fileList = [];
		if ( shim[ name ] !== undefined ) {
			grunt.verbose.writeln( '    using shim value' );
			//use shim value
			fileList = fileList.concat( shim[ name ] );
		}
		else {
			grunt.verbose.writeln( '    using result value - ' + files );
			//make sure files is an array
			if (typeof files === 'string'){
				files = [files];
			}
			//we just need the path relative to the module directory
			files.forEach( function( file ){
				file = path.fix( file );
				fileList.push( file.replace( path.fix( path.join( bowerPath, name ) ) , "" ) );
			});
		}

		//expand list
		var expandedList = [];
		fileList.forEach( function( file ){
			grunt.verbose.writeln( '      globbing - ' + path.join( name, file ) );
			glob.sync( path.join( name, file ), { cwd: bowerPath, dot: true } ).forEach( function( filename ) {
				var src = path.fix( path.join( bowerPath, filename ) );
				grunt.verbose.writeln( 'src      ' + src );
				expandedList.push( src );
			});
		});

		//filter filetypes
		expandedList = expandedList.filter( function( file ){
			var ext = path.extname( file ).substr(1);
			if ( extensions ){
				return extensions.indexOf( ext ) >= 0;
			}
			else{
				return true;
			}
		});


		//get common path for building destination
		var commonPath = maintainCommonPaths ? "" : getCommonPathBase( expandedList );
		grunt.verbose.writeln( '   common path: ' + commonPath );


		//build default mapping
		var componentMap = {};
		grunt.verbose.writeln( '   mapping files:' );
		expandedList.forEach( function( file ){

			if ( expandedMap[ file ] !== undefined ) {
				//use user configured mapping if set
				componentMap[ file ] = expandedMap[ file ];
				grunt.log.writeln( '  * '+file+' -> '+ expandedMap[ file ] );
			}
			else {
				var newFilename = commonPath === "" ? file : file.replace( commonPath, "" );
				//console.log('      newfileName:',newFilename);
				var dest = path.join( destPath, newFilename );
				//console.log('      dest:',dest);

				if ( useNamespace === true || ( useNamespace === undefined && expandedList.length > 1 ) ){
					dest = dest.replace( destPath, path.join( destPath, name ) );
				}
				componentMap[ file ] = dest;
				grunt.log.writeln( '    '+file+' -> '+ dest );

			}

		});

		return componentMap;

	}
969747
def _construct_bower_command(bower_command):
    '''
    
    '''
    if not bower_command:
        raise CommandExecutionError(
            'bower_command, e.g. install, must be specified')

    cmd = ['bower'] + shlex.split(bower_command)
    cmd.extend(['--config.analytics', 'false',
                '--config.interactive', 'false',
                '--allow-root', '--json'])
    return cmd
1024077
function (grunt, rootPath, tasks) {
		tasks.forEach(function (name) {
			if (name === 'grunt-cli') return;
			var cwd = process.cwd();
			process.chdir(rootPath); // load files from proper root, I don't want to install everything locally per module!
			grunt.loadNpmTasks(name);
			process.chdir(cwd);
		});
	}
965860
def run(self):
        """"""
        # Try to create the directory
        if not os.path.exists(self.output):
            try:
                os.mkdir(self.output)
            except:
                print 'failed to create output directory %s' % self.output

        # Be sure it is a directory
        if not os.path.isdir(self.output):
            print 'invalid output directory %s' % self.output
            sys.exit(1)

        # Create the CSV handlers
        visitors = [
            _CompaniesCSV(self.output),
            _ActivitiesCSV(self.output),
            _ActivitiesSeenCSV(self.output),
            _QSACSV(self.output),
        ]

        # Run by each company populating the CSV files
        for path in glob.glob(os.path.join(self.input, '*.json')):
            with open(path, 'r') as f:
                try:
                    data = json.load(f, encoding='utf-8')
                except ValueError:
                    continue

                for visitor in visitors:
                    visitor.visit(data)
1303450
def execute(self, *, eopatch_folder):
        
        eopatch = EOPatch.load(os.path.join(self.folder, eopatch_folder), *self.args, **self.kwargs)
        return eopatch
699114
def run(self, element, outfolder):
        """"""
        filepath = self.relative_path_for_element(element)
        if outfolder and not os.path.isabs(filepath):
            filepath = os.path.join(outfolder, filepath)

        _logger.debug('{!r} --> {!r}'.format(element, filepath))

        self.ensure_folder(filepath)
        self.generate_file(element, filepath)
1150049
def method_missing(method_sym, *arguments, &_block)
      # We have to go inside the fastlane directory
      # since in the fastlane runner.rb we do the following
      #   custom_dir = ".."
      #   Dir.chdir(custom_dir) do
      # this goes one folder up, since we're inside the "fastlane"
      # folder at that point
      # Since we call an action from an action we need to go inside
      # the fastlane folder too

      self.runner.trigger_action_by_name(method_sym,
                                         FastlaneCore::FastlaneFolder.path,
                                         true,
                                         *arguments)
    end
369508
def run(self):
        
        run_command = (
            settings.project_customization.runfile.read_text().split()
        )
        chmod_string = (
            "chmod +x "
            + settings.project_customization.runfile.absolute().as_posix()
        )
        subprocess.run(chmod_string.split())
        subprocess.run(
            run_command, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr
        )
364876
def run():
    """"""
    
    # Grab server args
    args = client_helper.grab_server_args()

    # Start up workbench connection
    workbench = zerorpc.Client(timeout=300, heartbeat=60)
    workbench.connect('tcp://'+args['server']+':'+args['port'])

    # Upload the file into workbench
    my_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                           '../data/pe/bad/033d91aae8ad29ed9fbb858179271232')
    with open(my_file,'rb') as f:

        # Throw file into workbench
        filename = os.path.basename(my_file)
        raw_bytes = f.read()
        md5 = workbench.store_sample(raw_bytes, filename, 'exe')
        results = workbench.work_request('view', md5)
        print 'Filename: %s' % filename
        pprint.pprint(results)
216977
function run()
    {
        $loader = new Twig_Loader_Filesystem($this->templateDir);

        $twig = new Twig_Environment($loader);

        $GLOBALS['PHPDocMD_classDefinitions'] = $this->classDefinitions;
        $GLOBALS['PHPDocMD_linkTemplate'] = $this->linkTemplate;

        $filter = new Twig_SimpleFilter('classLink', ['PHPDocMd\\Generator', 'classLink']);
        $twig->addFilter($filter);

        foreach ($this->classDefinitions as $className => $data) {
            $output = $twig->render('class.twig', $data);

            file_put_contents($this->outputDir . '/' . $data['fileName'], $output);
        }

        $index = $this->createIndex();

        $index = $twig->render('index.twig',
            [
                'index'            => $index,
                'classDefinitions' => $this->classDefinitions,
            ]
        );

        file_put_contents($this->outputDir . '/' . $this->apiIndexFile, $index);
    }
848320
def execute(self):
        """"""
        if self._cli_arguments['cfn']:
            generate_sample_cfn_module(self.env_root)
        elif self._cli_arguments['sls']:
            generate_sample_sls_module(self.env_root)
        elif self._cli_arguments['sls-tsc']:
            generate_sample_sls_tsc_module(self.env_root)
        elif self._cli_arguments['stacker']:
            generate_sample_stacker_module(self.env_root)
        elif self._cli_arguments['tf']:
            generate_sample_tf_module(self.env_root)
        elif self._cli_arguments['cdk-tsc']:
            generate_sample_cdk_tsc_module(self.env_root)
        elif self._cli_arguments['cdk-py']:
            generate_sample_cdk_py_module(self.env_root)
        elif self._cli_arguments['cdk-csharp']:
            generate_sample_cdk_cs_module(self.env_root)
1136977
public function run()
    {
        $topdir = $this->getBasePath();

        foreach (scandir($topdir) as $filename) {

            // Skip directory link files
            if (($filename == '.') || ($filename == '..')) {
                continue;
            }

            if (is_dir($topdir . DIRECTORY_SEPARATOR . $filename)) {
                // Recurse into lower level directory, providing the namespace
                $this->loadFiles($filename, $filename);
            }
        }
    }