Commit 2f761842 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added time log for parser initialization + add back log of parsed vCards +...

Added time log for parser initialization + add back log of parsed vCards + added tool to generate random vcards
parent 598d6f95
......@@ -33,3 +33,4 @@ tests/belcard-folder
tests/belcard-unfolder
tests/belcard-parser
src/vcard_grammar.cpp
tools/output.vcf
......@@ -37,12 +37,17 @@ int main(int argc, char *argv[]) {
}
file = argv[1];
BelCardParser *parser = new BelCardParser();
auto t_start = std::chrono::high_resolution_clock::now();
shared_ptr<BelCardList> belCards = parser->parseFile(file);
BelCardParser *parser = new BelCardParser();
auto t_end = std::chrono::high_resolution_clock::now();
cout << "Parsing done in " << std::chrono::duration<double, std::milli>(t_end-t_start).count() << " milliseconds" << endl;
auto t_start_2 = std::chrono::high_resolution_clock::now();
shared_ptr<BelCardList> belCards = parser->parseFile(file);
auto t_end_2 = std::chrono::high_resolution_clock::now();
cout << *belCards << endl;
cout << "Parser initialized in " << std::chrono::duration<double, std::milli>(t_end - t_start).count() << " milliseconds" << endl;
cout << "Parsing done in " << std::chrono::duration<double, std::milli>(t_end_2 - t_start_2).count() << " milliseconds" << endl;
delete parser;
return 0;
......
#!/usr/bin/env python
# -*- coding: utf8 -*-
from barnum import gen_data
import codecs
import frogress
import random
gender_vcard_list = ['M', 'F', 'O', 'N', 'U']
def generate_vCard():
gender_initial = gender_vcard_list[random.randint(0, 4)]
gender = None
if gender_initial == 'M':
gender = 'Male'
elif gender_initial == 'F':
gender = 'Female'
(first_name, last_name) = gen_data.create_name(gender=gender)
adr = gen_data.create_street()
zip, city, state = gen_data.create_city_state_zip()
vCard = 'BEGIN:VCARD\r\n'
vCard += 'VERSION:4.0\r\n'
vCard += 'FN:{} {}\r\n'.format(first_name, last_name)
vCard += 'N:{};{};;;\r\n'.format(last_name, first_name)
vCard += 'TEL:tel:{}\r\n'.format(gen_data.create_phone())
vCard += 'GENDER:{}\r\n'.format(gender_initial)
vCard += 'EMAIL:{}\r\n'.format(gen_data.create_email(name=(first_name, last_name)).lower())
vCard += 'IMPP:sip:{}@{}\r\n'.format(first_name.lower(), 'sip.linphone.org')
vCard += 'ADR:;;{};{};{};{};\r\n'.format(adr, city, state, zip)
vCard += 'NOTE:{}\r\n'.format(gen_data.create_sentence())
vCard += 'ORG:{}\r\n'.format(gen_data.create_company_name())
vCard += 'BDAY:{0:%Y%m%d}\r\n'.format(gen_data.create_birthday())
vCard += 'END:VCARD\r\n'
return vCard
def main():
output = ''
count = 1000
widgets = [frogress.BarWidget, frogress.PercentageWidget, frogress.ProgressWidget('vCard ')]
for i in frogress.bar(range(count), steps=count, widgets=widgets):
output += generate_vCard()
with codecs.open('output.vcf', 'w', 'utf-8') as f:
f.write(output)
if __name__ == "__main__":
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment