How to use path_parent method in avocado

Best Python code snippet using avocado_python

json_test.py

Source:json_test.py Github

copy

Full Screen

1<<<<<<< HEAD2import json3import cssutils4import logging5from pprint import pprint6import os7import sys8import operator9sys.setrecursionlimit(30000)10cssutils.log.setLevel(logging.CRITICAL)11with open('state.json') as data_file:12 data = json.load(data_file)13ERROR_KEYS = ["MEDIA_RULE", "UNKNOWN_RULE", "CHARSET_RULE"]14dct = {}15tally = 016num_files = 017#Directory Path18path_parent = 'C:\windows10share\\batchtest1'19print (path_parent)20#Tally up a:link selector21for path, dirs, file in os.walk(path_parent):22 if len(file) == 0:23 continue24 num_files += 125 with open(path + "\\" + file[0]) as data_file:26 data = json.load(data_file)27 for i in range(len(data["css"])):28 if "a:link" in data["css"][i]["src"]:29 tally += 130 break31 dct = {}32#Tally up a:visited selector33for path, dirs, file in os.walk(path_parent):34 if len(file) == 0:35 continue36 num_files += 137 with open(path + "\\" + file[0]) as data_file:38 data = json.load(data_file)39 for i in range(len(data["css"])):40 if "a:visited" in data["css"][i]["src"]:41 tally += 142 break43 dct = {}44#Determine number of definitions45dct_test = {}46for path, dirs, file in os.walk(path_parent):47 visited = False48 print (path)49 if len(file) == 0:50 continue51 with open(path + "\\" + file[0]) as data_file:52 data = json.load(data_file)53 f = open("something.txt", "w")54 for i in range(len(data["css"])):55 sheet = cssutils.parseString(data["css"][i]["src"])56 for rule in sheet:57 if rule.typeString != "STYLE_RULE":58 continue59 selector = rule.selectorText60 if " a:visited" in selector:61 print(rule)62 styles = (rule.style.cssText).split(";")63 for definition in styles:64 if attribute not in dct_test:65 dct_test[attribute] = 166 else:67 dct_test[attribute] += 168 visited = True69 break70 if visited == True:71 break72 if visited == True:73 sorted_keys = sorted(dct_test.items(), key=operator.itemgetter(1))74 pprint(sorted_keys)75print (tally)76print (tally/num_files)77# f = open("csstest.css", "w")78=======79import json80import cssutils81import logging82from pprint import pprint83import os84import sys8586sys.setrecursionlimit(3000)87cssutils.log.setLevel(logging.CRITICAL)88with open('state.json') as data_file:89 data = json.load(data_file)9091ERROR_KEYS = ["MEDIA_RULE", "UNKNOWN_RULE", "CHARSET_RULE"]92dct = {}93tally = 094num_files = 095# for i in range(len(data["css"])):96# sheet = cssutils.parseString(data["css"][i]["src"])97# for rule in sheet:98# if rule.typeString != "STYLE_RULE":99# continue100# selector = rule.selectorText101# styles = rule.style.cssText102# dct[selector] = styles103#104# for key in dct.keys():105# if "a:link" in key:106# tally += 1107108path_parent = 'C:\windows10share\\batchtest1reduced'109print (path_parent)110111for path, dirs, file in os.walk(path_parent):112 if len(file) == 0:113 continue114 num_files += 1115 print(num_files)116 with open(path + "\\" + file[0]) as data_file:117 data = json.load(data_file)118119 for i in range(len(data["css"])):120 if "a:link" in data["css"][i]["src"]:121 tally += 1122 break123 # sheet = cssutils.parseString(data["css"][i]["src"])124 # # for rule in sheet:125 # # if rule.typeString != "STYLE_RULE":126 # # continue127 # # selector = rule.selectorText128 # # styles = rule.style.cssText129 # # dct[selector] = styles130 #131 # # for key in dct.keys():132 # # if "a:link" in key:133 # # tally += 1134135 dct = {}136137for path, dirs, file in os.walk(path_parent):138 print (path)139 if len(file) == 0:140 continue141142 with open(path + "\\" + file[0]) as data_file:143 data = json.load(data_file)144145 dct_test = {}146 f = open("something.txt", "w")147 for i in range(len(data["css"])):148 sheet = cssutils.parseString(data["css"][i]["src"])149 for rule in sheet:150 if rule.typeString != "STYLE_RULE":151 continue152 selector = rule.selectorText153 styles = rule.style.cssText154 dct_test[selector] = styles155156 for key in dct_test.keys():157 if "a:link" in key:158159160print (tally)161print (tally/num_files)162# f = open("csstest.css", "w")163>>>>>>> 53c1eaa2e35d0dd8f34a7044e7e1746c97c7a9ad...

