def read_houses(lst): houses = [] for h in lst: t = house.House(MLS=h['MLS'], Price=util.format_number(h['Asking Price']), Taxes=util.format_number(h['Yearly Taxes']), HOA=util.format_number(h['HOA (Monthly)']), Address=h['Address']) houses.append(t) return houses
def main(**kwargs): print('project-id,weighted-median,lower-half-avg') for proj in load_projects(): data = load_project_data(proj['id']) wmed_forecast = get_weighted_median_vote(data['votes']) med_forecast = get_median_vote(data['votes']) print(':'.join(( proj['id'], format_number(med_forecast), format_number(wmed_forecast), )))
def parse_house(data, mlsnum): try: b = bs.BeautifulSoup(data) mls = b.findAll('td', attrs={"id":"mls_id"})[0].getText() if mls is None: raise NotFoundException("Couldn't find the house") price = _find_price(b) address = _find_address(b) taxes = _find_taxes(b) status = _find_status(b) hoa = _find_hoa(b) beds = _find_beds(b) baths = _find_baths(b) except IndexError: raise NotFoundException("Error finding") except: print("Error retrieving {0}".format(mlsnum)) raise h = house.House(MLS=mls, Price=price, Address=address, HOA=hoa, Status=status, Taxes=util.format_number(taxes), Beds=beds, Baths=baths ) return h
def __str__(self): """'Pretty' formatting of the Matrix44.""" # Pretty printing generates a lot of ugly code - oh the irony! # Changed in release 0.0.3 so that the decimal point is always # line up on the columns cols = [ map(format_number, col) for col in self.columns() ] def decimal_pos(n): if '.' in n: return n.index('.') return len(n) for col_no, col in enumerate(cols[:]): decimal = max( decimal_pos(format_number(c)) for c in col ) cols[col_no] = [" "*(decimal-decimal_pos(c))+c for c in col] max_col_lengths = [ max(len(c) for c in col) for col in cols ] rows = [[], [], [], []] for row_no in xrange(4): for col_no in xrange(4): v = cols[col_no][row_no] rows[row_no].append( v.ljust(max_col_lengths[col_no]) ) rows = [" ".join(row).rstrip() for row in rows] return "\n".join("[ %s ]"%row for row in rows) return str(cols)
def main(**kwargs): sheet = get_sheet() assert sheet.acell('K2').value.strip() == 'Median' assert sheet.acell('L2').value.strip() == 'Weighted Median' assert sheet.acell('P2').value.strip() == 'Wings Used' rownum = 2 for proj in list(load_projects()): rownum += 1 data = load_project_data(proj['id']) median = get_median_vote(data['votes']) wmedian = get_weighted_median_vote(data['votes']) weight_sum = get_weight_sum(data['votes']) assert sheet.cell(rownum, 1).value.strip() == proj['name'] sheet.update_acell('K%d' % rownum, '%s' % format_number(median)) sheet.update_acell('L%d' % rownum, '%s' % format_number(wmedian)) sheet.update_acell('P%d' % rownum, '%s' % format_number(weight_sum)) ts = datetime.utcnow().strftime('%d %b, %H:%M UTC') sheet.update_acell('A1', ts)
def parse_house(xmlstr): x = xmlparse.parseString(xmlstr) try: mlsnum = getnodetext(x.getElementsByTagName('MLSNumber')[0]) price = getnodetext(x.getElementsByTagName('Price')[0]) status = getnodetext(x.getElementsByTagName('ListingStatus')[0]) except: raise try: taxes = getnodetext(x.getElementsByTagName('Taxes')[0]) except: taxes = None try: addr = x.getElementsByTagName('Address')[0] city = x.getElementsByTagName('City')[0] state = x.getElementsByTagName('State')[0] zip = x.getElementsByTagName('Zip')[0] address = '{0}, {1}, {2} {3}'.format(getnodetext(addr), getnodetext(city), getnodetext(state), getnodetext(zip)) except: address = None try: nodes = x.getElementsByTagName( 'MainFeature') # Find the 'Rental Price' name element hoa = "0" for n in nodes: # RE/MAX stores the HOA in an element called 'Fees' but doesn't specify # whether it's annually, monthly, ... if n.getAttribute("Name") == "Fees": hoa = n.getAttribute("Value") except: pass h = house.House(MLS=mlsnum, Price=util.format_number(price), Address=address, HOA=util.format_number(hoa), Status=status, Taxes=util.format_number(taxes)) return h
def __str__(self): """'Pretty' formatting of the Matrix44.""" max_len = max( len(format_number(v)) for v in self.components() ) def format_row(row): return "%s" % " ".join( format_number(value).ljust(max_len) for value in row ) rows = [ format_row(row).rstrip() for row in self.rows() ] max_row_len = max(len(row) for row in rows) return "\n".join( "[ %s ]" % row.ljust(max_row_len) for row in rows )
async def presence_changer(self): presences = util.Cycle([ discord.Game(name="with {} Guilds".format( util.format_number(len(self.guilds)))), discord.Activity(type=discord.ActivityType.watching, name="{} Users".format( util.format_number(self.get_total_users()))), discord.Activity(type=discord.ActivityType.listening, name="the $help command.") ]) while True: if self.is_ready() and not self.maintenance: await self.change_presence(activity=presences.current) presences.next() await asyncio.sleep(300) elif self.maintenance: await self.change_presence(activity=discord.Activity( type=discord.ActivityType.listening, name="bot owners only."))
def __str__(self): x, y, z = self._v return "(%s, %s, %s)" % (format_number(x), format_number(y), format_number(z))
def __str__(self): return "(" + ", ".join(format_number(c) for c in self._c) + ")"
def __str__(self): return "( position %s, radius %s )" % (self.position, format_number(self.radius))
def format_number(context, num, code=""): if code == "": return util.format_number(num) else: return util.format_number(num, code)
def format_row(row): return "(%s)" % ", ".join(format_number(value) for value in row)
def format_row(row): return "%s" % " ".join( format_number(value).ljust(max_len) for value in row)
def __str__(self): return "(%s, %s, %s)" % (format_number( self._v[0]), format_number(self._v[1]), format_number(self._v[2]))