コード例 #1
0
import modules.utils as u

#Method 1
u.get_file_names("./modules/")

#Method 2
u.get_all_file_names("./modules/")

#Method 3
myList = [
    "myFile.csv", "output.txt", "utils.py", "week2ex1c.py", "Week_2.ipynb"
]
u.print_line_one(myList)

#Method 4
list_emails = [
    "myFile.csv", "*****@*****.**", "utils.py", "*****@*****.**", "Week_2.ipynb"
]
u.print_emails(list_emails)

#Method 5
md_list = ["./modules/read.md", "./modules/readme.md"]
u.write_headlines(md_list)
コード例 #2
0
    #  print('List:', args.list)
    #  print('Len', vars(args))

    # only first arg. usage: python_handin_template/Week_2.py python_handin_template/datamsg.txt
    if not (args.output_file and args.list):
        print_file_content_2(args.input_file)
    # only input and output. usage: python python_handin_template/Week_2.py python_handin_template/datamsg.txt -f python_handin_template/datawrite.txt -l word1 word2 word3
    else:
        lst = print_file_content_2(args.input_file)
        # not sure why the commented lines were necessary in Thomas' sample file. Seems to work without.
        # if args.list:
        #   lst.extend(args.list)
        # print('LISTEN:',lst)
        write_list_to_file(args.output_file, args.list)

# Exercise 2
from modules import utils
print("Exercise 2")
print("Get file names (writing to file output.txt)")
utils.get_file_names('./')
print("Get all file names (writing to file output2.txt")
utils.get_all_file_names('./')
print("Print first line of file:")
utils.print_line_one('python_handin_template/file_data/datamsg2.txt',
                     'python_handin_template/file_data/datamsg.txt')
print("Print all rows containing email (@ validation):")
utils.print_emails('python_handin_template/file_data/datamsg2.txt',
                   'python_handin_template/file_data/datamsg.txt')
print("Print all rows containing headline of MD files (# validation):")
utils.write_headlines('python_handin_template/README.md',
                      'python_handin_template/file_data/README.md')
コード例 #3
0
def test_write_headlines(md_files):
    utils.write_headlines(md_files)
コード例 #4
0
import modules.utils as util

if __name__ == '__main__':
    util.get_file_names("/home/jovyan/python_handin_template")
    util.get_all_file_names("/home/jovyan/python_handin_template")
    file_list = ["output1.txt", "output.txt", "python_handin_template/textfiles/pythonfile.csv"]
    util.print_line_one(file_list)
    email_list = ["readtest.txt", "output1.txt", "python_handin_template/textfiles/emails.txt"]
    util.print_emails(email_list)
    util.write_headlines("python_handin_template/textfiles/headlines.md")