Compile a SKU Postscript file

@param string $path_to_ps

@throws \LogicException
351168
public function compile( $path_to_ps ) {

		if ( empty( $this->sku ) ) {
			throw new \LogicException( '$this->sku is not set' );
		}

		$sku = \Pressbooks\Utility\get_contents( PB_PLUGIN_DIR . 'symbionts/postscriptbarcode/code128.ps' );

		$invocation = $this->invocation(
			$this->sku,
			null,
			null,
			$this->textFont,
			$this->textSize
		);

		// @codingStandardsIgnoreStart
		file_put_contents( $path_to_ps, $sku );
		file_put_contents( $path_to_ps, $invocation, FILE_APPEND | LOCK_EX );
		file_put_contents( $path_to_ps, ( "\n" . 'showpage' ), FILE_APPEND | LOCK_EX );
		// @codingStandardsIgnoreEnd
	}
1090622
public function crop( $path_to_png, $border = '20x20' ) {

		$command = PB_CONVERT_COMMAND . ' ' . escapeshellarg( $path_to_png ) . " -trim +repage -bordercolor white -border {$border} " . escapeshellarg( $path_to_png );

		// Execute command
		$output = [];
		$return_var = 0;
		exec( $command, $output, $return_var ); // @codingStandardsIgnoreLine

		if ( ! empty( $output ) ) {
			// @codingStandardsIgnoreStart
			debug_error_log( $command );
			debug_error_log( print_r( $output, true ) );
			// @codingStandardsIgnoreEnd
		}
	}
385013
public function compile($to){
		copy($this->path->skeleton, $to);
		$epub = new \ZipArchive();
		if( true === $epub->open($to) ){
			$this->deliver($epub, $this->temp_dir);
		}
	}
477829
function compress($from_path,$to_path){
        $from_path=realpath($from_path);
        $to_path=realpath($to_path);
        if(!is_dir($to_path)){
            mkdir($to_path,0777,true);
        }
        if(is_dir($from_path)&&is_dir($to_path)&&is_writable($to_path)){
            return $this->recursion_compress($from_path,$to_path);
        }else{
            return false;
        }
    }
306526
public function compileIntoElement($input, $path = null)
    {
        $this->path = $path;
        $this->namedBlocks = [];

        $node = $this->parser->parse($input, $path); //Let exceptions fall through

        $element = $this->compileNode($node);

        if ($element && !($element instanceof ElementInterface)) {
            $this->throwException(
                get_class($node).
                ' compiled into a value that does not implement ElementInterface: '.
                (is_object($element) ? get_class($element) : gettype($element)),
                $node
            );
        } // @codeCoverageIgnore

        return $element;
    }
1115982
public function setPGTStorageFile($path='')
    {
    	// Sequence validation
        $this->ensureIsProxy();

    	// Argument validation
    	if (gettype($path) != 'string')
        	throw new CAS_TypeMismatchException($path, '$path', 'string');

        // create the storage object
        $this->setPGTStorage(new CAS_PGTStorage_File($this, $path));
    }
996206
public function generateFile(array $datas, $skeletonDir, $pathTemplate, $pathTo)
    {
        $continue = true;
        while ($continue) {
            $results = $this->view->render(
                $skeletonDir,
                $pathTemplate,
                $datas
            );

            $this->context->log("<info>[LOG] Generate $pathTo \nfrom $skeletonDir$pathTemplate</info>");
            $this->context->log($results);

            $continue = $this->context->confirm(
                "\n<question>Regenerate ?</question> ",
                'sanbox_regenerate'
            );
        }
    }
94350
public function execute($path = null)
    {
        $content = '';

        // loop files
        foreach ($this->data as $source => $js) {
            /*
             * Combine js: separating the scripts by a ;
             * I'm also adding a newline: it will be eaten when whitespace is
             * stripped, but we need to make sure we're not just appending
             * a new script right after a previous script that ended with a
             * singe-line comment on the last line (in which case it would also
             * be seen as part of that comment)
             */
            $content .= $js."\n;";
        }

        /*
         * Let's first take out strings, comments and regular expressions.
         * All of these can contain JS code-like characters, and we should make
         * sure any further magic ignores anything inside of these.
         *
         * Consider this example, where we should not strip any whitespace:
         * var str = "a   test";
         *
         * Comments will be removed altogether, strings and regular expressions
         * will be replaced by placeholder text, which we'll restore later.
         */
        $this->extractStrings('\'"`');
        $this->stripComments();
        $this->extractRegex();
        $content = $this->replace($content);

        $content = $this->propertyNotation($content);
        $content = $this->shortenBools($content);
        $content = $this->stripWhitespace($content);

        /*
         * Earlier, we extracted strings & regular expressions and replaced them
         * with placeholder text. This will restore them.
         */
        $content = $this->restoreExtractedData($content);

        return $content;
    }
