Exemplo n.º 1
0
def generate_accounts(amount):
    known_accounts = []

    for person in range(0, amount):
        accounts = []
        first_name, last_name = gen_data.create_name()
        zip, city, state = gen_data.create_city_state_zip()
        address_id = str(random.randint(0, sys.maxint))

        UID = str(random.randint(0, sys.maxint))
        birth_day = gen_data.create_birthday()
        street_address = gen_data.create_street()
        email_address = gen_data.create_email(name=(first_name, last_name))

        print_instance(get_random_uuid_uri(), "nco:PersonContact")
        print_property("nco:fullname", str.join(' ', [first_name, last_name]))
        print_property("nco:nameGiven", first_name)
        print_property("nco:nameFamily", last_name)

        for j in range(0, random.randint(0, 4)):
            account_data = get_random_in_list(ACCOUNTS)
            user_account = str.join(
                '', [account_data[2], str(j), email_address])
            print_property("nco:hasIMAccount", user_account, t="uri")
            accounts.append((user_account, account_data))
            known_accounts.insert(0, user_account)

        print_property("nco:birthDate", str(birth_day), final=True)

    return known_accounts
Exemplo n.º 2
0
def generate_accounts(amount):
    known_accounts = []

    for person in range(0, amount):
        accounts = []
        first_name, last_name = gen_data.create_name()
        zip, city, state = gen_data.create_city_state_zip()
        address_id = str(random.randint(0, sys.maxint))

        UID = str(random.randint(0, sys.maxint))
        birth_day = gen_data.create_birthday()
        street_address = gen_data.create_street()
        email_address = gen_data.create_email(name=(first_name, last_name))

        print_instance(get_random_uuid_uri(), "nco:PersonContact")
        print_property("nco:fullname", str.join(" ", [first_name, last_name]))
        print_property("nco:nameGiven", first_name)
        print_property("nco:nameFamily", last_name)

        for j in range(0, random.randint(0, 4)):
            account_data = get_random_in_list(ACCOUNTS)
            user_account = str.join("", [account_data[2], str(j), email_address])
            print_property("nco:hasIMAccount", user_account, t="uri")
            accounts.append((user_account, account_data))
            known_accounts.insert(0, user_account)

        print_property("nco:birthDate", str(birth_day), final=True)

    return known_accounts
Exemplo n.º 3
0
def generate_im_group_chats(amount, friends_list):
    for i in range(0, amount):
        random_friend = get_random_in_list(friends_list)
        my_account_prefix = random_friend.split(':')[0] + ":"
        my_account = filter(lambda x: x[3].startswith(my_account_prefix),
                            ACCOUNTS)[0]
        addresses = [my_account[3], random_friend]

        print_instance(get_random_uuid_uri(), "nmo:CommunicationChannel")

        for i in range(0, random.randint(0, 10)):
            print_instance(get_random_uuid_uri(), "nmo:IMMessage")

            if i % 2 == 0:
                print_property("nmo:sentDate", getPseudoRandomDate())
            else:
                print_property("nmo:sentDate", getPseudoRandomDate())
                print_property("nmo:receivedDate", getPseudoRandomDate())

            print_anon_node("nmo:from",
                            "nco:IMContact",
                            "nco:hasIMAccount",
                            addresses[i % 2],
                            t="uri")
            print_anon_node("nmo:to",
                            "nco:IMContact",
                            "nco:hasIMAccount",
                            addresses[(i + 1) % 2],
                            t="uri",
                            final=True)

            print_property("nie:plainTextContent",
                           get_random_text(),
                           t="str",
                           final=True)
def gen_webhistory_ttl(entries):

    print_namespaces()

    for i in range(0, entries):
        domain = DOMAINS[random.randint(0, len(DOMAINS) - 1)]

        print "<%s> a nfo:WebHistory;" % (get_random_uuid_uri())
        print_property("nie:title", "%s %s" % (domain[7:], str(i)))
        print_property("nie:contentCreated", getPseudoRandomDate())
        print_property("nfo:domain", domain)
        print_property("nfo:uri", get_random_url_in_domain(domain), final=True)
def gen_webhistory_ttl(entries):

    print_namespaces()

    for i in range(0, entries):
        domain = DOMAINS[random.randint(0, len(DOMAINS) - 1)]

        print "<%s> a nfo:WebHistory;" % (get_random_uuid_uri())
        print_property("nie:title", "%s %s" % (domain[7:], str(i)))
        print_property("nie:contentCreated", getPseudoRandomDate())
        print_property("nfo:domain", domain)
        print_property("nfo:uri", get_random_url_in_domain(domain), final=True)
