repo_id
stringclasses 208
values | file_path
stringlengths 31
190
| content
stringlengths 1
2.65M
| __index_level_0__
int64 0
0
|
---|---|---|---|
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/BMI-calculator/04_BMI_calculator.py
|
"""
We will use this script to learn Python to absolute beginners
The script is an example of BMI_Calculator implemented in Python
The BMI_Calculator:
# Get the weight(Kg) of the user
# Get the height(m) of the user
# Caculate the BMI using the formula
BMI=weight in kg/height in meters*height in meters
Exercise 4:
Write a program to calculate the BMI by accepting user input from the keyboard and check whether the user comes
in underweight ,normal weight or obesity. Read the CSV which contains player data and compare a user BMI
with a player.Create functions for calculating BMI and check the user category.
i)Get user weight in kg
ii)Get user height in meter
iii) Use this formula to calculate the BMI
BMI = weight_of_the_user/(height_of_the_user * height_of_the_user)
iv)Use this level to check user category
#)Less than or equal to 18.5 is represents underweight
#)Between 18.5 -24.9 indicate normal weight
#)Between 25 -29.9 denotes over weight
#)Greater than 30 denotes obese
# Hint
i)Create a function to get the input
ii)Create a function to calculate BMi
iii)Create one more function for checking user category
iv)Create a function to read the CSV file and return the matched player
"""
import os
def get_input_to_calcluate_bmi():
"This function gets the input from the user"
print("Enter the weight of the user in Kg's")
# Get the weight of the user through keyboard
weight_of_the_user = input()
# Get the height of the user through keyboard
print("Enter the height of the user in meters")
height_of_the_user = input()
return weight_of_the_user,height_of_the_user
def calculate_bmi(weight_of_the_user,height_of_the_user):
"This function calculates the bmi"
# Calculate the BMI of the user according to height and weight
bmi_of_the_user = round(weight_of_the_user/(height_of_the_user * height_of_the_user),1)
# Return the BMI of the user to the called function
return bmi_of_the_user
def check_user_bmi_category(bmi):
"This function checks if the user is underweight, normal, overweight or obese"
if bmi <= 18.5:
print("The user is considered as underweight")
elif bmi > 18.5 and bmi < 24.9:
print("The user is considered as normal weight")
elif bmi > 25 and bmi <= 29.9:
print("The user is considered as overweight")
elif bmi >=30:
print("The user is considered as obese")
def compare_user_bmi_with_player_csv(bmi_value):
"This functions reads the CSV file and compare the BMI value with players and returns the players name"
# To read the CSV file we have to join the path where it's located
filename = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','data',"all_players_data.csv"))
matched_player = []
# To open the text file and assign to object fp
with open(filename,"r") as fp:
all_lines = fp.readlines()
for each_line in all_lines:
# Fetch the player name from the file
player_name = each_line.split(',')[0]
# Fetch the player BMI from the file
player_bmi = each_line.split(',')[-1].split('\n')[0]
# Checks player BMI and user BMI are equal
if float(player_bmi) == bmi_value:
matched_player.append({player_name:player_bmi})
if not matched_player:
print("Your BMI is not matching with any of the players dataset which is used here")
else:
print("Your BMI is matching with")
print matched_player
# Program starts here
if __name__ == "__main__":
# This calling function gets the input from the user
weight_of_the_user,height_of_the_user = get_input_to_calcluate_bmi()
# This calling function calculates the BMI of the user
bmi_value = calculate_bmi(weight_of_the_user,height_of_the_user)
print("BMI of the user is :", bmi_value)
# This function is used to calculate the user's criteria
check_user_bmi_category(bmi_value)
# This function is used to read the csv file and compare the BMI value
compare_user_bmi_with_player_csv(bmi_value)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/BMI-calculator/05_BMI_calculator.py
|
"""
We will use this script to learn Python to absolute beginners
The script is an example of BMI_Calculator implemented in Python
The BMI_Calculator:
# Get the weight(Kg) of the user
# Get the height(m) of the user
# Caculate the BMI using the formula
BMI=weight in kg/height in meters*height in meters
Exercise 5:
Write a program to calculate the BMI by accepting user input from the keyboard and check whether the user comes
in underweight ,normal weight or obesity by creating a class. Read the CSV files which contains player data
and compare your BMI with a player.Create functions for getting input from the user,calculating BMI and check
the user category.While getting input check the value you entered is of correct type if not
your program should not get crashed.
i)Get user weight in kg
ii)Get user height in meter
iii) Use this formula to calculate the BMI
BMI = weight_of_the_user/(height_of_the_user * height_of_the_user)
iv)Use this level to check user category
#)Less than or equal to 18.5 is represents underweight
#)Between 18.5 -24.9 indicate normal weight
#)Between 25 -29.9 denotes over weight
#)Greater than 30 denotes obese
# Hint
i)Create a function to get the input from the user
ii)Use exceptional handling to check user input's type
ii)Calculate the BMI
iii)Check the BMI with player BMI by reading the CSV file
"""
import os
def get_input_to_calcluate_bmi():
"This function gets the input from the user"
# Getting input will be repeated until the user enters the proper input
while True:
print("Enter the weight of the user in Kg's")
# Get the input from the user and check it's of correct type
try:
weight_of_the_user = float(raw_input())
# isintance will check the type of the input and returns true/false
if isinstance(weight_of_the_user,float):
break
# If user inputs wrong type then the except will run
except ValueError:
print("The value you have enteed is not a float value.Please enter the input in float value and in kilograms")
# Get the height of the user through keyboard
while True:
print("Enter the height of the user in Kg's")
try:
height_of_the_user = float(raw_input())
if isinstance(height_of_the_user,float):
break
except ValueError:
print("The value you have enteed is not a float value.Please enter the input in float value and in meters")
return weight_of_the_user,height_of_the_user
def calculate_bmi(weight_of_the_user,height_of_the_user):
"This function calculates the bmi"
# Calculate the BMI of the user according to height and weight
bmi_of_the_user = round(weight_of_the_user/(height_of_the_user * height_of_the_user),1)
# Return the BMI of the user to the called function
return bmi_of_the_user
def check_user_bmi_category(bmi):
"This function checks if the user is underweight, normal, overweight or obese"
if bmi <= 18.5:
print("The user is considered as underweight")
elif bmi > 18.5 and bmi < 24.9:
print("The user is considered as normal weight")
elif bmi > 25 and bmi <= 29.9:
print("The user is considered as overweight")
elif bmi >=30:
print("The user is considered as obese")
def compare_user_bmi_with_player_csv(bmi_value):
"This functions reads the CSV file and compare the BMI value with players and returns the players name"
# To read the CSV file we have to join the path where it's located
filename = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','data',"all_players_data.csv"))
matched_player = []
# To open the text file and assign to object fp
with open(filename,"r") as fp:
all_lines = fp.readlines()
for each_line in all_lines:
# Fetch the player name from the file
player_name = each_line.split(',')[0]
# Fetch the player BMI from the file
player_bmi = each_line.split(',')[-1].split('\n')[0]
# Checks player BMI and user BMI are equal
if float(player_bmi) == bmi_value:
matched_player.append({player_name:player_bmi})
if not matched_player:
print("Your BMI is not matching with any of the players dataset which is used here")
else:
print("Your BMI is matching with")
print matched_player
# Program starts here
if __name__ == "__main__":
# This calling function gets the input from the user
weight_of_the_user,height_of_the_user = get_input_to_calcluate_bmi()
# This calling function calculates the BMI of the user
bmi_value = calculate_bmi(weight_of_the_user,height_of_the_user)
print("BMI of the user is :",bmi_value)
# This function is used to calculate the user's criteria
compare_user_bmi_with_player_csv(bmi_value)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/BMI-calculator/03_BMI_calculator.py
|
"""
We will use this script to learn Python to absolute beginners
The script is an example of BMI_Calculator implemented in Python
The BMI_Calculator:
# Get the weight(Kg) of the user
# Get the height(m) of the user
# Caculate the BMI using the formula
BMI=weight in kg/height in meters*height in meters
Exercise 3:
Write a program to calculate the BMI by accepting user input from the keyboard and check whether the user
comes in underweight ,normal weight or obesity. Create functions for calculating BMI and
check the user category.
i)Get user weight in kg
ii)Get user height in meter
iii) Use this formula to calculate the BMI
BMI = weight_of_the_user/(height_of_the_user * height_of_the_user)
iv)Use this level to check user category
#)Less than or equal to 18.5 is represents underweight
#)Between 18.5 -24.9 indicate normal weight
#)Between 25 -29.9 denotes over weight
#)Greater than 30 denotes obese
# Hint
i)Create a function to get the input
ii)Create one more function to calculate BMi
iii)Create one more function for checking user category
"""
def get_input_to_calcluate_bmi():
"This function gets the input from the user"
print("Enter the weight of the user in Kgs")
# Get the weight of the user through keyboard
weight_of_the_user = input()
# Get the height of the user through keyboard
print("Enter the height of the user in meters")
height_of_the_user = input()
return weight_of_the_user,height_of_the_user
def calculate_bmi(weight_of_the_user,height_of_the_user):
"This function calculates the BMI"
# Calculate the BMI of the user according to height and weight
bmi_of_the_user = weight_of_the_user/(height_of_the_user * height_of_the_user)
# Return the BMI of the user to the called function
return bmi_of_the_user
def check_user_bmi_category(bmi):
"This function checks if the user is underweight, normal, overweight or obese"
if bmi <= 18.5:
print("The user is considered as underweight")
elif bmi > 18.5 and bmi < 24.9:
print("The user is considered as normal weight")
elif bmi > 25 and bmi <= 29.9:
print("The user is considered as overweight")
elif bmi >=30:
print("The user is considered as obese")
# Program starts here
if __name__ == "__main__":
# This calling function gets the input from the user
weight_of_the_user,height_of_the_user = get_input_to_calcluate_bmi()
# This calling function stores the BMI of the user
bmi_value = calculate_bmi(weight_of_the_user,height_of_the_user)
print("BMI of the user is :",bmi_value)
# This function is used to calculate the user's criteria
check_user_bmi_category(bmi_value)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/BMI-calculator/06_BMI_Calculator.py
|
"""
We will use this script to learn Python to absolute beginners
The script is an example of BMI_Calculator implemented in Python
The BMI_Calculator:
# Get the weight(Kg) of the user
# Get the height(m) of the user
# Caculate the BMI using the formula
BMI=weight in kg/height in meters*height in meters
Exercise 5:
Write a program to calculate the BMI by accepting user input from the keyboard and check whether the user comes
in underweight ,normal weight or obesity by creating a class. Read the CSV files which contains player data
and compare your BMI with a player.Create functions for getting input from the user,calculating BMI and check
the user category.While getting input check the value you entered is of correct type if not
your program should not get crashed.
i)Get user weight in kg
ii)Get user height in meter
iii) Use this formula to calculate the BMI
BMI = weight_of_the_user/(height_of_the_user * height_of_the_user)
iv)Use this level to check user category
#)Less than or equal to 18.5 is represents underweight
#)Between 18.5 -24.9 indicate normal weight
#)Between 25 -29.9 denotes over weight
#)Greater than 30 denotes obese
# Hint
i)Create a function to get the input from the user
ii)Use exceptional handling to check user input's type
ii)Calculate the BMI
iii)Check the BMI with player BMI by reading the CSV file
"""
import os
import csv
def get_input_to_calcluate_bmi():
"This function gets the input from the user"
# Getting input will be repeated until the user enters the proper input
while True:
print("Enter the weight of the user in Kg's")
# Get the input from the user and check it's of correct type
try:
weight_of_the_user = float(raw_input())
# isintance will check the type of the input and returns true/false
if isinstance(weight_of_the_user,float):
break
# If user inputs wrong type then the except will run
except ValueError:
print("The value you have enteed is not a float value.Please enter the input in float value and in kilograms")
# Get the height of the user through keyboard
while True:
print("Enter the height of the user in Kg's")
try:
height_of_the_user = float(raw_input())
if isinstance(height_of_the_user,float):
break
except ValueError:
print("The value you have enteed is not a float value.Please enter the input in float value and in meters")
return weight_of_the_user,height_of_the_user
def calculate_bmi(weight_of_the_user,height_of_the_user):
"This function calculates the bmi"
# Calculate the BMI of the user according to height and weight
bmi_of_the_user = round(weight_of_the_user/(height_of_the_user * height_of_the_user),1)
# Return the BMI of the user to the called function
return bmi_of_the_user
def check_user_bmi_category(bmi):
"This function checks if the user is underweight, normal, overweight or obese"
if bmi <= 18.5:
print("The user is considered as underweight")
elif bmi > 18.5 and bmi < 24.9:
print("The user is considered as normal weight")
elif bmi > 25 and bmi <= 29.9:
print("The user is considered as overweight")
elif bmi >=30:
print("The user is considered as obese")
def compare_user_bmi_with_player_csv(bmi_of_the_user):
"This functions reads the csv file and compare the BMI value with players and returns the players name"
filename = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','data',"all_players_data.csv"))
matched_player = []
with open(filename,"r") as fp:
csv_file = csv.reader(fp)
next(csv_file)
for i, row in enumerate(csv_file):
bmi_value_in_row = row[3]
player_name = row[0]
if float(bmi_value_in_row) == bmi_of_the_user:
matched_player.append({player_name:bmi_value_in_row})
if not matched_player:
print("No matching data")
else:
print("Your BMI is matching with")
print matched_player
# Program starts here
if __name__ == "__main__":
# This calling function gets the input from the user
weight_of_the_user,height_of_the_user = get_input_to_calcluate_bmi()
# This calling function calculates the BMI of the user
bmi_value = calculate_bmi(weight_of_the_user,height_of_the_user)
print("BMI of the user is :",bmi_value)
# This function is used to calculate the user's criteria
check_user_bmi_category(bmi_value)
# This function is used to read the CSV file and compare the BMI value
compare_user_bmi_with_player_csv(bmi_value)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/BMI-calculator/02_BMI_calculator.py
|
"""
We will use this script to learn Python to absolute beginners
The script is an example of BMI_Calculator implemented in Python
The BMI_Calculator:
# Get the weight(Kg) of the user
# Get the height(m) of the user
# Caculate the BMI using the formula
BMI=weight in kg/height in meters*height in meters
Exercise 2:
Write a program to calculate the BMI by accepting user input from the keyboard and check whether the user
comes in underweight ,normal weight overweight or obesity.
i)Get user weight in kg
ii)Get user height in meter
iii) Use this formula to calculate the bmi
BMI = weight_of_the_user/(height_of_the_user * height_of_the_user)
iv)Use this level to check user category
#)Less than or equal to 18.5 is represents underweight
#)Between 18.5 -24.9 indicate normal weight
#)Between 25 -29.9 denotes over weight
#)Greater than 30 denotes obese
"""
print("Enter the weight of the user in Kg's")
# Get the weight of the user through keyboard
weight_of_the_user = input()
# Get the height of the user through keyboard
print("Enter the height of the user in meters")
height_of_the_user = input()
# Calculate the BMI of the user according to height and weight
bmi = weight_of_the_user/(height_of_the_user * height_of_the_user)
print("BMI of the user is :",bmi)
# Check the user comes under under weight, normal or obesity
if bmi <= 18.5:
print("The user is considered as underweight")
elif bmi > 18.5 and bmi < 24.9:
print("The user is considered as normal weight")
elif bmi > 25 and bmi <= 29.9:
print("The user is considered as overweight")
elif bmi >=30:
print("The user is considered as obese")
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/07_employee_salary_calculation.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of salary calculation implemented in Python
The take home salary will be calculated for each person who are all in the CSV file
We use CSV reader to read the CSV
The salary calculator:
Net_Income = Gross_Income - Taxable_Due
Taxable_Due = taxable_income + Social_security + Medicare_tax
Taxable_Income = Gross_Income -120,00
Social_security = 6.2% of Gross_Income
Medicare_Tax = 1.45 % of Gross_Income
Federal tax brackets
10% $0 to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% $500,001 or more
"""
import os,csv
def employee_federal_tax(employee_name,taxable_income):
"This method calculates the employee federal tax brackets"
tax_bracket = [9525,29175,43799,74999,42499,299999,500000]
tax_rate = [10,12,22,24,32,35,37]
sigma_of_federal_tax = 0
if taxable_income >= 500001:
for i in range(6):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-500001)*37)/100)
elif taxable_income > 200001 and taxable_income <= 500000:
for i in range(5):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-200001)*35)/100)
elif taxable_income > 157501 and taxable_income <= 200000:
for i in range(4):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-157501)*32)/100)
elif taxable_income > 82501 and taxable_income <= 157500:
for i in range(3):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-82501)*24)/100)
elif taxable_income > 38701 and taxable_income <= 82500:
for i in range(2):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-38701)*22)/100)
elif taxable_income >= 9525 and taxable_income <= 38700:
for i in range(1):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-9526)*12)/100)
elif taxable_income >0 and taxable_income < 9525:
federal_tax = ((taxable_income *10)/100)
else:
federal_tax =0
print("The employee no need to pay the federal tax")
print("%s federal tax is %s" %(employee_name,federal_tax))
return federal_tax
def employee_take_homes_salary(employee_name,employee_gross_income,federal_tax):
"This function calculates the employee take home salary"
# 6.2% of gross income is social security
social_security = ((float(employee_gross_income) *6.2)/100)
if social_security >= 7960.80:
social_security = 7960
print("The social security for %s is %s"%(employee_name,social_security))
# 1.45% of gross income is medicare tax
medicare_tax = float(employee_gross_income) *(1.45/100)
print("The medicare tax for %s is %s"%(employee_name,medicare_tax))
# Taxable due
taxable_due = federal_tax + social_security + medicare_tax
# Net income(Take home salary)
net_income = round(float(employee_gross_income) - taxable_due,2)
return net_income
def calculate_take_home_salary(csv_file):
"Calcualtes the take home salary"
taxable_deduction = 12000
for row in csv_file:
# Fetch the employee name from the file
employee_name = row[0]
# Fetch the employee gross income from the file
employee_gross_income = row[6]
# Taxable income
taxable_income = (float(employee_gross_income)) - taxable_deduction
# This is the calling function to calculate the federal tax
federal_tax = employee_federal_tax(employee_name,taxable_income)
# This is the calling function to calculate the employee take home salary
net_income = employee_take_homes_salary(employee_name,employee_gross_income,federal_tax)
print("The %s take home salary is %s"%(employee_name,net_income))
print("------------------------------------------------------------------")
def read_employee_salary_csv_file():
"This functions reads the CSV file"
# To read the CSV file we have to join the path where it's located
filename = os.path.abspath(os.path.join('..','training/data',"employee_payroll.csv"))
# To open the text file and assign to object fp
with open(filename,"r") as fp:
csv_file = csv.reader(fp)
calculate_take_home_salary(csv_file)
# Program starts here
if __name__ == "__main__":
read_employee_salary_csv_file()
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/01_employee_salary_calculation.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of salary calculation implemented in Python
The salary calculator:
Net_Income = Gross_Income - Taxable_Due
Taxable_Due = Federal_tax + Social_security + Medicare_tax
Taxable_Income = Gross_Income -120,00
Social_security = 6.2% of Gross_Income
Medicare_Tax = 1.45 % of Gross_Income
"""
# Enter the gross income
print("Enter the gross income")
# raw_input gets the input from the keyboard through user
gross_income = float(raw_input())
# Enter the federal tax
print("Enter the federal_tax")
# Getting the federal tax from the user
fedral_tax = float(raw_input())
# Taxable income will be reduced from gross income.This is the fixed dedutable income
taxable_deduction = 12000
# 6.2% of gross income is social security
social_security = gross_income *(6.2/100)
print("The employee social_security is",social_security)
# 1.45% of gross income is medicare tax
medicare_tax = gross_income *(1.45/100)
print("The employee medicare tax is",medicare_tax)
# Taxable due
taxable_due = fedral_tax + social_security + medicare_tax
# Net income
net_income = gross_income - taxable_due
print("The employee take home salary is",net_income)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/shopping_cart_module.py
|
class ShoppingCart:
"Add,update and remove the items from the shopping cart"
def __init__(self):
self.shopping_cart = {}
def add_item(self,item):
"Adding and updating the items into the cart"
if not self.shopping_cart.has_key(item.item_name):
self.shopping_cart.update({item.item_name:item.item_quantity})
else:
for key,value in self.shopping_cart.iteritems():
if key == item.item_name and value == item.item_quantity:
print ("The item and quantity you are trying to add are in the shopping cart already,no need to add it")
elif key == item.item_name and value != item.item_quantity:
self.shopping_cart.update({item.item_name:item.item_quantity})
print("The item has been updated with new quantity")
return self.shopping_cart
def remove_item(self,item):
"Removing an item from the list"
if not self.shopping_cart:
print("There is no shopping cart and you cant delete it")
for key,values in self.shopping_cart.iteritems():
if key ==item.item_name and values == item.item_quantity:
item_to_remove = key
self.shopping_cart.pop(item_to_remove)
return self.shopping_cart
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/06_shopping_cart.py
|
"""
Write a program to create a shopping cart in which you can add the items and quantity,
update the quantity and remove an item from the list.
"""
class Item():
"Get the items to be added into the shopping cart"
def __init__(self,item_name,item_quantity):
self.item_name = item_name
self.item_quantity = item_quantity
class ShoppingCart():
"Add,update and remove the items from the shopping cart"
def __init__(self):
self.shopping_cart = {}
def add_item(self,item):
"Adding and updating the items into the cart"
#if not self.shopping_cart.has_key(item.item_name): had to remove this line as has_key is no longer used in python 3.x
if not item.item_name in self.shopping_cart.keys():
self.shopping_cart.update({item.item_name:item.item_quantity})
else:
for key,value in self.shopping_cart.items(): #changed iteritems with items()
if key == item.item_name and value == item.item_quantity:
print ("The item and quantity you are trying to add are in the shopping cart already,no need to add it")
elif key == item.item_name and value != item.item_quantity:
self.shopping_cart.update({item.item_name:item.item_quantity})
print("The item has been updated with new quantity")
return self.shopping_cart
def remove_item(self,item):
"Removing an item from the list"
if not self.shopping_cart:
print("There is no shopping cart and you cant delete it")
for key,values in self.shopping_cart.items(): #changed iteritems with items()
if key ==item.item_name and values == item.item_quantity:
item_to_remove = key
self.shopping_cart.pop(item_to_remove)
return self.shopping_cart
# Program starts here
if __name__ == "__main__":
# item1 is an object of class Item
item1 = Item('Sugar',1)
item2 = Item('Salt',2)
item3 = Item('Banana',1)
# cartobject is an object of the shopping cart class
cartobject = ShoppingCart()
shopping_list = cartobject.add_item(item1)
print("Added the first item in the list",shopping_list)
shopping_list = cartobject.add_item(item2)
print("Added the second item in the list",shopping_list)
shopping_list = cartobject.add_item(item3)
print("Added the third item in the list",shopping_list)
item4 = Item('Banana',3)
shopping_list = cartobject.add_item(item4)
print("Added the fourth item in the list",shopping_list)
shopping_list = cartobject.remove_item(item2)
print("Removed an item from the list",shopping_list)
item5 = Item('Sugar',1)
shopping_list = cartobject.add_item(item5)
print("Added the fifth item in the list",shopping_list)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/02_employee_salary_calculation.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of salary calculation implemented in Python
The salary calculator:
Net_Income = Gross_Income - Taxable_Due
Taxable_Due = taxable_income + Social_security + Medicare_tax
Taxable_Income = Gross_Income -120,00
Social_security = 6.2% of Gross_Income
Medicare_Tax = 1.45 % of Gross_Income
Federal tax brackets
10% $0 to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% $500,001 or more
"""
# Enter the gross income
print("Enter the gross income")
gross_income = float(raw_input())
# Taxable income will be reduced from gross income
taxable_deduction = 12000
# Taxable income
taxable_income = gross_income-taxable_deduction
# This list contains the list of salary taxable brackets
tax_bracket = [9525,29175,43799,74999,42499,299999,500000]
# This list contains the percentage of tax for the taxable brackets
tax_rate = [10,12,22,24,32,35,37]
sigma_of_federal_tax = 0
# If else loop to check in which category the employee will come for the tax calculation
if taxable_income >= 500001:
for i in range(6):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-500001)*37)/100)
elif taxable_income > 200001 and taxable_income <= 500000:
for i in range(5):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-200001)*35)/100)
elif taxable_income > 157501 and taxable_income <= 200000:
for i in range(4):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-157501)*32)/100)
elif taxable_income > 82501 and taxable_income <= 157500:
for i in range(3):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-82501)*24)/100)
elif taxable_income > 38701 and taxable_income <= 82500:
for i in range(2):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-38701)*22)/100)
elif taxable_income >= 9525 and taxable_income <= 38700:
for i in range(1):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-9526)*12)/100)
elif taxable_income >0 and taxable_income < 9525:
federal_tax = ((taxable_income *10)/100)
else:
federal_tax =0
print("The employee no need to pay the federal tax")
print("The employee federal tax is " , federal_tax)
# 6.2% of gross income is social security
social_security = ((gross_income *6.2)/100)
if social_security >= 7960.80:
social_security = 7960
print("The employee social security is",social_security)
# 1.45% of gross income is medicare tax
medicare_tax = gross_income *(1.45/100)
print("The employee medicare tax is",medicare_tax)
# Taxable due
taxable_due = federal_tax + social_security + medicare_tax
# Net income
net_income = gross_income - taxable_due
print("The employee take home salary is : ", net_income)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/04_employee_salary_calculation.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of salary calculation implemented in Python
We read the CSV files and calcuate the take home salary of each employee
The salary calculator:
Net_Income = Gross_Income - Taxable_Due
Taxable_Due = taxable_income + Social_security + Medicare_tax
Taxable_Income = Gross_Income -120,00
Social_security = 6.2% of Gross_Income
Medicare_Tax = 1.45 % of Gross_Income
Federal tax brackets
10% $0 to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% $500,001 or more
"""
# Importing the OS module to make use in this program.
import os
def employee_federal_tax(employee_name,taxable_income):
"This method calculates the employee federal tax brackets"
tax_bracket = [9525,29175,43799,74999,42499,299999,500000]
tax_rate = [10,12,22,24,32,35,37]
sigma_of_federal_tax = 0
if taxable_income >= 500001:
for i in range(6):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-500001)*37)/100)
elif taxable_income > 200001 and taxable_income <= 500000:
for i in range(5):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-200001)*35)/100)
elif taxable_income > 157501 and taxable_income <= 200000:
for i in range(4):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-157501)*32)/100)
elif taxable_income > 82501 and taxable_income <= 157500:
for i in range(3):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-82501)*24)/100)
elif taxable_income > 38701 and taxable_income <= 82500:
for i in range(2):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-38701)*22)/100)
elif taxable_income >= 9525 and taxable_income <= 38700:
for i in range(1):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-9526)*12)/100)
elif taxable_income >0 and taxable_income < 9525:
federal_tax = ((taxable_income *10)/100)
else:
federal_tax =0
print("The employee no need to pay the federal tax")
print("%s federal tax is %s" %(employee_name,federal_tax))
return federal_tax
def employee_take_homes_salary(employee_name,employee_gross_income,federal_tax):
"This function calculates the employee take home salary"
# 6.2% of gross income is social security
social_security = ((float(employee_gross_income) *6.2)/100)
if social_security >= 7960.80:
social_security = 7960
print("The social security for %s is %s"%(employee_name,social_security))
# 1.45% of gross income is medicare tax
medicare_tax = float(employee_gross_income) *(1.45/100)
print 'The medicare tax for %s is %s'%(employee_name,medicare_tax)
# Taxable due
taxable_due = federal_tax + social_security + medicare_tax
# Net income(Take home salary)
net_income = round(float(employee_gross_income) - taxable_due,2)
return net_income
def calculate_take_home_salary(all_lines):
"Calls the federal tax,employee take home salary function"
taxable_deduction = 12000
for each_line in all_lines:
# Fetch the employee name from the file
employee_name = each_line.split(',')[0]
# Fetch the employee gross income from the file
employee_gross_income = each_line.split(',')[6]
# Taxable income
taxable_income = (float(employee_gross_income)) - taxable_deduction
# This is the calling function to calculate the federal tax
federal_tax = employee_federal_tax(employee_name,taxable_income)
# This is the calling function to calculate the employee take home salary
net_income = employee_take_homes_salary(employee_name,employee_gross_income,federal_tax)
print("The %s take home salary is %s"%(employee_name,net_income))
print("------------------------------------------------------------------")
def read_employee_salary_csv_file():
"This functions reads the CSV file"
# To read the CSV file we have to join the path where it's located
filename = os.path.abspath(os.path.join('..','training/data',"employee_payroll.csv"))
# To open the text file and assign to object fp
with open(filename,"r") as fp:
all_lines = fp.readlines()
# Calling the function to calculate the salray
calculate_take_home_salary(all_lines)
# Program starts here
if __name__ == "__main__":
# This is the calling function to read the CSV file
read_employee_salary_csv_file()
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/08_shopping_cart.py
|
"""
Write a program to create a shopping cart in which you can add the items and quantity,
update the quantity and remove an item from the list.
"""
from shopping_cart_module import ShoppingCart
class Item():
"Get the items to be added into the shopping cart"
def __init__(self,item_name,item_quantity):
self.item_name = item_name
self.item_quantity = item_quantity
# Program starts here
if __name__ == "__main__":
# item1 is an object of class Item
item1 = Item('Sugar',1)
item2 = Item('Salt',2)
item3 = Item('Banana',1)
# cartobject is an object of the shopping cart class
cartobject = ShoppingCart()
shopping_list = cartobject.add_item(item1)
print("Added the first item in the list",shopping_list)
shopping_list = cartobject.add_item(item2)
print("Added the second item in the list",shopping_list)
shopping_list = cartobject.add_item(item3)
print("Added the third item in the list",shopping_list)
item4 = Item('Banana',3)
shopping_list = cartobject.add_item(item4)
print("Added the fourth item in the list",shopping_list)
shopping_list = cartobject.remove_item(item2)
print("Removed an item from the list",shopping_list)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/05_employee_salary_calculation.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of salary calculation implemented in Python
Check if the user gives the wrong input and loop it until get the correct
input from the user
The salary calculator:
Net_Income = Gross_Income - Taxable_Due
Taxable_Due = taxable_income + Social_security + Medicare_tax
Taxable_Income = Gross_Income -120,00
Social_security = 6.2% of Gross_Income
Medicare_Tax = 1.45 % of Gross_Income
Federal tax brackets
10% $0 to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% $500,001 or more
"""
def employee_federal_tax(taxable_income):
"This method calculates the employee federal tax brackets"
tax_bracket = [9525,29175,43799,74999,42499,299999,500000]
tax_rate = [10,12,22,24,32,35,37]
sigma_of_federal_tax = 0
if taxable_income >= 500001:
for i in range(6):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-500001)*37)/100)
elif taxable_income > 200001 and taxable_income <= 500000:
for i in range(5):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-200001)*35)/100)
elif taxable_income > 157501 and taxable_income <= 200000:
for i in range(4):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-157501)*32)/100)
elif taxable_income > 82501 and taxable_income <= 157500:
for i in range(3):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-82501)*24)/100)
elif taxable_income > 38701 and taxable_income <= 82500:
for i in range(2):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-38701)*22)/100)
elif taxable_income > 9526 and taxable_income <= 38700:
for i in range(1):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-9526)*12)/100)
elif taxable_income >0 and taxable_income <= 9525:
federal_tax = ((taxable_income *10)/100)
else:
federal_tax =0
print("The employee no need to pay the federal tax")
print("The employee federal tax is " , federal_tax)
return federal_tax
def employee_take_home_salary(federal_tax):
"This function calculates the employee take home salary"
# 6.2% of gross income is social security
social_security = ((gross_income *6.2)/100)
if social_security >= 7960.80:
social_security = 7960
print("The social security for an employee is",social_security)
# 1.45% of gross income is medicare tax
medicare_tax = gross_income *(1.45/100)
print("The medicare tax for an employee is ",medicare_tax)
# Taxable due
taxable_due = federal_tax + social_security + medicare_tax
# Net income(Take home salary)
net_income = gross_income - taxable_due
print("The employee take home salary is : ", net_income)
# Program starts here
if __name__ == "__main__":
# Getting input will be repeated until the user enters the proper input
while True:
print("Enter the employee gross income")
# Get the input from the user and check it's of correct type
try:
gross_income = float(raw_input())
break
# If user inputs wrong type then the except will run
except ValueError:
print("The value you have entered is not a float value.Please enter the input in float value")
# Taxable income
taxable_deduction = 12000
taxable_income = gross_income-taxable_deduction
# This is the calling function to calculate the federal tax
federal_tax = employee_federal_tax(taxable_income)
# This is the calling function to calculaet the employee take home salary
employee_take_home_salary(federal_tax)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/employee-salary-calculation/03_employee_salary_calculation.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of salary calculation implemented in Python
The salary calculator:
Net_Income = Gross_Income - Taxable_Due
Taxable_Due = taxable_income + Social_security + Medicare_tax
Taxable_Income = Gross_Income -120,00
Social_security = 6.2% of Gross_Income
Medicare_Tax = 1.45 % of Gross_Income
Federal tax brackets
10% $0 to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% $500,001 or more
"""
def employee_federal_tax(taxable_income):
"This function calculates the employee federal tax brackets"
tax_bracket = [9525,29175,43799,74999,42499,299999,500000]
tax_rate = [10,12,22,24,32,35,37]
sigma_of_federal_tax = 0
if taxable_income >= 500001:
for i in range(6):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-500001)*37)/100)
elif taxable_income > 200001 and taxable_income <= 500000:
for i in range(5):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-200001)*35)/100)
elif taxable_income > 157501 and taxable_income <= 200000:
for i in range(4):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-157501)*32)/100)
elif taxable_income > 82501 and taxable_income <= 157500:
for i in range(3):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-82501)*24)/100)
elif taxable_income > 38701 and taxable_income <= 82500:
for i in range(2):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-38701)*22)/100)
elif taxable_income >= 9525 and taxable_income <= 38700:
for i in range(1):
federal_tax_bracket = ((tax_rate[i]*tax_bracket[i])/100)
sigma_of_federal_tax = federal_tax_bracket + sigma_of_federal_tax
federal_tax = sigma_of_federal_tax + (((taxable_income-9526)*12)/100)
elif taxable_income >0 and taxable_income < 9525:
federal_tax = ((taxable_income *10)/100)
else:
federal_tax =0
print("The employee no need to pay the federal tax")
print("The employee federal tax is ", federal_tax)
return federal_tax
def employee_take_home_salary(federal_tax):
"This function calculates the employee take home salary"
# 6.2% of gross income is social security
social_security = ((gross_income *6.2)/100)
if social_security >= 7960.80:
social_security = 7960
print("The social security for an employee is",social_security)
# 1.45% of gross income is medicare tax
medicare_tax = round(gross_income *(1.45/100),2)
print("The medicare tax for an employee is ",medicare_tax)
# Taxable due
taxable_due = federal_tax + social_security + medicare_tax
# Net income(Take home salary)
net_income = gross_income - taxable_due
return net_income
# Program starts here
if __name__ == "__main__":
# Enter the gross income
print("Enter the gross income")
gross_income = float(raw_input())
taxable_deduction = 12000
# Taxable income
taxable_income = gross_income-taxable_deduction
# This is the calling function to calculate the federal tax
federal_tax = employee_federal_tax(taxable_income)
# This is the calling function to calculaet the employee take home salary
take_home_salary = employee_take_home_salary(federal_tax)
print("The employee take home salary is : ", take_home_salary)
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/data/employee_payroll.csv
|
Gary Altenberg,"Lieutenant, Fire Suppression",128808.87,220909.48,13126.31,44430.12,362844.66,2012,,San Francisco,
Gregory Suhr,Chief of Police,302578,0,18974.11,69810.19,321552.11,2012,,San Francisco,
Khoa Trinh,Electronic Maintenance Tech,111921,146415.32,78057.41,53102.29,336393.73,2012,,San Francisco,
Joanne Hayes-White,"Chief, Fire Department",296943.01,0,17816.59,72047.88,314759.6,2012,,San Francisco,
Frederick Binkley,EMT/Paramedic/Firefighter,126863.19,192424.49,17917.18,44438.25,337204.86,2012,,San Francisco,
Amy Hart,Dept Head V,271607.74,0,19782.03,84681.82,291389.77,2012,,San Francisco,
Edward Reiskin,"Gen Mgr, Public Trnsp Dept",294000.17,0,0,82001.94,294000.17,2012,,San Francisco,
John Martin,Dept Head V,287747.89,0,5274.57,81824.37,293022.46,2012,,San Francisco,
John Goldberg,Captain 3,104404,0,245999.41,24287.23,350403.41,2012,,San Francisco,
David Franklin,Asst Chf of Dept (Fire Dept),204032.52,85503.16,26193.09,58486.1,315728.77,2012,,San Francisco,
Brendan Ward,"Battlion Chief, Fire Suppressi",174822.47,118215.58,28845.78,49648.09,321883.83,2012,,San Francisco,
Samson Lai,"Battlion Chief, Fire Suppressi",174822.44,112731.28,28660.28,53249.56,316214,2012,,San Francisco,
Rudy Castellanos,"Battlion Chief, Fire Suppressi",176771.74,124413.13,15803.39,52320.9,316988.26,2012,,San Francisco,
Marty Ross,"Battlion Chief, Fire Suppressi",174822.41,99623.51,36522.39,55353.92,310968.31,2012,,San Francisco,
Mark Kearney,Assistant Deputy Chief 2,124573.5,22599.6,180516.68,32381,327689.78,2012,,San Francisco,
Leda Rozier,Transit Manager 2,98211.01,0,200951.3,60285.44,299162.31,2012,,San Francisco,
Ellen Moffatt,Asst Med Examiner,260528.26,3394.9,20400,73017.12,284323.16,2012,,San Francisco,
Raymond Guzman,Dep Chf of Dept (Fire Dept),244102.02,24204.66,20232.29,64702.72,288538.97,2012,,San Francisco,
Edward Harrington,Executive Contract Employee,232815.01,0,51564.01,67667.09,284379.02,2012,,San Francisco,
Judy Melinek,Asst Med Examiner,260528.15,377.21,18425.37,72286.35,279330.73,2012,,San Francisco,
Michael Morris,Assistant Deputy Chief 2,223371,7415.52,63426.03,56202.98,294212.55,2012,,San Francisco,
Michael Rolovich,"Captain, Fire Suppression",145659.03,125868.06,30474.97,45129.03,302002.06,2012,,San Francisco,
James Dudley,Deputy Chief 3,263426.5,0,22857.87,59265.59,286284.37,2012,,San Francisco,
Mark Gonzales,Dep Chf of Dept (Fire Dept),252423.6,8357.25,15742.21,68783.23,276523.06,2012,,San Francisco,
Harlan Kelly-Jr,Executive Contract Employee,249362.77,0,13810.69,80999.77,263173.46,2012,,San Francisco,
Darryl Hunter,"Captain, Fire Suppression",145659.03,115673.73,32610,49571.51,293942.76,2012,,San Francisco,
Trent Rhorer,Dept Head V,253649.8,0,6486,80660.61,260135.8,2012,,San Francisco,
Michael Delane,"Captain, Fire Suppression",147069.71,113372.94,33012.58,45978.15,293455.23,2012,,San Francisco,
Barbara Garcia,Dept Head V,253435.69,0,6486,79477.91,259921.69,2012,,San Francisco,
Susan Currin,"Adm, SFGH Medical Center",254878.82,0,9486,75003.33,264364.82,2012,,San Francisco,
Philip Stevens,"Captain, Fire Suppression",124573.5,53895.92,130200.4,28907.03,308669.82,2012,,San Francisco,
Thomas Harvey,Assistant Deputy Chief 2,226475.05,0,54967.53,55722.16,281442.58,2012,,San Francisco,
Thomas Siragusa,Asst Chf of Dept (Fire Dept),208830.92,54545.03,20726.5,52943.62,284102.45,2012,,San Francisco,
Benjamin Rosenfield,Controller,252210.73,0,3486,80986.55,255696.73,2012,,San Francisco,
Croce Casciato,Captain 3,108175.03,0,203471.13,24941.13,311646.16,2012,,San Francisco,
Edwin Lee,Mayor,260574.05,0,0,74698.5,260574.05,2012,,San Francisco,
Stephen Tacchini,Captain 3,104404,0,204290.09,24688.54,308694.09,2012,,San Francisco,
David Shinn,Deputy Chief 3,263426.5,0,12320.8,57576.73,275747.3,2012,,San Francisco,
Kevin Cashman,Deputy Chief 3,253094.51,0,22206.4,56561.05,275300.91,2012,,San Francisco,
Joseph Driscoll,"Captain, Fire Suppression",145658.98,114513.29,28743.36,42919.16,288915.63,2012,,San Francisco,
Scott Scholzen,Firefighter,109783.86,160418.47,19873.8,41230.89,290076.13,2012,,San Francisco,
Ai Kyung Chung,Anesthetist,227221.89,5693.99,16887.9,78554.11,249803.78,2012,,San Francisco,
Pete Fay Jr,"Battlion Chief, Fire Suppressi",176515.48,74246.62,23772,53207.72,274534.1,2012,,San Francisco,
John Ehrlich,Captain 3,98747.52,1386.38,203735.92,23607.08,303869.82,2012,,San Francisco,
Venus Azar,Asst Med Examiner,243271.98,0,13708.15,68106.81,256980.13,2012,,San Francisco,
Denise Schmitt,Deputy Chief 3,263390.6,0,819.01,60298.97,264209.61,2012,,San Francisco,
Jay Huish,Dept Head V,243115.1,0,3486,77382.62,246601.1,2012,,San Francisco,
Gregory Stangland,EMT/Paramedic/Firefighter,128091.78,133645.42,16130.24,43913.33,277867.44,2012,,San Francisco,
Arthur Kenney,Asst Chf of Dept (Fire Dept),204032.52,29768.35,34685.53,53152.06,268486.4,2012,,San Francisco,
Kevin Taylor,"Battlion Chief, Fire Suppressi",176515.48,71643.89,23352.06,47455.23,271511.43,2012,,San Francisco,
Robert Postel,Asst Chf of Dept (Fire Dept),202075.56,48667.42,12813.53,55037.41,263556.51,2012,,San Francisco,
Yifang Qian,Senior Physician Specialist,184892.12,0,72743.26,60232.85,257635.38,2012,,San Francisco,
Sharon McCole-Wicher,Nursing Supervisor Psychiatric,202921.06,0,48236.76,66508.04,251157.82,2012,,San Francisco,
Kirk Richardson,"Battlion Chief, Fire Suppressi",174822.5,67875.53,21516.98,52568.73,264215.01,2012,,San Francisco,
Naomi Kelly,Dept Head V,240555.97,0,3486,71610.31,244041.97,2012,,San Francisco,
Kevin Burke,Asst Chf of Dept (Fire Dept),204032.52,23514.83,29831.6,58085.97,257378.95,2012,,San Francisco,
Lorrie Kalos,"Battlion Chief, Fire Suppressi",174822.48,63116.25,24255.85,52687.8,262194.58,2012,,San Francisco,
Robert Shaw,"Dep Dir for Investments, Ret",236735.52,0,4877.56,71427.77,241613.08,2012,,San Francisco,
Leanora Militello,"Manager VIII, MTA",204395.73,0,51225.59,57053.94,255621.32,2012,,San Francisco,
Monique Moyer,Port Director,236334.64,0,5234,70781.21,241568.64,2012,,San Francisco,
Mark Smith,Anesthetist,221084.95,3892.42,9874.61,75463.4,234851.98,2012,,San Francisco,
James Vannucchi,"Battlion Chief, Fire Suppressi",174822.43,53465.15,30760.78,49888.38,259048.36,2012,,San Francisco,
Alvin Lau,Firefighter,110847.13,139260.09,17844.19,40823.19,267951.41,2012,,San Francisco,
Bryan Rubenstein,"Battlion Chief, Fire Suppressi",174822.44,58091.97,23603.24,52059.82,256517.65,2012,,San Francisco,
Shelley Mitchell,Anesthetist,220727.4,1658.57,10610.61,75578.69,232996.58,2012,,San Francisco,
Sarah Cary,Anesthetist,217483.34,2617.14,13166.26,74687.57,233266.74,2012,,San Francisco,
Heinz Hofmann,Lieutenant 3,88317.99,11469.37,183112.41,23177.83,282899.77,2012,,San Francisco,
Michael Thompson,"Battlion Chief, Fire Suppressi",176515.52,54339.84,22064.5,52776.95,252919.86,2012,,San Francisco,
Arnold Choy,"Lieutenant, Fire Suppression",127573.43,120550.52,14195.17,42607.88,262319.12,2012,,San Francisco,
Kevin Smith,"Battlion Chief, Fire Suppressi",176515.52,45860.99,27969.77,53182.45,250346.28,2012,,San Francisco,
Wing Chan,Incident Support Specialist,120740.1,123729.82,16194.51,42331.26,260664.43,2012,,San Francisco,
Rex Hale,"Battlion Chief, Fire Suppressi",176515.49,49002.61,24503.36,52693.66,250021.46,2012,,San Francisco,
Mike Breiling,EMT/Paramedic/Firefighter,128091.78,114613.5,15375.99,43970.93,258081.27,2012,,San Francisco,
Christopher Happy,Asst Med Examiner,220372.95,325.8,17412.18,63852.13,238110.93,2012,,San Francisco,
Jose Velo,Assistant Deputy Chief 2,226475.02,0,16877.44,58449.76,243352.46,2012,,San Francisco,
Erika Hoo,"Captain, Fire Suppression",140183.68,82566.67,32936.23,45854.59,255686.58,2012,,San Francisco,
George Gascon,District Attorney,227238.02,0,0,73883.42,227238.02,2012,,San Francisco,
Paul Chignell,Captain 3,104404.02,0,172352.33,24078.34,276756.35,2012,,San Francisco,
Mivic Hirose,Manager VIII,219285.94,0,8486,72127.06,227771.94,2012,,San Francisco,
Martin Beltran,Firefighter,109783.87,130268.39,19688.1,39980.84,259740.36,2012,,San Francisco,
Robert Winslow,"Lieutenant, Fire Suppression",127573.44,108989.99,22025.46,40696.95,258588.89,2012,,San Francisco,
Tryg McCoy,Dep Dir V,219344.41,0,10595,68540.05,229939.41,2012,,San Francisco,
Jeffrey Myers,Emergency Medical Svcs Chief,226475,0,13588.5,57982.22,240063.5,2012,,San Francisco,
Douglas Spikes,EMT/Paramedic/Firefighter,128091.81,110423.84,16011.55,43394.92,254527.2,2012,,San Francisco,
Ana Sampera,Nursing Supervisor,195242,0,34867.77,67221.66,230109.77,2012,,San Francisco,
Schlene Peet,Nursing Supervisor,183307.55,0,46996.4,66455.63,230303.95,2012,,San Francisco,
Edward Chu,"Lieutenant, Fire Suppression",127933.79,110241.31,15563.02,42506.53,253738.12,2012,,San Francisco,
John Haley Jr,"Deputy Dir II, MTA",224511.96,0,3701,68030.78,228212.96,2012,,San Francisco,
Lyn Tomioka,Deputy Chief 3,234405.5,0,5884.63,55870.5,240290.13,2012,,San Francisco,
George Garcia,"Battlion Chief, Fire Suppressi",144510.79,76624.1,32650.42,42316.01,253785.31,2012,,San Francisco,
Ray Crawford,"Captain, Emergency Med Svcs",146599.41,84399.91,18675.54,46380.51,249674.86,2012,,San Francisco,
Michael Bryant,"Battlion Chief, Fire Suppressi",176515.5,41747.56,24263.24,52962.59,242526.3,2012,,San Francisco,
Leslie Dubbin,Nursing Supervisor,189376,0,42697.6,62778.08,232073.6,2012,,San Francisco,
Michael Carlin,Dep Dir V,219285.91,0,8486,67046.57,227771.91,2012,,San Francisco,
Matthew Lane,EMT/Paramedic/Firefighter,126863.19,113864.58,11716.55,42169.12,252444.32,2012,,San Francisco,
Shelia Hunter,"Lieutenant, Fire Suppression",128808.87,102878.98,18677.33,43899.1,250365.18,2012,,San Francisco,
George Fouras,Senior Physician Specialist,188422.07,0,41553.96,63481.32,229976.03,2012,,San Francisco,
Michael Biel,Deputy Chief 3,221828,0,19194.1,52217.79,241022.1,2012,,San Francisco,
Mark Osuna,Captain 3,193179.13,33730.44,15773.93,50390.97,242683.5,2012,,San Francisco,
Matthew McNaughton,Asst Chf of Dept (Fire Dept),204032.52,2601.47,28161.83,58242.74,234795.82,2012,,San Francisco,
Charles Crane,"Battlion Chief, Fire Suppressi",176515.51,51949.05,13581.09,50933.68,242045.65,2012,,San Francisco,
Julie Labonte,Manager VIII,206580.2,0,14416.62,71204.26,220996.82,2012,,San Francisco,
Nela Ponferrada,Nursing Supervisor,195242,0,34410.5,62028.51,229652.5,2012,,San Francisco,
John Rahaim,Dept Head IV,220164.24,0,3486,67677.51,223650.24,2012,,San Francisco,
Mark Johnson,"Battlion Chief, Fire Suppressi",174822.43,39792.6,22624.05,51764.36,237239.08,2012,,San Francisco,
Jeffrey Barden,"Captain, Fire Suppression",145659,77043.41,19712,46373.67,242414.41,2012,,San Francisco,
Marisa Moret,"Cfdntal Chf Atty 2,(Cvl&Crmnl)",214883.94,0,3008,70458.13,217891.94,2012,,San Francisco,
Siu-Kwan Chow,Senior Physician Specialist,175143.71,0,52140.69,60705.43,227284.4,2012,,San Francisco,
James Fazackerley,"Captain, Emergency Med Svcs",145659.02,76318.3,18207.39,46710.43,240184.71,2012,,San Francisco,
Grad Green,Nursing Supervisor Psychiatric,191666,0,32745.08,62345.57,224411.08,2012,,San Francisco,
Daniel Cox,Anesthetist,209065.51,419.34,6427.9,70613.41,215912.75,2012,,San Francisco,
Dwight Newton,Firefighter,109783.84,114847.47,20767.88,41047.25,245399.19,2012,,San Francisco,
Guy Goodwin,EMT/Paramedic/Firefighter,126863.18,108598.97,8835.86,42099.94,244298.01,2012,,San Francisco,
Ricky Hui,Firefighter,109783.86,118346.08,18239.08,39865.82,246369.02,2012,,San Francisco,
Khairul Ali,"Battlion Chief, Fire Suppressi",174822.44,34670.87,23604.24,52250.59,233097.55,2012,,San Francisco,
Luis Herrera,Dept Head IV,211329.22,0,7057.82,66841,218387.04,2012,,San Francisco,
Patrick D'Arcy,"Captain, Fire Suppression",140873.68,80789.33,17493.99,45922.78,239157,2012,,San Francisco,
Kirsten Barash,Anesthetist,204792.11,3468.02,6406.59,69941.09,214666.72,2012,,San Francisco,
Therese Stewart,"Cfdntal Chf Atty 2,(Cvl&Crmnl)",214883.94,0,3008,66624,217891.94,2012,,San Francisco,
Samuel Romero,"Battlion Chief, Fire Suppressi",164827.51,49402,19884.49,49732.7,234114,2012,,San Francisco,
Theresa Dentoni,Nursing Supervisor,189376,0,32563.52,61793.33,221939.52,2012,,San Francisco,
Richard Corriea,Commander 3,214088.02,0,18767.6,50674.88,232855.62,2012,,San Francisco,
Jesse Smith,"Cfdntal Chf Atty 2,(Cvl&Crmnl)",214883.95,0,3008,65439.18,217891.95,2012,,San Francisco,
Kyle Merkins,"Lieutenant, Fire Suppression",200404,15164.29,14232.94,52934.32,229801.23,2012,,San Francisco,
John Brown,Manager VIII,212002.39,0,3486,67158.85,215488.39,2012,,San Francisco,
Carl Jepsen,Firefighter,110847.12,112211.85,19014.3,40113.67,242073.27,2012,,San Francisco,
Michael Gonzales,"Lieutenant, Fire Suppression",127573.4,97474.3,14566.44,42378.82,239614.14,2012,,San Francisco,
Dennis Herrera,City Attorney,216129.87,0,0,65379.38,216129.87,2012,,San Francisco,
Todd Plunkett,Firefighter,110847.12,110253.41,19124.51,40910,240225.04,2012,,San Francisco,
Sonali Bose,"Deputy Dir II, MTA",208267.82,0,3486,69303.38,211753.82,2012,,San Francisco,
Floyd Rollins,"Lieutenant, Fire Suppression",127573.41,90736.2,18610.95,44060.09,236920.56,2012,,San Francisco,
Vincent Repetto,Inspector 3,135977.73,65229.56,41854.76,37837.59,243062.05,2012,,San Francisco,
Amparo Rodriguez,Nurse Manager,168421.8,4850.69,45728.2,61767.66,219000.69,2012,,San Francisco,
Mitchell Lee,Firefighter,109783.86,112415.38,18804.63,39701.4,241003.87,2012,,San Francisco,
Morgan Petiti,Firefighter,110847.13,111834.58,17778.34,40142.94,240460.05,2012,,San Francisco,
William Rader,EMT/Paramedic/Firefighter,126863.18,94661.81,16300.24,42777.4,237825.23,2012,,San Francisco,
Kenneth Smith,"Lieutenant, Fire Suppression",127573.38,93296,16695.1,43007.62,237564.48,2012,,San Francisco,
Hagop Hajian,Senior Physician Specialist,182190.73,0,36617.15,61712.7,218807.88,2012,,San Francisco,
Donna Lee,Anesthetist,201934.95,1309.53,7576.49,69571.16,210820.97,2012,,San Francisco,
Roland Pickens,Manager VIII,207565,0,3486,69191.94,211051,2012,,San Francisco,
Anne Kronenberg,Dept Head IV,207565,0,3486,69103.17,211051,2012,,San Francisco,
Andrew Saitz,"Lieutenant, Fire Suppression",128808.87,90819.83,17292.95,43141.75,236921.65,2012,,San Francisco,
Margaret Callahan,Human Resources Director,203782.02,0,6498.01,69717.9,210280.03,2012,,San Francisco,
Johnson You,Firefighter,110847.12,109506.2,18855.83,40725.54,239209.15,2012,,San Francisco,
Alec Balmy,"Lieut,Fire Prev",165093.42,54390.01,14857.16,45566.53,234340.59,2012,,San Francisco,
Susan Buchbinder,Manager VIII,211721.94,0,3486,64638.29,215207.94,2012,,San Francisco,
Alexander Chen,Senior Physician Specialist,180380.18,0,37635.99,61769.43,218016.17,2012,,San Francisco,
Cantrez Triplitt,"Lieutenant, Fire Suppression",128808.89,90571.12,16101.16,43618.36,235481.17,2012,,San Francisco,
Gerald Mansur,EMT/Paramedic/Firefighter,126863.21,93158.31,15894.8,43135.08,235916.32,2012,,San Francisco,
Patricia Carr,Nursing Supervisor,189376,0,26679.6,62852.14,216055.6,2012,,San Francisco,
Patricia Coggan,Nurse Manager,161730,0,57208.55,59835.54,218938.55,2012,,San Francisco,
Philip Ginsburg,Dept Head IV,204806.46,0,4604.13,69310.6,209410.59,2012,,San Francisco,
Colleen Riley,Manager VIII,205579.94,0,3486,68788.27,209065.94,2012,,San Francisco,
Ernest Johnson,Firefighter,103226.6,133355.19,16317.63,24733.11,252899.42,2012,,San Francisco,
Michael Castagnola,"Captain, Fire Suppression",147069.67,56411.49,28918.78,45088.19,232399.94,2012,,San Francisco,
Eric Neff,Police Officer 3,109118.22,27043.59,109131.14,32140.44,245292.95,2012,,San Francisco,
Mercedes German,Nursing Supervisor,195242.05,0,19524.19,62368.16,214766.24,2012,,San Francisco,
Gregory Cacharelis,Firefighter,109783.87,108781.84,18752.89,39811.82,237318.6,2012,,San Francisco,
Timothy Gibson,Police Officer 3,95449.67,5481.28,148736.75,27377.58,249667.7,2012,,San Francisco,
Irene Sung,Supervising Physician Spec,186584.52,0,27988.07,62362.41,214572.59,2012,,San Francisco,
Mark Castagnola,"Lieutenant, Fire Suppression",128576.16,86249.98,21203.48,40600.22,236029.62,2012,,San Francisco,
Edward Roland,"Captain, Fire Suppression",141894.01,53486.93,33291.26,47898.3,228672.2,2012,,San Francisco,
Dwayne Curry,"Lieutenant, Fire Suppression",128808.89,88418.36,15718.72,43509.1,232945.97,2012,,San Francisco,
Madonna Valencia,Nursing Supervisor,178156,0,37966.87,60170.75,216122.87,2012,,San Francisco,
Kathryn Ballou,Nursing Supervisor Psychiatric,183666,0,32155.19,60217.3,215821.19,2012,,San Francisco,
Luis Ibarra-Rivera,"Lieutenant, Fire Suppression",128808.88,85351.58,17971.12,43703.89,232131.58,2012,,San Francisco,
Chris Vein,Special Assistant 22,203704.37,0,3486,68285.81,207190.37,2012,,San Francisco,
Regina Gomez,Nursing Supervisor,183666.01,0,31103.69,60653.58,214769.7,2012,,San Francisco,
Jonathan Baxter,EMT/Paramedic/Firefighter,126863.19,92637.89,12747.96,43064.26,232249.04,2012,,San Francisco,
Kevin Jones,Inspector 3,135973.02,50426.43,51111.55,37782.66,237511,2012,,San Francisco,
Patricia O'Connor,Nursing Supervisor,182846,0,32087.49,60352.55,214933.49,2012,,San Francisco,
Margaret Rykowski,Nursing Supervisor Psychiatric,193131.6,0,19313.16,62800.5,212444.76,2012,,San Francisco,
Jennifer Matz,Dept Head III,202939.28,0,3486,68122.9,206425.28,2012,,San Francisco,
Michael Browne,Sergeant 3,135977.71,56320.58,41687.47,39551.22,233985.76,2012,,San Francisco,
Alan Reynaud,"Lieutenant, Fire Suppression",127573.37,83318.15,18701.49,43782.35,229593.01,2012,,San Francisco,
Mohammed Nuru,Dept Head IV,204674.49,0,4730.5,63648.24,209404.99,2012,,San Francisco,
Elizabeth Johnson,Manager VIII,208037.63,0,1716,63240.77,209753.63,2012,,San Francisco,
Alexander Boal,Anesthetist,214350.93,1867.2,7431.42,49184.21,223649.55,2012,,San Francisco,
Janet Hines,Nurse Manager,177158,0,36294.49,59271.3,213452.49,2012,,San Francisco,
Manuel Alvarenga,Firefighter,109783.85,100642.03,22361.25,39796.43,232787.13,2012,,San Francisco,
William Braconi,Sergeant 3,135973,71748.62,25766.49,39033.5,233488.11,2012,,San Francisco,
Nikolas Lemos,Forensic Toxicologist,187207.03,0,27281.9,58001.65,214488.93,2012,,San Francisco,
David Zwyer,EMT/Paramedic/Firefighter,124175.64,90560.04,15522.02,42081.66,230257.7,2012,,San Francisco,
Bonnie Taylor,Senior Physician Specialist,182580.85,0,27387.66,61865.98,209968.51,2012,,San Francisco,
Mikail Ali,Commander 3,214088.04,0,5884.73,51847.12,219972.77,2012,,San Francisco,
Sebastian Wong,"Captain, Emergency Med Svcs",145659.05,64739.17,18207.38,42989,228605.6,2012,,San Francisco,
Burk Delventhal,Chief Atty1 (Civil & Criminal),206752,0,312.5,64406.22,207064.5,2012,,San Francisco,
John Cremen,"Battlion Chief, Fire Suppressi",176515.48,34152.34,10590.92,50014.45,221258.74,2012,,San Francisco,
Evette Geer-Stevens,Transit Supervisor,88400.7,137462.8,4212,41172.48,230075.5,2012,,San Francisco,
Jeffrey Adachi,Public Defender,207643.84,0,0,62778.68,207643.84,2012,,San Francisco,
Constantine Zachos,Police Officer 3,102265.48,8524.03,112000.3,47492.33,222789.81,2012,,San Francisco,
Matthew Hutchinson,"Lieutenant, Fire Suppression",128808.86,82119.08,15186.76,43626.12,226114.7,2012,,San Francisco,
Zachary Pumphrey,"Battlion Chief, Fire Suppressi",176515.52,19046.43,22064.45,52027.11,217626.4,2012,,San Francisco,
Pablo Siguenza,"Captain, Fire Suppression",147069.74,56291.36,19463.72,46740.41,222824.82,2012,,San Francisco,
Ken Yee,"Captain, Fire Suppression",145659.03,58745.2,19015.94,46135.59,223420.17,2012,,San Francisco,
Aisha Krieger,"Lieutenant, Fire Suppression",128808.9,80376.57,16790.17,43538.94,225975.64,2012,,San Francisco,
Paul Shimazaki,EMT/Paramedic/Firefighter,126863.16,88819.1,11139.51,42266.51,226821.77,2012,,San Francisco,
Anthony Dumont,"Captain, Emergency Med Svcs",145492.37,54613.27,26411.3,42330.95,226516.94,2012,,San Francisco,
Thomas Busby,Firefighter,109783.88,100597.63,18374.43,40090.86,228755.94,2012,,San Francisco,
Helen Szeto,Anesthetist,186715.41,3226.65,12045.99,66802.51,201988.05,2012,,San Francisco,
Mary Hansell,Nursing Supervisor,188528,0,18852.8,61360.25,207380.8,2012,,San Francisco,
Todd Rydstrom,Dep Dir V,189434.26,0,11024.51,68069.81,200458.77,2012,,San Francisco,
Karen Kubick,Manager VIII,190550.98,0,10650.11,67271.66,201201.09,2012,,San Francisco,
Tomas Aragon,Supervising Physician Spec,206988.44,0,0,61469.29,206988.44,2012,,San Francisco,
Edmund Dea,"Battlion Chief, Fire Suppressi",175614.01,35195.17,13593.3,44030.27,224402.48,2012,,San Francisco,
Nelson Aceto,Wire Rope Cable Maint Sprv,88634.01,86853.43,49346.03,43504.79,224833.47,2012,,San Francisco,
Harold Byrd,Transit Supervisor,88062,129414.28,9038.21,41733.06,226514.49,2012,,San Francisco,
John Hickey,"Battlion Chief, Fire Suppressi",174822.44,15999.99,25825.73,51578.26,216648.16,2012,,San Francisco,
Gregory McFarland,Firefighter,108978.94,101537.25,17839.97,39394.09,228356.16,2012,,San Francisco,
Joseph Viglizzo,Firefighter,109783.87,100967.38,17304.94,39593.41,228056.19,2012,,San Francisco,
Robert Moser,Captain 3,193179.08,20277.37,5721.33,48317.22,219177.78,2012,,San Francisco,
Ivar Satero,Dep Dir V,200798.52,0,3486,63187.81,204284.52,2012,,San Francisco,
Edward Labrado,Firefighter,120740.11,84165.89,20421.23,41937.16,225327.23,2012,,San Francisco,
Roselyn Jequinto,Nurse Manager,171133.43,8277.3,27448.83,60379.04,206859.56,2012,,San Francisco,
Jack Chow,Firefighter,109783.85,99175.19,18553.47,39647.12,227512.51,2012,,San Francisco,
Kevin Kuhn,Firefighter,110847.09,97173.04,18123.48,40847.29,226143.61,2012,,San Francisco,
Cristina Reyes,Nurse Manager,177158.07,0,30243.79,59508.16,207401.86,2012,,San Francisco,
Douglas Riba,Incident Support Specialist,119582,88182.07,19731.03,39066.1,227495.1,2012,,San Francisco,
Brian Murphy,Firefighter,110847.11,86051.23,27479.26,42171.33,224377.6,2012,,San Francisco,
Tyrone Pruitt,"Lieut,Fire Prev",165133.21,4015.29,51158.33,46240.93,220306.83,2012,,San Francisco,
Ruben Caballero,Nurse Practitioner,176415.2,26019.69,1174.3,62854.74,203609.19,2012,,San Francisco,
Bond Yee,"Deputy Dir II, MTA",200099.6,0,4132,62078.15,204231.6,2012,,San Francisco,
Jason Cherniss,Captain 3,193179.15,20239.71,4510.77,48337.04,217929.63,2012,,San Francisco,
Daniel Yonts,"Lieutenant, Fire Suppression",127573.38,73422.09,21329.26,43826.64,222324.73,2012,,San Francisco,
Catherine Dodd,Dept Head III,184877.89,0,13482.32,67439.76,198360.21,2012,,San Francisco,
Tyronne Julian,Transit Supervisor,93320.1,118250.68,11532.66,42675.58,223103.44,2012,,San Francisco,
John Cavanaugh,"Captain, Emergency Med Svcs",147069.69,52922.31,19132.08,46484.73,219124.08,2012,,San Francisco,
Nicol Juratovac,"Captain, Fire Suppression",147069.68,61857.99,11448.85,45038.64,220376.52,2012,,San Francisco,
Charles Hardiman,EMT/Paramedic/Firefighter,126863.16,79924.84,15857.94,42621.53,222645.94,2012,,San Francisco,
Richard Zercher,Supervising Physician Spec,204434.9,0,73.5,60723.84,204508.4,2012,,San Francisco,
Edmund Vail,"Lieutenant, Fire Suppression",127573.39,81788.41,13414.09,42438.7,222775.89,2012,,San Francisco,
Derek Wing,Firefighter,110847.09,95458.63,18566.11,40211.47,224871.83,2012,,San Francisco,
Twyila Lay,Nurse Practitioner,167944.05,16407.04,16200.8,64378.32,200551.89,2012,,San Francisco,
John Murphy,Commander 3,199213.01,0,17485.08,48089.3,216698.09,2012,,San Francisco,
Cristine DeBerry,Manager VIII,187883.99,0,10062.31,66833.19,197946.3,2012,,San Francisco,
James Draper,"Lieutenant, Fire Suppression",128808.87,71284,20901.07,43756.83,220993.94,2012,,San Francisco,
Michael Coleman,Firefighter,110847.12,94582.05,19279.13,40019.81,224708.3,2012,,San Francisco,
Monique Zmuda,Dep Dir V,198900.48,0,3486,62320.02,202386.48,2012,,San Francisco,
Donald Goggin,"Lieutenant, Fire Suppression",127573.38,76530.73,16840.12,43594.13,220944.23,2012,,San Francisco,
Jay Kloo,Nurse Manager,166624,0,38088.17,59709.64,204712.17,2012,,San Francisco,
Kenneth Cordero,"Captain, Fire Suppression",145659.02,54421.93,18207.37,46111.4,218288.32,2012,,San Francisco,
Glenn Kircher,"Captain, Fire Suppression",145659.02,57470.75,15656.25,45514.63,218786.02,2012,,San Francisco,
Pauline Marx,Dep Dir IV,198700.36,0,3486,61930.47,202186.36,2012,,San Francisco,
Sofia Mathews,"Insp, Fire Dept",155894.8,55251.55,9353.71,43534.11,220500.06,2012,,San Francisco,
Gregory Wagner,Manager VIII,192722.41,0,1500,69783.29,194222.41,2012,,San Francisco,
Amen Chow,Pharmacist,137402.72,57119.08,17506.24,51959.79,212028.04,2012,,San Francisco,
Denis O'Leary,Captain 3,196265.03,2803.85,17383.17,47454.47,216452.05,2012,,San Francisco,
Deborah Jeter,Dep Dir IV,195905.3,0,3486,63963.8,199391.3,2012,,San Francisco,
Valerie Inouye,Manager VIII,192885.07,0,3486,66888.05,196371.07,2012,,San Francisco,
Ted Yamasaki,Dep Dir IV,194031.08,0,5024.47,64086.5,199055.55,2012,,San Francisco,
Brandon Tom,EMT/Paramedic/Firefighter,126863.22,77626.2,15875.86,42693.54,220365.28,2012,,San Francisco,
Timothy Sullivan,Firefighter,109783.86,94938.18,18608.12,39712.88,223330.16,2012,,San Francisco,
William Siffermann,"Chf Prob Ofc, Juv Court",195196.7,0,4030.07,63752.79,199226.77,2012,,San Francisco,
William McFarland,Supervising Physician Spec,202376.3,0,245,60356.19,202621.3,2012,,San Francisco,
Sean Bonetti,"Lieutenant, Fire Suppression",127573.4,75650.23,15946.74,43804.43,219170.37,2012,,San Francisco,
Berglioth Mathews,"Lieutenant, Fire Suppression",128808.87,84177.9,8054.47,41859.09,221041.24,2012,,San Francisco,
John Loftus,Commander 3,205022.02,0,9632.76,48228.18,214654.78,2012,,San Francisco,
Thomas Watts,Sergeant 3,135977.69,73292.13,14465.15,39002.56,223734.97,2012,,San Francisco,
Lisa Hoffmann,Dep Dir IV,194473.61,0,3486,64589.92,197959.61,2012,,San Francisco,
Lisa Golden,Supervising Physician Spec,198834.31,0,3222,60487.41,202056.31,2012,,San Francisco,
Joanne Hoeper,Chief Atty1 (Civil & Criminal),201384.4,0,312.5,60796.93,201696.9,2012,,San Francisco,
Wendy Still,Chief Adult Probation Officer,192454.46,0,5185.04,64849.52,197639.5,2012,,San Francisco,
Eric Stiveson,Firefighter,109783.87,95499.07,17433.54,39688.71,222716.48,2012,,San Francisco,
Stephen Maguire,Firefighter,110969.48,83564.33,26111.25,41334.67,220645.06,2012,,San Francisco,
Rajiv Bhatia,Supervising Physician Spec,201618.91,0,245,60073.64,201863.91,2012,,San Francisco,
Kathleen Maxwell,Nurse Manager,177158.44,2173.38,24552.09,58019.21,203883.91,2012,,San Francisco,
Catherine James,Supervising Physician Spec,197324.51,0,5089.88,59409.1,202414.39,2012,,San Francisco,
Jon Walton,Dep Dir IV,195972.96,0,3486,62018.15,199458.96,2012,,San Francisco,
Gregory Stewart,"Captain, Fire Suppression",147109.63,45808.95,21860.21,46660.59,214778.79,2012,,San Francisco,
Ghodsi Davary,Nursing Supervisor,192009.5,0,11346.93,58038.23,203356.43,2012,,San Francisco,
Garret Tom,Captain 3,196265.05,2872.5,14473.15,47741.2,213610.7,2012,,San Francisco,
Stephen Wu,Senior Physician Specialist,167934.03,0,34692.66,58637.18,202626.69,2012,,San Francisco,
Louis Cassanego,Captain 3,196265.03,0,17308.26,47646.07,213573.29,2012,,San Francisco,
Andre Williams,Firefighter,109783.86,91905.09,18944.86,40292.42,220633.81,2012,,San Francisco,
Alan Harvey,Firefighter,110847.11,90513.91,21717.24,37711.96,223078.26,2012,,San Francisco,
Albert Yu,Supervising Physician Spec,194386.84,0,7500,58828.08,201886.84,2012,,San Francisco,
Kurt Bruneman,Lieutenant 3,155319.5,0,57270.89,47744.1,212590.39,2012,,San Francisco,
Dominic Celaya,Captain 3,196250.3,3049.64,14461.36,46538.93,213761.3,2012,,San Francisco,
Josephine Rapadas,Nurse Manager,177816.66,7878.24,16162.32,58406.18,201857.22,2012,,San Francisco,
Christiane Hayashi,"Deputy Dir I, MTA",190545.43,0,3486,66198.54,194031.43,2012,,San Francisco,
David Pfeifer,Assistant Chief Attorney 2,199434.43,0,312.5,60459.05,199746.93,2012,,San Francisco,
Theresa Lee,Dep Dir V,189434.29,0,3486,67230.58,192920.29,2012,,San Francisco,
Flavia Bayati,Nurse Manager,171804.01,0,30125.19,58082.23,201929.2,2012,,San Francisco,
Michael Daly,Nurse Manager,171804.03,0,30098.59,58102.79,201902.62,2012,,San Francisco,
Robert Maerz,Assistant Chief Attorney 2,199434.45,0,312.5,60208.64,199746.95,2012,,San Francisco,
Glenn Mar,Lieutenant 3,155308.47,39819.1,24855.52,39782.46,219983.09,2012,,San Francisco,
Pierre Francois,"Captain, Fire Suppression",146443.11,46233.19,20353.56,46710.47,213029.86,2012,,San Francisco,
Sharon Woo,Assistant Chief Attorney 2,199434.47,0,312.5,59947.54,199746.97,2012,,San Francisco,
Sharon Ferrigno,Captain 3,196265.02,7450.56,9458.02,46266.69,213173.6,2012,,San Francisco,
Gordon Hoy,Manager VIII,189992.66,0,3486,65770.61,193478.66,2012,,San Francisco,
Marcellina Ogbu,Dep Dir V,189274.51,0,3486,66307.34,192760.51,2012,,San Francisco,
Allen Turpin,Senior Physician Specialist,187254.97,0,11430.71,60309.52,198685.68,2012,,San Francisco,
Mary Tse,"Insp, Fire Dept",144659.55,63761.59,8679.55,41881.77,217100.69,2012,,San Francisco,
Lawrence Nicholls,Nurse Manager,171804,0,30682.01,56484.4,202486.01,2012,,San Francisco,
James Calonico,Lieutenant 3,160158.35,33910.73,22607.03,42212.62,216676.11,2012,,San Francisco,
Kenneth Cofflin,"Lieut,Fire Prev",153393.05,50270.21,11583.52,43641.66,215246.78,2012,,San Francisco,
Kenneth Lombardi,"Captain, Fire Suppression",193507,0,14548.31,50679.14,208055.31,2012,,San Francisco,
John Garrity,Captain 3,196265.05,1149,14106.52,47209.78,211520.57,2012,,San Francisco,
David Briggs,Manager VIII,189028.7,0,3486,66150.22,192514.7,2012,,San Francisco,
Ellen Levin,Manager VIII,189434.23,0,3486,65707.54,192920.23,2012,,San Francisco,
Karen Roye,Dept Head III,192871.93,0,3486,62248.44,196357.93,2012,,San Francisco,
Martin Lalor Jr,Sergeant 3,139706.99,60754.25,17860.94,40108.53,218322.18,2012,,San Francisco,
Heralio Serrano,Supervising Physician Spec,192854.82,0,5899,59590.14,198753.82,2012,,San Francisco,
Mark Solomon,Manager I,89249.38,10319.57,135998.38,22704.94,235567.33,2012,,San Francisco,
Philip Pera,Sergeant 3,135977.69,75954.15,7139.45,39168.48,219071.29,2012,,San Francisco,
Robert Lopez,"Lieutenant, Fire Suppression",127427.41,64905,23424.26,42146.14,215756.67,2012,,San Francisco,
Steven Ritchie,Dep Dir V,189769.28,0,6650.11,61407.74,196419.39,2012,,San Francisco,
Ann Mannix,Captain 3,196241.4,2937.31,9457.51,49068.62,208636.22,2012,,San Francisco,
Thomas Cleary,Captain 3,193179.08,9191.58,8348.7,46944.59,210719.36,2012,,San Francisco,
Eric Vintero,Captain 3,192172.79,7156.03,10013.92,48320.06,209342.74,2012,,San Francisco,
Thomas Newland,Inspector 3,135981.25,51618.77,31554.19,38406.69,219154.21,2012,,San Francisco,
Robert Armanino,Lieutenant 3,155320,10607.7,46603.15,44973.94,212530.85,2012,,San Francisco,
John Barker,Senior Physician Specialist,165424.43,0,35155.14,56860.14,200579.57,2012,,San Francisco,
Charlie Orkes,Commander 3,204740.5,0,1826.4,50728.89,206566.9,2012,,San Francisco,
David Thompson,"Lieutenant, Fire Suppression",128808.84,68286.7,16101.14,43964.33,213196.68,2012,,San Francisco,
Kjell Harshman,EMT/Paramedic/Firefighter,126863.21,71726.35,15857.94,42693.09,214447.5,2012,,San Francisco,
Fuad Sweiss,Dep Dir IV,192643.13,0,3486,61007.78,196129.13,2012,,San Francisco,
Victor Wyrsch,"Battlion Chief, Fire Suppressi",175612.61,11535.8,19990.84,49966.19,207139.25,2012,,San Francisco,
William Roualdes,Lieutenant 3,155319.5,23950.22,33452.02,44183.96,212721.74,2012,,San Francisco,
David Kucia,Police Officer 3,99304.33,18181.32,111506.56,27819.75,228992.21,2012,,San Francisco,
Kathryn Fowler,Nurse Manager,161729.72,0,36949.85,58125.23,198679.57,2012,,San Francisco,
Daniel Cunningham,Inspector 3,135981.23,56920.74,24965.16,38935.96,217867.13,2012,,San Francisco,
Arthur Borges,Lieutenant 3,86353.19,3703.98,144700.72,22039.24,234757.89,2012,,San Francisco,
Toney Chaplin,Inspector 3,135977.66,57472.87,24189.65,39067.94,217640.18,2012,,San Francisco,
Terrence Yuen,Court Executive Officer,185054.8,0,0,71603.13,185054.8,2012,,San Francisco,
Ross Mirkarimi,Sheriff (SFERS),82571.03,0,124080.66,49984.61,206651.69,2012,,San Francisco,
Tuamelie Moala,Dep Dir V,189434.27,0,5697.5,61420.79,195131.77,2012,,San Francisco,
Gregory Corrales,Captain 3,196265.04,0,12594.54,47645.97,208859.58,2012,,San Francisco,
Glen Kojimoto,"Captain, Fire Suppression",147069.67,49544.14,14186.65,45617.5,210800.46,2012,,San Francisco,
Debbie Tam,Nursing Supervisor,195488.32,0,1426.86,59355.19,196915.18,2012,,San Francisco,
Leonardo Fermin Jr,Dep Dir V,189434.29,0,3486,63343.39,192920.29,2012,,San Francisco,
David Martinovich,Inspector 3,135977,43249.38,38782.02,38136.29,218008.4,2012,,San Francisco,
Steven Williams,"Lieutenant, Fire Suppression",124496.5,78045.38,12540.44,40904.01,215082.32,2012,,San Francisco,
Stuart Beach,"Captain, Emergency Med Svcs",145658.99,49033.55,16069.11,45171.02,210761.65,2012,,San Francisco,
Barbara Hale,Dep Dir V,189434.28,0,5697.5,60701.51,195131.78,2012,,San Francisco,
Zhi Jiar Zhuang,Senior Physician Specialist,185616.91,0,10649.01,59423.65,196265.92,2012,,San Francisco,
Daniel Leydon,Lieutenant 3,109085.69,5575.64,114130.05,26892.42,228791.38,2012,,San Francisco,
Annette Hobrucker-Pfeifer,EMT/Paramedic/Firefighter,127405.78,71906.72,14465.72,41891.03,213778.22,2012,,San Francisco,
Rosemary Lee,Nurse Manager,177158.02,453.8,18415.81,59631.33,196027.63,2012,,San Francisco,
Tangerine Brigham,Dep Dir V,189274.5,0,3486,62837.64,192760.5,2012,,San Francisco,
Daniel Mahoney,Captain 3,196265,0,12003.07,47256.04,208268.07,2012,,San Francisco,
Timothy Flaherty,Sergeant 3,135977.73,64913.69,17231.98,37386.98,218123.4,2012,,San Francisco,
Martin Gran,Dir Emp Relations Div,192695.98,0,141.18,62656.67,192837.16,2012,,San Francisco,
Matthew Rothschild,Assistant Chief Attorney 2,195862.56,0,312.5,59261.53,196175.06,2012,,San Francisco,
Glen Zorrilla,Firefighter,110847.12,86381.68,18061.07,40102.05,215289.87,2012,,San Francisco,
Robert Tai,Firefighter,110847.11,89676.35,15132.56,39689.76,215656.02,2012,,San Francisco,
Ollie Banks,Firefighter,109783.86,88419.45,17035.62,40036.55,215238.93,2012,,San Francisco,
Milton Estes,Supervising Physician Spec,185529.33,0,13560.37,56053.83,199089.7,2012,,San Francisco,
Tim Areja,Firefighter,109783.85,87049.3,18558.47,39638.1,215391.62,2012,,San Francisco,
Sam Yuen,Police Officer 2,114667.02,82328.48,22048.32,35797.21,219043.82,2012,,San Francisco,
William McFarland,"Lieutenant, Fire Suppression",128808.84,65924.39,19350.45,40687.33,214083.68,2012,,San Francisco,
Albert Cendana,Senior Physician Specialist,164974.38,0,33094.44,56688.37,198068.82,2012,,San Francisco,
Edgar Lopez,Manager VII,186408.41,0,3486,64847.56,189894.41,2012,,San Francisco,
Noreen Ambrose,Assistant Chief Attorney 2,195150.07,0,312.5,59108.74,195462.57,2012,,San Francisco,
Bronwyn Gundogdu,Nursing Supervisor,195242.01,0,0,59167.18,195242.01,2012,,San Francisco,
Kandace Bender,Dep Dir V,189594.02,0,3486,61287.89,193080.02,2012,,San Francisco,
William Canning,Lieutenant 3,82622.56,2539.3,148354.64,20806.56,233516.5,2012,,San Francisco,
Elisa Ramirez,Nurse Manager,177158.02,0,17715.86,59410.96,194873.88,2012,,San Francisco,
John Feeney,Captain 3,196265.07,3145,5697.8,49117.22,205107.87,2012,,San Francisco,
David Counter,Manager VII,185100.27,0,7286,61680.78,192386.27,2012,,San Francisco,
Albert Pardini,Captain 3,196265.04,0,11404.04,46326.21,207669.08,2012,,San Francisco,
Glenn Ortiz-Schuldt,"Captain, Fire Suppression",144946.6,44125.5,19080.12,45767.31,208152.22,2012,,San Francisco,
Elaine Coleman,Nurse Manager,177158.01,0,17715.82,59015.34,194873.83,2012,,San Francisco,
Troy Williams,Nurse Manager,166927,0,29814.53,57110.51,196741.53,2012,,San Francisco,
Thomas Abbott,"Battlion Chief, Fire Suppressi",176515.53,3015.76,22638.35,51622.87,202169.64,2012,,San Francisco,
Surinderjeet Bajwa,Manager VIII,189630.74,0,3486,60620.68,193116.74,2012,,San Francisco,
Deborah Logan,Nurse Manager,167997.62,0,29057.7,56565.25,197055.32,2012,,San Francisco,
Lan Lee,Nurse Manager,166624,0,29819.04,57163.66,196443.04,2012,,San Francisco,
Ruby Martin,Registered Nurse,174044.89,949.5,19811.98,58670.2,194806.37,2012,,San Francisco,
James Emery,Assistant Chief Attorney 1,193922,0,312.5,59203.56,194234.5,2012,,San Francisco,
Fernando De Alba,"Captain, Fire Suppression",163377.7,19415.08,24769.69,45873.29,207562.47,2012,,San Francisco,
Ryan Kennedy,"Lieutenant, Fire Suppression",128808.88,64030.28,16450.61,43944.73,209289.77,2012,,San Francisco,
Kathryn How,Manager VIII,189434.28,0,3486,60303.94,192920.28,2012,,San Francisco,
Michael Connolly,Captain 3,196265.06,848.48,7186.56,48855.43,204300.1,2012,,San Francisco,
Eduardo Gonzalez,"Battlion Chief, Fire Suppressi",93262,28825.75,105250.6,25739.67,227338.35,2012,,San Francisco,
Jill Lecount,Nurse Manager,177158.05,0,17715.81,58182.49,194873.86,2012,,San Francisco,
Margaret Hannaford,Manager VII,179682.52,0,14922.12,58407.48,194604.64,2012,,San Francisco,
Juliet Ellis,Dep Dir IV,186580.16,0,6197.68,60153.22,192777.84,2012,,San Francisco,
Dale Carnes,"Captain, Fire Suppression",168937.74,19706.73,16495.97,47718.25,205140.44,2012,,San Francisco,
Samuel Nieto,Firefighter,110847.1,79905.21,21505.29,40530.85,212257.6,2012,,San Francisco,
Patrick Grimesey,Firefighter,109783.86,83918.68,19316.79,39584.08,213019.33,2012,,San Francisco,
Timothy Falvey,Captain 3,193179.01,5734.45,5532.76,48130.58,204446.22,2012,,San Francisco,
Teresita Pontejos-Murphy,Senior Physician Specialist,184736.82,0,9353.93,58451.46,194090.75,2012,,San Francisco,
Masa Rambo,Nurse Practitioner,178916.02,0,8563.83,65059.99,187479.85,2012,,San Francisco,
Matthew Schwartz,"Captain, Fire Suppression",147069.66,37764.32,21065.79,46571.1,205899.77,2012,,San Francisco,
James Miller,Lieutenant 3,155319.48,29466.12,25224.93,42412.05,210010.53,2012,,San Francisco,
Michael Morley,Inspector 3,135971.92,49588.57,30493.37,36239.69,216053.86,2012,,San Francisco,
Antonio Flores,Inspector 3,135977.74,44233.26,35669.44,36406.96,215880.44,2012,,San Francisco,
Michael Rubin,Firefighter,108950.23,84499.96,18740.22,40016.59,212190.41,2012,,San Francisco,
Eugene Clendinen,Manager VIII,187576.34,0,4600.77,60011.86,192177.11,2012,,San Francisco,
Troy Jolliff,Firefighter,109783.87,86492.64,16599.58,39133.13,212876.09,2012,,San Francisco,
James Kimball,Firefighter,110847.09,74342.21,27969.33,38839.82,213158.63,2012,,San Francisco,
Geoffrey Neumayr,Project Manager 4,193297,0,0,58690.99,193297,2012,,San Francisco,
Daniel Wlodarczyk,Senior Physician Specialist,189367.5,0,4315.5,58219.28,193683,2012,,San Francisco,
John Sanford Jr,Captain 3,196265.08,0,9458.1,46128.01,205723.18,2012,,San Francisco,
Attica Bowden,"Invstgtor,Fire Dept",137819.43,55968.43,15581.62,42368.24,209369.48,2012,,San Francisco,
John Burke,Sergeant 3,135977.71,45540.61,30972.65,39091.22,212490.97,2012,,San Francisco,
Carl Barnes,Firefighter,110847.11,77565,22402.46,40744.3,210814.57,2012,,San Francisco,
Michael Moynihan,EMT/Paramedic/Firefighter,128091.75,62748.33,16821.68,43619.93,207661.76,2012,,San Francisco,
Bernard Maguire,EMT/Paramedic/Firefighter,128091.77,64474.29,16011.53,42693.21,208577.59,2012,,San Francisco,
Dion McDonnell,"Sergeant, (Police Department)",128367.78,61180.7,23748.95,37695.4,213297.43,2012,,San Francisco,
Joseph Engler,Lieutenant 3,155320.07,25600.64,28045.16,42024.8,208965.87,2012,,San Francisco,
Shannon Sakowski,Anesthetist,174982.77,3155.69,9486.02,63336.2,187624.48,2012,,San Francisco,
Peter Acton,Manager VII,187607.21,0,3486,59829.67,191093.21,2012,,San Francisco,
Steven Wozniak,Senior Physician Specialist,182889.1,0,9144.2,58735.65,192033.3,2012,,San Francisco,
Richard Untalan,"Lieutenant, Fire Suppression",128808.89,59361.68,19230.47,43300.41,207401.04,2012,,San Francisco,
Teresa Barrett,Captain 3,196265.02,0,4750.13,49435.03,201015.15,2012,,San Francisco,
Donnie Hornbuckle,Firefighter,110847.11,88575.21,12104.88,38811.4,211527.2,2012,,San Francisco,
Ryan Crean,"Lieutenant, Fire Suppression",128808.86,58917.87,20120.67,42438.27,207847.4,2012,,San Francisco,
Timothy Sinclair,Senior Physician Specialist,182800.1,0,9258.16,58189.76,192058.26,2012,,San Francisco,
Jiro Yamamoto,"Lieutenant, Fire Suppression",127573.36,63594.31,15946.76,43046.35,207114.43,2012,,San Francisco,
Curtis Chan,Senior Physician Specialist,183152.9,0,10488,56433.71,193640.9,2012,,San Francisco,
Cheryl Davis,Manager VII,181911.84,0,3486,64469.51,185397.84,2012,,San Francisco,
Roger Ng,Firefighter,110847.12,80423.7,18385.6,39963.05,209656.42,2012,,San Francisco,
Garrett Dowd,Manager V,114116.13,0,91314.02,44040.09,205430.15,2012,,San Francisco,
Curtis Lum,Captain 3,196265.07,0,6452.02,46733.77,202717.09,2012,,San Francisco,
Robert Bonnet,Police Officer 3,122024.6,69980.98,21810.42,35519.27,213816,2012,,San Francisco,
Hong Luu,Electronic Maintenance Tech,101088,93639.89,10051.82,44549.63,204779.71,2012,,San Francisco,
Zeba Iman Nazeeri-Simmons,Manager VII,186185.8,0,3486,59590.53,189671.8,2012,,San Francisco,
Paul Henderson,Assistant Chief Attorney 1,189937.52,0,312.5,58916.34,190250.02,2012,,San Francisco,
John Nestor,Sergeant 3,74952.03,23506.41,130572.2,20032.84,229030.64,2012,,San Francisco,
Julie Van Nostern,Assistant Chief Attorney 1,189937.62,0,312.5,58809.54,190250.12,2012,,San Francisco,
Anita Paratley,"Captain, Fire Suppression",147069.67,35237.37,19314.73,47403.12,201621.77,2012,,San Francisco,
Patrick Rivera,Manager VII,186040.58,0,3486,59445.82,189526.58,2012,,San Francisco,
Denise Bailey,EMT/Paramedic/Firefighter,126863.21,64247.33,14899.64,42912.28,206010.18,2012,,San Francisco,
Carl Fabbri,Lieutenant 3,155320.12,38672.9,12385.53,42540.15,206378.55,2012,,San Francisco,
Robert Bryan,Assistant Chief Attorney 1,189937.6,0,312.5,58630.09,190250.1,2012,,San Francisco,
Jerry Coleman,Assistant Chief Attorney 1,189937.52,0,312.5,58618.34,190250.02,2012,,San Francisco,
Glenn Frey,EMT/Paramedic/Firefighter,128091.74,61614.85,16031.48,43015.63,205738.07,2012,,San Francisco,
Maria Bee,Assistant Chief Attorney 1,189937.52,0,312.5,58477.41,190250.02,2012,,San Francisco,
Kate Herrman Stacy,Assistant Chief Attorney 1,189937.55,0,312.5,58460.99,190250.05,2012,,San Francisco,
Caryn Bortnick,Assistant Chief Attorney 1,189937.53,0,312.5,58438.69,190250.03,2012,,San Francisco,
Sahir Putrus,EMT/Paramedic/Firefighter,128091.76,61686.38,16011.55,42863.35,205789.69,2012,,San Francisco,
John Stanfield,"Lieutenant, Fire Suppression",128209.05,60167.63,16370.8,43853.98,204747.48,2012,,San Francisco,
David Smiley,"Lieutenant, Fire Suppression",128808.84,65409.12,12169.48,42179.37,206387.44,2012,,San Francisco,
Theresa Mueller,Assistant Chief Attorney 1,189937.62,0,312.5,58290.1,190250.12,2012,,San Francisco,
June Cravet,Assistant Chief Attorney 1,189937.52,0,312.5,58144,190250.02,2012,,San Francisco,
Donald Margolis,Assistant Chief Attorney 1,189937.57,0,312.5,58128.68,190250.07,2012,,San Francisco,
Braden Woods,Assistant Chief Attorney 1,189937.52,0,312.5,58098.81,190250.02,2012,,San Francisco,
Gene Nakajima,Senior Physician Specialist,181303.82,0,9233.03,57749.96,190536.85,2012,,San Francisco,
Julia M Friedlander,Assistant Chief Attorney 1,189937.65,0,312.5,58002.3,190250.15,2012,,San Francisco,
John Hart,Lieutenant 3,145764.42,41208.28,20777.96,40465.34,207750.66,2012,,San Francisco,
Vagn Petersen,Nurse Practitioner,163186.4,9025.59,13783.79,62184.32,185995.78,2012,,San Francisco,
Joseph Fischer III,Sergeant 3,135967.56,63408.21,9514.62,39249.45,208890.39,2012,,San Francisco,
Judith Sansone,Nursing Supervisor,172775.98,0,17277.64,58073.15,190053.62,2012,,San Francisco,
Owen Clements,Assistant Chief Attorney 1,189937.52,0,312.5,57865.05,190250.02,2012,,San Francisco,
Aleeta Van Runkle,Assistant Chief Attorney 1,189937.56,0,312.5,57824.71,190250.06,2012,,San Francisco,
Michael Kirtley,Firefighter,109376.03,81416.24,18042.92,39211.13,208835.19,2012,,San Francisco,
Rose Quinones,Physician Assistant,168296,23937.95,1375,54393.93,193608.95,2012,,San Francisco,
Kimiko Burton,Assistant Chief Attorney 2,189937.53,0,312.5,57735.22,190250.03,2012,,San Francisco,
Derrick Jackson,Sergeant 2,133534.32,55837.24,20063.84,38492.35,209435.4,2012,,San Francisco,
Raemona Williams,"Battlion Chief, Fire Suppressi",175927.23,11915.36,10555.62,49486.12,198398.21,2012,,San Francisco,
Wayne Snodgrass,Assistant Chief Attorney 1,189937.56,0,312.5,57620.49,190250.06,2012,,San Francisco,
Andre Andrews Sr,Transit Supervisor,98644.1,94436.17,11166.66,43553.36,204246.93,2012,,San Francisco,
Richard McGee,"Battlion Chief, Fire Suppressi",174822.43,4221.75,18400.56,50343.75,197444.74,2012,,San Francisco,
Amit Kothari,"Deputy Dir I, MTA",183386.44,0,3516,60862.79,186902.44,2012,,San Francisco,
Michael Castain,Firefighter,110847.11,77715.13,18605.18,40498.34,207167.42,2012,,San Francisco,
Henry Yee,Sergeant 3,135967.49,66619.51,6031.51,39045.24,208618.51,2012,,San Francisco,
Leon White,EMT/Paramedic/Firefighter,128091.74,58744.71,17731.36,43016.85,204567.81,2012,,San Francisco,
Celerina Valiente,Registered Nurse,129121.08,39690.35,26351.59,52202.74,195163.02,2012,,San Francisco,
Stephen Tittel,Captain 3,196265,0,4786.12,46205.18,201051.12,2012,,San Francisco,
Michael Ellis,Electrical Trnst Shop Sprv 1,119611,60306.93,21554.89,45760.49,201472.82,2012,,San Francisco,
Joseph Reilly,Lieutenant 3,82622.15,1993,141335.31,21122.04,225950.46,2012,,San Francisco,
Dennis O'Neill,"Lieutenant, Fire Suppression",128808.84,62540.98,13210,42441.65,204559.82,2012,,San Francisco,
Joseph Goldenson,Manager VIII,186236.49,0,3486,57270.66,189722.49,2012,,San Francisco,
Joseph Woods,Manager VI,184084.23,0,3486,59178.38,187570.23,2012,,San Francisco,
Michael Smith,Firefighter,109783.88,81038.55,15669.45,40163.05,206491.88,2012,,San Francisco,
Miriam Damon,Nurse Manager,171804.01,0,17180.48,57644.67,188984.49,2012,,San Francisco,
Donald Ellison,"Deputy Dir I, MTA",177672.69,0,3486,65459.28,181158.69,2012,,San Francisco,
James Lowe,EMT/Paramedic/Firefighter,121594.57,68365.53,15212.63,41437.18,205172.73,2012,,San Francisco,
Chad Law,Firefighter,110847.13,77422.97,18614.69,39690.57,206884.79,2012,,San Francisco,
Andrew Logan,EMT/Paramedic/Firefighter,126882.68,71035.16,7937.07,40523.03,205854.91,2012,,San Francisco,
George Lysenko,"Lieutenant, Fire Suppression",128808.85,55041.92,18855.63,43645.02,202706.4,2012,,San Francisco,
Lauifi Seumaala,Firefighter,108415.56,78635.6,19804.57,39417.84,206855.73,2012,,San Francisco,
Christine Winkler,Nurse Manager,177158,0,13555.94,55478.73,190713.94,2012,,San Francisco,
Terry Smerdel,"Captain, Fire Suppression",145659,38284.54,18255.51,43875.08,202199.05,2012,,San Francisco,
Rowena Patel,Nurse Manager,161730,0,28636.82,55663.74,190366.82,2012,,San Francisco,
Dennis Kern,Dep Dir IV,177672.84,0,4370.58,63968.19,182043.42,2012,,San Francisco,
Joyce Hicks,Dept Head I,179186.54,0,3486,63272.83,182672.54,2012,,San Francisco,
Manuel Pegueros,Fire Safety Inspector 2,130468,58747.89,7828.1,48806.2,197043.99,2012,,San Francisco,
Mark Macias,Firefighter,109783.83,69273.27,25728.3,41043.34,204785.4,2012,,San Francisco,
Stephen Jonas,Sergeant 3,135967.42,58227.28,12250.83,39348.91,206445.53,2012,,San Francisco,
Karen Acosta,Nurse Manager,171064.04,0,17106.46,57584.6,188170.5,2012,,San Francisco,
Hung Ming Chu,Senior Physician Specialist,179326.89,0,9081.57,57342.61,188408.46,2012,,San Francisco,
Genevieve Farr,Nurse Manager,162186.39,0,29083.31,54414.72,191269.7,2012,,San Francisco,
Wayne Wong,"Lieutenant, Fire Suppression",127573.39,63034.63,12725.09,42344.63,203333.11,2012,,San Francisco,
Eric Leal,"Captain, Fire Suppression",145659.02,35771.29,18207.38,46034.3,199637.69,2012,,San Francisco,
David Lazar,Captain 3,196265.06,0,1113.61,48237.45,197378.67,2012,,San Francisco,
David Pine,Senior Physician Specialist,178187.13,0,10137.97,57262.03,188325.1,2012,,San Francisco,
Dustin Winn,"Lieutenant, Fire Suppression",127573.35,54519.23,20804.82,42678.54,202897.4,2012,,San Francisco,
William Storti,"Captain, Fire Suppression",147069.71,30683.5,21182.15,46637.15,198935.36,2012,,San Francisco,
Dawn Kamalanathan,Dep Dir IV,177672.75,0,4486,63399.29,182158.75,2012,,San Francisco,
Erick Martinez,Firefighter,109783.87,81580.79,15305.12,38874.14,206669.78,2012,,San Francisco,
Susan Giffin,Manager VI,180785.05,0,4986,59746.81,185771.05,2012,,San Francisco,
Douglas McEachern,Captain 3,196265.01,0,878.86,48362.02,197143.87,2012,,San Francisco,
John Kosta,Firefighter,110847.08,76356.91,18295.89,39994.53,205499.88,2012,,San Francisco,
Denise Flaherty,Captain 3,192763.13,1426.19,2175.73,49045.91,196365.05,2012,,San Francisco,
Charles Scott,Transit Supervisor,88739.4,105674.81,9170.46,41776.75,203584.67,2012,,San Francisco,
Raycardo Aviles,Firefighter,110847.09,81794.45,13638.13,39081.37,206279.67,2012,,San Francisco,
| 0 |
qxf2_public_repos/tsqa-basic
|
qxf2_public_repos/tsqa-basic/data/all_players_data.csv
|
David Ferrer,Male,Tennis,23.8
Marin Cilic,Male,Tennis,22.7
Milos Raonic,Male,Tennis,25.5
Tomas Berdych,Male,Tennis,23.9
Andy Murray,Male,Tennis,23.3
Kei Nishikori,Male,Tennis,23.4
Stan Wawrinka,Male,Tennis,24.2
Rafael Nadal,Male,Tennis,24.8
Roger Federer,Male,Tennis,24.8
Novak Djokovic,Male,Tennis,22.6
Alexis Sanchez,Male,Football,24.2
Branislav Ivanovic,Male,Football,24.3
Fraser Forster,Male,Football,23
Angel di Maria,Male,Football,23.7
Raheem Sterling,Male,Football,23.9
Cesc Fabregas,Male,Football,24.5
Eden Hazard,Male,Football,24.7
Diego Costa,Male,Football,22.9
Wilfried Bony,Male,Football,26
Sergio Aguero,Male,Football,25.7
Manuel Neuer,Male,Football,24.6
robert lewandowski,Male,Football,23
mosalah,Male,Football,23.1
Dominika Cibulkova,Female,Tennis,21.2
Angelique Kerber,Female,Tennis,23
Poorani,female,Tennis,24.1
Caroline Wozniacki,Female,Tennis,18.1
Eugenie Bouchard,Female,Tennis,18.3
Agnieszka Radwanska,Female,Tennis,18.9
Ana Ivanovic,Female,Tennis,20.4
Petra Kvitova,Female,Tennis,20.9
Simona Halep,Female,Tennis,21.3
Maria Sharapova,Female,Tennis,16.7
Serena Williams,Female,Tennis,22.2
P. V. Sindhu,Female,Badminton,20.2
Saina Nehwal,Female,Badminton,22
Carolina Marin,Female,Badminton,21.9
Tai Tzu-ying,Female,Badminton,21.4
Sakshi Malik,Female,wrestler,25
Mary Kom,Female,Boxer,21.6
Dipa Karmakar,Female,Gymnast,20.8
| 0 |
qxf2_public_repos
|
qxf2_public_repos/learn-python-through-selenium/LICENSE
|
MIT License
Copyright (c) 2019
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| 0 |
qxf2_public_repos
|
qxf2_public_repos/learn-python-through-selenium/README.md
|
# learn-python-through-selenium
Learn Python as you solve Selenium exercises
| 0 |
qxf2_public_repos
|
qxf2_public_repos/practice-testing-ai-ml/LICENSE
|
MIT License
Copyright (c) 2020 qxf2
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| 0 |
qxf2_public_repos
|
qxf2_public_repos/practice-testing-ai-ml/requirements.txt
|
Flask==3.0.0
scikit-learn == 1.1.3
prometheus-client==0.16.0
psutil==5.9.4
nltk==3.5
| 0 |
qxf2_public_repos
|
qxf2_public_repos/practice-testing-ai-ml/README.md
|
# Practice testing AI/ML based applications
Software testers can use the apps in this repo to practice testing applications that us AI and Machine Learning. Most professional testers do not get the chance to wet their feet at testing real AI/ML based applications. Even when motivated testers pick a random application and try testing, the applications and features seem too vast and opaque to test methodically. To get past this, we have developed some simple AI/ML based applications that do just one or two things well enough to challenge a professional tester. Your exercise will be to test the application and discuss your ideas with other testers. The applications listed have been developed and maintained by [Qxf2 Services](https://www.qxf2.com/?utm_source=qa-aiml-github-readme&utm_medium=click&utm_campaign=From%20QA%20AIML).
### LOCAL SETUP
1. Create a virtual environment for yourself (we used Python 3.7)
2. Activate the virtual environment
3. Install required Python modules `pip install -r requirements.txt`
3a. Type `python` to bring up the Python interpreter of your virtualenv
3b. `import nltk` and then `nltk.download('stopwords')`
3c. Exit out of the Python interpreter
4. Start the server `python ai_ml_app.py`
5. Visit http://localhost:6464 on your Browser
6. Read through the home page displayed to learn more about this application
### We would love to hear from you!
We are professional testers who are learning how to test AI/ML based applications. We are not experts. We do not have the right answers. In fact, we struggle! But we make an honest attempt to practice and improve. And we share our work on our [blog](https://qxf2.com/blog) and speak openly about the troubles we have testing more complex applications and the solutions we try out at our clients. So, if you are a tester on a journey similar to ours, please reach out and share your ideas, difficulties and thoughts. Reach out to us either on [LinkedIn](https://linkedin.com/company/qxf2-services) or [Twitter](https://twitter.com/@Qxf21) or email me (Arun: mak@qxf2.com) directly.
| 0 |
qxf2_public_repos
|
qxf2_public_repos/practice-testing-ai-ml/aiml.ini
|
[uwsgi]
module = wsgi:app
master = true
processes = 1
socket = aiml.sock
chmod-socket = 660
vacuum = true
die-on-term = true
| 0 |
qxf2_public_repos
|
qxf2_public_repos/practice-testing-ai-ml/ai_ml_app.py
|
"""
A Flask application that wraps around AI/ML models.
Qxf2 wrote this to help testers practice testing AI/ML based applications.
To learn more, see the README.md of this application.
"""
from flask import Flask, jsonify, render_template, request , Response
import is_pto.is_pto as pto_classifier
from prometheus_client import generate_latest , Gauge
import psutil
app = Flask(__name__)
cpu_usage = Gauge('cpu_usage', 'CPU usage percentage')
ram_usage = Gauge('ram_usage', 'Memory usage percentage')
@app.route("/")
def index():
"Home page"
return render_template("index.html")
@app.route("/about")
def about():
"About page"
return render_template("about.html")
@app.route("/is-pto", methods=['GET', 'POST'])
def is_pto():
"Is the message a PTO?"
response = render_template("is_pto.html")
if request.method == 'POST':
message = request.form.get('message')
prediction_score = int(pto_classifier.is_this_a_pto(message))
response = jsonify({"score" : prediction_score, "message" : message})
return response
@app.route("/metrics", methods=["GET"])
def metrics():
# update Prometheus gauges with CPU and RAM usage
cpu_percent = psutil.cpu_percent()
ram_info = psutil.virtual_memory()
cpu_usage.set(cpu_percent)
ram_usage.set(ram_info.percent)
# generate Prometheus metrics in the appropriate format
return Response(generate_latest(), mimetype="text/plain")
#---START OF SCRIPT
if __name__ == '__main__':
app.run(host='0.0.0.0', port=6464)
| 0 |
qxf2_public_repos
|
qxf2_public_repos/practice-testing-ai-ml/wsgi.py
|
from ai_ml_app import app
if __name__=='__main__':
app.run()
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/tests/requirements.txt
|
pytest==7.4.3
fastdiff==0.2.0
termcolor==1.1.0
requests==2.31.0
csv23==0.3.4
pytest-snapshot==0.9.0
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/tests/test_snapshot_is_pto_score.py
|
import csv
import requests
import os
import sys
def read_csv():
"Reading the CSV file"
pto_text = []
csv_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..','conf/pto-reasons-with-label.csv'))
with open(csv_file) as pto_file:
for each_row in pto_file:
pto_text.append(each_row.split(','))
with open(csv_file) as pto_file:
length_of_rows = csv.reader(pto_file)
length_of_rows = len(list(length_of_rows))
return pto_text, length_of_rows
def calculate_accuracy(pto_text, url, total_message_length):
"Accuracy calculation"
total_score = 0
for each_text in pto_text:
url = url
data = {'message': each_text}
response = requests.post(url,data=data)
actual_score = each_text[1]
actual_score = actual_score.strip()
if response.json()['score'] == int(actual_score):
total_score += 1
accuracy = total_score/total_message_length
return accuracy
def calcualte_true_false_val(redf_pto_text, url):
"Calculate true positive, false negative, false positive"
total_positive_predicted_message_correctly = 0
total_positive_predicted_message = 0
total_positive_message_not_predicted_correctly = 0
total_false_positive = 0
for each_precision_text in redf_pto_text:
data = {'message': each_precision_text[0]}
positive_predicited_message = each_precision_text[1]
positive_predicited_message = positive_predicited_message.strip()
if int(positive_predicited_message) == 1:
total_positive_predicted_message +=1
response = requests.post(url, data=data)
if response.json()['score'] == int(positive_predicited_message):
#True Positive
total_positive_predicted_message_correctly += 1
else:
#False Negative
total_positive_message_not_predicted_correctly += 1
else:
if response.json()['score'] == 1:
#False Positive
total_false_positive +=1
return total_positive_message_not_predicted_correctly, total_positive_predicted_message_correctly,total_false_positive
def cal_score_val(redf_false_negative, redf_true_positive, redf_false_positive):
"Calculate precision, recall, F1score"
precision = round(redf_true_positive/(redf_true_positive + redf_false_positive),2)
print(f'Precision:{precision}')
#Recall Calculation
recall = round(redf_true_positive/(redf_true_positive+redf_false_negative),2)
print(f'Recall:{recall}')
f1_score = round(2 *((precision*recall)/(precision+recall)),2)
print(f'F1 Score:{f1_score}')
return precision, recall, f1_score
def test_snapshot_accuracy(snapshot):
"Create snapshot of evaluation metric"
len_of_args = len(sys.argv)
pto_text,message_length = read_csv()
if len_of_args == 4:
app_url = sys.argv[4]
else:
app_url = "https://practice-testing-ai-ml.qxf2.com/is-pto"
response = requests.get(app_url)
accuracy = round(calculate_accuracy(pto_text,app_url,message_length),2)
false_negative, true_positive,false_positive = calcualte_true_false_val(pto_text, app_url)
precision,recall,f1_score = cal_score_val(false_negative, true_positive, false_positive)
#Creating snapshot directory
snapshot.assert_match(f"{accuracy},{precision},{recall},{f1_score}","overall_score.txt")
| 0 |
qxf2_public_repos/practice-testing-ai-ml/tests/snapshots/test_snapshot_is_pto_score
|
qxf2_public_repos/practice-testing-ai-ml/tests/snapshots/test_snapshot_is_pto_score/test_snapshot_accuracy/overall_score.txt
|
0.62,0.94,0.59,0.72
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/is_pto/is_pto.py
|
"""
Figure out if a message sent is a PTO or not
"""
import os
import pickle
import re
import is_pto.preprocess_message as message_cleaner
CURRENT_DIRECTORY = os.path.dirname(__file__)
MODEL_FILENAME = os.path.join(CURRENT_DIRECTORY, 'pto_classifier.pickle')
QUERIES_FILENAME = os.path.join(CURRENT_DIRECTORY,'queries.log')
def get_model():
"Return the model"
return pickle.load(open(MODEL_FILENAME, 'rb'))
def store_message(message):
"Store the input message to file for analysis at a later time"
with open(QUERIES_FILENAME,'a') as file_handler:
file_handler.write(message + "\n")
def is_this_a_pto(message):
"Return a prediction of whether this is a PTO or not"
answer = 0
model = get_model()
if len(message.strip().split()) == 1:
answer = 0
else:
message = message_cleaner.get_clean_message(message)
store_message(message)
answer = model.predict([message])[0]
return answer
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/is_pto/preprocess_message.py
|
"""
Preprocess incoming message to match what the training model uses
a) Clean the unwanted portions of the Skype message and SQS formatting
b) Mimic the training model - remove stop words and stem the words
"""
import re
from nltk.corpus import stopwords
from nltk.stem import SnowballStemmer
NOT_STOP_WORDS = ['not','off','be','will','before','after','out']
ADD_STOP_WORDS = ['today', 'tomorrow', 'yesterday']
def clean_sqs_skype_formatting(message):
"Clean up unwanted Skype and SQS formatting"
cleaned_message = re.sub(r'<quote.*</quote>', '', message)
cleaned_message = re.sub(r'<.*</.*?>', '', cleaned_message) #quoted message
cleaned_message = re.sub(r'\B@\w+', '', cleaned_message) #@mentions
cleaned_message = re.sub(r'&.*?;', '', cleaned_message) #encoded strings
cleaned_message = re.sub(r'^(\s)*$\n', '', cleaned_message) #emtpy lines
cleaned_message = cleaned_message.replace('<legacyquote>', '')
cleaned_message = cleaned_message.replace(',', ' ')
cleaned_message = cleaned_message.replace('.', ' ')
cleaned_message = cleaned_message.replace('"', ' ')
cleaned_message = cleaned_message.replace("'", ' ')
cleaned_message = cleaned_message.replace('\\', ' ')
return cleaned_message
def preprocess_message(message):
"Preprocess the message"
stemmer = SnowballStemmer('english')
words = stopwords.words("english")
for word in NOT_STOP_WORDS:
words.remove(word)
for word in ADD_STOP_WORDS:
words.append(word)
clean_message = " ".join([stemmer.stem(i) for i in re.sub("[^a-zA-Z]", " ", message).split() if i not in words]).lower()
return clean_message
def get_clean_message(message):
"Clean the message"
message = clean_sqs_skype_formatting(message)
message = preprocess_message(message)
return message
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/templates/index.html
|
{% extends "base.html" %} {% block content %}
<div class="row top-space-30">
<div class="col-md-8 col-md-offset-2">
<div class="panel">
<h3 id="summary">What is this?</h3>
<p class="mb-0 text-justify" id="description">Testers, use this site to practice testing AI/ML based applications. Most professional testers do not get the chance to wet their feet at testing real AI/ML based applications. Even when a motivated tester picks a random application and tries testing, the features seem too vast and opaque to test methodically. To get past this, we have developed some simple AI/ML based applications that do just one or two things well enough to challenge a professional tester. <i>Your exercise</i> will be to test the application and discuss your ideas with other testers. The applications listed have been developed and maintained by <a href="https://www.qxf2.com/?utm_source=qa-aiml-index&utm_medium=click&utm_campaign=From%20QA%20AIML">Qxf2 Services</a>. We would love to hear how you go about testing such apps! </p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel">
<h3 id="summary">Application list</h3>
<p class="mb-0 text-justify">As of Oct-2020, we have only one application: </p>
<ol>
<li>
<b>
<a href="/is-pto">Is this a 'leave message'?</a>
</b>
<p>Post a sentence and the app will tell you if you are applying for leave or not. This is a sentence classifier. I adapted the code in this <a href="https://www.youtube.com/watch?v=5xDE06RRMFk">YouTube tutorial</a> by <a href="http://coding-maniac.com/">Johannes Frey</a> to make this application. I trained it on around 3200 messages posted on Qxf2's 'leave' Skype channel. There is definitely a bias in the training dataset. We live in India and our English is different from say someone in Australia. Similarly, certain words seem to throw the classifier off and it is fun to discover these words and just add them randomly to your messages.</p>
</li>
</ol>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel">
<h3 id="summary">We would love to hear from you!</h3>
<p class="mb-0 text-justify">We are professional testers who are learning how to test AI/ML based applications. We are not experts. We do not have the right answers. In fact, we struggle! But we make an honest attempt to practice and improve. And we share our work on our <a href="https://qxf2.com/blog">blog</a> and speak openly about the troubles we have testing more complex applications and the solutions we try out at our clients. So, if you are a tester on a journey similar to ours, please reach out and share your ideas, difficulties and thoughts. Reach out to us either on <a href="https://linkedin.com/company/qxf2-services">LinkedIn</a> or <a href="https://twitter.com/@Qxf21">Twitter</a> or email me (Arun: mak@qxf2.com) directly.
</div>
<div class="col-md-2">
</div>
</div>
</div>
{% endblock %}
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/templates/about.html
|
{% extends "base.html" %} {% block content %}
<div class="row top-space-30">
<div class="col-md-8 col-md-offset-2">
<div class="panel">
<h3 class="top-space-30" id="summary">About this site</h3>
<p class="mb-0 top-space-30 text-justify">Hi, I am Arun and I run <a href="https://www.qxf2.com/?utm_source=qa-aiml-about&utm_medium=click&utm_campaign=From%20QA%20AIML">Qxf2 Services</a> - a company that offers software testing consultancy to startups. After a painful client engagement in early 2020, I realized we did not have the skill set, tooling and mental models to tackle many of the more technical challenges facing testers. This site is a genuine attempt to make me and my colleagues suck a little less at testing ¯\_(ツ)_/¯. If you find it useful or want to help us improve, please drop me a message at mak@qxf2.com.</p>
<p class="mb-0 top-space-30 text-justify">Since then, we have made significant progress, including the development of our dedicated AI/ML testing offering. This service is designed to help teams address the unique challenges of moving machine learning models into production while ensuring their effectiveness and reliability. To learn more about how our QA services can enhance your ML projects, please visit our <a href="https://qxf2.com/aiml-testing-offering">AI/ML Testing</a> offering page.</p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
{% endblock %}
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/templates/base.html
|
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-G18EK6WN60"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-G18EK6WN60');
</script>
<title>Practice testing AI/ML based applications</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
body {
padding-top: 40px;
font-size: 16px;
font-family: "Open Sans", serif;
line-height: 2.0;
}
.top-space-30 {
padding-top: 30px;
}
a.see-full-list {
line-height: 2.0;
font-family: "Open Sans", "Abel", Arial, sans-serif;
font-size: 12px;
}
td.details-control {
cursor: pointer;
}
tr.description {
font-family: "Abel", Arial;
color: grey;
line-height: 2.0;
}
.qxf2_copyright {
font-family: "Abel", Arial, sans-serif;
font-size: 12px;
}
img.logo{
max-height: 80px;
max-width: 80px;
}
img.pto-meme{
max-height: 250px;
max-width: 250px;
}
.toppy {
padding-top: 70px;
}
</style>
</head>
<body>
<!-- Fixed navbar Src: https://getbootstrap.com/examples/navbar-fixed-top/#-->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="/static/img/robot_queen.png"
alt="Practice testing AI/ML based applications" class="logo img-responsive img-circle"></img></a>
</div>
<div id="navbar" class="navbar-collapse collapse pull-right top-space-10">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
{% block content %}{% endblock %}
</div>
<div class="col-md-12">
<div class="row-fluid">
<!--Copyright-->
<p class="margin-base-vertical text-center qxf2_copyright">
© <a href="https://www.qxf2.com/?utm_source=qa-aiml&utm_medium=click&utm_campaign=From%20QA%20AIML">Qxf2
Services</a>
<script>document.write(new Date().getFullYear())</script>
<!---
<script>document.write(new Date().getFullYear())</script>-->
</p>
</div>
<!--Copyright-->
</div>
</body>
</html>
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/templates/is_pto.html
|
{% extends "base.html" %} {% block content %}
<div class="container toppy">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="margin-base-vertical top-space-30 text-center">Are you asking for leave?</h1>
<p class="input-group top-space-30">
<span class="input-group-addon">
<span class="icon-arrow-right"></span>
</span>
<input type="text" id="query" class="form-control input-lg"
placeholder="Enter 'I am out sick today' or try the examples below">
</p>
<p class="text-center top-space-40">
<button type="submit" class="btn btn-success btn-lg" id="isThisAPTO">Guess!</button>
</p>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<p class="text-center top-space-20" id="resultDiv">
</p>
</div>
</div>
<div class="row">
<div class="text-center">
<img src="/static/img/is_this_a_pto.jpg" class="pto-meme rounded mx-auto d-block">
</div>
</div>
<div class="row">
<div class="text-justify">
<h3 class="margin-base-vertical top-space-30">Examples</h1>
<p class="input-group top-space-30">Try out sentences that indicate that you want to take some time off from work. Some examples you can try are:
<ol>
<li>Taking PTO on these dates Nov-27th(Friday) Dec-3rd(Thursday)</li>
<li>I am cancelling my today's PTO and working today</li>
<li>I am travelling to hometown on some unplanned personal work... will not be able to work today. Taking PTO </li>
<li>Down with fever and cold. Taking the day off</li>
<li>I am having a bad headache so taking sick off for today.</li>
</ol> </p>
</div>
</div>
<div class="row">
<div class="text-justify">
<h3 class="margin-base-vertical top-space-30">About this app</h1>
<p class="input-group top-space-30">Post a sentence and the app will tell you if you are applying for leave or not. This is a sentence classifier. I adapted the code in this <a href="https://www.youtube.com/watch?v=5xDE06RRMFk">YouTube tutorial</a> by <a href="http://coding-maniac.com/">Johannes Frey</a> to make this application. I trained it on around 3200 messages posted on Qxf2's 'leave' Skype channel. There is definitely a bias in the training dataset. We live in India and our English is different from say someone in Australia. Similarly, certain words seem to throw the classifier off and it is fun to discover these words and just add them randomly to your messages. </p>
</div>
</div>
</div>
<script>
$("document").ready(function () {
$("#isThisAPTO").click(function () {
var message = $('#query').val();
var callDetails = {
type: 'POST',
url: '/is-pto',
data: {
'message': message
}
};
$.ajax(callDetails).done(function (result) {
if(result.score == 1){
$("#resultDiv").text(result.message + " is a PTO message");
}
else{
$("#resultDiv").text(result.message + " is not a PTO message");
}
});
});
});
</script>
{% endblock %}
| 0 |
qxf2_public_repos/practice-testing-ai-ml
|
qxf2_public_repos/practice-testing-ai-ml/conf/pto-reasons-with-label.csv
|
Down with fever will not be working today, 1
Son is not well so will be not working, 1
Having headache and need some rest, 1
I have some emergency work I have to go now, 1
I couldnt continue my day today as I have to go to bank, 1
I have some important personal meeting will meet you tomorrow , 1
My parents have come here so I have to be with them I will see you tomorrow, 1
Doctor advised me take rest so I have to do the same I will start work after my health improves, 1
Throat infection couldnt talk so will resume work after thoart clears, 1
I am leaving now will see you day after tomorrow, 0
I am not well today I am Sick, 1
I have a dentist appointment and I cannot make it today, 1
I don’t think I’ll be able to make it to office today because my little child is very sick, 1
I need to take my father/mother to their doctor’s appointment so not coming to office today, 1
One of my relative is passed away and I have to go and I cant come to the office, 1
Stuck in office and I cant attend the meeting, 1
Some wood work is going at home and I cant make it today, 1
There is no water at home and I cant make it to the office, 1
Some paper work I have to do today and will try to login from home, 0
There is no internet due to rain Will start my work if it resumes, 1
Daycare is closed and I have to look after my kid will login tomorrow, 1
We have a family function on next week so I am off for a week, 1
I have to attend the conference meet on Feb 20th so I will not work, 1
I had a knee injury I don’t think I will be able to come on today, 1
Something urgent has come up Actually I have to leave immediately out of townSo give me excuse for one day, 1
I have to visit my child's school so need a day off, 1
Got back very late last night as I ma out of town and didn’t manage to come back early I need a rest today, 1
My train got late and I just reached homeCan you won’t mind giving a day off, 1
I need to take my brother to the hospital and can’t leave him until he is treatedCan I please?, 1
Just missed a bus or a train! And now I need to wait for one hour Either I can take a leave or reach late in office, 1
I have to go for a blood donation on Feb 29th so Can I have a off on that day?, 1
Relative has come to our house and I have to take them out for some personal work I will come tomorrow, 1
My sister is blessed with a baby boy and I have to be therePlease manage the situation I will be back after a day, 1
my son’s annual sports day and prize distribution ceremony is timed exactly at the off time of our office So I cannot make it on time, 0
I am in Adhar card office and in the queue waiting for my turn due to process of getting new card I will be back in another three hours, 0
I had applied for the renewal of the passport and just now I had received their call to collect the passportPlease allow me to go, 1
As I am going for a trip and my leave starts from today, 1
I am not well and I am not working today, 1
Taking off today, 1
I am unable to come to office today because of unpredictable weather, 1
As I have to take my mother for her monthly checkup to hospital and I am not sure how much time it will take Kindly allow me the leave, 1
I have to attend the Annual Parents Teachers Meeting of my elder son I need a short leave for 2 hours on account of this today I will come to office at 11 am instead of 9 am, 0
I just wanted to let you know that I am not felling well and I cannot come to office I want to take off for today, 1
I am shifting from the flat to the house today So it would not be feasible for me to come to office today, 1
I am in need of an urgent short leave because my presence is urgently needed at the time of the admission of my son, 1
My mother is in the hospital she is needing bloodPlease free me for that time period Much thanks, 1
my wife’s uncle died todaygrant me leave to make it possible for me to join the funeral procession, 1
my wife’s uncle died today grant me to make it possible for me to join the funeral procession, 1
I had eaten raw cooked food yesterday and now I am suffering from food poisoning Kindly grant me the leave so that I can check myself from the doctor, 1
I had eaten raw cooked food yesterday and now I am suffering from food poisoning Give me one day time I can check myself from the doctor, 1
my mother is sick and feeling nausea She is not feeling well so retire me from my work for the first half as I would be with her at the hospital, 1
I want a half leave from my work today as I need to open new account in the nearby Bank, 1
I would not be available for the meeting today in office, 0
I feel very nauseating It seems that I need rest for one day, 1
my sister has fell down from stairs in school and sustained some injuries Therefore I won’t be able to come today, 1
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/e2e.conf
|
#Search Cases using Category
CATEGORY=A 5195 NY
#Bill Number
BILL_NUMBER=A 5195
#State Name
STATE_NAME=NY
#Session
SESSION=2015-2016 Regular Session
#Basic Information
TITLE=Establishes high-tech worker-NY
DESCRIPTION=Establishes high-tech worker-NY.
CATEGORIES=Technology
#FiscalNote Forecast
FISCALNOTE_FORECAST=4.5%
FLOOR=84.7%
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/Demo_Test.py
|
"""
Demo test run will do the following:
a) login
b) Search for a category
c) Access a specific bill and verify
- Bill number
- State
- Session
- Title
- Description
- Category
"""
import dotenv,os,sys,PageFactory,Conf_Reader
from optparse import OptionParser
from DriverFactory import DriverFactory
def check_options(options):
"Check if the command line options are valid"
options_flag = True
options.config_file = os.path.abspath(options.config_file)
#Check if the config file exists and is a file
if os.path.exists(options.config_file):
if not os.path.isfile(options.config_file):
print '\n****'
print 'Config file provided is not a file: '
print options.config_file
print '****'
options_flag = False
else:
print '\n****'
print 'Unable to locate the provided config file: '
print options.config_file
print '****'
options_flag = False
return options_flag
def run_demo_test(browser,config_file,base_url,test_run_id=None,sauce_flag=None,browser_version=None,platform=None):
"Demo Test Run"
#Setup a driver
driver_obj = DriverFactory()
driver = driver_obj.get_web_driver(browser,sauce_flag,browser_version,platform)
#a) Login
# get the test account credentials from the .credentials file
PY_SCRIPTS_PATH=os.path.dirname(__file__)
dotenv.load_dotenv(os.path.join(PY_SCRIPTS_PATH,"login.credentials"))
USERNAME = os.environ['LOGIN_USER']
PASSWORD = os.environ['LOGIN_PASSWORD']
login_obj = PageFactory.get_page_object("login",driver)
if login_obj.verify_header_text():
login_obj.write('PASS: Verifed the header text on login page')
else:
login_obj.write('FAIL: Header text is not matching on login page')
if login_obj.login(USERNAME,PASSWORD):
login_obj.write('PASS: Login was successful')
else:
login_obj.write('FAIL: Login failed')
#Create a Bills Page object, verify all fields
bills_obj = PageFactory.get_page_object('bills',driver)
#b) Search for a category
category_name = Conf_Reader.get_value(config_file,'CATEGORY')
if bills_obj.search_bills(category_name):
bills_obj.write('PASS: Searched for the bill category: %s.'%category_name)
else:
bills_obj.write('FAIL: Was not able to Search for the bill category: %s.'%category_name)
#c) Go to a specific bill
bill_number = Conf_Reader.get_value(config_file,'BILL_NUMBER')
if bills_obj.goto_specific_bill(bill_number):
bills_obj.write('PASS: Clicked on bill number: %s'%bill_number)
else:
bills_obj.write('FAIL: Unable to click on bill number: %s'%bill_number)
#Verify the bill number
if bills_obj.verify_bill_number(bill_number):
bills_obj.write('PASS: Obtained the expected bill number: %s'%bill_number)
else:
bills_obj.write('FAIL: Obtained an unexpected bill number: %s'%bills_obj.get_bill_number())
bills_obj.write('\t\tEXPECTED: %s'%bill_number)
#Verify the state name
state_name = Conf_Reader.get_value(config_file,'STATE_NAME')
if bills_obj.verify_state_name(state_name):
bills_obj.write('PASS: Obtained the expected state name: %s'%state_name)
else:
bills_obj.write('FAIL: Obtained an unexpected state name: %s'%bills_obj.get_state_name())
bills_obj.write('\t\tEXPECTED: %s'%state_name)
#Verify the session
session_name = Conf_Reader.get_value(config_file,'SESSION')
if bills_obj.verify_session_name(session_name):
bills_obj.write('PASS: Obtained the expected session: %s'%session_name)
else:
bills_obj.write('FAIL: Obtained an unexpected session: %s'%bills_obj.get_session())
bills_obj.write('\t\tEXPECTED: %s'%session_name)
#Verify the title
title_name = Conf_Reader.get_value(config_file,'TITLE')
if bills_obj.verify_title_name(title_name):
bills_obj.write('PASS: Obtained the expected title: %s'%title_name)
else:
bills_obj.write('FAIL: Obtained an unexpected title: %s'%bills_obj.get_title())
bills_obj.write('\t\tEXPECTED: %s'%title_name)
#Verify the description
description_name = Conf_Reader.get_value(config_file,'DESCRIPTION')
if bills_obj.verify_description_name(description_name):
bills_obj.write('PASS: Obtained the expected description: %s'%description_name)
else:
bills_obj.write('FAIL: Obtained an unexpected description: %s'%bills_obj.get_description())
bills_obj.write('\t\tEXPECTED: %s'%description_name)
#Verify the category
category_name = Conf_Reader.get_value(config_file,'CATEGORIES')
if bills_obj.verify_category_name(category_name):
bills_obj.write('PASS: Obtained the expected category: %s'%category_name)
else:
bills_obj.write('FAIL: Obtained an unexpected category: %s'%bills_obj.get_category())
bills_obj.write('\t\tEXPECTED: %s'%category_name)
#{?)Verify the forecast - we expect this to change
#We wont know how to design a good check until we know the underlying algorithm
fiscalnote_forecast = Conf_Reader.get_value(config_file,'FISCALNOTE_FORECAST')
if bills_obj.verify_fiscalnote_forecast(fiscalnote_forecast):
bills_obj.write('PASS: Obtained the expected forecast: %s'%fiscalnote_forecast)
else:
bills_obj.write('FAIL: Obtained an unexpected forecast: %s'%bills_obj.get_forecast())
bills_obj.write('\t\tEXPECTED: %s'%fiscalnote_forecast)
#(?)Verify the floor - we expect this to change
#We wont know how to design a good check until we know the underlying algorithm
floor = Conf_Reader.get_value(config_file,'FLOOR')
if bills_obj.verify_floor(floor):
bills_obj.write('PASS: Obtained the expected floor: %s'%floor)
else:
bills_obj.write('FAIL: Obtained an unexpected floor: %s'%bills_obj.get_floor())
bills_obj.write('\t\tEXPECTED: %s'%floor)
#W00t! Close the browser
driver.quit()
#---START OF SCRIPT
if __name__=='__main__':
print "Script start"
#This script takes an optional command line argument for the TestRail run id
usage = "\n----\n%prog -b <OPTIONAL: Browser> -c <OPTIONAL: configuration_file> -u <OPTIONAL: APP URL> -r <Test Run Id>\n----\nE.g.: %prog -b FF -c .conf -u https://app.fiscalnote.com -r 2\n---"
parser = OptionParser(usage=usage)
parser.add_option("-b","--browser",
dest="browser",
default="firefox",
help="Browser. Valid options are firefox, ie and chrome")
parser.add_option("-c","--config",
dest="config_file",
default=os.path.join(os.path.dirname(__file__),'e2e.conf'),
help="The full or relative path of the test configuration file")
parser.add_option("-u","--app_url",
dest="url",
default="https://app.fiscalnote.com",
help="The url of the application")
parser.add_option("-r","--test_run_id",
dest="test_run_id",
default=None,
help="The test run id in TestRail")
parser.add_option("-s","--sauce_flag",
dest="sauce_flag",
default="N",
help="Run the test in Sauce labs: Y or N")
parser.add_option("-v","--version",
dest="browser_version",
help="The version of the browser: a whole number",
default=None)
parser.add_option("-p","--platform",
dest="platform",
help="The operating system: Windows 7, Linux",
default="Windows 7")
(options,args) = parser.parse_args()
if check_options(options):
#Run the test only if the options provided are valid
run_demo_test(browser=options.browser,
config_file=os.path.abspath(options.config_file),
base_url=options.url,
test_run_id=options.test_run_id,
sauce_flag=options.sauce_flag,
browser_version=options.browser_version,
platform=options.platform)
else:
print 'ERROR: Received incorrect input arguments'
print parser.print_usage()
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/saucelabs.credentials
|
#Fill out your Sauce Lab credentials here
LOGIN_USER=$USER
LOGIN_KEY=$KEY
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/Login_Page.py
|
"""
Page object model for the login page
"""
from Page import Page
class Login_Page(Page):
"Page object for the Login page"
def start(self):
self.url = None
self.open(self.url)
# Assert Title of the Login Page and Login
self.assertIn("FiscalNote", self.driver.title)
"Xpath of all the field"
self.login_username = "//input[@placeholder='Email']"
self.login_password = "//input[@placeholder='Password']"
self.forget_passowrd_link_xpath ="//a[@href='/forgot-password')]"
self.header_text_xpath = "//h3[contains(@class,'text-center')]"
self.welcome_text_xpath = "//h1[contains(.,'Welcome to FiscalNote')]"
self.login_button_xpath = "//button[text()='Login']"
def verify_header_text(self):
"Verify the Header Text in Login Page"
results_flag = False
text = self.get_text(self.header_text_xpath)
if text == str("Login to FiscalNote"):
results_flag = True
else:
self.write("fail :" + str(text))
return results_flag
def login(self,username,password):
"Login using credentials provided"
results_flag = False
self.set_text(self.login_username,username)
self.set_text(self.login_password,password)
self.click_button(self.login_button_xpath)
self.wait(1)
if (self.get_text(self.welcome_text_xpath) == 'Welcome to FiscalNote'):
results_flag = True
return results_flag
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/Page.py
|
"""
Qxf2 Services: Page class that all page models can inherit from
There are useful wrappers for common Selenium operations
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import unittest,time
class Page(unittest.TestCase):
"Page class that all page models can inherit from"
def __init__(self,selenium_driver,base_url='https://app.fiscalnote.com/'):
"Constructor"
#We assume relative URLs start without a / in the beginning
if base_url[-1] != '/':
base_url += '/'
self.base_url = base_url
self.driver = selenium_driver
self.start() #Visit and initialize xpaths for the appropriate page
def open(self,url=None):
"Visit the page base_url + url"
if url == None:
self.driver.get(self.base_url)
else:
url = self.base_url + url
self.driver.get(url)
self.wait(2)
def get_xpath(self,xpath):
"Return the DOM element of the xpath OR the 'None' object if the element is not found"
dom_element = None
dom_element = self.driver.find_element_by_xpath(xpath)
return dom_element
def click_button(self,xpath):
"Click the button supplied"
button = self.get_xpath(xpath)
if button is not None:
try:
button.click()
except Exception,e:
self.write('Exception when clicking button with xpath: %s'%xpath,'error')
self.write(e)
else:
return True
return False
def click_element(self,xpath):
"Click the button supplied"
link = self.get_xpath(xpath)
if link is not None:
try:
link.click()
except Exception,e:
self.write('Exception when clicking link with xpath: %s'%xpath)
self.write(e)
else:
return True
return False
def set_text(self,xpath,value):
"Set the value of the text field"
text_field = self.get_xpath(xpath)
try:
text_field.clear()
except Exception, e:
self.write('ERROR: Could not clear the text field: %s'%xpath)
if value is None:
return
else:
text_field.send_keys(value)
def get_text(self,xpath):
"Return the text for a given xpath or the 'None' object if the element is not found"
text = ''
try:
text = self.get_xpath(xpath).text
except Exception,e:
self.write(e)
return None
else:
return text.encode('utf-8')
def get_dom_text(self,dom_element):
"Return the text of a given DOM element or the 'None' object if the element has no attribute called text"
text = ''
try:
text = dom_element.text
except Exception, e:
self.write(e)
return None
else:
return text.encode('utf-8')
def select_dropdown_option(self, select_locator, option_text):
"Selects the option in the drop-down"
#dropdown = self.driver.find_element_by_id(select_locator)
dropdown = self.driver.find_element_by_xpath(select_locator)
for option in dropdown.find_elements_by_tag_name('option'):
if option.text == option_text:
option.click()
break
def check_element_present(self,xpath):
"This method checks if the web element is present in page or not and returns True or False accordingly"
try:
self.get_xpath(xpath)
except NoSuchElementException:
return False
return True
def submit_search(self):
"Clicks on Search button"
self.click_button(self.search_button)
def teardown(self):
"Tears down the driver"
self.driver.close()
def write(self,msg):
"This method can be used to include logging"
print msg
def wait(self,wait_seconds=5):
"Performs wait for time provided"
time.sleep(wait_seconds)
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/Conf_Reader.py
|
"""
A simple conf reader.
For now, we just use dotenv and return a key.
In future, you can make this a class and extend get_value()
"""
import dotenv,os
def get_value(conf,key):
"Return the value in conf for a given key"
value = None
try:
dotenv.load_dotenv(conf)
value = os.environ[key]
except Exception,e:
print 'Exception in get_value'
print 'file: ',conf
print 'key: ',key
return value
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/DriverFactory.py
|
"""
DriverFactory class
NOTE: Change this class as you add support for:
1. SauceLabs/BrowserStack
2. More browsers like Opera
"""
from selenium import webdriver
import dotenv
class DriverFactory:
def __init__(self,browser='ff',sauce_flag='N',browser_version=None,platform=None):
"Constructor"
self.browser=browser
self.sauce_flag=sauce_flag
self.browser_version=browser_version
self.platform=platform
def get_web_driver(self,browser,sauce_flag,browser_version,platform):
"Return the appropriate driver"
if (sauce_flag == 'Y'):
web_driver = self.run_sauce(browser,browser_version,platform)
elif (sauce_flag == 'N'):
web_driver = self.run_local(browser,browser_version,platform)
else:
print "DriverFactory does not know the browser: ",browser
web_driver = None
return web_driver
def run_sauce(self,browser,browser_version,platform):
"Run the test on Sauce Labs"
PY_SCRIPTS_PATH=os.path.dirname(__file__)
dotenv.load_dotenv(os.path.join(PY_SCRIPTS_PATH,"saucelabs.credentials"))
USERNAME = os.environ['LOGIN_USER']
SAUCE_KEY = os.environ['LOGIN_KEY']
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = platform
elif browser.lower() == 'ie':
desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = platform
elif browser.lower() == 'chrome':
desired_capabilities = webdriver.DesiredCapabilities.CHROME
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = platform
desired_capabilities['name'] = 'Testing End to END FiscalNote Test'
return webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://%s:%s:80/wd/hub"%(USERNAME,SAUCE_KEY)
)
def run_local(self,browser,browser_version,platform):
"Run the test on your local machine"
if browser.lower() == "ff" or browser.lower() == 'firefox':
return webdriver.Firefox()
elif browser.lower() == "ie":
return webdriver.Ie()
elif browser.lower() == "chrome":
return webdriver.Chrome()
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/PageFactory.py
|
"""
PageFactory uses the factory design pattern.
get_page_object() returns the appropriate page object.
Add elif clauses as and when you implement new pages.
Pages implemented so far:
1. Login
2. Bills Page
"""
from Login_Page import Login_Page
from Bills_Page import Bills_Page
def get_page_object(page_name,driver,base_url='https://app.fiscalnote.com/'):
"Return the appropriate page object based on page_name"
test_obj = None
page_name = page_name.lower()
if page_name == "login":
test_obj = Login_Page(driver,base_url=base_url)
elif page_name == "bills":
test_obj = Bills_Page(driver,base_url=base_url)
return test_obj
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/Bills_Page.py
|
"""
Page object model for the Bills page
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from Page import Page
class Bills_Page(Page):
"Page object for the Bill page"
def start(self):
# Assert Title of the Login Page and Login
#self.assertIn("FiscalNote", self.driver.title)
url = "bills/index"
self.open(url)
"Xpath of all the field"
#Bills Page
self.browse = "//h6[text()='Browse']"
self.bills = "//a[text()='Bills']"
self.search_box = "//input[contains(@class,'ember-view ember-text-field')]"
self.submit_button = "//span[text()='Submit']"
self.click_bill_number = "//a[text()='%s']"
self.bill_number_xpath = "//div[contains(@class,'fn-page__topbar-elem title')]"
self.bill_state_xpath = "//div[contains(@class,'fn-page__topbar-elem text-center col-xs-6 col-sm-2')]/descendant::p[@class='value']"
self.bill_session_xpath = "//div[contains(@class,'fn-page__topbar-elem text-center col-xs-12 col-sm-4')]/descendant::p[@class='value']"
self.bill_title_xpath = "//h5[text()='Title']/following-sibling::p[contains(@class,'ember-view trunk8')][1]"
self.bill_description_xpath = "//h5[text()='Description']/following-sibling::p[contains(@class,'ember-view trunk8')][1]"
self.categories_xpath = "//span[contains(@class,'comma-separated-list-elem')]"
self.fiscalnote_forecast_xpath = "//span[contains(@class,'red analysis-header')]"
self.floor_xpath = "//span[contains(@class,'green analysis-header')]"
def search_bills(self,category_name):
"Search Bills based given Category Name"
results_flag = False
self.set_text(self.search_box,category_name)
if self.click_button(self.submit_button):
self.wait(3)
results_flag = True
return results_flag
def goto_specific_bill(self,bill_number):
"Click on specific Bill Number"
results_flag = False
if self.click_element(self.click_bill_number%bill_number):
self.wait(5)
results_flag = True
return results_flag
def get_bill_number(self):
"Get the bill number on the page"
return self.get_text(self.bill_number_xpath)
def verify_bill_number(self,bill_number):
"Verify the Bill Number"
results_flag = False
if self.get_bill_number()==bill_number:
results_flag = True
return results_flag
def get_state_name(self):
"Return the state name on the page"
return self.get_text(self.bill_state_xpath)
def verify_state_name(self,state_name):
"Verify the State Name"
results_flag = False
if self.get_state_name()==state_name:
results_flag = True
return results_flag
def get_session(self):
"Return the session on the page"
return self.get_text(self.bill_session_xpath)
def verify_session_name(self,session_name):
"Verify the Session Name"
results_flag = False
if self.get_session()==session_name:
results_flag = True
return results_flag
def get_title(self):
"Get the title name on the page"
return self.get_text(self.bill_title_xpath)
def verify_title_name(self,title_name):
"Verify the Title Name"
results_flag = False
if self.get_title()==title_name:
results_flag = True
return results_flag
def get_description(self):
"Return the description on the page"
return self.get_text(self.bill_description_xpath)
def verify_description_name(self,description_name):
"Verify the Description Name"
results_flag = False
if self.get_description()==description_name:
results_flag = True
return results_flag
def get_category(self):
"Return the category name on the page"
return self.get_text(self.categories_xpath)
def verify_category_name(self,category_name):
"Verify the Category Name"
results_flag = False
if self.get_category()==category_name:
results_flag = True
return results_flag
def get_forecast(self):
"Return the forecast on the page"
return self.get_text(self.fiscalnote_forecast_xpath)
def verify_fiscalnote_forecast(self,fiscalnote_forecast):
"Verify the Fiscalnote Forecast"
results_flag = False
if self.get_forecast()==fiscalnote_forecast:
results_flag = True
return results_flag
def get_floor(self):
"Return the floor on the page"
return self.get_text(self.floor_xpath)
def verify_floor(self,floor):
"Verify the Floor"
results_flag = False
if self.get_floor()==floor:
results_flag = True
return results_flag
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/login.credentials
|
#Fill out your credentials here (no quotes needed)
LOGIN_USER=$USERNAME
LOGIN_PASSWORD=$PASSWORD
| 0 |
qxf2_public_repos
|
qxf2_public_repos/FiscalNote/README.txt
|
---------
1. SETUP
---------
a. Install Python 2.x
b. Install Selenium
c. Add both to your PATH environment variable
d. If you do not have it already, get pip
e. 'pip install python-dotenv'
f. Update 'login.credentials' with your credentials
g. Update 'saucelabs.credentials' is you want to run on Sauce Labs
-------
2. RUN
-------
a. python Demo_Test.py -b ff
b. For more options: python Demo_Test.py -h
-----------
3. ISSUES?
-----------
a. If Python complains about an Import exception, please 'pip install $module_name'
b. If you are not setup with the drivers for the web browsers, you will see a helpful error from Selenium telling you where to go and get them
c. If login fails, its likely that you forgot to update the login.credentials file
d. Exception? 'module object has no attribute load_dotenv'? You have the wrong dotenv module. So first 'pip uninstall dotenv' and then 'pip install python-dotenv'
e. Others: Contact mak@qxf2.com
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Demo_Test.py
|
"""
Test case for 42floors functionality.
Our automated test will do the following:
#1.Choose the market
#2.Filter by size on office space page
#3.Open a listing on coworking page
"""
import os,PageFactory,Test_Rail,Conf_Reader
from optparse import OptionParser
from DriverFactory import DriverFactory
def check_file_exists(file_path):
#Check if the config file exists and is a file
conf_flag = True
if os.path.exists(file_path):
if not os.path.isfile(file_path):
print '\n****'
print 'Config file provided is not a file: '
print file_path
print '****'
conf_flag = False
else:
print '\n****'
print 'Unable to locate the provided config file: '
print file_path
print '****'
conf_flag = False
return conf_flag
def check_options(options):
"Check if the command line options are valid"
options.config_file = os.path.abspath(options.config_file)
return check_file_exists(options.config_file)
def run_demo_test(browser,conf,tconf,base_url,test_run_id=None,sauce_flag=None,browser_version=None,platform=None):
"Demo Test Run"
#Setup a driver
driver_obj = DriverFactory()
driver = driver_obj.get_web_driver(browser,sauce_flag,browser_version,platform)
driver.implicitly_wait(10) # Some elements are taking long to load
driver.maximize_window()
#Result flag which will check if testrail.conf is present
tconf_flag = check_file_exists(tconf)
#Result flag used by TestRail
result_flag = False
#1. Create a home page object and choose Market
#Create a login page object
home_obj = PageFactory.get_page_object("home",driver)
city_name = Conf_Reader.get_value(conf,'CITY_NAME')
result_flag = home_obj.choose_market(city_name)
if (result_flag):
msg = "Market was set to %s"%city_name
else:
msg = "Could not set market to %s"%city_name
home_obj.write(msg)
#Update TestRail
#Get the case id from tesrail.conf file
if tconf_flag:
case_id = Conf_Reader.get_value(tconf,'CHOOSE_MARKET')
Test_Rail.update_testrail(case_id,test_run_id,result_flag,msg=msg)
#2. Filter by size on office space page
#Create project space page object
office_space_obj = PageFactory.get_page_object("office-space",driver)
min_sqft = Conf_Reader.get_value(conf,'MIN_SQFT')
max_sqft = Conf_Reader.get_value(conf,'MAX_SQFT')
expected_result =Conf_Reader.get_value(conf,'EXPECTED_RESULT_FOR_SIZE')
result_flag = office_space_obj.filter_by_size(min_sqft,max_sqft,expected_result)
if (result_flag):
msg = "Search results for filter by size matched the expected result of %s space(s)"%expected_result
else:
msg = "Actual result did not match the expected result %s space"%expected_result
office_space_obj.write(msg)
#Update TestRail
#Get the case id from tesrail.conf file
if tconf_flag:
case_id = Conf_Reader.get_value(tconf,'OFFICESPACE_FILTER_SIZE')
Test_Rail.update_testrail(case_id,test_run_id,result_flag,msg=msg)
#3.Open a listing on co-working page
#Create co-working page object
coworking_obj = PageFactory.get_page_object("coworking",driver)
listing_name = Conf_Reader.get_value(conf,'LISTING_NAME_20MISSION')
listing_href = Conf_Reader.get_value(conf,'LISTING_HREF_20MISSION')
result_flag1 = coworking_obj.verify_listing(listing_name,listing_href)
if result_flag1:
result_flag2 = coworking_obj.click_listing(listing_href)
if result_flag2:
listing_obj = PageFactory.get_page_object("listing",driver)
result_flag = listing_obj.verify_listing_name(listing_name)
if (result_flag):
msg = "Listing matched for %s"%listing_name
else:
msg = "Listing did not match or '0' coworking spaces"
coworking_obj.write(msg)
#Update TestRail
#Get the case id from tesrail.conf file
if tconf_flag:
case_id = Conf_Reader.get_value(tconf,'COWORKING_LISTING')
Test_Rail.update_testrail(case_id,test_run_id,result_flag,msg=msg)
#Teardown
home_obj.wait(3)
home_obj.teardown() #You can use any page object to teardown
#---START OF SCRIPT
if __name__=='__main__':
print "Script start"
#This script takes an optional command line argument for the TestRail run id
usage = "\n----\n%prog -b <OPTIONAL: Browser> -c <OPTIONAL: configuration_file> -u <OPTIONAL: APP URL> -r <Test Run Id> -t <OPTIONAL: testrail_configuration_file> -s <OPTIONAL: sauce flag>\n----\nE.g.: %prog -b FF -c .conf -u https://app.fiscalnote.com -r 2 -t testrail.conf -s Y\n---"
parser = OptionParser(usage=usage)
parser.add_option("-b","--browser",
dest="browser",
default="firefox",
help="Browser. Valid options are firefox, ie and chrome")
parser.add_option("-c","--config",
dest="config_file",
default=os.path.join(os.path.dirname(__file__),'data.conf'),
help="The full or relative path of the test configuration file")
parser.add_option("-u","--app_url",
dest="url",
default="https://42floors.com/",
help="The url of the application")
parser.add_option("-r","--test_run_id",
dest="test_run_id",
default=None,
help="The test run id in TestRail")
parser.add_option("-s","--sauce_flag",
dest="sauce_flag",
default="N",
help="Run the test in Sauce labs: Y or N")
parser.add_option("-v","--version",
dest="browser_version",
help="The version of the browser: a whole number",
default=None)
parser.add_option("-p","--platform",
dest="platform",
help="The operating system: Windows 7, Linux",
default="Windows 7")
parser.add_option("-t","--testrail_caseid",
dest="testrail_config_file",
default=os.path.join(os.path.dirname(__file__),'testrail.conf'),
help="The full or relative path of the testrail configuration file")
(options,args) = parser.parse_args()
if check_options(options):
#Run the test only if the options provided are valid
run_demo_test(browser=options.browser,
conf=os.path.abspath(options.config_file),
base_url=options.url,
test_run_id=options.test_run_id,
sauce_flag=options.sauce_flag,
browser_version=options.browser_version,
platform=options.platform,
tconf=os.path.abspath(options.testrail_config_file))
else:
print 'ERROR: Received incorrect input arguments'
print parser.print_usage()
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Test_Rail.py
|
"""
TestRail integration
"""
import dotenv,os,testrail,Conf_Reader
def get_testrail_conf():
"Get the testrail account credentials from the testrail.env file"
testrail_file = os.path.join(os.path.dirname(__file__),'testrail.env')
#TestRail Url
testrail_url = Conf_Reader.get_value(testrail_file,'TESTRAIL_URL')
client = testrail.APIClient(testrail_url)
#TestRail User and Password
client.user = Conf_Reader.get_value(testrail_file,'TESTRAIL_USER')
client.password = Conf_Reader.get_value(testrail_file,'TESTRAIL_PASSWORD')
return client
def update_testrail(case_id,run_id,result_flag,msg=""):
"Update TestRail for a given run_id and case_id"
update_flag = False
#Get the TestRail client account details
client = get_testrail_conf()
#Update the result in TestRail using send_post function.
#Parameters for add_result_for_case is the combination of runid and case id.
#status_id is 1 for Passed, 2 For Blocked, 4 for Retest and 5 for Failed
status_id = 1 if result_flag is True else 5
if ((run_id is not None) and (case_id != 'None')) :
try:
result = client.send_post(
'add_result_for_case/%s/%s'%(run_id,case_id),
{'status_id': status_id, 'comment': msg })
except Exception,e:
print 'Exception in update_testrail() updating TestRail.'
print 'PYTHON SAYS: '
print e
else:
print 'Updated test result for case: %s in test run: %s with msg:%s'%(case_id,run_id,msg)
return update_flag
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Office_Space_Page.py
|
"""
Page object model for the office space page
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from Page import Page
class Office_Space_Page(Page):
"Page object for the Office Space page"
def start(self):
self.url = "office-space"
self.open(self.url)
# Assert Title of the Office Space Page
self.assertIn("Office Space", self.driver.title)
"Xpath of all the field"
self.size_link = "//span[@class='field-label'][text()='Size']"
self.minsize_input ="//input[@placeholder='Min sqft']"
self.maxsize_input = "//input[@placeholder='Max sqft']"
self.search_button = "//div[@class='field-search']/descendant::button[@type='submit']"
self.search_result = "//div[@class='results-count']"
def filter_by_size(self,min_sqft,max_sqft,expected_result):
#Search as per the given min and max size
self.click_element(self.size_link)
self.set_text(self.minsize_input,min_sqft)
self.set_text(self.maxsize_input,max_sqft)
self.click_element(self.search_button)
return self.verify_result(expected_result)
def verify_result(self,expected_result):
#Verifies the actual result with the expected result for the filter
actual_num_results = self.get_text(self.search_result)
actual_num_results = actual_num_results.split("office spaces")[0]
actual_num_results = actual_num_results.strip()
if int(expected_result) == int(actual_num_results):
return True
else:
self.write("OBTAINED result for number of office spaces: " + actual_num_results)
return False
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/REQUIREMENTS.txt
|
-----------------
1. REQUIREMENTS:
-----------------
a. Python 2.x
b. Selenium webdriver with Python binding
c. Python modules: selenium, logging
d. Selenium drivers for your browsers
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/testrail.conf
|
#If you use TestRail to manage your tests
#TestRail Case Id
CHOOSE_MARKET=
OFFICESPACE_FILTER_SIZE=
COWORKING_LISTING=
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Coworking_Page.py
|
"""
Page object model for the coworking page
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from Page import Page
class Coworking_Page(Page):
"Page object for the Office Space page"
def start(self):
self.url = "coworking"
self.open(self.url)
# Assert Title of the Office Space Page
self.assertIn("Coworking Spaces", self.driver.title)
"Xpath of all the field"
self.search_result = "//div[@class='results-count']"
self.listing_href = "//a[@href='%s']/descendant::div[@class='name']"
#Verify if there are coworking spaces available
if '0 coworking spaces' in self.get_text(self.search_result):
self.write(self.get_text(self.search_result))
self.coworking_available = False
else:
self.coworking_available = True
def verify_listing(self,listing_name,listing_href):
"Verify the listing on a the co-working page"
if self.coworking_available :
if listing_name in self.get_text(self.listing_href%listing_href):
self.write("Listing name matches with the listing href")
return True
else:
self.write("Listing name does not matches with the listing href")
return False
else:
self.write("No coworking listing available")
return False
def click_listing(self,listing_href):
return self.click_element(self.listing_href%listing_href)
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Page.py
|
"""
Page class that all page models can inherit from
There are useful wrappers for common Selenium operations
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import unittest,time,logging
from Base_Logging import Base_Logging
class Page(unittest.TestCase):
"Page class that all page models can inherit from"
def __init__(self,selenium_driver,base_url='https://basecamp.com/'):
"Constructor"
#We assume relative URLs start without a / in the beginning
if base_url[-1] != '/':
base_url += '/'
self.base_url = base_url
self.driver = selenium_driver
self.log_obj = Base_Logging(level=logging.DEBUG)
self.start() #Visit and initialize xpaths for the appropriate page
def open(self,url):
"Visit the page base_url + url"
url = self.base_url + url
if self.driver.current_url != url:
self.driver.get(url)
def get_page_xpaths(self,section):
"open configurations file,go to right sections,return section obj"
pass
def get_xpath(self,xpath):
"Return the DOM element of the xpath OR the 'None' object if the element is not found"
dom_element = None
try:
dom_element = self.driver.find_element_by_xpath(xpath)
except Exception,e:
self.write(str(e),'debug')
return dom_element
def click_element(self,xpath):
"Click the button supplied"
link = self.get_xpath(xpath)
if link is not None:
try:
link.click()
except Exception,e:
self.write('Exception when clicking link with xpath: %s'%xpath)
self.write(e)
else:
return True
return False
def set_text(self,xpath,value):
"Set the value of the text field"
text_field = self.get_xpath(xpath)
try:
text_field.clear()
except Exception, e:
self.write('ERROR: Could not clear the text field: %s'%xpath)
if value is None:
return
else:
text_field.send_keys(value)
def get_text(self,xpath):
"Return the text for a given xpath or the 'None' object if the element is not found"
text = ''
try:
text = self.get_xpath(xpath).text
except Exception,e:
self.write(e)
return None
else:
return text.encode('utf-8')
def get_dom_text(self,dom_element):
"Return the text of a given DOM element or the 'None' object if the element has no attribute called text"
text = ''
try:
text = dom_element.text
except Exception, e:
self.write(e)
return None
else:
return text.encode('utf-8')
def select_dropdown_option(self, select_locator, option_text):
"Selects the option in the drop-down"
#dropdown = self.driver.find_element_by_id(select_locator)
dropdown = self.driver.find_element_by_xpath(select_locator)
for option in dropdown.find_elements_by_tag_name('option'):
if option.text == option_text:
option.click()
break
def check_element_present(self,xpath):
" This method checks if the web element is present in page or not and returns True or False accordingly"
try:
self.get_xpath(xpath)
except NoSuchElementException:
return False
return True
def submit_search(self):
" Clicks on Search button"
self.click_button(self.search_button)
def teardown(self):
" Tears down the driver"
self.driver.quit()
def write(self,msg,level='info'):
" This method use the logging method"
self.log_obj.write(msg,level)
def wait(self,wait_seconds=5):
" Performs wait for time provided"
time.sleep(wait_seconds)
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Conf_Reader.py
|
"""
A simple conf reader.
For now, we just use dotenv and return a key.
In future, you can make this a class and extend get_value()
"""
import dotenv,os
def get_value(conf,key):
"Return the value in conf for a given key"
value = None
try:
dotenv.load_dotenv(conf)
value = os.environ[key]
except Exception,e:
print 'Exception in get_value'
print 'file: ',conf
print 'key: ',key
return value
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/DriverFactory.py
|
"""
DriverFactory class
NOTE: Change this class as you add support for:
1. SauceLabs/BrowserStack
2. More browsers like Opera
"""
import dotenv,os
from selenium import webdriver
class DriverFactory():
def __init__(self,browser='ff',sauce_flag='N',browser_version=None,platform=None):
self.browser=browser
self.sauce_flag=sauce_flag
self.browser_version=browser_version
self.platform=platform
def get_web_driver(self,browser,sauce_flag,browser_version,platform):
if (sauce_flag == 'Y'):
web_driver = self.run_sauce(browser,sauce_flag,browser_version,platform)
elif (sauce_flag == 'N'):
web_driver = self.run_local(browser,sauce_flag,browser_version,platform)
else:
print "DriverFactory does not know the browser: ",browser
web_driver = None
return web_driver
def run_sauce(self,browser,sauce_flag,browser_version,platform):
" Run the test in Sauce Labs is sauce flag is 'Y'"
# Get the sauce labs credentials from sauce.credentials file
PY_SCRIPTS_PATH=os.path.dirname(__file__)
dotenv.load_dotenv(os.path.join(PY_SCRIPTS_PATH,"sauce.credentials"))
USERNAME = os.environ['sauce_username']
PASSWORD = os.environ['sauce_key']
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = platform
elif browser.lower() == 'ie':
desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = platform
elif browser.lower() == 'chrome':
desired_capabilities = webdriver.DesiredCapabilities.CHROME
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = platform
desired_capabilities['name'] = 'Testing End to END Basecamp Test'
return webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD)
)
def run_local(self,browser,sauce_flag,browser_version,platform):
if self.browser.lower() == "ff" or self.browser.lower() == 'firefox':
return webdriver.Firefox()
elif self.browser.lower() == "ie":
return webdriver.Ie()
elif self.browser.lower() == "chrome":
return webdriver.Chrome()
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/README.md
|
# 42Floors
A Selenium + Python test for 42Floors by Qxf2. This example uses the Page Object Pattern.
If you designed the test data at 42Floors intelligently, you could make this into a robust, repeatable test.
---------
1. SETUP
---------
a. Install Python 2.x
b. Install Selenium
c. Add both to your PATH environment variable
d. If you do not have it already, get pip
-------
2. RUN
-------
a. python Demo_Test.py -b ff
b. For more options: python Demo_Test.py -h
-----------
3. ISSUES?
-----------
a. If Python complains about an Import exception, please 'pip install $module_name'
b. If you are not setup with the drivers for the web browsers, you will see a helpful error from Selenium telling you where to go and get them
c. Others: Contact mak@qxf2.com
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/PageFactory.py
|
"""
PageFactory uses the factory design pattern.
get_page_object() returns the appropriate page object.
Add elif clauses as and when you implement new pages.
Pages implemented so far:
1. Home
2. Office Space
3. Co working
4. Listing
"""
from selenium import webdriver
from Home_Page import Home_Page
from Office_Space_Page import Office_Space_Page
from Coworking_Page import Coworking_Page
from Listing_Page import Listing_Page
def get_page_object(page_name,driver,base_url='https://42floors.com/'):
"Return the appropriate page object based on page_name"
test_obj = None
page_name = page_name.lower()
if page_name == "home":
test_obj = Home_Page(driver,base_url=base_url)
elif page_name == "office-space":
test_obj = Office_Space_Page(driver,base_url=base_url)
elif page_name == "coworking":
test_obj = Coworking_Page(driver,base_url=base_url)
elif page_name == "listing":
test_obj = Listing_Page(driver,base_url=base_url)
return test_obj
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Home_Page.py
|
"""
Page object model for the home page
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from Page import Page
class Home_Page(Page):
"Page object for the Home page"
def start(self):
self.url = ""
self.open(self.url)
# Assert Title of the Home Page
self.assertIn("Office Space Listings - Commercial Real Estate", self.driver.title)
"Xpath of all the field"
self.choose_market_dropdown = "//span[text()='Market']"
self.select_city_name = "//ul[@class='markets-dropdown dropdown-menu']/descendant::a[contains(text(),'%s')]"
#self.selected_market = "//a[@class='dropdown-toggle market']/text()[2]"
self.selected_market = "//a[@class='dropdown-toggle market']"
def choose_market(self,city_name):
"Choose the given city from the drop down list"
#San Francisco Office Space | 42Floors
self.click_element(self.choose_market_dropdown)
self.wait(2)
self.click_element(self.select_city_name%city_name)
self.wait(2)
return self.verify_selected_market(city_name)
def verify_selected_market(self,city_name):
if city_name in self.get_text(self.selected_market):
return True
else:
return False
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Base_Logging.py
|
"""
Qxf2 Services: A plug-n-play class for logging.
This class wraps around Python's logging module.
"""
import logging, os, inspect
import datetime
import sys
class Base_Logging():
def __init__(self,log_file_name=None,level=logging.DEBUG,format='%(asctime)s|%(caller_func)s|%(levelname)s| %(message)s'):
"Constructor for the logging class"
self.log_file_name=log_file_name
self.level=level
self.format=format
self.log = self.set_log(self.log_file_name,self.level,self.format)
def set_log(self,log_file_name,level,format,test_module_name=None):
"Set logging: 1 stream handler, one file handler"
if test_module_name is None:
test_module_name = self.get_calling_module()
log = logging.getLogger(test_module_name)
self.reset_log(log)
self.set_log_level(log,level)
self.add_stream_handler(log,level,format)
if log_file_name is None:
log_file_name = test_module_name + '.log'
self.add_file_handler(log,level,format,log_file_name)
return log
def get_calling_module(self):
"Get the name of the module"
self.calling_module = inspect.stack()[-1][1].split(os.sep)[-1].split('.')[0]
return self.calling_module
def reset_log(self,log):
"Reset the log handlers if they exist"
try:
log.handlers = []
except Exception,e:
print 'Failed to close the logger object'
print 'Exception', e
def set_log_level(self,log,level=logging.INFO):
log.setLevel(level)
def set_stream_handler_level(self,streamHandler,level):
streamHandler.setLevel(level)
def set_stream_handler_formatter(self,streamHandler,formatter):
streamHandler.setFormatter('')
def add_stream_handler(self,log,handlerLevel,handlerFormat):
streamHandler = logging.StreamHandler()
self.set_stream_handler_level(streamHandler,handlerLevel)
self.set_stream_handler_formatter(streamHandler,handlerFormat)
log.addHandler(streamHandler)
def set_file_handler_level(self,fileHandler,level):
fileHandler.setLevel(level)
def set_file_handler_formatter(self,fileHandler,formatter):
fileHandler.setFormatter(formatter)
def add_file_handler(self,log,handlerLevel,handlerFormat,log_file_name):
fileHandler = logging.FileHandler(log_file_name)
self.set_file_handler_level(fileHandler,handlerLevel)
formatter = logging.Formatter(handlerFormat)
self.set_file_handler_formatter(fileHandler,formatter)
log.addHandler(fileHandler)
def write(self,msg,level='info'):
fname = inspect.stack()[2][3] #May be use a entry-exit decorator instead
d = {'caller_func': fname}
if level.lower()== 'debug':
self.log.debug(msg, extra=d)
elif level.lower()== 'info':
self.log.info(msg, extra=d)
elif level.lower()== 'warn' or level.lower()=='warning':
self.log.warn(msg, extra=d)
elif level.lower()== 'error':
self.log.error(msg, extra=d)
elif level.lower()== 'critical':
self.log.critical(msg, extra=d)
else:
self.log.critical("Unknown level passed for the msg: %s", msg, extra=d)
'''
getLogLevel()
getLogHandler()- return list
getHandlerFormatter()
removeLogHandler()
'''
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/testrail.py
|
#
# TestRail API binding for Python 2.x (API v2, available since
# TestRail 3.0)
#
# Learn more:
#
# http://docs.gurock.com/testrail-api2/start
# http://docs.gurock.com/testrail-api2/accessing
#
# Copyright Gurock Software GmbH. See license.md for details.
#
import urllib2, json, base64
class APIClient:
def __init__(self, base_url):
self.user = ''
self.password = ''
if not base_url.endswith('/'):
base_url += '/'
self.__url = base_url + 'index.php?/api/v2/'
#
# Send Get
#
# Issues a GET request (read) against the API and returns the result
# (as Python dict).
#
# Arguments:
#
# uri The API method to call including parameters
# (e.g. get_case/1)
#
def send_get(self, uri):
return self.__send_request('GET', uri, None)
#
# Send POST
#
# Issues a POST request (write) against the API and returns the result
# (as Python dict).
#
# Arguments:
#
# uri The API method to call including parameters
# (e.g. add_case/1)
# data The data to submit as part of the request (as
# Python dict, strings must be UTF-8 encoded)
#
def send_post(self, uri, data):
return self.__send_request('POST', uri, data)
def __send_request(self, method, uri, data):
url = self.__url + uri
request = urllib2.Request(url)
if (method == 'POST'):
request.add_data(json.dumps(data))
auth = base64.encodestring('%s:%s' % (self.user, self.password)).strip()
request.add_header('Authorization', 'Basic %s' % auth)
request.add_header('Content-Type', 'application/json')
e = None
try:
response = urllib2.urlopen(request).read()
except urllib2.HTTPError as e:
response = e.read()
if response:
result = json.loads(response)
else:
result = {}
if e != None:
if result and 'error' in result:
error = '"' + result['error'] + '"'
else:
error = 'No additional error message received'
raise APIError('TestRail API returned HTTP %s (%s)' %
(e.code, error))
return result
class APIError(Exception):
pass
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/Listing_Page.py
|
"""
Page object model for the listing page
"""
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from Page import Page
class Listing_Page(Page):
"Page object for the Listing page"
def start(self):
self.url = ""
#self.open(self.url)
# Assert Title of the Home Page
#self.assertIn("Office Space Listings - Commercial Real Estate", self.driver.title)
"Xpath of all the field"
self.listing_header = "//div[@class='property-header']/descendant::h1[@itemprop='name']"
def get_listing_header(self):
return self.get_text(self.listing_header)
def verify_listing_name(self,listing_name):
if (listing_name == self.get_listing_header()):
return True
else:
return False
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/testrail.env
|
#Fill in your testrail credentials here
TESTRAIL_URL=
TESTRAIL_USER=
TESTRAIL_PASSWORD=
| 0 |
qxf2_public_repos
|
qxf2_public_repos/42Floors/data.conf
|
# We separate all the data needed to run the test from the code itself
# This way when you want to change the data you dont need to mess with scripts
#Market
CITY_NAME=San Francisco
#Office Space
MIN_SQFT=10000
MAX_SQFT=11000
EXPECTED_RESULT_FOR_SIZE=25
#Coworking
LISTING_NAME_20MISSION=SpherePad on Union
LISTING_HREF_20MISSION=/coworking/spherepad-on-union/524-union-st
| 0 |
qxf2_public_repos
|
qxf2_public_repos/rust-lambda-action/LICENSE
|
MIT License
Copyright (c) 2023 sravantit25
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| 0 |
qxf2_public_repos
|
qxf2_public_repos/rust-lambda-action/README.md
|
# rust-lambda-action
A GitHub Action to deploy AWS Lambda functions written in Rust. Use version 1.0.1
### Background
This uses <a href="https://www.cargo-lambda.info/">Cargo Lambda</a> which is a Cargo plugin, or subcommand that provides several commands to run, build and deploy Rust functions on Lambda. More details on how to use Cargo lambda can be found here - https://github.com/awslabs/aws-lambda-rust-runtime
### Use
Deploys the specified directory within the repo to the Lambda function. Uses Amazon Linux 2 runtime for building Lambda functions.
### Pre-requisites
In order for the Action to have access to the code, use the `actions/checkout@v3` job before it.
### Structure
Lambda code should be structured normally as Lambda would expect it.
### Inputs
- `lambda_directory`
The directory which has the Lambda code
- `iam_role`
The AWS IAM role required to deploy this Lambda
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_DEFAULT_REGION`
### Implementation
1. Used cargo lambda build, to first build for Amazon Linux 2 runtime
2. Once the code is built, used cargo lambda deploy to upload function to AWS. This step requires IAM role and AWS credentials.
### Example workflow1
This assumes you are running the workflow from a parent directory where the rust lambda that needs to be deployed is placed in a separate directory inside the parent directory.
```yaml
name: deploy-dummy-lambda
on:
push:
branches:
- master
paths:
- 'dummy_lambda/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Deploy code to Lambda
uses: qxf2/rust-lambda-action@v1.0.1
with:
lambda_directory: 'dummy_lambda'
iam_role: ${{ secrets.AWS_IAM_ROLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.SKYPE_SENDER_REGION }}
```
### Example workflow2
This assumes you are running the workflow from the directory where the rust lambda that needs to be deployed is present. In this case, for the lambda_directory you can simply use .
```yaml
name: deploy-dummy-lambda
on:
push:
branches:
- master
paths:
- 'dummy_lambda/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Deploy code to Lambda
uses: qxf2/rust-lambda-action@v1.0.1
with:
lambda_directory: .
iam_role: ${{ secrets.AWS_IAM_ROLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.SKYPE_SENDER_REGION }}
```
| 0 |
qxf2_public_repos
|
qxf2_public_repos/rust-lambda-action/action.yml
|
name: rust-lambda-action
description: Deploy Rust lambdas
inputs:
lambda_directory:
description: the directory which has the lambda code
required: true
iam_role:
description: the iam role required to deploy this lambda to production
required: true
AWS_ACCESS_KEY_ID:
description: aws access key id
required: true
AWS_SECRET_ACCESS_KEY:
description: aws secret access key
required: true
AWS_DEFAULT_REGION:
description: aws default region
required: true
runs:
using: composite
steps:
- name: Install cargo lambda
run: |
python -m pip install --upgrade pip
pip install cargo-lambda
shell: bash
- uses: actions/checkout@v3
- name: Build lambda function
run: |
cd ${{ inputs.lambda_directory }}
cargo lambda build --release --arm64
shell: bash
- name: Deploy lambda
run: |
cd ${{ inputs.lambda_directory }}
cargo lambda deploy --iam-role ${{ inputs.iam_role }}
env:
AWS_ACCESS_KEY_ID: ${{ inputs.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ inputs.AWS_DEFAULT_REGION }}
shell: bash
| 0 |
qxf2_public_repos
|
qxf2_public_repos/wtfiswronghere/LICENSE
|
MIT License
Copyright (c) 2018
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| 0 |
qxf2_public_repos
|
qxf2_public_repos/wtfiswronghere/README.md
|
## Improve your Python by fixing errors
We present small code samples that have errors in them. Initially, there is only one error and it is relatively easy to spot. As we move up challenges, there are multiple errors and subtle bugs.
### Why do this at all?
By working through these examples, we hope you get better at:
* reading errors
* debugging
* reading and editing other people's code
* Googling for specific issues
* solving errors on your own
### Motivation for creating this repository
We noticed that people learning new programming languages lack some foundational skills like the ability to read errors, the knowledge to self-correct their own mistakes, the skill to limit their attention to only the relevant lines of code, etc. This repository is a collection of simple errors that beginners are likely to hit when they start to write Python code. Our idea is to present exercises in which beginners can experience errors and try to solve them on their own.
This repository has been created and maintained by [Qxf2 Services](https://www.qxf2.com/?utm_source=wftiswronghere&utm_medium=click&utm_campaign=From%20github). Qxf2 provides QA consultancy services for startups. If you found this repository useful, please let us know by giving us a star on GitHub.
### How to use this repository
We suggest you do the following
1. [Fork](https://qxf2.com/blog/github-workflow-contributing-code-using-fork/) this repository
2. In your terminal prompt (git bash, command prompt, etc.), navigate to each challenge directory (e.g.: `01_challenge`)
3. Run the one Python script in the challenge directory (`python 01_challenge.py`)
4. It should throw an error that reads similar to the `.png` in the challenge directory
5. Fix the error and rerun
6. If all goes good, you should see the output of running fizz buzz
7. Once you fix the issue, update the readme file in the challenge directory (`01_readme.md`) with:
a. what part of the error message gave you a clue
b. how you set about solving the issue (e.g.: I Googled `XXXX` that didn't help me narrow down my problem. After that, I tried Googling `Python XXXX` and finally ended up Googling for `Python XXXX error`. Then I found a page that looked promising because `YYYY`. Much thanks to reddit user [/u/danielsgriffin](https://www.reddit.com/user/danielsgriffin) for this tip!)
c. summarize what you learned.
8. Don't forget to commit your fixed code and updated readme
9. __Pro tip:__ Once you are setup, try your best to timebox each exercise to no more than 10-minutes. We recommend this tip for even rank beginners who know nearly nothing about Python!
NOTE: To get the most out of these exercises, we think beginners should use an IDE (e.g.: Visual Studio Code), use git and use one git branch per challenge. These are peripheral habits to the main exercises but they will go a long way in making you more comfortable in working with code.
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/08_challenge/08_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
class Fizz_Buzz:
"Class to implement FizzBuzz for multiples of 3 and 5"
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
num1 = 3
num2 = 5
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
"Initialize the fizzbuzz object"
fizzbuzz_obj = Fizz_Buzz()
fizzbuzz_obj.fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/05_challenge/myfile.txt
|
3
5
99
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/05_challenge/05_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of reading the numbers from file in Python
The problem is:
For all integers between 1 and 99 (include both):
# Read the input 3,5 and 99 from the input file
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
with open('mifile.txt','r') as f:
print 'i have created'
num1 = int(f.readline())
num2=int(f.readline())
max_num = int(f.readline())
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/11_challenge/11_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%3==0:
print(i,"fizz")
elif i%5==0:
print(i,"Buzz")
elif i%3==0 and i%5==0:
print(i,"fizzbuzz")
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/03_challenge/03_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%3==0 and i%5==0:
print(i,"fizzbuzz")
elif i%3==0:
print(i,"fizz")
elif i%5==0:
print(i,"Buzz")
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz('16')
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/09_challenge/09_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
num1 = 3
num2 = 5
# Google for 'range in python' to see what it does
for i in range(6,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/10_challenge/fizzbuzz.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%3==0 and i%5==0:
print(i,"fizzbuzz")
elif i%3==0:
print(i,"fizz")
elif i%5==0:
print(i,"Buzz")
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/10_challenge/10_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
import fizzbuzz
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/04_challenge/04_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
num1 = 3
num2 = 5
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/02_challenge/02_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%3==0 and i%5==0:
print(i,"fizzbuzz")
elif i%3==0:
print(i,"fizz")
elif i%5==0:
print(i,"Buzz")
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz()
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/07_challenge/07_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
num1 = 3
num2 = 5
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(99)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/13_challenge/13_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz
five_mul = 'buzz'
num1 = 3
num2 = 5
# Google for 'range in python' to see what it does
for i in range(1,max_num)
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzzy(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/01_challenge/01_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
num1 = 3
num2 = 5
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1=0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/12_challenge/12_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
class FizzBuzz():
def __init__(self):
"Initializer"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
self.num1 = 3
self.num2 = 4
self.three_mul = 'fizz'
self.five_mul = 'buzz'
def fizzbuzz(self,max_num):
"This method implements FizzBuzz"
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%self.num1==0 and i%self.num2==0:
print(i,self.three_mul+self.five_mul)
elif i%self.num1==0:
print(i,self.three_mul)
elif i%self.num2==0:
print(i,self.five_mul)
#----START OF SCRIPT
if __name__=='__main__':
#Testing the fizzbuzz class
test_obj = FizzBuzz()
test_obj.fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/06_challenge/06_challenge.py
|
"""
We will use this script to teach Python to absolute beginners
The script is an example of Fizz-Buzz implemented in Python
The FizzBuzz problem:
For all integers between 1 and 99 (include both):
# print fizz for multiples of 3
# print buzz for multiples of 5
# print fizzbuzz for multiples of 3 and 5"
"""
import conf
def fizzbuzz(max_num):
"This method implements FizzBuzz"
# adding some redundant declarations on purpose
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
num1 = conf.num1
num2 = conf.num
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(100)
| 0 |
qxf2_public_repos/wtfiswronghere
|
qxf2_public_repos/wtfiswronghere/06_challenge/conf.py
|
num1 = 3
num2 = 5
| 0 |
qxf2_public_repos
|
qxf2_public_repos/wisdomofreddit/index_comments.py
|
"""
Index comments within a csv file.
Current behavior:
a) Accepts index name as optional command line argument
b) By default creates index in the ./index directory relative to this file
c) Will not create an index unless command line parameter is true
"""
import os,csv,re,time
from optparse import OptionParser
from whoosh import index
from whoosh.fields import Schema, ID, TEXT, NUMERIC
from whoosh.analysis import StemmingAnalyzer
def get_schema():
"Return the schema"
schema = Schema(url=TEXT(stored=True),
comment=TEXT(stored=True,analyzer=StemmingAnalyzer()),
score=NUMERIC(stored=True),
created=TEXT(stored=True),
subreddit=TEXT(stored=True),
parent=TEXT(stored=True),
gilded=NUMERIC(stored=True),
name=TEXT(stored=True)
)
return schema
def create_index(index_dir,schema,index_name):
"Create a new index"
if not os.path.exists(index_dir):
os.mkdir(index_dir)
ix = index.create_in(index_dir,schema=schema,indexname=index_name)
ix = open_index(index_dir,index_name)
return ix
def open_index(index_dir,index_name):
"Open a given index"
return index.open_dir(index_dir,indexname=index_name)
def get_index(index_dir,schema,index_name,new_index_flag):
"Get the index handler object"
if new_index_flag.lower()=='true':
ix = create_index(index_dir,schema,index_name)
else:
ix = open_index(index_dir,index_name)
return ix
def pre_process_csv(csvfile):
"Pre-process the CSV file"
#a. remove new lines that are not needed
#b. remove non ASCII character
#c. remove empty lines
#d. remove header line
print "Pre-processing csv file ..."
header_row = ['link_id','id','score','body','name','created_utc','subreddit','parent_id','gilded']
clean_lines = []
fp = open(csvfile,'rb')
lines = fp.read().splitlines()
fp.close()
current_line = ''
for line in lines:
if line.strip() == '':
continue
if line.split(',') == header_row:
continue
line = re.sub(r'[^\x00-\x7F]+',' ', line)
line = line.strip()
if len(line)>3:
if line[0:3] == 't3_':#Check if it is a new row
if current_line != '':
clean_lines.append(current_line)
current_line = line
else: #If not new row, stitch to current line
current_line += ' ' + line
else:
current_line += ' ' + line
clean_lines.append(current_line)
return clean_lines
def update_index(csvfile,index_name=None,new_index_flag='false'):
"Create or update an index with the data in the csvfile"
csvfile = os.path.abspath(csvfile)
csvfile_exists = os.path.exists(csvfile)
if csvfile_exists:
line_count = 0
schema = get_schema()
index_dir = os.path.join(os.path.dirname(__file__),'indexdir')
if not os.path.exists(index_dir):
os.mkdir(index_dir)
ix = get_index(index_dir,schema,index_name,new_index_flag)
writer = ix.writer()
my_csv = pre_process_csv(csvfile)
line_count += 1
my_reader = csv.reader(my_csv,delimiter=',',quotechar='"')
print 'About to index the file'
for row in my_reader:
line_count += 1
if len(row) != 9:
print 'Error in file. Row is malformed'
print 'Offending row:',row
continue
#print 'About to process: ',row[0],row[1],row[2],row[3][0:140]
#1. URL
url = 'http://www.reddit.com/comments/%s/x/%s'%(row[0].split('t3_')[-1],row[1])
url = unicode(url,errors='ignore')
#2. Comment
comment = unicode(row[3],errors='ignore')
#3. Score
try:
score = int(row[2])
except Exception,e:
print 'Unable to process score: ',row[2]
score = 35
#4. Created
created = unicode(row[5])
#5. Subreddit
subreddit = unicode(row[6])
#6. Parent
parent = unicode(row[7].split('_')[-1])
#7. Gilded
try:
gilded = int(row[8])
except Exception,e:
print 'Unable to process gilded: ',row[8]
gilded = 0
#8. Name
name = unicode(row[4])
writer.add_document(url=url,
comment=comment,
score=score,
created=created,
subreddit=subreddit,
parent=parent,
gilded=gilded,
name=name)
if line_count%200 == 0:
print '.',
writer.commit()
else:
print 'Unable to locate the csv file: ',csvfile
#---START OF SCRIPT
if __name__=='__main__':
start_time = time.time()
print "Script start"
usage = "\n----\n%prog -f csv file to be indexed -n <OPTIONAL: Index name> -c <OPTIONAL: Create new index> \n----\nE.g.: %prog -n wor -c True \n---"
parser = OptionParser(usage=usage)
parser.add_option("-f","--filename",
dest="csvfile",
help="Path of the csv file you want indexed")
parser.add_option("-n","--indexname",
dest="index_name",
help="Name of the index you want to use")
parser.add_option("-c","--newindex",
dest="new_index_flag",
default="false",
help="Create a new index?")
parser.add_option("-d","--directory",
dest="csv_dir",
help="Directory with csvs to be indexed")
(options,args) = parser.parse_args()
if options.csv_dir is not None:
for my_file in os.listdir(os.path.abspath(options.csv_dir)):
my_file = os.path.abspath(options.csv_dir) + os.sep + my_file
if os.path.isfile(my_file) is True:
print 'About to index file: ',my_file.split(os.sep)[-1]
update_index(my_file,
index_name=options.index_name,
new_index_flag=options.new_index_flag)
options.new_index_flag = 'false'
else:
update_index(options.csvfile,
index_name=options.index_name,
new_index_flag=options.new_index_flag)
duration = int(time.time()-start_time)
print 'Duration: %d'%duration
| 0 |
qxf2_public_repos
|
qxf2_public_repos/wisdomofreddit/README.md
|
#Wisdom of reddit setup
Code to get Wisdom of reddit up and running locally
----------------
1. PYTHON SETUP
----------------
a. Install Python 2.x
b. Add to your PATH environment variable
c. If you do not have it already, get pip
d. 'pip install flask'
e. Install Whoosh
g. Install the csv library ('pip install csv')
--------------
2. DATA SETUP
--------------
a. Sign up for bigquery
b. Run this query
SELECT link_id,id,score,body,name,created_utc,subreddit,parent_id,gilded
FROM [fh-bigquery:reddit_comments.2015_01],
[fh-bigquery:reddit_comments.2015_02],
[fh-bigquery:reddit_comments.2015_03],
[fh-bigquery:reddit_comments.2015_04],
[fh-bigquery:reddit_comments.2015_05],
[fh-bigquery:reddit_comments.2015_06],
[fh-bigquery:reddit_comments.2015_07],
[fh-bigquery:reddit_comments.2015_08],
[fh-bigquery:reddit_comments.2015_09],
[fh-bigquery:reddit_comments.2015_10],
[fh-bigquery:reddit_comments.2010],
[fh-bigquery:reddit_comments.2011],
[fh-bigquery:reddit_comments.2012],
[fh-bigquery:reddit_comments.2013],
[fh-bigquery:reddit_comments.2014],
[fh-bigquery:reddit_comments.2007],
[fh-bigquery:reddit_comments.2008],
[fh-bigquery:reddit_comments.2009]
where score>35 and (length(body) - length(replace(body,' ','')) + 1) > 150
NOTE: This query will process 450 GB when run.
c. Export the table to csv format. Since the table is big, you will have multiple csvs
d. Store the csvs in ./data/
d. Run python index_comments.py -d ./data -n wor -c True (this step takes hours)
e. NOTE: -c True should be used only if you want to create the index from scratch
f. If things go well, you should see a ./indexdir created with a bunch of wor_*.seg files
-------
3. RUN
-------
a. python wisdomofreddit.py (this will run on port 6464 of your local host)
b. If things go well, you should see the Wisdom of reddit homepage and you should be able to search
-----------
4. ISSUES?
-----------
a. Contact mak@qxf2.com
| 0 |
qxf2_public_repos
|
qxf2_public_repos/wisdomofreddit/random_queries.txt
|
"Chess player here"
"cricket player here"
"engineer here"
"worlds best"
"holocaust survivor"
ex-cia
"funniest line"
"best prank"
"dentist here"
"harry potter"
"worst writer"
"writers block"
"russian here"
"in soviet russia"
"american politics"
"bill clinton"
"barack obama"
"president obama"
"popular conspiracy"
"biggest fail"
"worst enemy"
ex-boyfriend
"relationship problems"
"divorcee here"
"happily remarried"
"hardest puzzle"
"best trek"
"running advice"
depression
"benefits of meditation"
akido
mma training
"weight loss"
"boxing champion"
"worlds best pizza"
yummy food
"dumped my girlfriend"
"deliberate practice"
"most embarrassing"
"I lied through my teeth"
"remarkable story"
running marathon
best dragon
scary dinosaur
"I've been sober for"
"I messed up"
"amazing discovery"
"epic story"
"brilliant story"
archery practice
"great hobby"
circlejerk
academia cheating
doublethink
north korea
"fled north korea"
"fled china"
"wall street"
raj rajaratnam
singing sensation
"forest for the trees"
"tournament poker"
"Why do people"
bernie madoff
ellen pao
"single greatest"
"single greatest invention"
depression advice
"bugging me"
biggest scam
"steep learning curve"
fired negligence
weird court case
"weird neighbour"
cuttlefish
"late to the party"
Delicatessen counter
"best deli in"
obamacare ELI5
"Senate staffer"
"I'm a lawyer"
"questioned by police"
talking to a taxi driver
"Went to school with"
"Liver Transplant"
luckiest sob
tl;dr
idi amin
escaped pol pot
"holocaust of Cambodia"
narrow escape
iranian revolution
"I love stories like this"
wonderful story
ordinary galaxy
invest stock market
legendary coach
"Board of Trustees"
Torgeson story
"Bat biologist here"
mammals tough
"written several papers on the subject"
villa in Dubai
Seychelles
"how to launder money"
enron scandal
perfect crime
"the cabal"
reddit drama
"explosive speed"
banana olive
hungover
coworker passive
"direct patient care"
"nearly died"
"Jehovah's Witness family"
blood transfusion
"oil Sheikh"
"marketing professional"
"middle of nowhere"
wind turbine
wedding DJ
footprint blood
coroner
"off the Golden Gate Bridge"
"survivor of suicide"
"lesson of life"
"reign of terror"
"was a slave"
ancient greece
"fall from grace"
past prime
time travel
time dilation
kissing movies
"my first kiss"
overestimating chances
drunk adventure
"Stationed in afghanistan"
ptsd ied
work emergency room
NYPD bronx
broken elevator
broken hand
"morning routine"
"trip to london"
receptionist boss
craigslist true story
animal research dog
"couple of dates"
"story of betrayal"
"hiding in the basement"
"grew up in pakistan"
tofu
sushi
entire life dedicated
mathlete
greatest lawyer
graduation faux
greatest exit
infamous incident
arsonist
neighbor arrested
corporate bullshit
bill gates
"I told you so"
plagarism
"hate mail"
"fashion show"
"poet here"
anarchy office
"anonymous call"
"shaving in the morning"
"attention to detail"
journalist scoop
prodigy parent
"overbearing parents"
brilliant insight
big pharma
big oil
cancer cure
golden goose
googler here
impostor real-life
writer soap
"as a writer"
love learn
"death bed"
revenge petty
"biggest misconception"
"horrible habit"
"I said no"
"aa meetings"
"missing person"
"kidnapped me"
"lost my mind"
"secret code"
summer treehouse
Election cycle
coup staged
brutal romania
TIL mexico
dosa
sick fever
dog catch
liberty attack
shooting survivor
"weight loss journey"
diet fell down
apartment sound
speeding ticket
obscure fact
crossword puzzles
"reply all"
"minor brain damage"
dishwashing hobby
wheelchair airport
"crazy small world"
"massage therapist" funny
"early internet"
"family run business"
"worked at an auction house"
"family run business"
"worst thing to ever happen to me"
"I was the employee"
"same thing happened"
grocery checkout
"self driving cars"
"my bad"
"I call bullshit"
"called to investigate murder"
| 0 |
qxf2_public_repos
|
qxf2_public_repos/wisdomofreddit/wisdomofreddit.py
|
"""
wisdomofreddit is a search app for high quality reddit comments
"""
from whoosh import index
from whoosh import scoring
from whoosh.qparser import QueryParser
from flask import Flask
from flask import render_template
from flask import request
from flask import redirect, url_for
from flask import _request_ctx_stack
import os,csv,re,random,sqlite3
from ast import literal_eval
app = Flask(__name__)
def open_index(index_dir,index_name):
"Open a given index"
ix = index.open_dir(index_dir,indexname=index_name)
return ix
def get_random_query():
"Return a random query"
query = "Kasparov"
random_query_file = os.path.join(os.path.dirname(__file__),'random_queries.txt')
with open(random_query_file,'r') as fp:
lines = fp.readlines()
query = random.choice(lines)
query = query.strip()
return query
def search_comments(query):
"Ask whoosh to return the top 20 matches"
all_results = []
try:
index_dir = os.path.join(os.path.dirname(__file__),'indexdir')
ix = open_index(index_dir,index_name='wor')
if os.path.exists(r'/tmp/'):
fp = open('/tmp/query.log','a')
fp.write(str(query)+"\n")
fp.close()
with ix.searcher() as searcher:
parser = QueryParser("comment",ix.schema)
results = searcher.search(parser.parse(query),limit=25)
for result in results:
all_results.append(result)
if os.path.exists(r'/tmp/'):
fp = open('/tmp/results.log','a')
fp.write(str(all_results)[:1]+"\n")
fp.close()
except Exception,e:
if os.path.exists(r'/tmp/'):
fp = open('/tmp/error.log','a')
fp.write(str(e))
fp.close()
return all_results
@app.route("/")
def index_page():
"The search page"
return render_template('index.html')
@app.route("/search")
def search():
"Return relevant comments"
query = request.args.get('query')
if query.strip() == "":
return return_random_prompt()
else:
results = search_comments(query)
return render_template('results.html', query=query, results=results)
@app.route("/random")
def return_random_prompt():
"Return a random comment"
query = get_random_query()
results = []
while results == []:
results = search_comments(query)
return render_template('random.html', results=results)
@app.route("/about")
def about():
"The about page"
return render_template('about.html')
@app.route("/why")
def why():
"The why page"
return render_template('why.html')
@app.route("/uses")
def use_cases():
"The uses page"
return render_template('uses.html')
@app.route("/pro-tips")
def pro_tips():
"The pro-tips page"
return render_template('pro-tips.html')
@app.route("/examples")
def examples():
"The examples page"
return render_template('examples.html')
@app.route("/blog")
def blog():
"The blog"
return render_template('blog.html')
@app.route("/blogposts/real-scary-creepy-paranormal-stories")
def paranormal():
"Paranormal stories"
return render_template('blogposts/real-scary-creepy-paranormal-stories.html')
@app.route("/blogposts/mundane-coincidence-stories")
def mundane_coincidences():
"Mundane coincidences"
return render_template('blogposts/mundane-coincidence-stories.html')
@app.route('/api-tutorial-main')
def api_tutorial_main():
"Api Tutorial main page- If method is post redirect to api tutorial redirect with name and comments"
return render_template('api-tutorial-main.html')
@app.route('/api-tutorial-redirect',methods=['GET','POST'])
def api_tutorial_redirect():
"Api Tutorial Redirect page- Saves the name and comments and displays all the name and comments"
db_file = os.path.join(os.path.dirname(__file__),'tmp','wisdomofreddit.db') #Create a variabe as db_file to create the DB file in the temp directory
connection_obj = sqlite3.connect(db_file) #Connect to the db
cursor_obj = connection_obj.cursor()
if request.method == 'POST':
user_name = request.form['submitname']
user_comments = request.form['submitcomments']
value = [user_name,user_comments]
cursor_obj.execute("INSERT INTO comments VALUES (?,?)",value) #Insert values into the table. FYI comments table has already been created in the DB
connection_obj.commit() #Save the changes
results = cursor_obj.execute("SELECT * FROM comments") #Hold all the name and comments in a variable
return render_template('api-tutorial-redirect.html', results=results.fetchall())
@app.route('/trial-page-bug')
def trial_page_bug():
"Trial page for practicing bug reports"
return render_template('trial_page_bug.html')
@app.route('/trial-redirect-page-bug',methods=['GET','POST'])
def trial_redirect_page_bug():
"Trial redirects page specifies there is no validation for login"
return render_template('trial_redirect_page_bug.html')
@app.route('/retrieve-wrong-data')
def retrieve_wrong_data():
"Trial page for practicing bug reports redirect with name and comments"
return render_template('retrieve_wrong_data.html')
@app.route('/retrieve-wrong-data-redirect-page',methods=['GET','POST'])
def retrieve_wrong_data_redirect_page():
"Trial redirects page specifies that retieved username and comments are not correct"
db_file = os.path.join(os.path.dirname(__file__),'tmp','wisdomofreddit.db') #Create a variabe as db_file to create the DB file in the temp directory
connection_obj = sqlite3.connect(db_file) #Connect to the db
cursor_obj = connection_obj.cursor()
results = cursor_obj.execute("SELECT * FROM comments") #Hold all the name and comments in a variable
return render_template('retrieve_wrong_data_redirect_page.html', results=results.fetchall())
@app.route('/no-response')
def no_response():
"Trial page for practicing bug reports of no response"
return render_template('no_response.html')
@app.route('/no-response-page-bug',methods=['GET','POST'])
def no_response_page_bug():
"Trial page with no response after clicking the button"
return render_template('no_response_page_bug.html')
@app.route('/click-button-bug')
def click_button_bug():
"Trial page specifies no response after clicking the login button"
return render_template('click_button_bug.html')
#---START
if __name__=='__main__':
app.run(host='0.0.0.0',port=6464)
| 0 |
qxf2_public_repos/wisdomofreddit/static
|
qxf2_public_repos/wisdomofreddit/static/css/wor_style.css
|
/*Stylesheet for WisdomOfReddit*/
body {
padding-top: 40px;
font-size: 16px;
font-family: "Open Sans",serif;
}
h1 {
font-family: "Abel", Arial, sans-serif;
font-weight: 400;
font-size: 40px;
color: #000000;
line-height: 1.0;
}
h2 {
font-family: "Abel", Arial, sans-serif;
}
h3 {
font-family: "Abel", Arial, sans-serif;
}
p {
line-height: 2.0;
}
li {
line-height: 2.0;
}
/* Override B3 .panel adding a subtly transparent background */
.panel {
background-color: rgba(255, 255, 255, 0.9);
}
.toppy {
padding-top: 70px;
}
.comment {
/* Src: http://codepen.io/martinwolf/pen/qlFdp */
display: block; /* Fallback for non-webkit */
display: -webkit-box;
margin: 0 auto;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.p_result{
line-height: 1.8;
}
.margin-base-vertical {
margin: 40px 0;
}
.wor_copyright {
font-family: "Abel", Arial, sans-serif;
font-size: 12px;
}
/*Add vertical space above divs*/
.top-space-5 {
margin-top:5px;
}
.top-space-10 {
margin-top:10px;
}
.top-space {
margin-top:10px;
}
.top-space-15 {
margin-top:15px;
}
.top-space-20 {
margin-top:20px;
}
.top-space-25 {
margin-top:25px;
}
.top-space-30 {
margin-top:30px;
}
.top-space-40 {
margin-top:40px;
}
.top-space-50 {
margin-top:50px;
}
/*Logo*/
img.logo{
max-height: 100px;
max-width: 250px;
}
grey-text {
color: #7e7e7e;
margin-top: 5px;
}
.toppy-10 {
padding-top: 10px;
}
.toppy-20 {
padding-top: 20px;
}
.toppy-30 {
padding-top: 30px;
}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/api-tutorial-main.html
|
{% include "header.html" %}
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<h1 class="margin-base-vertical">Qxf2 Api Tutorial Main Page</h1>
<p class="text-justify">
This page is created by <a href="http://www.qxf2.com">Qxf2 Services</a> to help practice different API Http Methods like Get, Post, Put and Delete transactions. In api tutorial page you can test the post transaction by entering your Name and Comments and clicking on Submit.
</p>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="margin-base-vertical text-center">Writers, find what real people say!</h1>
<form action="/api-tutorial-redirect" method="post" class="margin-base-vertical">
<p class="input-group">
<span class="input-group-addon"><span class="icon-arrow-right"></span></span>
<input type="text" class="form-control input-lg" name="submitname" placeholder="Name">
</p>
<p class="input-group">
<span class="input-group-addon"><span class="icon-arrow-right"></span></span>
<input type="text" class="form-control input-lg" name="submitcomments" placeholder="Comments">
</p>
<p class="text-center top-space-40">
<button type="submit" class="btn btn-success btn-lg">Submit</button>
</p>
</form>
</div>
</div>
</div>
{% include "footer.html" %}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/no_response_page_bug.html
|
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<p>Page requested is not found:404 error
</div>
</div>
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/why.html
|
{% include "header.html" %}
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<blockquote class="blockquote-reverse">
<p>... life is infinitely stranger than anything which the mind of man could invent.</p>
<footer>Sir Arthur Conan Doyle, <cite>A Case of Identity</cite></footer>
</blockquote>
</div>
<div class="col-md-10 col-md-offset-1">
<h1>Why?</h1>
<p class="text-justify">
Ordinary people in relatable settings are at the heart of many great stories. Yet, it is incredibly hard to Google about the lives, experiences and characteristics of ordinary people. Inspired by <a href="http://writetodone.com/the-non-google-research-tool-that-makes-writing-easier/">this article</a>, I have set out to help writers peek into the lives and events of normal folk. I do this by tapping into comments written by ordinary people on <a href="https://reddit.com">reddit.com</a> - one of the largest online communities in the world, with more than 230 million users.
</p>
</div>
{% include "separator_1.html" %}
<div class="col-md-10 col-md-offset-1">
<h1>Goal</h1>
<p class="text-justify">
Paraphrasing my favorite author, Sir Arthur Conan Doyle, Wisdom of reddit exists to help writers hover over a great online community and peep in at the queer things which are going on, the strange coincidences, the plannings, the cross-purposes, the wonderful chains of events, working through generations, and leading to the most outre results.
</p>
</div>
</div>
{% include "separator_1.html" %}
{% include "footer.html" %}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/blog.html
|
{% include "header.html" %}
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<blockquote class="blockquote-reverse">
<p>There is no great writing, only great rewriting.</p>
<footer>Justice Brandeis</footer>
</blockquote>
</div>
<div class="col-md-10 col-md-offset-1">
<div class="row">
<h1>Wisdom of reddit blog</h1>
</div>
<div class="row toppy-20">
<h3><a href="/blogposts/mundane-coincidence-stories">2. Real people and the mundane coincidences they have experienced</a></h3>
<p class="text-justify">
I like short stories that have a twist at the end. O'Henry is one of my favorite authors. I love surprising twists at the end of stories. Are you looking for inspiration for your next O'Henry-esque short story? Here is a collection of popular reddit threads with hundreds of relevant comments written by normal people. Happy searching, happy reading!
</p>
{% include "separator_1.html" %}
<h3 class="toppy-20"><a href="/blogposts/real-scary-creepy-paranormal-stories">1. Real people write about their creepy, scary and paranormal experiences</a></h3>
<p class="text-justify">
Discover what normal people have writtern about the creepy, scary and paranormal experiences they have had. This post is a gold mine for anyone looking for inspiration for their next horror story. It is also a great starting point for anyone looking to binge read real life horror stories.
</p>
</div>
</div>
{% include "separator_1.html" %}
{% include "footer.html" %}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/form.html
|
<form action="/search" method="get" class="margin-base-vertical">
<p class="input-group">
<span class="input-group-addon"><span class="icon-arrow-right"></span></span>
<input type="text" class="form-control input-lg" name="query" placeholder="Leave empty for random comments">
</p>
<p class="text-center top-space-40">
<button type="submit" class="btn btn-success btn-lg">Find me some tangents!</button>
</p>
</form>
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/example_searches.html
|
<div class="row toppy-20">
<div class="col-md-10 col-md-offset-1 toppy-10">
<strong>Examples:</strong>
<code><a href="/search?query=construction+crew">construction crew</a></code>
<code><a href="/search?query=%22dentist+here%22">"dentist here"</a></code>
<code><a href="/search?query=dinosaur+fossil">dinosaur fossil</a></code>
<code><a href="/search?query=ex-marine">ex-marine</a></code>
<code><a href="/search?query=%22Googler+here%22">"Googler here"</a></code>
<code><a href="/search?query=%22grew+up+in+the+90s%22">"grew up in the 90s"</a></code>
<code><a href="/search?query=%22syrian+here%22">"syrian here"</a></code>
<code><a href="/search?query=quit+job">quit job</a></code>
<code><a href="/search?query=%22lived+in+pakistan%22">"lived in pakistan"</a></code>
<code><a href="/search?query=neighbor+arrest">neighbor arrest</a></code>
<code><a href="/search?query=%22second+tour+of+iraq%22">"second tour of iraq"</a></code>
<code><a href="/search?query=snake+theory">snake theory</a></code>
<code><a href="/search?query=%22won+the+lottery%22">"won the lottery"</a></code>
<code><a href="/search?query=%22worked+at+walmart%22+">"worked at walmart"</a></code>
</div>
</div>
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/index.html
|
{% include "header.html" %}
<div class="container toppy">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="margin-base-vertical text-center">Writers, find what real people say!</h1>
{% include "form.html" %}
</div>
</div>
</div>
{% include "example_searches.html" %}
{% include "separator_1.html" %}
{% include "footer.html" %}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/trial_redirect_page_bug.html
|
{% include "header.html" %}
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<h1 class="margin-base-vertical">Qxf2 Trial redirect page for bug report</h1>
<p class="text-justify">
This page is created by <a href="http://www.qxf2.com">Qxf2 Services</a> to help practice how to report the bug by introducing bugs in the application
</p>
</div>
<div class="col-md-10 col-md-offset-1">
<p class="text-justify">
Now the user can login by entering any username and password without any validation
</p>
</div>
</div>
{% include "footer.html" %}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/about.html
|
{% include "header.html"%}
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<blockquote class="blockquote-reverse">
Ordinary life is pretty complex stuff. <footer>Harvey Pekar</footer>
</blockquote>
</div>
<div class="col-md-10 col-md-offset-1">
<h1 class="margin-base-vertical">About Wisdom of reddit</h1>
<p class="text-justify">
Wisdom of reddit helps writers research the events, activities and lives of normal people. I think it will be a valuable research tool for writers looking to incorporate some realism into their stories. The results also help you discover online communities relevant to your interests. Wisdom of reddit is a property of <a href="http://www.qxf2.com">Qxf2 Services</a> and is being developed by <a href="https://www.linkedin.com/in/arunkumar-muralidharan-808ba810">Arunkumar Muralidharan</a>.
</p>
</div>
{% include "more_about.html"%}
</div>
{% include "footer.html"%}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/more_about.html
|
<div class="col-md-10 col-md-offset-1">
<u><h3>Technical details</h3></u>
<p class="text-justify">
Wisdom of reddit has indexed about 1.2 million comments out of a possible <a href="https://bigquery.cloud.google.com/dataset/fh-bigquery:reddit_comments">1.7 billion</a> comments. All comments that were chosen were at least 150 words long and have scored more than 35 upvotes. The comments span from October, 2007 to September, 2015. The tech stack of Wisdom of reddit includes: Python, Flask, Whoosh, Whoosh's default BM25f scoring algorithm, BigQuery, nginx, git and is hosted on EC2.
</p>
</div>
<div class="col-md-10 col-md-offset-1">
<u><h3>Known limitations</h3></u>
<p class="text-justify">
Wisdom of reddit has indexed only a small subset (~0.07%) of all reddit comments. All the 1.2 million comments chosen are at least 150 words long and have scored more than 35 upvotes. The comments span from October, 2007 to September, 2015. So it is possible that a comment you were looking for is not showing up.
</p>
</div>
<div class="col-md-10 col-md-offset-1">
<u><h3>What's cooking</h3></u>
<p class="text-justify">
I am working on the following (in order of priority):
<ul>
<li class="text-justify">Including relevant threads in the search results</li>
<li class="text-justify">Letting search queries be more natural</li>
<li class="text-justify">A more creative writing prompt that incorporates images and words</li>
<li class="text-justify">Covering all reddit comments - instead of just a sub set</li>
<li class="text-justify">Incorporating date and upvotes into the search results</li>
</ul>
A great way to get me to change my priorities, is to email me at mak@qxf2.com.
</p>
</div>
<div class="col-md-10 col-md-offset-1">
<u><h3>Feedback</h3></u>
<p class="text-justify">
If you find bugs or have suggestions, <u>please send feedback to: <b>mak@qxf2.com</b></u>.
</p>
</div>
<div class="col-md-10 col-md-offset-1">
<u><h3>Donations</h3></u>
<p class="text-justify">
Thanks - that's very thoughtful of you. I am fortunate enough to not need the money as of today. If Wisdom of reddit helped you, and you *really* feel like giving, please <a href="https://wikimediafoundation.org/wiki/Ways_to_Give">donate to the Wikimedia foundation</a> instead.
</p>
</div>
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/no_response.html
|
{% include "header.html" %}
<div class="container toppy">
<div class="col-md-10 col-md-offset-1">
<h1 class="margin-base-vertical">Qxf2 Trial Page for Bug Reporting</h1>
<p class="text-justify">
This page is created by <a href="https:/www.qxf2.com">Qxf2 Services</a> to help practice how to report the bug by introducing bugs in the application
</p>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="margin-base-vertical text-centre">Enter the name and password in the provided field</h1>
<form action="/no-response-page-bug" method="post" class="margin-base-vertical">
<p class="input-group">
<span class="input-group-addon"><span class="icon-arrow-right"></span></span>
<input type="text" class="form-control input-lg" name="submitname" placeholder="Username">
</p>
<p class="input-group">
<span class="input-group-addon"><span class="icon-arrow-right"></span></span>
<input type="text" class="form-control input-lg" name="password" placeholder="Password">
</p>
<p class="text-center top-space-40">
<button type="submit" class="btn btn-success btn-lg">Login</button>
</p>
</form>
</div>
</div>
</div>
{% include "footer.html" %}
| 0 |
qxf2_public_repos/wisdomofreddit
|
qxf2_public_repos/wisdomofreddit/templates/no_results.html
|
<div class="row top-space-20">
<div class="col-md-10 col-md-offset-1 panel">
<p class="text-justify">
Bummer! No results were found for your search term: <b>{{ query }}</b>.<br>
</p>
<p class="text-justify">
Thank you for trying out Wisdom of reddit! This search engine is a work in progress. We don't, as yet, have many features of more advanced search engines. Please check the spelling of your query, try a different search term or read a short write up on how to <a href="/pro-tips">get the most out of Wisdom of reddit</a>.
</p>
</div>
{% include "example_searches.html" %}
</div>
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.