VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/local/lib/node_modules/mediasoup/worker/deps/catch/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/node_modules/mediasoup/worker/deps/catch/scripts/fixWhitespace.py
#!/usr/bin/env python3

from  __future__ import  print_function
import os
from scriptCommon import catchPath

def isSourceFile( path ):
    return path.endswith( ".cpp" ) or path.endswith( ".h" ) or path.endswith( ".hpp" )

def fixAllFilesInDir( dir ):
    changedFiles = 0
    for f in os.listdir( dir ):
        path = os.path.join( dir,f )
        if os.path.isfile( path ):
            if isSourceFile( path ):
                if fixFile( path ):
                    changedFiles += 1
        else:
            fixAllFilesInDir( path )
    return changedFiles

def fixFile( path ):
    f = open( path, 'r' )
    lines = []
    changed = 0
    for line in f:
        trimmed = line.rstrip() + "\n"
        trimmed = trimmed.replace('\t', '    ')
        if trimmed != line:
            changed = changed +1
        lines.append( trimmed )
    f.close()
    if changed > 0:
        global changedFiles
        changedFiles = changedFiles + 1
        print( path + ":" )
        print( " - fixed " + str(changed) + " line(s)" )
        altPath = path + ".backup"
        os.rename( path, altPath )
        f2 = open( path, 'w' )
        for line in lines:
            f2.write( line )
        f2.close()
        os.remove( altPath )
        return True
    return False

changedFiles = fixAllFilesInDir(catchPath)
if changedFiles > 0:
    print( "Fixed " + str(changedFiles) + " file(s)" )
else:
    print( "No trailing whitespace found" )

VaKeR 2022