How to use resources_folder_path method in molecule

Best Python code snippet using molecule_python

util.py

Source:util.py Github

copy

Full Screen

1#! /usr/bin/python32#-*- coding: UTF-8 -*-3import re4import unidecode5from goose3 import Goose6GRAB_FIRST_TWO_SENTENCES_RE = '[.!?][\s]{1,2}(?=[A-Z])'7REMOVE_SPECIAL_CHARACTERS_RE = '[^A-Za-z0-9]+'8REMOVE_SPECIAL_CHARACTERS_KEEP_DASHES_RE = '[^A-Za-z0-9-]+'9CLOSE_PAREN = ")"10COLON = "&#58"11COMMA = ","12DASH = "-"13EMPTY = ""14MARKDOWN_SUFFIX = ".md"15OPEN_PAREN = "("16PERIOD = "."17QUOTE = "\""18UNDERSCORE = "_"19SPACE = " "20def get_excerpt_from_page(url):21 """ Rudimentary excerpt creator."""22 try:23 regex_object = re.compile(GRAB_FIRST_TWO_SENTENCES_RE)24 all_text_on_page = Goose().extract(url=url).cleaned_text if url != EMPTY else EMPTY25 sentences = regex_object.split(all_text_on_page, re.UNICODE)26 except:27 return EMPTY28 if len(sentences) == 0 or _is_common_bad_excerpt(sentences[0]):29 return EMPTY30 if len(sentences) == 1:31 return _cleanup_excerpt(sentences[0] + PERIOD.replace(COLON, EMPTY))32 else:33 return _cleanup_excerpt((sentences[0] + PERIOD + SPACE + sentences[1] + PERIOD).replace(COLON, EMPTY))34def _cleanup_excerpt(str):35 return " ".join(str.split()).replace(COLON, EMPTY).replace(":", "")36def _is_common_bad_excerpt(sentence):37 common_bad_excerpts = [38 "JavaScript isn't enabled in your browser",39 "Get YouTube without the ads",40 ]41 for excerpt in common_bad_excerpts:42 if excerpt in sentence:43 return True44 return False45def title_to_file_path(title, resource_type):46 resources_folder_path = "../../collections/_"47 if (resource_type == 'writing'):48 resources_folder_path = resources_folder_path + "writings/"49 elif (resource_type == 'multimedia' or resource_type == "media"):50 resources_folder_path = resources_folder_path + "multimedia/"51 if title == EMPTY or title == UNDERSCORE:52 return EMPTY53 return "{}{}{}".format(54 resources_folder_path,55 _camel_case_to_dashed(_remove_extraneous_symbols(title.replace("58", ""))),56 MARKDOWN_SUFFIX)57def author_to_file_path(valid_author_slug):58 """ Replaces extraneous symbols and cleans up accents and umlauts59 in author names. """60 if valid_author_slug == EMPTY or valid_author_slug == UNDERSCORE:61 return EMPTY62 return "{}{}{}".format(63 "../../collections/_authors/",64 valid_author_slug,65 MARKDOWN_SUFFIX)66def get_valid_author_slug(author):67 return _remove_extraneous_symbols_keep_dashes(unidecode.unidecode(68 re.sub(UNDERSCORE, DASH, re.sub(SPACE, DASH, author.strip().lower()))))69def _camel_case_to_dashed(title):70 return re.sub('([a-z0-9])([A-Z])', r'\1-\2',71 re.sub('(.)([A-Z][a-z]+)',r'\1-\2', title)).lower()72def _remove_extraneous_symbols(str):73 return _remove_extraneous_symbols_with_regex(74 str, REMOVE_SPECIAL_CHARACTERS_RE)75def _remove_extraneous_symbols_keep_dashes(str):76 return _remove_extraneous_symbols_with_regex(77 str, REMOVE_SPECIAL_CHARACTERS_KEEP_DASHES_RE)78def _remove_extraneous_symbols_with_regex(str, regex):79 str = _replace_apostrophe_char_with_char(['s', 'S', 't', 'T'], str)80 return re.sub(81 '-+',82 '-',83 re.sub(regex, EMPTY, str))84def _replace_apostrophe_char_with_char(chars, str):85 for char in chars:86 str = re.sub(r"(\w+)'{}".format(char), r'\1{}'.format(char.lower()), str)...

Full Screen

Full Screen

folder_helper.py

Source:folder_helper.py Github

copy

Full Screen

1IMAGES_FOLDER_NAME = 'images'2FONTS_FOLDER_NAME = 'fonts'3REPORTS_FOLDER_NAME = 'reports'4RESOURCES_FOLDER_NAME = 'resources'5AUDIO_FOLDER_NAME = 'audio'6RESOURCES_FOLDER_PATH = f'C:/Users/Dell/Desktop/avi/lab_1/{RESOURCES_FOLDER_NAME}'7IMAGES_FOLDER_PATH = f'{RESOURCES_FOLDER_PATH}/{IMAGES_FOLDER_NAME}'8FONTS_FOLDER_PATH = f'{RESOURCES_FOLDER_PATH}/{FONTS_FOLDER_NAME}'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful