def labelPanels(axl, axlist=None, font='Arial', fontsize=18, weight = 'normal'): """ Label the panels like a specific panel Parameters ---------- axl : dict or list axlist : list, optional list of labels to use for the axes, defaults to None font : str, optional Font to use for the labels, defaults to Arial fontsize : int, optional Font size in points for the labels, defaults to 18 weight : str, optional Font weight to use, defaults to 'normal' """ if type(axl) is dict: axt = [axl[x] for x in axl] axlist = axl.keys() axl = axt if type(axl) is not list: axl = [axl] if axlist is None: axlist = string.uppercase(1,len(axl)) # assume we wish to go in sequence for i, ax in enumerate(axl): labelText = pg.TextItem(axlist[i]) y = ax.getAxis('left').range x = ax.getAxis('bottom').range ax.addItem(labelText) labelText.setPos(x[0], y[1])
def labelPanels(axl, axlist=None, font='Arial', fontsize=18, weight='normal'): """ Label the panels like a specific panel Parameters ---------- axl : dict or list axlist : list, optional list of labels to use for the axes, defaults to None font : str, optional Font to use for the labels, defaults to Arial fontsize : int, optional Font size in points for the labels, defaults to 18 weight : str, optional Font weight to use, defaults to 'normal' """ if type(axl) is dict: axt = [axl[x] for x in axl] axlist = axl.keys() axl = axt if type(axl) is not list: axl = [axl] if axlist is None: axlist = string.uppercase(1, len(axl)) # assume we wish to go in sequence for i, ax in enumerate(axl): labelText = pg.TextItem(axlist[i]) y = ax.getAxis('left').range x = ax.getAxis('bottom').range ax.addItem(labelText) labelText.setPos(x[0], y[1])
def copy_with_inline_images( self, out, inp, orig ): for l in inp.readlines(): # inline base64 r = re.search( r'^(.*)(["\'])(img/.*\.png)["\'](.*)$', l ) if r: img = self._find_file( r.group( 3 ), orig, False ) if len( img ): beg = r.group( 1 ) gui = r.group( 2 ) end = r.group( 4 ) # base64 data b = os.popen( "base64 -w 0 " + img ).read() # mimetype kin = "" cmime = [ ( 'jpeg', [ '.jpg', '.jpeg' ] ), ( 'png' , [ '.png' ] ), ( 'gif' , [ '.gif' ] ), ] for mime, ext in cmime: for e in ext: if img.endswith( e ) or img.endswith( string.uppercase( e ) ): kin = mime break if len( kin ): out.write( beg + gui + "data:image/" + kin + ";base64," + b + gui + end + "\n" ) continue else: print 'Unknown extension for ' + r.group( 3 ) else: print r.group( 3 ) + ' not found.' out.write( l )
def create_connect_args(self, url): """ Connection strings are EXASolution specific. See EXASolution manual on Connection-String-Parameters """ opts = url.translate_connect_args(username='******') opts.update(url.query) # always enable efficient conversion to Python types: see https://www.exasol.com/support/browse/EXASOL-898 opts['INTTYPESINRESULTSIFPOSSIBLE'] = 'y' keys = opts query = url.query connect_args = {} for param in ('ansi', 'unicode_results', 'autocommit'): if param in keys: connect_args[uppercase(param)] = asbool(keys.pop(param)) dsn_connection = 'dsn' in keys or \ ('host' in keys and 'port' not in keys) if dsn_connection: connectors = ['DSN=%s' % (keys.pop('host', '') or \ keys.pop('dsn', ''))] else: port = '' if 'port' in keys and not 'port' in query: port = ':%d' % int(keys.pop('port')) connectors = ["DRIVER={%s}" % keys.pop('driver', self.pyodbc_driver_name), 'EXAHOST=%s%s' % (keys.pop('host', ''), port), 'EXASCHEMA=%s' % keys.pop('database', '')] user = keys.pop("user", None) if user: connectors.append("UID=%s" % user) connectors.append("PWD=%s" % keys.pop('password', '')) else: connectors.append("Trusted_Connection=Yes") # if set to 'Yes', the ODBC layer will try to automagically # convert textual data from your database encoding to your # client encoding. This should obviously be set to 'No' if # you query a cp1253 encoded database from a latin1 client... if 'odbc_autotranslate' in keys: connectors.append("AutoTranslate=%s" % keys.pop("odbc_autotranslate")) connectors.extend(['%s=%s' % (k, v) for k, v in six.iteritems(keys)]) return [[";".join(connectors)], connect_args]
def copy_with_inline_images(self, out, inp, orig): for l in inp.readlines(): # inline base64 r = re.search(r'^(.*)(["\'])(img/.*\.png)["\'](.*)$', l) if r: img = self._find_file(r.group(3), orig, False) if len(img): beg = r.group(1) gui = r.group(2) end = r.group(4) # base64 data b = os.popen("base64 -w 0 " + img).read() # mimetype kin = "" cmime = [ ('jpeg', ['.jpg', '.jpeg']), ('png', ['.png']), ('gif', ['.gif']), ] for mime, ext in cmime: for e in ext: if img.endswith(e) or img.endswith( string.uppercase(e)): kin = mime break if len(kin): out.write(beg + gui + "data:image/" + kin + ";base64," + b + gui + end + "\n") continue else: print 'Unknown extension for ' + r.group(3) else: print r.group(3) + ' not found.' out.write(l)
def populateCSVTotal(list1, list2): """ Populate CSV file for all movies Input: Two lists of movie titles, one from The-Numbers.com and one from BoxOfficeMojo.com Output: TotalMovie.csv file """ # Initialize IMDb, The-Numbers, and BoxOfficeMojo dictionaries for first list of movies imdb_dict = imdb_grab(list1) imdb_dict_2 = imdb_grab(list2) imdb_dict_2.update(imdb_dict) numbers_dict = getNumbers() bom_dict = getBom() # Update BoxOfficeMojo dictionary with movies from The-Numbers.com for letter in string.uppercase(): for i in range(len(list1)): try: bom_dict[letter][list1[i]].update(imdb_dict[list1[i]]) except: pass try: bom_dict[letter][list1[i]].update(numbers_dict[letter][list1[i]]) except: pass for i in range(len(list1)): try: bom_dict[letter][list1[i]].update(imdb_dict_2[list1[i]]) except: pass try: bom_dict[letter][list1[i]].update(numbers_dict[letter][list1[i]]) except: pass for j in range(len(list2)): try: bom_dict[letter][list2[j]].update(imdb_dict_2[list2[j]]) except: pass # Write CSV file with information for every movie with open('TotalMovie.csv', 'wb') as f: writer = csv.writer(f) header = ["Title", "TotalGross", "OpeningGross", "Rating", \ "Country", "TotalTheaters", "DomesticBO", "Directors", \ "Studio", "OpeningTheaters", "OpeningDate", "Genre", "Budget", "Runtime"] writer.writerow(header) for letter in string.uppercase(): # Populate each row # If no information is available, append 0 for key in bom_dict[letter].keys(): row = [] row.append(bom_dict[letter][key]["Title"]) try: row.append(bom_dict[letter][key]["TotalGross"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["OpeningGross"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Rating"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Country"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["TotalTheaters"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["DomesticBO"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Directors"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Studio"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["OpeningTheaters"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["OpeningDate"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Genre"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Budget"]) except: row.append(0.0) try: row.append(bom_dict[letter][key]["Runtime"]) except: row.append(0.0) writer.writerow(row)
def getTotalList(dictionary): list_of_movies = [] for letter in string.uppercase(): for key in dictionary[letter].keys(): list_of_movies.append(key)
t='sarat' t.uppercase Traceback (most recent call last): File "<string>", line 1, in <fragment> AttributeError: 'str' object has no attribute 'uppercase' str='sarat' str.uppercase Traceback (most recent call last): File "<string>", line 1, in <fragment> AttributeError: 'str' object has no attribute 'uppercase' k=string.uppercase(str) Traceback (most recent call last): File "<string>", line 1, in <fragment> NameError: name 'string' is not defined import string k=string.uppercase(str) Traceback (most recent call last): File "<string>", line 1, in <fragment> TypeError: 'str' object is not callable k=string.uppercase(t) Traceback (most recent call last): File "<string>", line 1, in <fragment> TypeError: 'str' object is not callable s='sads' string.upper(s) 'SADS' s='sadS' string.upper(s) 'SADS' s 'sadS'
from __future__ import absolute_import, division # Here's a comment. import string print(string.uppercase('what'))