Exemplo n.º 6
0
def process_atom_feed (d):
    atom_uri =  get_self_link (d)
    print '<%s> a nmo:FeedChannel;' % atom_uri
    print_property ("nie:title", d.feed.title)
    print_property ("nie:description", d.feed.get('subtitle', None))
    print_property ("nie:contentLastModified", d.feed.updated.replace('Z', "+00:00"), final=True)
    print ""
    
    for entry in d.entries:
        process_atom_entries (entry, atom_uri)
Exemplo n.º 7
0
def process_atom_feed(d):
    atom_uri = get_self_link(d)
    print "<%s> a nmo:FeedChannel;" % atom_uri
    print_property("nie:title", d.feed.title)
    print_property("nie:description", d.feed.get("subtitle", None))
    print_property("nie:contentLastModified", d.feed.updated.replace("Z", "+00:00"), final=True)
    print ""

    for entry in d.entries:
        process_atom_entries(entry, atom_uri)
Exemplo n.º 8
0
def process_atom_entries (entry, atom_uri):
    print '<%s> a nmo:FeedMessage;' % entry.id
    print_property ("nie:title", entry.title)
    date =  entry.updated or entry.published
    if (date):
        print_property ("nie:contentLastModified", date.replace('Z', "+00:00"))
    print_property ("nmo:communicationChannel", atom_uri, "uri")
    #print_property ("nmo:htmlMessageContent", entry.summary.encode ('utf8'))
    author, email = parse_author_contact (entry.get('author', None))
    if (email and not email == ''):
        print '\tnco:contributor [a nco:Contact; nco:fullname "%s"; nco:hasEmailAddress <mailto:%s>];' % (author.encode ('utf8'),
                                                                                                           email.encode ('utf8')) 
        print ""
    else:
        if (author):
            print '\tnco:contributor [a nco:Contact; nco:fullname "%s"];' % (author.encode ('utf8'))
            print ""
        
    print_property ("nie:links", entry.link, "uri", final=True)
Exemplo n.º 9
0
def process_atom_entries(entry, atom_uri):
    print "<%s> a nmo:FeedMessage;" % entry.id
    print_property("nie:title", entry.title)
    date = entry.updated or entry.published
    if date:
        print_property("nie:contentLastModified", date.replace("Z", "+00:00"))
    print_property("nmo:communicationChannel", atom_uri, "uri")
    # print_property ("nmo:htmlMessageContent", entry.summary.encode ('utf8'))
    author, email = parse_author_contact(entry.get("author", None))
    if email and not email == "":
        print '\tnco:contributor [a nco:Contact; nco:fullname "%s"; nco:hasEmailAddress <mailto:%s>];' % (
            author.encode("utf8"),
            email.encode("utf8"),
        )
        print ""
    else:
        if author:
            print '\tnco:contributor [a nco:Contact; nco:fullname "%s"];' % (author.encode("utf8"))
            print ""

    print_property("nie:links", entry.link, "uri", final=True)
Exemplo n.º 10
0
def generate_im_group_chats(amount, friends_list):
    for i in range(0, amount):
        random_friend = get_random_in_list(friends_list)
        my_account_prefix = random_friend.split(":")[0] + ":"
        my_account = filter(lambda x: x[3].startswith(my_account_prefix), ACCOUNTS)[0]
        addresses = [my_account[3], random_friend]

        print_instance(get_random_uuid_uri(), "nmo:CommunicationChannel")

        for i in range(0, random.randint(0, 10)):
            print_instance(get_random_uuid_uri(), "nmo:IMMessage")

            if i % 2 == 0:
                print_property("nmo:sentDate", getPseudoRandomDate())
            else:
                print_property("nmo:sentDate", getPseudoRandomDate())
                print_property("nmo:receivedDate", getPseudoRandomDate())

            print_anon_node("nmo:from", "nco:IMContact", "nco:hasIMAccount", addresses[i % 2], t="uri")
            print_anon_node("nmo:to", "nco:IMContact", "nco:hasIMAccount", addresses[(i + 1) % 2], t="uri", final=True)

            print_property("nie:plainTextContent", get_random_text(), t="str", final=True)
Exemplo n.º 11
0
def gen_bookmarks_ttl (filename):

    print_namespaces ()

    for line in open (filename, 'r'):
        if (line.startswith ("#")):
            continue

        url, title, tags = line.split('|')
        print "<%s> a nfo:Bookmark;" % (gen_bookmark_uuid ())
        print_property ("nie:title", title)
        print_property ("nie:contentCreated", getPseudoRandomDate ())
        for tag in tags.strip().split(','):
            print '\tnao:hasTag [a nao:Tag; nao:prefLabel "%s"];' % (tag.strip())
        
        print_property ("nfo:bookmarks", url, "uri", True)
