github.com/pachyderm/pachyderm@v1.13.4/etc/testing/pipeline-build/python_no_deps/main.py (about)

     1  import os
     2  import sys
     3  import argparse
     4  
     5  LENGTH = 4
     6  INPUT_DIRECTORY = "/pfs/in"
     7  OUTPUT_DIRECTORY = "/pfs/out"
     8  
     9  def main():
    10      pad_char = "0" if len(sys.argv) <= 1 else sys.argv[1]
    11      
    12      for fname in os.listdir(INPUT_DIRECTORY):
    13          if os.path.isfile(os.path.join(INPUT_DIRECTORY, fname)):
    14              with open(os.path.join(INPUT_DIRECTORY, fname), "r") as f_in:
    15                  contents = f_in.read()
    16                  if len(contents) < LENGTH:
    17                      contents = (pad_char * (LENGTH - len(contents))) + contents
    18                  with open(os.path.join(OUTPUT_DIRECTORY, fname), "w") as f_out: 
    19                      f_out.write("{}".format(contents))
    20  
    21  if __name__ == "__main__":
    22      main()