예제 #1
0
def make_resume_files(profile, output_dir):
    """
    Create resume files
    Args:
        profile: the dict of the profile
        output_dir: the output directory

    Returns:
        None
    """
    log = Logger()
    log.notice('Creating resume files')

    output_dir = os.path.join(output_dir, 'resume')
    make_dir(output_dir)
    copy_files(__name__, 'awesome_cv_files', output_dir)

    has_publications = make_publication_section(profile[PUBLICATIONS],
                                                output_dir)
    make_skill_section(profile[SKILLS], profile[LANGUAGES], output_dir)

    for section in RESUME_SECTIONS:
        make_resume_section(profile, section, output_dir)

    make_resume_main(profile, has_publications, output_dir)
    compile_resume(output_dir, has_publications)
예제 #2
0
def make_resume_files(profile, output_dir, timeout):
    """
    Create resume files
    Args:
        profile: the dict of the profile
        output_dir: the output directory
        timeout: the timeout value

    Returns:
        None
    """
    log = Logger()
    log.notice("Creating resume files")

    output_dir = os.path.join(output_dir, "resume")
    make_dir(output_dir)
    copy_files(
        __name__.split(".")[0], "templates/awesome_cv_files", output_dir)

    if PUBLICATIONS in profile:
        has_publications = make_publication_section(profile[PUBLICATIONS],
                                                    output_dir)
    else:
        has_publications = False

    if SKILLS in profile and LANGUAGES in profile:
        make_skill_section(profile[SKILLS], profile[LANGUAGES], output_dir)

    for section in RESUME_SECTIONS:
        make_resume_section(profile, section, output_dir)

    make_resume_main(profile, has_publications, output_dir)
    compile_resume(output_dir, has_publications, timeout)
예제 #3
0
def run(driver, email, password, keep_creds, output_dir, scrape_only, resume_only, website_only, profile_file, timeout,
        **kwargs):
    # Setup logging
    logbook.set_datetime_format('local')
    format_string = '[{record.time:%Y-%m-%d %H:%M:%S}] {record.level_name}: {record.message}'
    StreamHandler(sys.stdout, format_string=format_string).push_application()
    log = Logger()

    # Create output directory
    make_dir(output_dir)

    # Check if user has provided the profile json file
    if profile_file is None:
        if driver.lower() not in DRIVERS:
            raise ValueError(f'Browser driver has to be one of these: {", ".join(DRIVERS)}')

        # Check if credentials file exists
        credentials_file = os.path.expanduser(CREDENTIALS_FILE)
        if os.path.exists(credentials_file):
            with open(credentials_file) as f:
                credentials = json.load(f)
                email = credentials['email']
                password = credentials['password']
        else:
            if email is None:
                email = input('Enter your LinkedIn login email: ')
            if password is None:
                password = getpass('Enter your LinkedIn login password: '******'Scraping LinkedIn profile')
        log.notice('Please keep the browser window on top')
        profile = scrape(driver.lower(), email, password, output_dir, timeout)

        if keep_creds:
            store_creds(email, password, credentials_file)
    else:
        with open(profile_file) as f:
            profile = json.load(f)

    if not scrape_only:
        if resume_only:
            make_resume_files(profile, output_dir, timeout)
        elif website_only:
            make_website_files(profile, output_dir)
        else:
            make_resume_files(profile, output_dir, timeout)
            make_website_files(profile, output_dir)
예제 #4
0
def store_creds(email, password, creds_file):
    """
    Store login credentials
    Args:
        email: the LinkedIn login email
        password: the LinkedIn login password
        creds_file: the credentials file to store the login credentials

    Returns:
        None
    """
    log = Logger()
    log.warn(f'It is highly NOT recommended to keep your login credentials, '
             f'you can always remove the file {CREDENTIALS_FILE} to remove them')

    make_dir(os.path.expanduser(f'~/.{PACKAGE_NAME}'))
    credentials = {'email': email, 'password': password}

    with open(creds_file, 'w') as f:
        json.dump(credentials, f)
