def findAllNameComponentsFromTrack(item=dict(), plist=dict(), counter=0): componentTest=True try: TRACK = str(item['Track ID']) except: TRACK = "track_%s" % counter #print(plist['Tracks'][TRACK]) try: URIlocation = plist['Tracks'][TRACK]['Location'] except: URIlocation = '' componentTest=False try: trackName = slugify(plist['Tracks'][TRACK]['Name'], separator="_", max_length=80, word_boundary=True) except: trackName = "_" try: trackArtist = slugify(plist['Tracks'][TRACK]['Artist'], separator="_", max_length=20, word_boundary=True) except: trackArtist = "_" try: trackAlbum = slugify(plist['Tracks'][TRACK]['Album'], separator="_", max_length=20, word_boundary=True) except: trackAlbum = "_" return (componentTest, TRACK, URIlocation, trackName, trackArtist, trackAlbum)
def build_cuts_from_dist_data(prop_names, values, weathering): ''' Build a list of EC distillation cut objects from boiling point distribution data. - prop_names: The list of property names - values: A list of Excel cell objects representing the properties. - weathering: The fractional oil weathering amount. Note: The labels have a bit of a problem. Most of them are percent value labels, which is fine, but additionally, we have 'initial_boiling_point', and 'fbp'. These are unusable because there is no indication of what fraction the initial and final boiling point has. I could assume the initial boiling point has a fraction of 0%, but it is clear that the final boiling point is a temperature somewhere between the 95% and 100% temperatures. So it is a fraction somewhere between 95% and 100%, which we don't precisely know. ''' cuts = [] dist_data = dict(zip(prop_names, [v[0].value for v in values])) # The only labels we care about are the percent value labels for frac in ([(p / 100.0) for p in range(5, 100, 5)] + [1]): label = slugify('{:0}'.format(frac)) vapor_temp_c = dist_data[label] cuts.append(build_cut_kwargs(vapor_temp_c, frac, weathering)) return [ECCut(**c) for c in cuts]
def get_row_field_names(xl_sheet): ''' This is tailored to parse the data format of the Excel spreadsheet of oil properties that was given to NOAA by Environment Canada (2017). Column 0 contains field category names in which each single category is represented by a contiguous group of rows, and only the first row contains the name of the category. Within the group of category rows, column 1 contains specific oil property names. So to get a specific property for an oil, one needs to reference (category, property) A property name within a category is not unique. For example, emulsion at 15C has multiple standard_deviation fields. There also exist rows that are not associated with any oil property which contain blank fields for both category and property. For field names, we would like to keep them lowercase, strip out the special characters, and separate the individual word components of the field name with '_' ''' row_fields = defaultdict(lambda: defaultdict(list)) row_prev_name = None for idx, row in enumerate(xl_sheet.rows): if all([(r.value is None) for r in row[:2]]): category_name, field_name = None, None elif row[0].value is not None: category_name = slugify(row[0].value).lower() row_prev_name = category_name if row[1].value is not None: field_name = slugify(unicode(row[1].value)).lower() else: field_name = None else: category_name = row_prev_name if row[1].value is not None: field_name = slugify(unicode(row[1].value)).lower() else: field_name = None row_fields[category_name][field_name].append(idx) return row_fields
def findDirectoryForFinalPlaylist(outDirectory='', SelectedPlaylist=''): folderCounter = 0 try: exists, desktopPath = path_resolver('Desktop') except: desktopPath = '' if outDirectory == '': outDirectory = TKaskDirectory(title='Select Destination MP3 Directory', initialdir=desktopPath) PLAYLIST_FOLDER='' for fnum in range(1,1000): folderCounter += 1 PLAYLIST_FOLDER = os.path.join(outDirectory, "%s_%03d" % ( slugify(SelectedPlaylist, separator="_"), folderCounter)) if os.path.isdir(PLAYLIST_FOLDER): if os.listdir(PLAYLIST_FOLDER): continue else: break return PLAYLIST_FOLDER
(after extension; first planned for 2015), and the Python team of volunteers will not fix security issues, or improve it in other ways after that date. With the end-of-life, only Python 3.5.x and later will be supported. Python interpreters are available for many operating systems. A global community of programmers develops and maintains CPython, an open source reference implementation. A non-profit organization, the Python Software Foundation, manages and directs resources for Python and CPython development. ''' keys = key_freq(TEXT, 10, 1000, 'qweqweqwe', alpha=1000, beta='asdasds') print(DOM, DOMAIN) name = 'Python interpreters are available for many operating systems' slug = slugify(name, stopwords=('for', 'are')) print(slug, rd.randint(1, 10)) s = ['python', 'for', 'you'] def mutate(text): s.sort() print(len(text.split()), 'количество слов в тексте.') print(s) mutate('hello world') print(s)
def link(self): return slugify(self.name)
def toSlug(nombre, apellido): completo = nombre + ' ' + apellido return 'Su valor en slug es: ' + slugify(completo)