Full Screen

Full Screen

projekat.py

Source:projekat.py Github

copy

Full Screen

1import os2import shutil3import log4def pushfunction(a, folder):5 p = os.path.basename(os.path.normpath(folder))6 print(p)7 print(os.getcwd())8 logdir = os.path.join(os.path.abspath('vercontrol'), p)9 10 print(logdir)11 if not os.path.exists(logdir):12 os.makedirs(logdir)13 os.chdir(logdir)14 log.log_it(a,logdir) #ubelezavamo commit, i povecavamo verzijju15 path_parent = os.path.dirname(os.getcwd()) #vracanje jedan dir iznad16 os.chdir(path_parent) #vracanje jedan dir iznad17 path_parent = os.path.dirname(os.getcwd()) #vracanje jedan dir iznad18 os.chdir(path_parent) #vracanje jedan dir iznad19 dirpath = os.path.join('./previousver', p)20 dirpath = os.path.join(dirpath, log.vernumbstring)21 if not os.path.exists(dirpath):22 os.makedirs(dirpath)23 src = folder24 dest = dirpath #iz currentver u previousver25 files = os.listdir(src) #kopiramo26 for f in files:27 shutil.copy(src + f, dest)28def selverfunction(b, folder):29 b_save = b30 b = b + "/" #polaz - folder izabrane verzije31 p = os.path.basename(os.path.normpath(folder))32 print(p) 33 dirpath = os.path.join('./previousver', p)34 dirpath = os.path.join(dirpath, b)35 if not os.path.exists(dirpath):36 return 037 src = dirpath #destinacija - currentver folder38 dest = folder39 for f in os.listdir(dest): #brisemo sve iz destinacije pre kopiranja40 os.remove(os.path.join(dest, f))41 files = os.listdir(src) #kopiramo42 for f in files:43 shutil.copy(src + f, dest)44 45 os.chdir('./vercontrol')46 logdir = os.path.join('./', p)47 if not os.path.exists(logdir):48 os.makedirs(logdir)49 a = "Reverted to " + b_save + ". version"50 os.chdir(logdir)51 log.log_it(a, logdir)52 path_parent = os.path.dirname(os.getcwd()) #vracanje jedan dir iznad53 os.chdir(path_parent) #vracanje jedan dir iznad54 path_parent = os.path.dirname(os.getcwd()) #vracanje jedan dir iznad55 os.chdir(path_parent) #vracanje jedan dir iznad...

Full Screen

Full Screen

tally.py

Source:tally.py Github

copy

Full Screen

1import json2import cssutils3import logging4from pprint import pprint5import os6import sys7import operator8sys.setrecursionlimit(30000)9cssutils.log.setLevel(logging.CRITICAL)10with open('state.json') as data_file:11 data = json.load(data_file)12ERROR_KEYS = ["MEDIA_RULE", "UNKNOWN_RULE", "CHARSET_RULE"]13dct = {}14tally = 015num_files = 016#Directory Path17path_parent = 'C:\windows10share\\batchtest1reduced'18print (path_parent)19#Tally up a:link selector20for path, dirs, file in os.walk(path_parent):21 if len(file) == 0:22 continue23 num_files += 124 with open(path + "\\" + file[0]) as data_file:25 data = json.load(data_file)26 for i in range(len(data["css"])):27 if " a:link" in data["css"][i]["src"]:28 tally += 129 break30 dct = {}31#Tally up a:visited selector32for path, dirs, file in os.walk(path_parent):33 if len(file) == 0:34 continue35 num_files += 136 with open(path + "\\" + file[0]) as data_file:37 data = json.load(data_file)38 for i in range(len(data["css"])):39 if " a:visited" in data["css"][i]["src"]:40 tally += 141 break42 dct = {}43tally_link_visited = 044for path, dirs, file in os.walk(path_parent):45 visited = False46 link = False47 if len(file) == 0:48 continue49 num_files += 150 with open(path + "\\" + file[0]) as data_file:51 data = json.load(data_file)52 for i in range(len(data["css"])):53 if " a:visited" in data["css"][i]["src"]:54 visited = True55 if " a:link" in data["css"][i]["src"]:56 link = True57 if link and visited:58 tally_link_visited += 1...

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 avocado 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