예제 #5
0
def make_website_files(profile, output_dir):
    """
    Create website files
    Args:
        profile: the dict of the profile
        output_dir: the output directory

    Returns:
        None
    """
    log = Logger()
    log.notice('Creating website files...')

    output_dir = os.path.join(output_dir, 'website')
    make_dir(output_dir)
    copy_files(
        __name__.split('.')[0], 'templates/dev_portfolio_files', output_dir)

    lines = []
    comment_line = has_sum = has_exp = has_edu = has_prj = has_skl = has_con = False

    with open(
            pkg_resources.resource_filename(
                __name__.split('.')[0], PORTFOLIO_TEMPLATE)) as f:
        for line in f:
            line = line.strip('\n')
            indent = re.match(r'\s+', line)

            if indent is not None:
                indent = indent.group()

            if 'section-headers-here' in line:
                for section in PORTFOLIO_SECTIONS:
                    if section == CONTACT or (section in profile
                                              and profile[section]):
                        lines += make_section_header(section, indent)
            elif NAME in profile and 'name-here' in line:
                lines.append(line.replace('name-here', profile[NAME]))
            elif POSITION in profile and 'title-here' in line:
                lines.append(line.replace('title-here', profile[POSITION]))
            elif NAME in profile and 'copyright-here' in line:
                lines.append(
                    line.replace('copyright-here',
                                 f'{arrow.now().year} {profile[NAME]}'))

            # About section
            elif 'id="about"' in line:
                if SUMMARY not in profile or not profile[SUMMARY]:
                    comment_line = True
                    lines += make_comment_line(line)
                else:
                    has_sum = True
                    lines.append(line)
            elif has_sum and 'summary-here' in line:
                lines += make_summary_section(profile[SUMMARY], indent)

            # Experience section
            elif 'id="experience"' in line:
                if EXPERIENCE not in profile or not profile[EXPERIENCE]:
                    comment_line = True
                    lines += make_comment_line(line)
                else:
                    has_exp = True
                    lines.append(line)
            elif has_exp and 'experience-here' in line:
                lines += make_experience_section(profile[EXPERIENCE], indent)

            # Education section
            elif 'id="education"' in line:
                if EDUCATION not in profile or not profile[EDUCATION]:
                    comment_line = True
                    lines += make_comment_line(line)
                else:
                    has_edu = True
                    lines.append(line)
            elif has_edu and 'education-here' in line:
                lines += make_education_section(profile[EDUCATION], indent)

            # Projects section
            elif 'id="projects"' in line:
                if PROJECTS not in profile or not profile[PROJECTS]:
                    comment_line = True
                    lines += make_comment_line(line)
                else:
                    has_prj = True
                    lines.append(line)
            elif has_prj and 'projects-here' in line:
                lines += make_projects_section(profile[PROJECTS], indent)

            # Skills section
            elif 'id="skills"' in line:
                if SKILLS not in profile or not profile[SKILLS]:
                    comment_line = True
                    lines += make_comment_line(line)
                else:
                    has_skl = True
                    lines.append(line)
            elif has_skl and 'skills-here' in line:
                lines += make_skills_section(profile[SKILLS], indent)

            # Contact section
            elif CONTACT in profile and EMAIL in profile[
                    CONTACT] and 'email-here' in line:
                lines.append(
                    line.replace('email-here', profile[CONTACT][EMAIL]))
            elif 'col-sm-5 social' in line:
                if CONTACT not in profile or \
                        all(x not in profile[CONTACT] or not profile[CONTACT][x] for x in CONTACTS):
                    comment_line = True
                    lines += make_comment_line(line)
                else:
                    has_con = True
                    lines.append(line)
            elif has_con and 'contact-here' in line:
                lines += make_contact_section(profile[CONTACT], indent)

            # Comment out sections
            elif comment_line and any(x in line for x in SECTION_ENDS):
                comment_line = False
            elif comment_line:
                lines += make_comment_line(line)

            # No changes to line
            else:
                lines.append(line)

    with open(os.path.join(output_dir, 'index.html'), 'w') as f:
        f.write('\n'.join(lines))