def addDiscountToSeniorCitizen(self): ans = getInput("Are you giving any discount to senior citizen? (Y/N)") if ans == "Y": discount = getInput("Senior Citizen Discount: ") Discount.discount_details["senior_citizen_discount"] = discount else: Discount.discount_details["senior_citizen_discount"] = 0
def getUserDetails(self): drawLines() print "Lets capture customer details" drawLines() self.name = getInput("Customer Name: ") self.number = getInput("Mobile Number: ") self.age = getInput("Age: ")
def addDiscountToEmployee(self): ans = getInput("Are you giving any discount to your employees? (Y/N)") if ans == "Y": discount = getInput("Employee Discount: ") Discount.discount_details["employee_discount"] = discount else: Discount.discount_details["employee_discount"] = 0
def createRegister(self): register_name = getInput("Please input the register name:") register = {'name': register_name, 'items': {}} self.store_opening_inventory[register_name] = register ans = getInput("Do you want to add more registers (Y/N)?") if ans == "Y": self.createRegister()
def main(): if args.day is None: # Compute all the available solutions for d in s: inp = util.getInput(d) run_solution(d, s[d], inp) run_solution(d, s[d], inp, True) else: # Compute the specified solution if args.day in s: inp = open(args.input, 'r').readlines() if args.input else util.getInput( args.day) run_solution(args.day, s[args.day], inp, args.b) return
def GET(self): params = getInput(web.input()) github_url = params['github'] print github_url m2 = hashlib.md5() m2.update(github_url) url_md5 = m2.hexdigest() if os.path.exists(dirs + '/' + _get_time() + url_md5): with open(dirs + '/' + _get_time() + url_md5, 'r') as f: c = f.readline() # if not c == None: # return c _json = requests.get(github_url, verify=False) print _json.text if (_json): _json_data = json.loads(_json.text) for j in _json_data: print j n = j['name'].lower() print n if n == 'readme.md': github_url += j['path'] _json = requests.get(github_url, verify=False) break with open(dirs + '/' + _get_time() + url_md5, 'w') as f: f.write(_json.text.encode('utf-8')) return _json.text
def GET(self): if not os.path.exists(dirs): os.mkdir(dirs) print web.input() params = getInput(web.input()) print params since = params.get('since') language = params.get('language') if not language == None: language = urllib.quote(language) print language if not language == None: filename = _get_time() + since + language + '.json' else: filename = _get_time() + since + '.json' if os.path.exists(dirs + '/' + filename): with open(dirs + '/' + filename,'r') as f: content = f.readline() if not content == '': return content if not language == None: trending_api = CODEHUB_API_LAN % (since,language) else: trending_api = CODEHUB_API % since print trending_api _trending_json = requests.get(trending_api) with open('CodeJsonData/' + filename,'w') as f: f.write(_trending_json.text.encode('utf-8')) return _trending_json.text
def GET(self): print 'Star' time1 = time.time() self.s = requests.Session() params = getInput(web.input()) repos = params.get('githubs') repos = repos.replace('"','"') print repos _json_repos = json.loads(repos) username = params.get('username') self.s.cookies = read_cookies(username) self._repos = [] threads = [] self.repo_size = len(_json_repos) for repo in _json_repos: t = threading.Thread(target=self.status,args=(repo,)) threads.append(t) for t in threads: t.setDaemon(True) t.start() while not self.repo_size == 0: pass _json_resp = json.dumps(self._repos) print _json_resp,time.time() - time1 return _json_resp
def start_transactions(): drawLines() print "Start Billing" drawLines() ans = getInput("Are you a current employee (Y/N)?") if ans == "Y": emp = Employee() cust_details = emp.getEmployeeDetails() else: cust = Customer() cust_details = cust.getCustomerDetails() Transaction(cust_details) print "Completed Billing" drawLines() ans = getInput("Do you want to do more transactions (Y/N)?") if ans == "Y": start_transactions()
def getEmployeeDetails(self): self.getUserDetails() self.emp_code = getInput("Employee Code: ") emp_details = { "name" : self.name, "number": self.number, "emp_code": self.emp_code, } drawLines() return emp_details
def chooseItem(self, register, billed_items): item = {} item['register'] = register item_no = getInput("Please select the item from above catalogue:") item_name = list( Store.store_inventory[register]['items'])[int(item_no) - 1] item['item'] = item_name item['discount_percent'] = int( Store.store_inventory[register]['discount_percent']) + int( Store.store_inventory[register]['items'][item_name] ['discount_percent']) item['price'] = Store.store_inventory[register]['items'][item_name][ 'price'] count = getInput("Please mention the number of " + item_name + " you need:") item['count'] = count ans = getInput("Do you want to bill more items (Y/N)?") billed_items.append(item) Store.repopulateAvailableStock(item) if ans == "Y": self.billItems(billed_items) return billed_items
def GET(self): print web.input() params = util.getInput(web.input()) q = params['q'] if not os.path.exists(search): os.mkdir(search) with open(search + '/q.txt', 'a') as f: f.write(_get_time() + '----' + q + '\n') q = urllib.quote(str(q)) print q api = SEARCH_API % q print api, header r = requests.get(api, verify=False, headers=header) return r.text
def addItemToRegister(self): print "Lets add items to your register. Please select the register:" for index, (key, value) in enumerate(self.store_opening_inventory.items()): print str(index + 1) + " " + key register = raw_input() item = getInput("Please input the " + list(self.store_opening_inventory)[int(register) - 1] + " name:") self.store_opening_inventory[list( self.store_opening_inventory)[int(register) - 1]]['items'][item] = { 'name': item } stock = getInput("Please input the stock count:") self.store_opening_inventory[list(self.store_opening_inventory)[ int(register) - 1]]['items'][item]['count'] = int(stock) price = getInput("Please input the price:") self.store_opening_inventory[list(self.store_opening_inventory)[ int(register) - 1]]['items'][item]['price'] = int(price) ans = getInput("Do you want to add more items (Y/N)?") if ans == "Y": self.addItemToRegister()
def GET(self): print 'Star' s = requests.Session() params = getInput(web.input()) repo = params.get('github') username = params.get('username') s.cookies = read_cookies(username) star = s.get('https://github.com/' + repo,verify=False) auto_token_content = re.findall(repo + '/star"(.*?)</div>',star.text) print auto_token_content data = { 'utf8':'%E2%9C%93', 'authenticity_token':get_auth_token(auto_token_content[0]) } s.headers.update({'X-Requested-With':'XMLHttpRequest'}) star_re = s.post('https://github.com/' + repo + '/star',data=data,verify=False) return star_re.text
def GET(self): self.s = requests.Session() print 'aaaa' params = getInput(web.input()) print params self.username = params.get('username') self.password = params.get('password') with open('login_record.txt', 'w') as f: f.write(self.username + ':' + self.password + '/n') print self.username, self.password user, avatar, secret_username = self.login() js = { 'user': user, 'avatar': avatar.replace('40', '400'), 'fuck_username': secret_username } return json.dumps(js)
def addDiscount(self, dict_item, dict_name): discount = getInput(dict_name + " Discount: ") dict_item['discount_percent'] = discount return dict_item
def GET(self): print 'Star' params = getInput(web.input()) return GithubFollow.follow(params.get('to_user'), params.get('username'))
parentsMap = {} pq = [] nodeCosts = defaultdict(lambda: float('inf')) nodeCosts[startingNode] = 0 heap.heappush(pq, (0, startingNode)) while pq: # go greedily by always extending the shorter cost nodes first _, node = heap.heappop(pq) visited.add(node) for adjNode in G.neighbours(node): if adjNode in visited: continue weight = G.cell(adjNode) newCost = nodeCosts[node] + weight if nodeCosts[adjNode] > newCost: parentsMap[adjNode] = node nodeCosts[adjNode] = newCost heap.heappush(pq, (newCost, adjNode)) return parentsMap, nodeCosts g = ChitonGrid(util.getInput()) g.scale() (pmap, dists) = dijkstraCopy(g, grid.xy(0, 0)) (x, y) = g.xySize() print(f"dist={dists[grid.xy(x-1, y-1)]}")