910043
public function compile()
    {
        $pharFilePath = dirname(__FILE__).'/../../build/packagist-security-checker.phar';

        if (file_exists($pharFilePath)) {
            unlink($pharFilePath);
        }

        $phar = new Phar($pharFilePath, 0, 'packagist-security-checker.phar');
        $phar->setSignatureAlgorithm(\Phar::SHA1);

        $phar->startBuffering();

        $this
            ->addPHPFiles($phar)
            ->addVendorFiles($phar)
            ->addComposerVendorFiles($phar)
            ->addBin($phar)
            ->addStub($phar)
            ->addLicense($phar);

        $phar->stopBuffering();

        unset($phar);
    }
630254
public function compile($path)
	{

                // get the template data
                $string = $path->template;

		// Compile to PHP
		$contents = $this->compileString($string);

                // check/save cache
		if ( ! is_null($this->cachePath))
		{
			$this->files->put($this->getCompiledPath($path), $contents);
		}
	}
309164
function compile(source_file_path) {
    let pathParsed = path.parse(source_file_path);
    let nameParsed = path.parse(pathParsed.name);

    if (nameParsed.ext == '.module') {
      return Promise.reject({
        message: 'Modules are not supposed to be loaded'
      });
    }

    var str = fs.readFileSync(source_file_path, {
      encoding: 'utf8'
    });

    return getCompiler(str, source_file_path).render();
  }
545606
private function require_file($path) {
		$path = realpath($path);
		if (file_exists($path)) {
			require_once $path;

			// Opcache compilation
			$opcache_enabled = ini_get('opcache.enable');
			$opcache_cli_enabled = ini_get('opcache.enable_cli');
			if ( (php_sapi_name() == 'cli' and $opcache_cli_enabled) or (php_sapi_name() != 'cli' and $opcache_enabled)) {
				if (function_exists('opcache_is_script_cached') and function_exists('opcache_compile_file')) {
					if (!opcache_is_script_cached($path)) {
						// We have noticed OPcache sometimes yields a warning when compiling a file,
						// while that exact same file compiled just fine moments earlier. Worse, it
						// seems the OPcache for said file becomes corrupt somehow. This might
						// be a bug somewhere. We'll try to work around this issue by suppressing the
						// warning and explicitly invalidate the cache for the file if compilation fails.
						if (@opcache_compile_file($path) === false) {
							opcache_invalidate($path, true);
						}
					}
				}
			}

			return true;
		} else {
			throw new \Exception('File not found');
		}
	}
1364777
function OLE_PPS_File($name)
    {
        $this->_tmp_dir = System::tmpdir();
        $this->OLE_PPS(
            null, 
            $name,
            OLE_PPS_TYPE_FILE,
            null,
            null,
            null,
            null,
            null,
            '',
            array());
    }
712593
def compile_pycos(toc):
    
    global BUILDPATH

    # For those modules that need to be rebuilt, use the build directory
    # PyInstaller creates during the build process.
    basepath = os.path.join(BUILDPATH, "localpycos")

    new_toc = []
    for (nm, fnm, typ) in toc:

        # Trim the terminal "c" or "o"
        source_fnm = fnm[:-1]

        # If the source is newer than the compiled, or the compiled doesn't
        # exist, we need to perform a build ourselves.
        if mtime(source_fnm) > mtime(fnm):
            try:
                py_compile.compile(source_fnm)
            except IOError:
                # If we're compiling on a system directory, probably we don't
                # have write permissions; thus we compile to a local directory
                # and change the TOC entry accordingly.
                ext = os.path.splitext(fnm)[1]

                if "__init__" not in fnm:
                    # If it's a normal module, use last part of the qualified
                    # name as module name and the first as leading path
                    leading, mod_name = nm.split(".")[:-1], nm.split(".")[-1]
                else:
                    # In case of a __init__ module, use all the qualified name
                    # as leading path and use "__init__" as the module name
                    leading, mod_name = nm.split("."), "__init__"

                leading = os.path.join(basepath, *leading)

                if not os.path.exists(leading):
                    os.makedirs(leading)

                fnm = os.path.join(leading, mod_name + ext)
                py_compile.compile(source_fnm, fnm)

        new_toc.append((nm, fnm, typ))

    return new_toc
