Exemplo n.º 1
0
def main():
    user_input = InputClass
    ans = user_input.choose_event()
    while ans != "4":
        if ans == "1":
            publ = content.News()
        elif ans == "2":
            publ = content.Advert()
        elif ans == "3":
            publ = content.UserComment()
        publ.create_publication_body()
        file_pub = WriteContentToTxt(publ)
        file_pub.write_content()
        ans = user_input.choose_event()
Exemplo n.º 2
0
    for draft_publication in list_of_draft_publications:  # loop through a list of data suitable for publication creating
        if draft_publication[0] == "1":
            publ = content.News(
                draft_publication
            )  # if choice = 1 => create News content from 'draft_publication'
        elif draft_publication[0] == "2":
            publ = content.Advert(
                draft_publication
            )  # if choice = 2 => create Adv content from 'draft_publication'
            if publ.mistakes_flag == 1:  # if we find an incorrect date while 'publ' is created
                source_file.set_successful_processing(
                )  # set flag 'file successful processing' to false (default value for procedure)
                continue  # skip this publication
        elif draft_publication[0] == "3":
            publ = content.UserComment(
                draft_publication
            )  # if choice = 3 => create UserComment content from 'draft_publication'
        publ.create_publication_body(
        )  # form publication body for each content type
        publ.write_content()  # write publication to a file
    del source_file  # call destructor for file deleting

elif source_of_input == "1":  # user has chose input from console
    publication_type = user_input.read_correct_char(
        ("0", "1", "2", "3"), hint_for_console_input)  # ask for first input
    while publication_type != "0":  # loop until user has chose 0 and  write it to a file
        if publication_type == "1":
            publ = content.News()  # if choice = 1 => create News content
        elif publication_type == "2":
            publ = content.Advert()  # if choice = 2 => create Adv content
        elif publication_type == "3":
Exemplo n.º 3
0
import content
from input_class import InputClass

user_input = InputClass  # create object to read user choice
ans = user_input.choose_event()  # ask for first input
while ans != "4":  # loop until user has not choose 4
    if ans == "1":
        publ = content.News()  # if choice = 1 => create News content
    elif ans == "2":
        publ = content.Advert()  # if choice = 2 => create Adv content
    elif ans == "3":
        publ = content.UserComment(
        )  # if choice = 3 => create User Comment content
    publ.create_publication_body()  # use method to  create publication body
    publ.write_content()  # and  write it to a file
    ans = user_input.choose_event()  # ask user for new choice