Exemplo n.º 12
0
def generate_mail(amount, known_emails):
    for i in range(0, amount):
        random_address_friend = "mailto:" + get_random_in_list(known_emails)
        random_address_me = "mailto:" + get_random_in_list(MAIL_ADDRESSES)

        print_instance(get_random_uuid_uri(), "nmo:Email")

        # Half sent, half received
        if i % 2 == 0:
            #sent
            print_anon_node("nmo:from",
                            "nco:Contact",
                            "nco:hasEmailAddress",
                            random_address_me,
                            t="uri")
            print_anon_node("nmo:to",
                            "nco:Contact",
                            "nco:hasEmailAddress",
                            random_address_friend,
                            t="uri")
            print_property("nmo:sentDate", getPseudoRandomDate())
            print_property("nie:isLogicalPartOf",
                           "mailfolder://" + random_address_me[7:] + "/Sent",
                           t="uri")
        else:
            #received
            print_anon_node("nmo:to",
                            "nco:Contact",
                            "nco:hasEmailAddress",
                            random_address_me,
                            t="uri")
            print_anon_node("nmo:from",
                            "nco:Contact",
                            "nco:hasEmailAddress",
                            random_address_friend,
                            t="uri")
            print_property("nmo:receivedDate", getPseudoRandomDate())
            print_property("nie:isLogicalPartOf",
                           "mailfolder://" + random_address_me[7:] + "/Inbox",
                           t="uri")

        if random.randint(0, 5) > 3:
            print_anon_node("nmo:cc",
                            "nco:Contact",
                            "nco:hasEmailAddress",
                            "mailto:" + get_random_in_list(known_emails),
                            t="uri")

        if random.randint(0, 5) > 3:
            print_anon_node("nmo:bcc",
                            "nco:Contact",
                            "nco:hasEmailAddress",
                            "mailto:" + get_random_in_list(known_emails),
                            t="uri")

        print_property("nmo:messageSubject", get_random_text_short())
        print_property("nmo:status", "eeeeeh uuuhhhmmmmm")
        print_property("nmo:responseType", "blublublu")
        print_property("nmo:messageId",
                       "<" + get_random_message_id() + "@email.net>")
        print_property("nie:plainTextContent", get_random_text())
        print_anon_node("nmo:replyTo",
                        "nco:Contact",
                        "nco:hasEmailAddress",
                        REPLY_TO,
                        t="uri")

        # FIXME Add message headers
        # FIXME Add inReplyTo
        print_property("nie:contentSize",
                       random.randint(20, 120),
                       t="str",
                       final=True)
Exemplo n.º 13
0
def generate_im_messages(n_convs, n_channels, msgs_per_convs, friends_list,
                         n_friends):
    for i in range(0, len(friends_list)):
        same_friend = friends_list[i]

        channel_id = get_random_uuid_uri()
        print_instance(channel_id, "nmo:CommunicationChannel")

        print_property("nmo:lastMessageDate", getPseudoRandomDate())

        print "\tnmo:hasParticipant nco:default-contact-me ;"

        if same_friend:
            print_anon_node("nmo:hasParticipant",
                            "nco:IMContact",
                            "nco:hasIMAccount",
                            same_friend,
                            t="uri",
                            final=True)

        for j in range(0, n_convs):
            conversation_id = get_random_uuid_uri()
            print_instance(conversation_id, "nmo:Conversation", final=True)

            if same_friend:
                random_friend = same_friend
            else:
                random_friend = get_random_in_list(friends_list)

            my_account_prefix = random_friend.split(':')[0] + ":"
            my_account = filter(lambda x: x[3].startswith(my_account_prefix),
                                ACCOUNTS)[0]
            addresses = [my_account[3], random_friend]

            for k in range(0, random.randint(1, msgs_per_convs + 1)):
                print_instance(get_random_uuid_uri(), "nmo:IMMessage")

                print_property("nmo:communicationChannel", channel_id, t="uri")

                print_property("nmo:conversation", conversation_id, t="uri")
                if k % 2 == 0:
                    print_property("nmo:sentDate", getPseudoRandomDate())
                else:
                    print_property("nmo:sentDate", getPseudoRandomDate())
                    print_property("nmo:receivedDate", getPseudoRandomDate())

                print_property("nie:plainTextContent", get_random_text())

                print_anon_node("nmo:from",
                                "nco:IMContact",
                                "nco:hasIMAccount",
                                addresses[k % 2],
                                t="uri")
                print_anon_node("nmo:to",
                                "nco:IMContact",
                                "nco:hasIMAccount",
                                addresses[(k + 1) % 2],
                                t="uri",
                                final=True)
