1. Pedro Ferreira
  2. concatenate_files

Commits

d...@drk-PC.lan  committed 8e3ef2f

- improve the messages formatting (and tell which files are being concatenated)

  • Participants
  • Parent commits b5318dc
  • Branches default

Comments (0)

Files changed (1)

File concatenate_files.py

View file
 
         except IOError:
 
-            print( "Didn't find:", path )
+            print( "    Didn't find:", path )
 
         else:
             content = currentFile.read()
             currentFile.close()
 
             text += content
+            
+            print( "    {}".format( os.path.basename( path ) ) )
 
     return text
 
 
-'''
-    to doo:
-    
-    poder chamar a funcao tambem com uma variavel (no formato json), a substituir o ficheiro de config
-    
-    poder especificar o encoding na configuration
-    
-    ter argumento para o encoding do ficheiro que cria (default ser utf-8)
-    
-    print() o path completo para a folder (from folder), mas depois o dos ficheiros ser relativo para ter menos texto
-'''
+
 
 
 def concatenate( config, resultingFileName="result.txt", basePath="" ):
             # normalize the path
         path = os.path.abspath( path )
 
-        print( "Dealing with folder:", path )
+        print( "\nDealing with folder:", path, "\n" )
 
             # if there's an empty list, it means to open all the files in that folder (its in random order)		
         if len( configContent[ folder ] ) == 0:
 
-            print( "    Concatenating all the files in this folder." )
+            print( "  Concatenating all the files in this folder." )
 
                 # get a list of the file names in the directory
             fileNames = os.listdir( path )