1277704
private function modifyComposerFile()
    {
        if (!is_writeable('composer.json')) {
            throw new Exception('Make sure a composer.json file exists and is writable');
        }

        $json = file_get_contents('composer.json');
        $composer = json_decode($json);

        if (!isset($composer->autoload) || !isset($composer->autoload->{'psr-4'})) {
            $composer->autoload = new stdClass();
            $composer->autoload->{'psr-4'} = new stdClass();
        }

        // Composer namespaces requires an extra slash at the end
        $namespace = $this->namespace . '\\';
        $composer->autoload->{'psr-4'}->{$namespace} = 'src';

        file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
    }
182558
protected function alchemyPdf(string $pdfPath, string $imagePath, array $options = [])
    {
        try {
            $this->containerUtil->isBundleActive('alchemy/ghostscript');
        } catch (\Exception $e) {
            throw new \Exception('Package alchemy/ghostscript is not installed. Please install or use another pdf transcoder.');
        }
        $imageExtension = pathinfo($imagePath, PATHINFO_EXTENSION);
        $allowedExtensions = ['jpg', 'jpeg', 'png'];

        if (!\in_array($imageExtension, $allowedExtensions)) {
            throw new InvalidTypeException('Only one of the following file types is allowed: '.implode(
                ', ', $allowedExtensions)
            );
        }

        if ('jpg' === $imageExtension) {
            $imageExtension = 'jpeg';
        }
        $command = [
            '-sDEVICE='.$imageExtension,
            '-dNOPAUSE',
            '-dBATCH',
            '-dSAFER',
            '-sOutputFile='.$imagePath,
        ];

        if (isset($option['page']) && \is_int($options['page']) && $options['page'] > 0) {
            $command[] = sprintf('-dFirstPage=%d', $options['page']);
            $command[] = sprintf('-dLastPage=%d', $options['page']);
        }

        try {
            $command[] = $pdfPath;
            $transcoder = Transcoder::create();
            $transcoder->command($command);
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
599784
protected function doCompile($_content, $isTemplateSource = false)
    {
        /* here is where the compiling takes place. Smarty
          tags in the templates are replaces with PHP code,
          then written to compiled files. */
        // init the lexer/parser to compile the template
        $this->parser =
            new $this->parser_class(new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $_content), $this),
                                    $this);
        if ($isTemplateSource && $this->template->caching) {
            $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n");
        }
        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        } else {
            $mbEncoding = null;
        }

        if ($this->smarty->_parserdebug) {
            $this->parser->PrintTrace();
            $this->parser->lex->PrintTrace();
        }
        // get tokens from lexer and parse them
        while ($this->parser->lex->yylex()) {
            if ($this->smarty->_parserdebug) {
                echo "<pre>Line {$this->parser->lex->line} Parsing  {$this->parser->yyTokenName[$this->parser->lex->token]} Token " .
                    htmlentities($this->parser->lex->value) . "</pre>";
            }
            $this->parser->doParse($this->parser->lex->token, $this->parser->lex->value);
        }

        // finish parsing process
        $this->parser->doParse(0, 0);
        if ($mbEncoding) {
            mb_internal_encoding($mbEncoding);
        }
        // check for unclosed tags
        if (count($this->_tag_stack) > 0) {
            // get stacked info
            list($openTag, $_data) = array_pop($this->_tag_stack);
            $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag .
                                          "{$this->smarty->right_delimiter} tag");
        }
        // call post compile callbacks
        foreach ($this->postCompileCallbacks as $cb) {
            $parameter = $cb;
            $parameter[0] = $this;
            call_user_func_array($cb[0], $parameter);
        }
        // return compiled code
        return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode;
    }