Exemplo n.º 14
0
def generate_me():
    print "nco:default-contact-me a nco:PersonContact ;"
    print_property("nco:fullname", "Me Nokia")
    print_property("nco:nameGiven", "Me")
    print_property("nco:nameFamily", "Nokia")
    print_property("nco:birthDate", "1980-01-01")

    # Email accounts
    for address in MAIL_ADDRESSES:
        print_property("nco:hasEmailAddress", "mailto:" + address, t="uri")

    print_property("nco:hasIMAccount", "msn:[email protected]", t="uri")
    print_property("nco:hasIMAccount", "gtalk:[email protected]", t="uri")
    print_property("nco:hasIMAccount",
                   "skype:[email protected]",
                   t="uri",
                   final=True)

    for account in ACCOUNTS:
        generate_account(account, account[3], "Me")

    # Email addresses and accounts
    # (FIXME: it should be n:m instead of 1:1)
    i = 0
    for address in MAIL_ADDRESSES:
        print_instance("mailto:" + address, "nco:EmailAddress")
        print_property("nco:emailAddress", address, final=True)

        print_instance(get_random_uuid_uri(), "nmo:MailAccount")
        print_property("nmo:accountName", "Mail " + str(i))
        print_property("nmo:accountDisplayName",
                       get_random_in_list(ACCOUNT_EXTENSIONS) + " EMail")
        print_property("nmo:fromAddress", "mailto:" + address, t="uri")
        for folder in get_folder_names(address):
            print_property("nie:hasLogicalPart", folder, t="uri")
        print_property("nmo:signature", get_random_text(), final=True)

        #for folder in get_folder_names (address):
        #    generate_mailfolder (folder)

        i += 1
Exemplo n.º 15
0
def generate_mailfolder(folderuri):
    # mailfolder://[email protected]/x/y/x ----> foldername X, displayName x
    print_instance(folderuri, "nmo:MailFolder")
    print_property("nmo:folderName",
                   folderuri.rpartition('/')[2].upper(),
                   final=True)
Exemplo n.º 16
0
def generate_account(account_data, user_account, firstname):
    print_instance(user_account, "nco:IMAccount")
    #print_property ("nco:imStatus", random.randint (0, 5), t = "int")
    print_property("nco:imAccountType", get_account_name(account_data[0]))
    print_property("nco:imProtocol", account_data[2][:-1])
    print_property("nco:imNickname", get_nickname(firstname), final=True)
Exemplo n.º 17
0
def generate_account(account_data, user_account, firstname):
    print_instance(user_account, "nco:IMAccount")
    # print_property ("nco:imStatus", random.randint (0, 5), t = "int")
    print_property("nco:imAccountType", get_account_name(account_data[0]))
    print_property("nco:imProtocol", account_data[2][:-1])
    print_property("nco:imNickname", get_nickname(firstname), final=True)
Exemplo n.º 18
0
def generate_mail(amount, known_emails):
    for i in range(0, amount):
        random_address_friend = "mailto:" + get_random_in_list(known_emails)
        random_address_me = "mailto:" + get_random_in_list(MAIL_ADDRESSES)

        print_instance(get_random_uuid_uri(), "nmo:Email")

        # Half sent, half received
        if i % 2 == 0:
            # sent
            print_anon_node("nmo:from", "nco:Contact", "nco:hasEmailAddress", random_address_me, t="uri")
            print_anon_node("nmo:to", "nco:Contact", "nco:hasEmailAddress", random_address_friend, t="uri")
            print_property("nmo:sentDate", getPseudoRandomDate())
            print_property("nie:isLogicalPartOf", "mailfolder://" + random_address_me[7:] + "/Sent", t="uri")
        else:
            # received
            print_anon_node("nmo:to", "nco:Contact", "nco:hasEmailAddress", random_address_me, t="uri")
            print_anon_node("nmo:from", "nco:Contact", "nco:hasEmailAddress", random_address_friend, t="uri")
            print_property("nmo:receivedDate", getPseudoRandomDate())
            print_property("nie:isLogicalPartOf", "mailfolder://" + random_address_me[7:] + "/Inbox", t="uri")

        if random.randint(0, 5) > 3:
            print_anon_node(
                "nmo:cc", "nco:Contact", "nco:hasEmailAddress", "mailto:" + get_random_in_list(known_emails), t="uri"
            )

        if random.randint(0, 5) > 3:
            print_anon_node(
                "nmo:bcc", "nco:Contact", "nco:hasEmailAddress", "mailto:" + get_random_in_list(known_emails), t="uri"
            )

        print_property("nmo:messageSubject", get_random_text_short())
        print_property("nmo:status", "eeeeeh uuuhhhmmmmm")
        print_property("nmo:responseType", "blublublu")
        print_property("nmo:messageId", "<" + get_random_message_id() + "@email.net>")
        print_property("nie:plainTextContent", get_random_text())
        print_anon_node("nmo:replyTo", "nco:Contact", "nco:hasEmailAddress", REPLY_TO, t="uri")

        # FIXME Add message headers
        # FIXME Add inReplyTo
        print_property("nie:contentSize", random.randint(20, 120), t="str", final=True)
Exemplo n.º 19
0
def generate_im_messages(n_convs, n_channels, msgs_per_convs, friends_list, n_friends):
    for i in range(0, len(friends_list)):
        same_friend = friends_list[i]

        channel_id = get_random_uuid_uri()
        print_instance(channel_id, "nmo:CommunicationChannel")

        print_property("nmo:lastMessageDate", getPseudoRandomDate())

        print "\tnmo:hasParticipant nco:default-contact-me ;"

        if same_friend:
            print_anon_node("nmo:hasParticipant", "nco:IMContact", "nco:hasIMAccount", same_friend, t="uri", final=True)

        for j in range(0, n_convs):
            conversation_id = get_random_uuid_uri()
            print_instance(conversation_id, "nmo:Conversation", final=True)

            if same_friend:
                random_friend = same_friend
            else:
                random_friend = get_random_in_list(friends_list)

            my_account_prefix = random_friend.split(":")[0] + ":"
            my_account = filter(lambda x: x[3].startswith(my_account_prefix), ACCOUNTS)[0]
            addresses = [my_account[3], random_friend]

            for k in range(0, random.randint(1, msgs_per_convs + 1)):
                print_instance(get_random_uuid_uri(), "nmo:IMMessage")

                print_property("nmo:communicationChannel", channel_id, t="uri")

                print_property("nmo:conversation", conversation_id, t="uri")
                if k % 2 == 0:
                    print_property("nmo:sentDate", getPseudoRandomDate())
                else:
                    print_property("nmo:sentDate", getPseudoRandomDate())
                    print_property("nmo:receivedDate", getPseudoRandomDate())

                print_property("nie:plainTextContent", get_random_text())

                print_anon_node("nmo:from", "nco:IMContact", "nco:hasIMAccount", addresses[k % 2], t="uri")
                print_anon_node(
                    "nmo:to", "nco:IMContact", "nco:hasIMAccount", addresses[(k + 1) % 2], t="uri", final=True
                )
Exemplo n.º 20
0
def generate_me():
    print "nco:default-contact-me a nco:PersonContact ;"
    print_property("nco:fullname", "Me Nokia")
    print_property("nco:nameGiven", "Me")
    print_property("nco:nameFamily", "Nokia")
    print_property("nco:birthDate", "1980-01-01")

    # Email accounts
    for address in MAIL_ADDRESSES:
        print_property("nco:hasEmailAddress", "mailto:" + address, t="uri")

    print_property("nco:hasIMAccount", "msn:[email protected]", t="uri")
    print_property("nco:hasIMAccount", "gtalk:[email protected]", t="uri")
    print_property("nco:hasIMAccount", "skype:[email protected]", t="uri", final=True)

    for account in ACCOUNTS:
        generate_account(account, account[3], "Me")

    # Email addresses and accounts
    # (FIXME: it should be n:m instead of 1:1)
    i = 0
    for address in MAIL_ADDRESSES:
        print_instance("mailto:" + address, "nco:EmailAddress")
        print_property("nco:emailAddress", address, final=True)

        print_instance(get_random_uuid_uri(), "nmo:MailAccount")
        print_property("nmo:accountName", "Mail " + str(i))
        print_property("nmo:accountDisplayName", get_random_in_list(ACCOUNT_EXTENSIONS) + " EMail")
        print_property("nmo:fromAddress", "mailto:" + address, t="uri")
        for folder in get_folder_names(address):
            print_property("nie:hasLogicalPart", folder, t="uri")
        print_property("nmo:signature", get_random_text(), final=True)

        # for folder in get_folder_names (address):
        #    generate_mailfolder (folder)

        i += 1
Exemplo n.º 21
0
def generate_mailfolder(folderuri):
    # mailfolder://[email protected]/x/y/x ----> foldername X, displayName x
    print_instance(folderuri, "nmo:MailFolder")
    print_property("nmo:folderName", folderuri.rpartition("/")[2].upper(), final=True)